feat: 增强仓储CRUD与种子配置

This commit is contained in:
2025-12-02 09:46:44 +08:00
parent ffc4f0885f
commit 1a01454266
16 changed files with 587 additions and 56 deletions

View File

@@ -68,4 +68,33 @@ public sealed class EfPaymentRepository : IPaymentRepository
{
return _context.SaveChangesAsync(cancellationToken);
}
/// <inheritdoc />
public Task UpdatePaymentAsync(PaymentRecord payment, CancellationToken cancellationToken = default)
{
_context.PaymentRecords.Update(payment);
return Task.CompletedTask;
}
/// <inheritdoc />
public async Task DeletePaymentAsync(long paymentId, long tenantId, CancellationToken cancellationToken = default)
{
var refunds = await _context.PaymentRefundRecords
.Where(x => x.TenantId == tenantId && x.PaymentRecordId == paymentId)
.ToListAsync(cancellationToken);
if (refunds.Count > 0)
{
_context.PaymentRefundRecords.RemoveRange(refunds);
}
var existing = await _context.PaymentRecords
.Where(x => x.TenantId == tenantId && x.Id == paymentId)
.FirstOrDefaultAsync(cancellationToken);
if (existing == null)
{
return;
}
_context.PaymentRecords.Remove(existing);
}
}