feat: 新增一键确认收款接口
问题: 原recordPayment只创建Pending支付记录,不更新账单状态
用户点击确认收款后需要再次审核才能生效
解决方案:
- 新增POST /api/admin/v1/billings/{id}/payments/confirm接口
- 内部原子化执行: 创建支付+自动审核+更新账单状态
- 保留原recordPayment接口用于需要审核的场景
新增文件:
- ConfirmPaymentCommand.cs
- ConfirmPaymentCommandHandler.cs
- ConfirmPaymentCommandValidator.cs
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using FluentValidation;
|
||||
using TakeoutSaaS.Application.App.Billings.Commands;
|
||||
|
||||
namespace TakeoutSaaS.Application.App.Billings.Validators;
|
||||
|
||||
/// <summary>
|
||||
/// 一键确认收款命令验证器。
|
||||
/// </summary>
|
||||
public sealed class ConfirmPaymentCommandValidator : AbstractValidator<ConfirmPaymentCommand>
|
||||
{
|
||||
public ConfirmPaymentCommandValidator()
|
||||
{
|
||||
// 1. 账单 ID 必填
|
||||
RuleFor(x => x.BillingId)
|
||||
.GreaterThan(0)
|
||||
.WithMessage("账单 ID 必须大于 0");
|
||||
|
||||
// 2. (空行后) 支付金额必须大于 0
|
||||
RuleFor(x => x.Amount)
|
||||
.GreaterThan(0)
|
||||
.WithMessage("支付金额必须大于 0")
|
||||
.LessThanOrEqualTo(1_000_000_000)
|
||||
.WithMessage("支付金额不能超过 10 亿");
|
||||
|
||||
// 3. (空行后) 支付方式必填
|
||||
RuleFor(x => x.Method)
|
||||
.IsInEnum()
|
||||
.WithMessage("支付方式无效");
|
||||
|
||||
// 4. (空行后) 交易号必填
|
||||
RuleFor(x => x.TransactionNo)
|
||||
.NotEmpty()
|
||||
.WithMessage("交易号不能为空")
|
||||
.MaximumLength(64)
|
||||
.WithMessage("交易号不能超过 64 个字符");
|
||||
|
||||
// 5. (空行后) 支付凭证 URL(可选)
|
||||
RuleFor(x => x.ProofUrl)
|
||||
.MaximumLength(500)
|
||||
.WithMessage("支付凭证 URL 不能超过 500 个字符")
|
||||
.When(x => !string.IsNullOrWhiteSpace(x.ProofUrl));
|
||||
|
||||
// 6. (空行后) 备注(可选)
|
||||
RuleFor(x => x.Notes)
|
||||
.MaximumLength(500)
|
||||
.WithMessage("备注不能超过 500 个字符")
|
||||
.When(x => !string.IsNullOrWhiteSpace(x.Notes));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user