feat: complete phase six backoffice operations

This commit is contained in:
2026-07-28 14:31:43 +08:00
parent 747ff59d76
commit 99e4e43122
31 changed files with 23504 additions and 26 deletions

View File

@@ -529,3 +529,70 @@ internal sealed class CommerceReconciliationIssueEventConfiguration : IEntityTyp
builder.HasOne<User>().WithMany().HasForeignKey(entity => entity.ActorUserId).OnDelete(DeleteBehavior.SetNull);
}
}
internal sealed class CommerceAdjustmentVoucherConfiguration : IEntityTypeConfiguration<CommerceAdjustmentVoucher>
{
public void Configure(EntityTypeBuilder<CommerceAdjustmentVoucher> builder)
{
builder.ConfigureTenantEntity("commerce_adjustment_vouchers");
builder.ConfigureTimestamps();
builder.Property(entity => entity.VoucherNo).HasMaxLength(100);
builder.Property(entity => entity.Status).HasSnakeCaseEnum();
builder.Property(entity => entity.Direction).HasSnakeCaseEnum();
builder.Property(entity => entity.Currency).HasMaxLength(10);
builder.Property(entity => entity.Reason).HasMaxLength(1000);
builder.Property(entity => entity.ProofAssetKey).HasMaxLength(500);
builder.Property(entity => entity.Metadata).IsJson("{}");
builder.HasIndex(entity => new { entity.TenantId, entity.VoucherNo }).IsUnique();
builder.HasIndex(entity => new { entity.TenantId, entity.Status, entity.CreatedAt });
builder.HasIndex(entity => new { entity.TenantId, entity.IssueId, entity.CreatedAt });
builder.ToTable(table => table.HasCheckConstraint("ck_commerce_adjustment_vouchers_amount", "amount_cents > 0"));
builder.HasOne<CommerceReconciliationIssue>().WithMany()
.HasForeignKey(entity => new { entity.TenantId, entity.IssueId })
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
.OnDelete(DeleteBehavior.SetNull);
builder.HasOne<CommerceReconciliationBatch>().WithMany()
.HasForeignKey(entity => new { entity.TenantId, entity.BatchId })
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
.OnDelete(DeleteBehavior.SetNull);
builder.HasOne<CommerceReconciliationItem>().WithMany()
.HasForeignKey(entity => new { entity.TenantId, entity.ItemId })
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
.OnDelete(DeleteBehavior.SetNull);
builder.HasOne<Order>().WithMany()
.HasForeignKey(entity => new { entity.TenantId, entity.OrderId })
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
.OnDelete(DeleteBehavior.SetNull);
builder.HasOne<Payment>().WithMany()
.HasForeignKey(entity => new { entity.TenantId, entity.PaymentId })
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
.OnDelete(DeleteBehavior.SetNull);
builder.HasOne<CommerceRefundRequest>().WithMany()
.HasForeignKey(entity => new { entity.TenantId, entity.RefundRequestId })
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
.OnDelete(DeleteBehavior.SetNull);
builder.HasOne<User>().WithMany().HasForeignKey(entity => entity.CreatedBy).OnDelete(DeleteBehavior.SetNull);
builder.HasOne<User>().WithMany().HasForeignKey(entity => entity.ReviewedBy).OnDelete(DeleteBehavior.SetNull);
}
}
internal sealed class CommerceAdjustmentVoucherEventConfiguration : IEntityTypeConfiguration<CommerceAdjustmentVoucherEvent>
{
public void Configure(EntityTypeBuilder<CommerceAdjustmentVoucherEvent> builder)
{
builder.ConfigureEntity("commerce_adjustment_voucher_events");
builder.HasAlternateKey(entity => new { entity.TenantId, entity.Id });
builder.Property(entity => entity.FromStatus).HasNullableSnakeCaseEnum();
builder.Property(entity => entity.ToStatus).HasSnakeCaseEnum();
builder.Property(entity => entity.Note).HasMaxLength(1000);
builder.Property(entity => entity.Details).IsJson("{}");
builder.Property(entity => entity.CreatedAt).HasDefaultValueSql("now()");
builder.HasIndex(entity => new { entity.TenantId, entity.VoucherId, entity.CreatedAt });
builder.HasOne<Tenant>().WithMany().HasForeignKey(entity => entity.TenantId).OnDelete(DeleteBehavior.Cascade);
builder.HasOne<CommerceAdjustmentVoucher>().WithMany()
.HasForeignKey(entity => new { entity.TenantId, entity.VoucherId })
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
.OnDelete(DeleteBehavior.Cascade);
builder.HasOne<User>().WithMany().HasForeignKey(entity => entity.ActorUserId).OnDelete(DeleteBehavior.SetNull);
}
}

View File

@@ -82,7 +82,6 @@ internal sealed class AuthLoginEventConfiguration : IEntityTypeConfiguration<Aut
public void Configure(EntityTypeBuilder<AuthLoginEvent> builder)
{
builder.ConfigureEntity("auth_login_events");
builder.HasAlternateKey(entity => new { entity.TenantId, entity.Id });
builder.Property(entity => entity.Provider).HasMaxLength(50);
builder.Property(entity => entity.Identifier).HasMaxLength(320);
builder.Property(entity => entity.Result).HasSnakeCaseEnum();