forked from xiongyuxing/tiku-backend.net
feat: complete phase six backoffice operations
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("svip_question_limit");
|
||||
|
||||
b.Property<Guid>("TenantId")
|
||||
b.Property<Guid?>("TenantId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("tenant_id");
|
||||
|
||||
@@ -12956,9 +12956,6 @@ namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_auth_login_events");
|
||||
|
||||
b.HasAlternateKey("TenantId", "Id")
|
||||
.HasName("ak_auth_login_events_tenant_id_id");
|
||||
|
||||
b.HasIndex("UserId")
|
||||
.HasDatabaseName("ix_auth_login_events_user_id");
|
||||
|
||||
|
||||
@@ -415,7 +415,7 @@ namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
background_color = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
|
||||
sort_order = table.Column<int>(type: "integer", nullable: false),
|
||||
is_active = table.Column<bool>(type: "boolean", nullable: false),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
||||
},
|
||||
@@ -441,7 +441,7 @@ namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
file_name = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
||||
description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
|
||||
metadata = table.Column<JsonElement>(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
||||
},
|
||||
@@ -530,7 +530,7 @@ namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
user_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
provider = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
||||
identifier = table.Column<string>(type: "character varying(320)", maxLength: 320, nullable: true),
|
||||
@@ -544,7 +544,6 @@ namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_auth_login_events", x => x.id);
|
||||
table.UniqueConstraint("ak_auth_login_events_tenant_id_id", x => new { x.tenant_id, x.id });
|
||||
table.ForeignKey(
|
||||
name: "fk_auth_login_events_tenants_tenant_id",
|
||||
column: x => x.tenant_id,
|
||||
|
||||
17959
Tiku.Infrastructure/Persistence/Migrations/20260728062148_AddCommerceAdjustmentVouchers.Designer.cs
generated
Normal file
17959
Tiku.Infrastructure/Persistence/Migrations/20260728062148_AddCommerceAdjustmentVouchers.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,213 @@
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddCommerceAdjustmentVouchers : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "commerce_adjustment_vouchers",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
||||
issue_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
batch_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
item_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
order_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
payment_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
refund_request_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
created_by = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
reviewed_by = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
voucher_no = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
||||
status = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
|
||||
direction = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
|
||||
amount_cents = table.Column<int>(type: "integer", nullable: false),
|
||||
currency = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
|
||||
reason = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: false),
|
||||
proof_asset_key = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
||||
reviewed_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
closed_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
metadata = table.Column<JsonElement>(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_commerce_adjustment_vouchers", x => x.id);
|
||||
table.UniqueConstraint("ak_commerce_adjustment_vouchers_tenant_id_id", x => new { x.tenant_id, x.id });
|
||||
table.CheckConstraint("ck_commerce_adjustment_vouchers_amount", "amount_cents > 0");
|
||||
table.ForeignKey(
|
||||
name: "fk_commerce_adjustment_vouchers_commerce_reconciliation_batche~",
|
||||
columns: x => new { x.tenant_id, x.batch_id },
|
||||
principalTable: "commerce_reconciliation_batches",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
table.ForeignKey(
|
||||
name: "fk_commerce_adjustment_vouchers_commerce_reconciliation_issues~",
|
||||
columns: x => new { x.tenant_id, x.issue_id },
|
||||
principalTable: "commerce_reconciliation_issues",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
table.ForeignKey(
|
||||
name: "fk_commerce_adjustment_vouchers_commerce_reconciliation_items_~",
|
||||
columns: x => new { x.tenant_id, x.item_id },
|
||||
principalTable: "commerce_reconciliation_items",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
table.ForeignKey(
|
||||
name: "fk_commerce_adjustment_vouchers_commerce_refund_requests_tenan~",
|
||||
columns: x => new { x.tenant_id, x.refund_request_id },
|
||||
principalTable: "commerce_refund_requests",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
table.ForeignKey(
|
||||
name: "fk_commerce_adjustment_vouchers_orders_tenant_id_order_id",
|
||||
columns: x => new { x.tenant_id, x.order_id },
|
||||
principalTable: "orders",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
table.ForeignKey(
|
||||
name: "fk_commerce_adjustment_vouchers_payments_tenant_id_payment_id",
|
||||
columns: x => new { x.tenant_id, x.payment_id },
|
||||
principalTable: "payments",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
table.ForeignKey(
|
||||
name: "fk_commerce_adjustment_vouchers_tenants_tenant_id",
|
||||
column: x => x.tenant_id,
|
||||
principalTable: "tenants",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_commerce_adjustment_vouchers_users_created_by",
|
||||
column: x => x.created_by,
|
||||
principalTable: "users",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
table.ForeignKey(
|
||||
name: "fk_commerce_adjustment_vouchers_users_reviewed_by",
|
||||
column: x => x.reviewed_by,
|
||||
principalTable: "users",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "commerce_adjustment_voucher_events",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
voucher_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
from_status = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
||||
to_status = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
|
||||
actor_user_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
note = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
|
||||
details = table.Column<JsonElement>(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_commerce_adjustment_voucher_events", x => x.id);
|
||||
table.UniqueConstraint("ak_commerce_adjustment_voucher_events_tenant_id_id", x => new { x.tenant_id, x.id });
|
||||
table.ForeignKey(
|
||||
name: "fk_commerce_adjustment_voucher_events_commerce_adjustment_vouc~",
|
||||
columns: x => new { x.tenant_id, x.voucher_id },
|
||||
principalTable: "commerce_adjustment_vouchers",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_commerce_adjustment_voucher_events_tenants_tenant_id",
|
||||
column: x => x.tenant_id,
|
||||
principalTable: "tenants",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_commerce_adjustment_voucher_events_users_actor_user_id",
|
||||
column: x => x.actor_user_id,
|
||||
principalTable: "users",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_commerce_adjustment_voucher_events_actor_user_id",
|
||||
table: "commerce_adjustment_voucher_events",
|
||||
column: "actor_user_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_commerce_adjustment_voucher_events_tenant_id_voucher_id_cre~",
|
||||
table: "commerce_adjustment_voucher_events",
|
||||
columns: new[] { "tenant_id", "voucher_id", "created_at" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_commerce_adjustment_vouchers_created_by",
|
||||
table: "commerce_adjustment_vouchers",
|
||||
column: "created_by");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_commerce_adjustment_vouchers_reviewed_by",
|
||||
table: "commerce_adjustment_vouchers",
|
||||
column: "reviewed_by");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_commerce_adjustment_vouchers_tenant_id_batch_id",
|
||||
table: "commerce_adjustment_vouchers",
|
||||
columns: new[] { "tenant_id", "batch_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_commerce_adjustment_vouchers_tenant_id_issue_id_created_at",
|
||||
table: "commerce_adjustment_vouchers",
|
||||
columns: new[] { "tenant_id", "issue_id", "created_at" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_commerce_adjustment_vouchers_tenant_id_item_id",
|
||||
table: "commerce_adjustment_vouchers",
|
||||
columns: new[] { "tenant_id", "item_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_commerce_adjustment_vouchers_tenant_id_order_id",
|
||||
table: "commerce_adjustment_vouchers",
|
||||
columns: new[] { "tenant_id", "order_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_commerce_adjustment_vouchers_tenant_id_payment_id",
|
||||
table: "commerce_adjustment_vouchers",
|
||||
columns: new[] { "tenant_id", "payment_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_commerce_adjustment_vouchers_tenant_id_refund_request_id",
|
||||
table: "commerce_adjustment_vouchers",
|
||||
columns: new[] { "tenant_id", "refund_request_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_commerce_adjustment_vouchers_tenant_id_status_created_at",
|
||||
table: "commerce_adjustment_vouchers",
|
||||
columns: new[] { "tenant_id", "status", "created_at" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_commerce_adjustment_vouchers_tenant_id_voucher_no",
|
||||
table: "commerce_adjustment_vouchers",
|
||||
columns: new[] { "tenant_id", "voucher_no" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "commerce_adjustment_voucher_events");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "commerce_adjustment_vouchers");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1338,6 +1338,221 @@ namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Tiku.Domain.Commerce.CommerceAdjustmentVoucher", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("id")
|
||||
.HasDefaultValueSql("gen_random_uuid()");
|
||||
|
||||
b.Property<int>("AmountCents")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("amount_cents");
|
||||
|
||||
b.Property<Guid?>("BatchId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("batch_id");
|
||||
|
||||
b.Property<DateTimeOffset?>("ClosedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("closed_at");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("created_at")
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
b.Property<Guid?>("CreatedBy")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("created_by");
|
||||
|
||||
b.Property<string>("Currency")
|
||||
.IsRequired()
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("character varying(10)")
|
||||
.HasColumnName("currency");
|
||||
|
||||
b.Property<string>("Direction")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)")
|
||||
.HasColumnName("direction");
|
||||
|
||||
b.Property<Guid?>("IssueId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("issue_id");
|
||||
|
||||
b.Property<Guid?>("ItemId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("item_id");
|
||||
|
||||
b.Property<JsonElement>("Metadata")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("metadata")
|
||||
.HasDefaultValueSql("'{}'::jsonb");
|
||||
|
||||
b.Property<Guid?>("OrderId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("order_id");
|
||||
|
||||
b.Property<Guid?>("PaymentId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("payment_id");
|
||||
|
||||
b.Property<string>("ProofAssetKey")
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("character varying(500)")
|
||||
.HasColumnName("proof_asset_key");
|
||||
|
||||
b.Property<string>("Reason")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("character varying(1000)")
|
||||
.HasColumnName("reason");
|
||||
|
||||
b.Property<Guid?>("RefundRequestId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("refund_request_id");
|
||||
|
||||
b.Property<DateTimeOffset?>("ReviewedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("reviewed_at");
|
||||
|
||||
b.Property<Guid?>("ReviewedBy")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("reviewed_by");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<Guid>("TenantId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("tenant_id");
|
||||
|
||||
b.Property<DateTimeOffset>("UpdatedAt")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("updated_at")
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
b.Property<string>("VoucherNo")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)")
|
||||
.HasColumnName("voucher_no");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_commerce_adjustment_vouchers");
|
||||
|
||||
b.HasAlternateKey("TenantId", "Id")
|
||||
.HasName("ak_commerce_adjustment_vouchers_tenant_id_id");
|
||||
|
||||
b.HasIndex("CreatedBy")
|
||||
.HasDatabaseName("ix_commerce_adjustment_vouchers_created_by");
|
||||
|
||||
b.HasIndex("ReviewedBy")
|
||||
.HasDatabaseName("ix_commerce_adjustment_vouchers_reviewed_by");
|
||||
|
||||
b.HasIndex("TenantId", "BatchId")
|
||||
.HasDatabaseName("ix_commerce_adjustment_vouchers_tenant_id_batch_id");
|
||||
|
||||
b.HasIndex("TenantId", "ItemId")
|
||||
.HasDatabaseName("ix_commerce_adjustment_vouchers_tenant_id_item_id");
|
||||
|
||||
b.HasIndex("TenantId", "OrderId")
|
||||
.HasDatabaseName("ix_commerce_adjustment_vouchers_tenant_id_order_id");
|
||||
|
||||
b.HasIndex("TenantId", "PaymentId")
|
||||
.HasDatabaseName("ix_commerce_adjustment_vouchers_tenant_id_payment_id");
|
||||
|
||||
b.HasIndex("TenantId", "RefundRequestId")
|
||||
.HasDatabaseName("ix_commerce_adjustment_vouchers_tenant_id_refund_request_id");
|
||||
|
||||
b.HasIndex("TenantId", "VoucherNo")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("ix_commerce_adjustment_vouchers_tenant_id_voucher_no");
|
||||
|
||||
b.HasIndex("TenantId", "IssueId", "CreatedAt")
|
||||
.HasDatabaseName("ix_commerce_adjustment_vouchers_tenant_id_issue_id_created_at");
|
||||
|
||||
b.HasIndex("TenantId", "Status", "CreatedAt")
|
||||
.HasDatabaseName("ix_commerce_adjustment_vouchers_tenant_id_status_created_at");
|
||||
|
||||
b.ToTable("commerce_adjustment_vouchers", null, t =>
|
||||
{
|
||||
t.HasCheckConstraint("ck_commerce_adjustment_vouchers_amount", "amount_cents > 0");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Tiku.Domain.Commerce.CommerceAdjustmentVoucherEvent", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("id")
|
||||
.HasDefaultValueSql("gen_random_uuid()");
|
||||
|
||||
b.Property<Guid?>("ActorUserId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("actor_user_id");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("created_at")
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
b.Property<JsonElement>("Details")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("details")
|
||||
.HasDefaultValueSql("'{}'::jsonb");
|
||||
|
||||
b.Property<string>("FromStatus")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)")
|
||||
.HasColumnName("from_status");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("character varying(1000)")
|
||||
.HasColumnName("note");
|
||||
|
||||
b.Property<Guid>("TenantId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("tenant_id");
|
||||
|
||||
b.Property<string>("ToStatus")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)")
|
||||
.HasColumnName("to_status");
|
||||
|
||||
b.Property<Guid>("VoucherId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("voucher_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_commerce_adjustment_voucher_events");
|
||||
|
||||
b.HasAlternateKey("TenantId", "Id")
|
||||
.HasName("ak_commerce_adjustment_voucher_events_tenant_id_id");
|
||||
|
||||
b.HasIndex("ActorUserId")
|
||||
.HasDatabaseName("ix_commerce_adjustment_voucher_events_actor_user_id");
|
||||
|
||||
b.HasIndex("TenantId", "VoucherId", "CreatedAt")
|
||||
.HasDatabaseName("ix_commerce_adjustment_voucher_events_tenant_id_voucher_id_cre~");
|
||||
|
||||
b.ToTable("commerce_adjustment_voucher_events", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Tiku.Domain.Commerce.CommerceReconciliationBatch", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -12937,7 +13152,7 @@ namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
.HasColumnType("character varying(32)")
|
||||
.HasColumnName("result");
|
||||
|
||||
b.Property<Guid>("TenantId")
|
||||
b.Property<Guid?>("TenantId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("tenant_id");
|
||||
|
||||
@@ -12953,9 +13168,6 @@ namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_auth_login_events");
|
||||
|
||||
b.HasAlternateKey("TenantId", "Id")
|
||||
.HasName("ak_auth_login_events_tenant_id_id");
|
||||
|
||||
b.HasIndex("UserId")
|
||||
.HasDatabaseName("ix_auth_login_events_user_id");
|
||||
|
||||
@@ -14640,6 +14852,94 @@ namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
.HasConstraintName("fk_code_batches_tenants_tenant_id");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Tiku.Domain.Commerce.CommerceAdjustmentVoucher", b =>
|
||||
{
|
||||
b.HasOne("Tiku.Domain.Identity.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("CreatedBy")
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.HasConstraintName("fk_commerce_adjustment_vouchers_users_created_by");
|
||||
|
||||
b.HasOne("Tiku.Domain.Identity.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("ReviewedBy")
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.HasConstraintName("fk_commerce_adjustment_vouchers_users_reviewed_by");
|
||||
|
||||
b.HasOne("Tiku.Domain.Tenancy.Tenant", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_commerce_adjustment_vouchers_tenants_tenant_id");
|
||||
|
||||
b.HasOne("Tiku.Domain.Commerce.CommerceReconciliationBatch", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId", "BatchId")
|
||||
.HasPrincipalKey("TenantId", "Id")
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.HasConstraintName("fk_commerce_adjustment_vouchers_commerce_reconciliation_batche~");
|
||||
|
||||
b.HasOne("Tiku.Domain.Commerce.CommerceReconciliationIssue", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId", "IssueId")
|
||||
.HasPrincipalKey("TenantId", "Id")
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.HasConstraintName("fk_commerce_adjustment_vouchers_commerce_reconciliation_issues~");
|
||||
|
||||
b.HasOne("Tiku.Domain.Commerce.CommerceReconciliationItem", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId", "ItemId")
|
||||
.HasPrincipalKey("TenantId", "Id")
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.HasConstraintName("fk_commerce_adjustment_vouchers_commerce_reconciliation_items_~");
|
||||
|
||||
b.HasOne("Tiku.Domain.Commerce.Order", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId", "OrderId")
|
||||
.HasPrincipalKey("TenantId", "Id")
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.HasConstraintName("fk_commerce_adjustment_vouchers_orders_tenant_id_order_id");
|
||||
|
||||
b.HasOne("Tiku.Domain.Commerce.Payment", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId", "PaymentId")
|
||||
.HasPrincipalKey("TenantId", "Id")
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.HasConstraintName("fk_commerce_adjustment_vouchers_payments_tenant_id_payment_id");
|
||||
|
||||
b.HasOne("Tiku.Domain.Commerce.CommerceRefundRequest", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId", "RefundRequestId")
|
||||
.HasPrincipalKey("TenantId", "Id")
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.HasConstraintName("fk_commerce_adjustment_vouchers_commerce_refund_requests_tenan~");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Tiku.Domain.Commerce.CommerceAdjustmentVoucherEvent", b =>
|
||||
{
|
||||
b.HasOne("Tiku.Domain.Identity.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("ActorUserId")
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.HasConstraintName("fk_commerce_adjustment_voucher_events_users_actor_user_id");
|
||||
|
||||
b.HasOne("Tiku.Domain.Tenancy.Tenant", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_commerce_adjustment_voucher_events_tenants_tenant_id");
|
||||
|
||||
b.HasOne("Tiku.Domain.Commerce.CommerceAdjustmentVoucher", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId", "VoucherId")
|
||||
.HasPrincipalKey("TenantId", "Id")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_commerce_adjustment_voucher_events_commerce_adjustment_vouc~");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Tiku.Domain.Commerce.CommerceReconciliationBatch", b =>
|
||||
{
|
||||
b.HasOne("Tiku.Domain.Identity.User", null)
|
||||
@@ -17401,7 +17701,6 @@ namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId")
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_auth_login_events_tenants_tenant_id");
|
||||
|
||||
b.HasOne("Tiku.Domain.Identity.User", null)
|
||||
|
||||
@@ -136,6 +136,8 @@ public sealed class TikuDbContext(
|
||||
public DbSet<CommerceReconciliationItem> CommerceReconciliationItems => Set<CommerceReconciliationItem>();
|
||||
public DbSet<CommerceReconciliationIssue> CommerceReconciliationIssues => Set<CommerceReconciliationIssue>();
|
||||
public DbSet<CommerceReconciliationIssueEvent> CommerceReconciliationIssueEvents => Set<CommerceReconciliationIssueEvent>();
|
||||
public DbSet<CommerceAdjustmentVoucher> CommerceAdjustmentVouchers => Set<CommerceAdjustmentVoucher>();
|
||||
public DbSet<CommerceAdjustmentVoucherEvent> CommerceAdjustmentVoucherEvents => Set<CommerceAdjustmentVoucherEvent>();
|
||||
public DbSet<PointActivityTask> PointActivityTasks => Set<PointActivityTask>();
|
||||
public DbSet<PointActivityClaim> PointActivityClaims => Set<PointActivityClaim>();
|
||||
public DbSet<PointExchangeItem> PointExchangeItems => Set<PointExchangeItem>();
|
||||
|
||||
Reference in New Issue
Block a user