using FluentValidation;
using TakeoutSaaS.Application.App.Finance.Transactions.Queries;
using TakeoutSaaS.Domain.Finance.Enums;

namespace TakeoutSaaS.Application.App.Finance.Transactions.Validators;

/// <summary>
/// 交易流水详情查询验证器。
/// </summary>
public sealed class GetFinanceTransactionDetailQueryValidator : AbstractValidator<GetFinanceTransactionDetailQuery>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public GetFinanceTransactionDetailQueryValidator()
    {
        RuleFor(x => x.StoreId).GreaterThan(0);
        RuleFor(x => x.SourceId).GreaterThan(0);
        RuleFor(x => x.SourceType)
            .Must(x => x is FinanceTransactionSourceType.PaymentRecord
                or FinanceTransactionSourceType.PaymentRefundRecord
                or FinanceTransactionSourceType.RefundRequest
                or FinanceTransactionSourceType.StoredCardRechargeRecord
                or FinanceTransactionSourceType.MemberPointLedger)
            .WithMessage("sourceType 非法");
    }
}
