feat: 商品SKU支持异步保存与软禁用替换策略
All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 56s
All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 56s
This commit is contained in:
@@ -233,6 +233,10 @@ public sealed class TakeoutAppDbContext(
|
||||
/// </summary>
|
||||
public DbSet<ProductSku> ProductSkus => Set<ProductSku>();
|
||||
/// <summary>
|
||||
/// SKU 异步保存任务。
|
||||
/// </summary>
|
||||
public DbSet<ProductSkuSaveJob> ProductSkuSaveJobs => Set<ProductSkuSaveJob>();
|
||||
/// <summary>
|
||||
/// 套餐分组。
|
||||
/// </summary>
|
||||
public DbSet<ProductComboGroup> ProductComboGroups => Set<ProductComboGroup>();
|
||||
@@ -485,6 +489,7 @@ public sealed class TakeoutAppDbContext(
|
||||
ConfigureProductSchedule(modelBuilder.Entity<ProductSchedule>());
|
||||
ConfigureProductScheduleProduct(modelBuilder.Entity<ProductScheduleProduct>());
|
||||
ConfigureProductSku(modelBuilder.Entity<ProductSku>());
|
||||
ConfigureProductSkuSaveJob(modelBuilder.Entity<ProductSkuSaveJob>());
|
||||
ConfigureProductComboGroup(modelBuilder.Entity<ProductComboGroup>());
|
||||
ConfigureProductComboGroupItem(modelBuilder.Entity<ProductComboGroupItem>());
|
||||
ConfigureProductAddonGroup(modelBuilder.Entity<ProductAddonGroup>());
|
||||
@@ -1321,9 +1326,28 @@ public sealed class TakeoutAppDbContext(
|
||||
builder.Property(x => x.Weight).HasPrecision(10, 3);
|
||||
builder.Property(x => x.AttributesJson).HasColumnType("text");
|
||||
builder.Property(x => x.IsEnabled).HasDefaultValue(true);
|
||||
builder.HasIndex(x => new { x.TenantId, x.ProductId });
|
||||
builder.HasIndex(x => new { x.TenantId, x.SkuCode }).IsUnique();
|
||||
}
|
||||
|
||||
private static void ConfigureProductSkuSaveJob(EntityTypeBuilder<ProductSkuSaveJob> builder)
|
||||
{
|
||||
builder.ToTable("product_sku_save_jobs");
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.Property(x => x.StoreId).IsRequired();
|
||||
builder.Property(x => x.ProductId).IsRequired();
|
||||
builder.Property(x => x.Status).HasConversion<int>();
|
||||
builder.Property(x => x.Mode).HasMaxLength(16).IsRequired();
|
||||
builder.Property(x => x.PayloadJson).HasColumnType("text").IsRequired();
|
||||
builder.Property(x => x.ProgressTotal).IsRequired();
|
||||
builder.Property(x => x.ProgressProcessed).IsRequired();
|
||||
builder.Property(x => x.FailedCount).IsRequired();
|
||||
builder.Property(x => x.ErrorMessage).HasMaxLength(2000);
|
||||
builder.Property(x => x.HangfireJobId).HasMaxLength(64);
|
||||
builder.HasIndex(x => new { x.TenantId, x.ProductId, x.CreatedAt });
|
||||
builder.HasIndex(x => new { x.TenantId, x.Status, x.CreatedAt });
|
||||
}
|
||||
|
||||
private static void ConfigureProductComboGroup(EntityTypeBuilder<ProductComboGroup> builder)
|
||||
{
|
||||
builder.ToTable("product_combo_groups");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace TakeoutSaaS.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddProductSkuSaveJobsAndReplaceIndex : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "product_sku_save_jobs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false, comment: "实体唯一标识。")
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
StoreId = table.Column<long>(type: "bigint", nullable: false, comment: "所属门店 ID。"),
|
||||
ProductId = table.Column<long>(type: "bigint", nullable: false, comment: "所属商品 ID。"),
|
||||
Status = table.Column<int>(type: "integer", nullable: false, comment: "任务状态。"),
|
||||
Mode = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false, comment: "任务模式(当前固定 replace)。"),
|
||||
PayloadJson = table.Column<string>(type: "text", nullable: false, comment: "任务请求负载 JSON 快照。"),
|
||||
ProgressTotal = table.Column<int>(type: "integer", nullable: false, comment: "总处理数。"),
|
||||
ProgressProcessed = table.Column<int>(type: "integer", nullable: false, comment: "已处理数。"),
|
||||
FailedCount = table.Column<int>(type: "integer", nullable: false, comment: "失败条数。"),
|
||||
ErrorMessage = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: true, comment: "失败摘要。"),
|
||||
HangfireJobId = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true, comment: "Hangfire 任务 ID。"),
|
||||
StartedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "开始执行时间(UTC)。"),
|
||||
FinishedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "完成时间(UTC)。"),
|
||||
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间(UTC)。"),
|
||||
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最近一次更新时间(UTC),从未更新时为 null。"),
|
||||
DeletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "软删除时间(UTC),未删除时为 null。"),
|
||||
CreatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "创建人用户标识,匿名或系统操作时为 null。"),
|
||||
UpdatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "最后更新人用户标识,匿名或系统操作时为 null。"),
|
||||
DeletedBy = table.Column<long>(type: "bigint", nullable: true, comment: "删除人用户标识(软删除),未删除时为 null。"),
|
||||
TenantId = table.Column<long>(type: "bigint", nullable: false, comment: "所属租户 ID。")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_product_sku_save_jobs", x => x.Id);
|
||||
},
|
||||
comment: "商品 SKU 异步保存任务。");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_product_skus_TenantId_ProductId",
|
||||
table: "product_skus",
|
||||
columns: new[] { "TenantId", "ProductId" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_product_sku_save_jobs_TenantId_ProductId_CreatedAt",
|
||||
table: "product_sku_save_jobs",
|
||||
columns: new[] { "TenantId", "ProductId", "CreatedAt" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_product_sku_save_jobs_TenantId_Status_CreatedAt",
|
||||
table: "product_sku_save_jobs",
|
||||
columns: new[] { "TenantId", "Status", "CreatedAt" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "product_sku_save_jobs");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_product_skus_TenantId_ProductId",
|
||||
table: "product_skus");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5138,6 +5138,8 @@ namespace TakeoutSaaS.Infrastructure.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TenantId", "ProductId");
|
||||
|
||||
b.HasIndex("TenantId", "SkuCode")
|
||||
.IsUnique();
|
||||
|
||||
@@ -5147,6 +5149,108 @@ namespace TakeoutSaaS.Infrastructure.Migrations
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductSkuSaveJob", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasComment("实体唯一标识。");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasComment("创建时间(UTC)。");
|
||||
|
||||
b.Property<long?>("CreatedBy")
|
||||
.HasColumnType("bigint")
|
||||
.HasComment("创建人用户标识,匿名或系统操作时为 null。");
|
||||
|
||||
b.Property<DateTime?>("DeletedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasComment("软删除时间(UTC),未删除时为 null。");
|
||||
|
||||
b.Property<long?>("DeletedBy")
|
||||
.HasColumnType("bigint")
|
||||
.HasComment("删除人用户标识(软删除),未删除时为 null。");
|
||||
|
||||
b.Property<string>("ErrorMessage")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)")
|
||||
.HasComment("失败摘要。");
|
||||
|
||||
b.Property<int>("FailedCount")
|
||||
.HasColumnType("integer")
|
||||
.HasComment("失败条数。");
|
||||
|
||||
b.Property<DateTime?>("FinishedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasComment("完成时间(UTC)。");
|
||||
|
||||
b.Property<string>("HangfireJobId")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)")
|
||||
.HasComment("Hangfire 任务 ID。");
|
||||
|
||||
b.Property<string>("Mode")
|
||||
.IsRequired()
|
||||
.HasMaxLength(16)
|
||||
.HasColumnType("character varying(16)")
|
||||
.HasComment("任务模式(当前固定 replace)。");
|
||||
|
||||
b.Property<string>("PayloadJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasComment("任务请求负载 JSON 快照。");
|
||||
|
||||
b.Property<long>("ProductId")
|
||||
.HasColumnType("bigint")
|
||||
.HasComment("所属商品 ID。");
|
||||
|
||||
b.Property<int>("ProgressProcessed")
|
||||
.HasColumnType("integer")
|
||||
.HasComment("已处理数。");
|
||||
|
||||
b.Property<int>("ProgressTotal")
|
||||
.HasColumnType("integer")
|
||||
.HasComment("总处理数。");
|
||||
|
||||
b.Property<DateTime?>("StartedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasComment("开始执行时间(UTC)。");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer")
|
||||
.HasComment("任务状态。");
|
||||
|
||||
b.Property<long>("StoreId")
|
||||
.HasColumnType("bigint")
|
||||
.HasComment("所属门店 ID。");
|
||||
|
||||
b.Property<long>("TenantId")
|
||||
.HasColumnType("bigint")
|
||||
.HasComment("所属租户 ID。");
|
||||
|
||||
b.Property<DateTime?>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasComment("最近一次更新时间(UTC),从未更新时为 null。");
|
||||
|
||||
b.Property<long?>("UpdatedBy")
|
||||
.HasColumnType("bigint")
|
||||
.HasComment("最后更新人用户标识,匿名或系统操作时为 null。");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TenantId", "ProductId", "CreatedAt");
|
||||
|
||||
b.HasIndex("TenantId", "Status", "CreatedAt");
|
||||
|
||||
b.ToTable("product_sku_save_jobs", null, t =>
|
||||
{
|
||||
t.HasComment("商品 SKU 异步保存任务。");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TakeoutSaaS.Domain.Products.Entities.ProductSpecTemplate", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
|
||||
Reference in New Issue
Block a user