feat: 新增一键确认收款接口
问题: 原recordPayment只创建Pending支付记录,不更新账单状态
用户点击确认收款后需要再次审核才能生效
解决方案:
- 新增POST /api/admin/v1/billings/{id}/payments/confirm接口
- 内部原子化执行: 创建支付+自动审核+更新账单状态
- 保留原recordPayment接口用于需要审核的场景
新增文件:
- ConfirmPaymentCommand.cs
- ConfirmPaymentCommandHandler.cs
- ConfirmPaymentCommandValidator.cs
This commit is contained in:
@@ -157,6 +157,29 @@ public sealed class BillingsController(IMediator mediator) : BaseApiController
|
||||
return ApiResponse<PaymentRecordDto>.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 一键确认收款(记录支付 + 立即审核通过)。
|
||||
/// </summary>
|
||||
/// <param name="id">账单 ID。</param>
|
||||
/// <param name="command">确认收款命令。</param>
|
||||
/// <param name="cancellationToken">取消标记。</param>
|
||||
/// <returns>确认后的支付记录。</returns>
|
||||
[HttpPost("{id:long}/payments/confirm")]
|
||||
[PermissionAuthorize("bill:pay")]
|
||||
[ProducesResponseType(typeof(ApiResponse<PaymentRecordDto>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<PaymentRecordDto>> ConfirmPayment(long id, [FromBody, Required] ConfirmPaymentCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
// 1. 绑定账单标识
|
||||
command = command with { BillingId = id };
|
||||
|
||||
// 2. (空行后) 一键确认收款(含:写入 VerifiedBy/VerifiedAt,并同步更新账单已收金额/状态)
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
|
||||
// 3. (空行后) 返回结果
|
||||
return ApiResponse<PaymentRecordDto>.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 审核支付记录。
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user