fix:修复注释错误
This commit is contained in:
@@ -30,14 +30,14 @@ public sealed class ConfirmPaymentCommandHandler(
|
||||
throw new BusinessException(ErrorCodes.Unauthorized, "未登录或无效的操作者身份");
|
||||
}
|
||||
|
||||
// 2. (空行后) 查询账单
|
||||
// 2. 查询账单
|
||||
var billing = await billingRepository.FindByIdAsync(request.BillingId, cancellationToken);
|
||||
if (billing is null)
|
||||
{
|
||||
throw new BusinessException(ErrorCodes.NotFound, "账单不存在");
|
||||
}
|
||||
|
||||
// 3. (空行后) 业务规则检查
|
||||
// 3. 业务规则检查
|
||||
if (billing.Status == TenantBillingStatus.Paid)
|
||||
{
|
||||
throw new BusinessException(ErrorCodes.BusinessError, "已支付账单不允许重复收款");
|
||||
@@ -48,7 +48,7 @@ public sealed class ConfirmPaymentCommandHandler(
|
||||
throw new BusinessException(ErrorCodes.BusinessError, "已取消账单不允许收款");
|
||||
}
|
||||
|
||||
// 4. (空行后) 金额边界:不允许超过剩余应收(与前端校验保持一致)
|
||||
// 4. 金额边界:不允许超过剩余应收(与前端校验保持一致)
|
||||
var totalAmount = billing.CalculateTotalAmount();
|
||||
var remainingAmount = totalAmount - billing.AmountPaid;
|
||||
if (request.Amount > remainingAmount)
|
||||
@@ -56,7 +56,7 @@ public sealed class ConfirmPaymentCommandHandler(
|
||||
throw new BusinessException(ErrorCodes.BadRequest, "支付金额不能超过剩余应收");
|
||||
}
|
||||
|
||||
// 5. (空行后) 幂等校验:交易号唯一
|
||||
// 5. 幂等校验:交易号唯一
|
||||
if (!string.IsNullOrWhiteSpace(request.TransactionNo))
|
||||
{
|
||||
var exists = await paymentRepository.GetByTransactionNoAsync(request.TransactionNo.Trim(), cancellationToken);
|
||||
@@ -66,7 +66,7 @@ public sealed class ConfirmPaymentCommandHandler(
|
||||
}
|
||||
}
|
||||
|
||||
// 6. (空行后) 构建支付记录并立即审核通过
|
||||
// 6. 构建支付记录并立即审核通过
|
||||
var now = DateTime.UtcNow;
|
||||
var payment = new TenantPayment
|
||||
{
|
||||
@@ -84,15 +84,15 @@ public sealed class ConfirmPaymentCommandHandler(
|
||||
|
||||
payment.Verify(currentUserAccessor.UserId);
|
||||
|
||||
// 7. (空行后) 同步更新账单已收金额/状态(支持分次收款)
|
||||
// 7. 同步更新账单已收金额/状态(支持分次收款)
|
||||
billing.MarkAsPaid(payment.Amount, payment.TransactionNo ?? string.Empty);
|
||||
|
||||
// 8. (空行后) 持久化变更(同一 DbContext 下单次 SaveChanges 可提交两张表)
|
||||
// 8. 持久化变更(同一 DbContext 下单次 SaveChanges 可提交两张表)
|
||||
await paymentRepository.AddAsync(payment, cancellationToken);
|
||||
await billingRepository.UpdateAsync(billing, cancellationToken);
|
||||
await paymentRepository.SaveChangesAsync(cancellationToken);
|
||||
|
||||
// 9. (空行后) 返回 DTO
|
||||
// 9. 返回 DTO
|
||||
return payment.ToPaymentRecordDto();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user