feat:商户管理

This commit is contained in:
2025-12-29 16:40:27 +08:00
parent 57f4c2d394
commit dd91c1010a
62 changed files with 10536 additions and 165 deletions

View File

@@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
using TakeoutSaaS.Domain.Deliveries.Repositories;
using TakeoutSaaS.Domain.Inventory.Repositories;
using TakeoutSaaS.Domain.Merchants.Repositories;
using TakeoutSaaS.Domain.Merchants.Services;
using TakeoutSaaS.Domain.Orders.Repositories;
using TakeoutSaaS.Domain.Payments.Repositories;
using TakeoutSaaS.Domain.Products.Repositories;
@@ -63,6 +64,7 @@ public static class AppServiceCollectionExtensions
// 1. 账单领域/导出服务
services.AddScoped<IBillingDomainService, BillingDomainService>();
services.AddScoped<IBillingExportService, BillingExportService>();
services.AddScoped<IMerchantExportService, MerchantExportService>();
services.AddOptions<AppSeedOptions>()
.Bind(configuration.GetSection(AppSeedOptions.SectionName))

View File

@@ -469,6 +469,7 @@ public sealed class TakeoutAppDbContext(
builder.Property(x => x.Industry).HasMaxLength(64);
builder.Property(x => x.LogoUrl).HasColumnType("text");
builder.Property(x => x.Remarks).HasMaxLength(512);
builder.Property(x => x.OperatingMode).HasConversion<int>();
builder.HasIndex(x => x.Code).IsUnique();
builder.HasIndex(x => x.ContactPhone).IsUnique();
}
@@ -533,7 +534,17 @@ public sealed class TakeoutAppDbContext(
builder.Property(x => x.District).HasMaxLength(64);
builder.Property(x => x.Address).HasMaxLength(256);
builder.Property(x => x.ReviewRemarks).HasMaxLength(512);
builder.Property(x => x.OperatingMode).HasConversion<int>();
builder.Property(x => x.IsFrozen).HasDefaultValue(false);
builder.Property(x => x.FrozenReason).HasMaxLength(500);
builder.Property(x => x.ClaimedByName).HasMaxLength(100);
builder.Property(x => x.RowVersion)
.IsRowVersion()
.IsConcurrencyToken()
.HasColumnType("bytea");
builder.HasIndex(x => x.TenantId);
builder.HasIndex(x => new { x.TenantId, x.Status });
builder.HasIndex(x => x.ClaimedBy);
}
private static void ConfigureStore(EntityTypeBuilder<Store> builder)
@@ -544,6 +555,10 @@ public sealed class TakeoutAppDbContext(
builder.Property(x => x.Name).HasMaxLength(128).IsRequired();
builder.Property(x => x.Phone).HasMaxLength(32);
builder.Property(x => x.ManagerName).HasMaxLength(64);
builder.Property(x => x.BusinessLicenseNumber).HasMaxLength(50);
builder.Property(x => x.LegalRepresentative).HasMaxLength(100);
builder.Property(x => x.RegisteredAddress).HasMaxLength(500);
builder.Property(x => x.BusinessLicenseImageUrl).HasMaxLength(500);
builder.Property(x => x.Province).HasMaxLength(64);
builder.Property(x => x.City).HasMaxLength(64);
builder.Property(x => x.District).HasMaxLength(64);
@@ -553,6 +568,9 @@ public sealed class TakeoutAppDbContext(
builder.Property(x => x.DeliveryRadiusKm).HasPrecision(6, 2);
builder.HasIndex(x => new { x.TenantId, x.MerchantId });
builder.HasIndex(x => new { x.TenantId, x.Code }).IsUnique();
builder.HasIndex(x => new { x.MerchantId, x.BusinessLicenseNumber })
.IsUnique()
.HasFilter("\"BusinessLicenseNumber\" IS NOT NULL AND \"Status\" <> 3");
}
private static void ConfigureProductCategory(EntityTypeBuilder<ProductCategory> builder)

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using TakeoutSaaS.Domain.Common.Enums;
using TakeoutSaaS.Domain.Merchants.Entities;
using TakeoutSaaS.Domain.Merchants.Enums;
using TakeoutSaaS.Domain.Merchants.Repositories;
@@ -24,6 +25,26 @@ public sealed class EfMerchantRepository(TakeoutAppDbContext context, TakeoutLog
.FirstOrDefaultAsync(cancellationToken);
}
/// <inheritdoc />
public Task<Merchant?> FindByIdAsync(long merchantId, CancellationToken cancellationToken = default)
{
return context.Merchants
.IgnoreQueryFilters()
.AsNoTracking()
.Where(x => x.Id == merchantId)
.FirstOrDefaultAsync(cancellationToken);
}
/// <inheritdoc />
public Task<Merchant?> FindByTenantIdAsync(long tenantId, CancellationToken cancellationToken = default)
{
return context.Merchants
.IgnoreQueryFilters()
.AsNoTracking()
.Where(x => x.TenantId == tenantId)
.FirstOrDefaultAsync(cancellationToken);
}
/// <inheritdoc />
public async Task<IReadOnlyList<Merchant>> SearchAsync(long tenantId, MerchantStatus? status, CancellationToken cancellationToken = default)
{
@@ -208,9 +229,79 @@ public sealed class EfMerchantRepository(TakeoutAppDbContext context, TakeoutLog
public async Task<IReadOnlyList<MerchantAuditLog>> GetAuditLogsAsync(long merchantId, long tenantId, CancellationToken cancellationToken = default)
{
return await logsContext.MerchantAuditLogs
.IgnoreQueryFilters()
.AsNoTracking()
.Where(x => x.TenantId == tenantId && x.MerchantId == merchantId)
.OrderByDescending(x => x.CreatedAt)
.ToListAsync(cancellationToken);
}
/// <inheritdoc />
public async Task<IReadOnlyList<Merchant>> SearchAsync(
long? tenantId,
MerchantStatus? status,
OperatingMode? operatingMode,
string? keyword,
CancellationToken cancellationToken = default)
{
var query = context.Merchants
.IgnoreQueryFilters()
.AsNoTracking()
.AsQueryable();
if (tenantId.HasValue && tenantId.Value > 0)
{
query = query.Where(x => x.TenantId == tenantId.Value);
}
if (status.HasValue)
{
query = query.Where(x => x.Status == status.Value);
}
if (operatingMode.HasValue)
{
query = query.Where(x => x.OperatingMode == operatingMode.Value);
}
if (!string.IsNullOrWhiteSpace(keyword))
{
var normalized = keyword.Trim();
query = query.Where(x =>
EF.Functions.ILike(x.BrandName, $"%{normalized}%") ||
EF.Functions.ILike(x.BusinessLicenseNumber ?? string.Empty, $"%{normalized}%"));
}
return await query
.OrderByDescending(x => x.CreatedAt)
.ToListAsync(cancellationToken);
}
/// <inheritdoc />
public Task AddChangeLogAsync(MerchantChangeLog log, CancellationToken cancellationToken = default)
{
return logsContext.MerchantChangeLogs.AddAsync(log, cancellationToken).AsTask();
}
/// <inheritdoc />
public async Task<IReadOnlyList<MerchantChangeLog>> GetChangeLogsAsync(
long merchantId,
long tenantId,
string? fieldName = null,
CancellationToken cancellationToken = default)
{
var query = logsContext.MerchantChangeLogs
.IgnoreQueryFilters()
.AsNoTracking()
.Where(x => x.TenantId == tenantId && x.MerchantId == merchantId);
if (!string.IsNullOrWhiteSpace(fieldName))
{
query = query.Where(x => x.FieldName == fieldName);
}
return await query
.OrderByDescending(x => x.CreatedAt)
.ToListAsync(cancellationToken);
}
}

View File

@@ -25,6 +25,16 @@ public sealed class EfStoreRepository(TakeoutAppDbContext context) : IStoreRepos
.FirstOrDefaultAsync(cancellationToken);
}
/// <inheritdoc />
public async Task<IReadOnlyList<Store>> GetByMerchantIdAsync(long merchantId, long tenantId, CancellationToken cancellationToken = default)
{
return await context.Stores
.AsNoTracking()
.Where(x => x.TenantId == tenantId && x.MerchantId == merchantId)
.OrderBy(x => x.Name)
.ToListAsync(cancellationToken);
}
/// <inheritdoc />
public async Task<IReadOnlyList<Store>> SearchAsync(long tenantId, StoreStatus? status, CancellationToken cancellationToken = default)
{
@@ -44,6 +54,31 @@ public sealed class EfStoreRepository(TakeoutAppDbContext context) : IStoreRepos
return stores;
}
/// <inheritdoc />
public async Task<Dictionary<long, int>> GetStoreCountsAsync(long? tenantId, IReadOnlyCollection<long> merchantIds, CancellationToken cancellationToken = default)
{
if (merchantIds.Count == 0)
{
return new Dictionary<long, int>();
}
var query = context.Stores.AsNoTracking();
if (!tenantId.HasValue || tenantId.Value <= 0)
{
query = query.IgnoreQueryFilters();
}
else
{
query = query.Where(x => x.TenantId == tenantId.Value);
}
return await query
.Where(x => merchantIds.Contains(x.MerchantId))
.GroupBy(x => x.MerchantId)
.Select(group => new { group.Key, Count = group.Count() })
.ToDictionaryAsync(x => x.Key, x => x.Count, cancellationToken);
}
/// <inheritdoc />
public async Task<IReadOnlyList<StoreBusinessHour>> GetBusinessHoursAsync(long storeId, long tenantId, CancellationToken cancellationToken = default)
{

View File

@@ -0,0 +1,152 @@
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
using System.Globalization;
using TakeoutSaaS.Domain.Common.Enums;
using TakeoutSaaS.Domain.Merchants.Entities;
using TakeoutSaaS.Domain.Merchants.Enums;
using TakeoutSaaS.Domain.Merchants.Services;
using TakeoutSaaS.Domain.Stores.Entities;
using TakeoutSaaS.Domain.Stores.Enums;
namespace TakeoutSaaS.Infrastructure.App.Services;
/// <summary>
/// 商户导出服务实现PDF
/// </summary>
public sealed class MerchantExportService : IMerchantExportService
{
public MerchantExportService()
{
QuestPDF.Settings.License = LicenseType.Community;
}
/// <inheritdoc />
public Task<byte[]> ExportToPdfAsync(
Merchant merchant,
string? tenantName,
IReadOnlyList<Store> stores,
IReadOnlyList<MerchantAuditLog> auditLogs,
CancellationToken cancellationToken = default)
{
ArgumentNullException.ThrowIfNull(merchant);
var safeStores = stores ?? Array.Empty<Store>();
var safeAuditLogs = auditLogs ?? Array.Empty<MerchantAuditLog>();
var document = Document.Create(container =>
{
container.Page(page =>
{
page.Size(PageSizes.A4);
page.Margin(24);
page.DefaultTextStyle(x => x.FontSize(10));
page.Content().Column(column =>
{
column.Spacing(10);
column.Item().Text("Merchant Export").FontSize(16).SemiBold();
column.Item().Element(section => BuildBasicSection(section, merchant, tenantName));
column.Item().Element(section => BuildStoresSection(section, safeStores, cancellationToken));
column.Item().Element(section => BuildAuditSection(section, safeAuditLogs, cancellationToken));
});
});
});
return Task.FromResult(document.GeneratePdf());
}
private static void BuildBasicSection(IContainer container, Merchant merchant, string? tenantName)
{
container.Border(1).BorderColor(Colors.Grey.Lighten2).Padding(10).Column(column =>
{
column.Spacing(4);
column.Item().Text("Basic Information").SemiBold();
column.Item().Text($"Merchant: {merchant.BrandName}");
column.Item().Text($"Tenant: {tenantName ?? "-"} (ID: {merchant.TenantId})");
column.Item().Text($"Operating Mode: {ResolveOperatingMode(merchant.OperatingMode)}");
column.Item().Text($"Status: {merchant.Status}");
column.Item().Text($"Frozen: {(merchant.IsFrozen ? "Yes" : "No")}");
column.Item().Text($"License Number: {merchant.BusinessLicenseNumber ?? "-"}");
column.Item().Text($"Legal Representative: {merchant.LegalPerson ?? "-"}");
column.Item().Text($"Registered Address: {merchant.Address ?? "-"}");
column.Item().Text($"Contact Phone: {merchant.ContactPhone}");
column.Item().Text($"Contact Email: {merchant.ContactEmail ?? "-"}");
column.Item().Text($"Approved At: {FormatDateTime(merchant.ApprovedAt)}");
column.Item().Text($"Approved By: {merchant.ApprovedBy?.ToString() ?? "-"}");
});
}
private static void BuildStoresSection(IContainer container, IReadOnlyList<Store> stores, CancellationToken cancellationToken)
{
container.Border(1).BorderColor(Colors.Grey.Lighten2).Padding(10).Column(column =>
{
column.Spacing(4);
column.Item().Text("Stores").SemiBold();
if (stores.Count == 0)
{
column.Item().Text("No stores.");
return;
}
for (var i = 0; i < stores.Count; i++)
{
cancellationToken.ThrowIfCancellationRequested();
var store = stores[i];
column.Item().Text($"{i + 1}. {store.Name} | {ResolveStoreStatus(store.Status)} | {store.Address ?? "-"} | {store.Phone ?? "-"}");
}
});
}
private static void BuildAuditSection(IContainer container, IReadOnlyList<MerchantAuditLog> auditLogs, CancellationToken cancellationToken)
{
container.Border(1).BorderColor(Colors.Grey.Lighten2).Padding(10).Column(column =>
{
column.Spacing(4);
column.Item().Text("Audit History").SemiBold();
if (auditLogs.Count == 0)
{
column.Item().Text("No audit records.");
return;
}
for (var i = 0; i < auditLogs.Count; i++)
{
cancellationToken.ThrowIfCancellationRequested();
var log = auditLogs[i];
var title = string.IsNullOrWhiteSpace(log.Title) ? log.Action.ToString() : log.Title;
column.Item().Text($"{i + 1}. {title} | {log.OperatorName ?? "-"} | {FormatDateTime(log.CreatedAt)}");
if (!string.IsNullOrWhiteSpace(log.Description))
{
column.Item().Text($" {log.Description}");
}
}
});
}
private static string ResolveOperatingMode(OperatingMode? mode)
=> mode switch
{
OperatingMode.SameEntity => "SameEntity",
OperatingMode.DifferentEntity => "DifferentEntity",
_ => "-"
};
private static string ResolveStoreStatus(StoreStatus status)
=> status switch
{
StoreStatus.Closed => "Closed",
StoreStatus.Preparing => "Preparing",
StoreStatus.Operating => "Operating",
StoreStatus.Suspended => "Suspended",
_ => status.ToString()
};
private static string FormatDateTime(DateTime? value)
=> value.HasValue ? value.Value.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture) : "-";
}

View File

@@ -30,6 +30,11 @@ public sealed class TakeoutLogsDbContext(
/// </summary>
public DbSet<MerchantAuditLog> MerchantAuditLogs => Set<MerchantAuditLog>();
/// <summary>
/// 商户变更日志集合。
/// </summary>
public DbSet<MerchantChangeLog> MerchantChangeLogs => Set<MerchantChangeLog>();
/// <summary>
/// 运营操作日志集合。
/// </summary>
@@ -54,6 +59,7 @@ public sealed class TakeoutLogsDbContext(
base.OnModelCreating(modelBuilder);
ConfigureTenantAuditLog(modelBuilder.Entity<TenantAuditLog>());
ConfigureMerchantAuditLog(modelBuilder.Entity<MerchantAuditLog>());
ConfigureMerchantChangeLog(modelBuilder.Entity<MerchantChangeLog>());
ConfigureOperationLog(modelBuilder.Entity<OperationLog>());
ConfigureOperationLogInboxMessage(modelBuilder.Entity<OperationLogInboxMessage>());
ConfigureMemberGrowthLog(modelBuilder.Entity<MemberGrowthLog>());
@@ -75,10 +81,29 @@ public sealed class TakeoutLogsDbContext(
builder.ToTable("merchant_audit_logs");
builder.HasKey(x => x.Id);
builder.Property(x => x.MerchantId).IsRequired();
builder.Property(x => x.Title).HasMaxLength(128).IsRequired();
builder.Property(x => x.Action).HasConversion<int>().IsRequired();
builder.Property(x => x.Title).HasMaxLength(200).IsRequired();
builder.Property(x => x.Description).HasMaxLength(1024);
builder.Property(x => x.OperatorName).HasMaxLength(64);
builder.Property(x => x.OperatorName).HasMaxLength(100);
builder.Property(x => x.IpAddress).HasMaxLength(50);
builder.HasIndex(x => new { x.TenantId, x.MerchantId });
builder.HasIndex(x => new { x.MerchantId, x.CreatedAt });
builder.HasIndex(x => new { x.TenantId, x.CreatedAt });
}
private static void ConfigureMerchantChangeLog(EntityTypeBuilder<MerchantChangeLog> builder)
{
builder.ToTable("merchant_change_logs");
builder.HasKey(x => x.Id);
builder.Property(x => x.MerchantId).IsRequired();
builder.Property(x => x.FieldName).HasMaxLength(100).IsRequired();
builder.Property(x => x.OldValue).HasColumnType("text");
builder.Property(x => x.NewValue).HasColumnType("text");
builder.Property(x => x.ChangeType).HasMaxLength(20).IsRequired();
builder.Property(x => x.ChangedByName).HasMaxLength(100);
builder.Property(x => x.ChangeReason).HasMaxLength(512);
builder.HasIndex(x => new { x.MerchantId, x.CreatedAt });
builder.HasIndex(x => new { x.TenantId, x.CreatedAt });
}
private static void ConfigureOperationLog(EntityTypeBuilder<OperationLog> builder)

View File

@@ -0,0 +1,244 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TakeoutSaaS.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddMerchantManagement : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "OperatingMode",
table: "tenants",
type: "integer",
nullable: true,
comment: "经营模式(同一主体/不同主体)。");
migrationBuilder.AddColumn<string>(
name: "BusinessLicenseImageUrl",
table: "stores",
type: "character varying(500)",
maxLength: 500,
nullable: true,
comment: "门店营业执照图片地址(主体不一致模式使用)。");
migrationBuilder.AddColumn<string>(
name: "BusinessLicenseNumber",
table: "stores",
type: "character varying(50)",
maxLength: 50,
nullable: true,
comment: "门店营业执照号(主体不一致模式使用)。");
migrationBuilder.AddColumn<string>(
name: "LegalRepresentative",
table: "stores",
type: "character varying(100)",
maxLength: 100,
nullable: true,
comment: "门店法人(主体不一致模式使用)。");
migrationBuilder.AddColumn<string>(
name: "RegisteredAddress",
table: "stores",
type: "character varying(500)",
maxLength: 500,
nullable: true,
comment: "门店注册地址(主体不一致模式使用)。");
migrationBuilder.AddColumn<DateTime>(
name: "ApprovedAt",
table: "merchants",
type: "timestamp with time zone",
nullable: true,
comment: "审核通过时间。");
migrationBuilder.AddColumn<long>(
name: "ApprovedBy",
table: "merchants",
type: "bigint",
nullable: true,
comment: "审核通过人。");
migrationBuilder.AddColumn<DateTime>(
name: "ClaimExpiresAt",
table: "merchants",
type: "timestamp with time zone",
nullable: true,
comment: "领取过期时间。");
migrationBuilder.AddColumn<DateTime>(
name: "ClaimedAt",
table: "merchants",
type: "timestamp with time zone",
nullable: true,
comment: "领取时间。");
migrationBuilder.AddColumn<long>(
name: "ClaimedBy",
table: "merchants",
type: "bigint",
nullable: true,
comment: "当前领取人。");
migrationBuilder.AddColumn<string>(
name: "ClaimedByName",
table: "merchants",
type: "character varying(100)",
maxLength: 100,
nullable: true,
comment: "当前领取人姓名。");
migrationBuilder.AddColumn<DateTime>(
name: "FrozenAt",
table: "merchants",
type: "timestamp with time zone",
nullable: true,
comment: "冻结时间。");
migrationBuilder.AddColumn<string>(
name: "FrozenReason",
table: "merchants",
type: "character varying(500)",
maxLength: 500,
nullable: true,
comment: "冻结原因。");
migrationBuilder.AddColumn<bool>(
name: "IsFrozen",
table: "merchants",
type: "boolean",
nullable: false,
defaultValue: false,
comment: "是否冻结业务。");
migrationBuilder.AddColumn<long>(
name: "LastReviewedBy",
table: "merchants",
type: "bigint",
nullable: true,
comment: "最近一次审核人。");
migrationBuilder.AddColumn<int>(
name: "OperatingMode",
table: "merchants",
type: "integer",
nullable: true,
comment: "经营模式(同一主体/不同主体)。");
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "merchants",
type: "bytea",
rowVersion: true,
nullable: false,
defaultValue: new byte[0],
comment: "并发控制版本。");
migrationBuilder.CreateIndex(
name: "IX_stores_MerchantId_BusinessLicenseNumber",
table: "stores",
columns: new[] { "MerchantId", "BusinessLicenseNumber" },
unique: true,
filter: "\"BusinessLicenseNumber\" IS NOT NULL AND \"Status\" <> 3");
migrationBuilder.CreateIndex(
name: "IX_merchants_ClaimedBy",
table: "merchants",
column: "ClaimedBy");
migrationBuilder.CreateIndex(
name: "IX_merchants_TenantId_Status",
table: "merchants",
columns: new[] { "TenantId", "Status" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_stores_MerchantId_BusinessLicenseNumber",
table: "stores");
migrationBuilder.DropIndex(
name: "IX_merchants_ClaimedBy",
table: "merchants");
migrationBuilder.DropIndex(
name: "IX_merchants_TenantId_Status",
table: "merchants");
migrationBuilder.DropColumn(
name: "OperatingMode",
table: "tenants");
migrationBuilder.DropColumn(
name: "BusinessLicenseImageUrl",
table: "stores");
migrationBuilder.DropColumn(
name: "BusinessLicenseNumber",
table: "stores");
migrationBuilder.DropColumn(
name: "LegalRepresentative",
table: "stores");
migrationBuilder.DropColumn(
name: "RegisteredAddress",
table: "stores");
migrationBuilder.DropColumn(
name: "ApprovedAt",
table: "merchants");
migrationBuilder.DropColumn(
name: "ApprovedBy",
table: "merchants");
migrationBuilder.DropColumn(
name: "ClaimExpiresAt",
table: "merchants");
migrationBuilder.DropColumn(
name: "ClaimedAt",
table: "merchants");
migrationBuilder.DropColumn(
name: "ClaimedBy",
table: "merchants");
migrationBuilder.DropColumn(
name: "ClaimedByName",
table: "merchants");
migrationBuilder.DropColumn(
name: "FrozenAt",
table: "merchants");
migrationBuilder.DropColumn(
name: "FrozenReason",
table: "merchants");
migrationBuilder.DropColumn(
name: "IsFrozen",
table: "merchants");
migrationBuilder.DropColumn(
name: "LastReviewedBy",
table: "merchants");
migrationBuilder.DropColumn(
name: "OperatingMode",
table: "merchants");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "merchants");
}
}
}

View File

@@ -0,0 +1,454 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using TakeoutSaaS.Infrastructure.Logs.Persistence;
#nullable disable
namespace TakeoutSaaS.Infrastructure.Migrations.LogsDb
{
[DbContext(typeof(TakeoutLogsDbContext))]
[Migration("20251229071940_AddMerchantManagementLogs")]
partial class AddMerchantManagementLogs
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.1")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("TakeoutSaaS.Domain.Membership.Entities.MemberGrowthLog", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasComment("实体唯一标识。");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<int>("ChangeValue")
.HasColumnType("integer")
.HasComment("变动数量。");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone")
.HasComment("创建时间UTC。");
b.Property<long?>("CreatedBy")
.HasColumnType("bigint")
.HasComment("创建人用户标识,匿名或系统操作时为 null。");
b.Property<int>("CurrentValue")
.HasColumnType("integer")
.HasComment("当前成长值。");
b.Property<DateTime?>("DeletedAt")
.HasColumnType("timestamp with time zone")
.HasComment("软删除时间UTC未删除时为 null。");
b.Property<long?>("DeletedBy")
.HasColumnType("bigint")
.HasComment("删除人用户标识(软删除),未删除时为 null。");
b.Property<long>("MemberId")
.HasColumnType("bigint")
.HasComment("会员标识。");
b.Property<string>("Notes")
.HasMaxLength(256)
.HasColumnType("character varying(256)")
.HasComment("备注。");
b.Property<DateTime>("OccurredAt")
.HasColumnType("timestamp with time zone")
.HasComment("发生时间。");
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", "MemberId", "OccurredAt");
b.ToTable("member_growth_logs", null, t =>
{
t.HasComment("成长值变动日志。");
});
});
modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.MerchantAuditLog", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasComment("实体唯一标识。");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<int>("Action")
.HasColumnType("integer")
.HasComment("动作类型。");
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>("Description")
.HasMaxLength(1024)
.HasColumnType("character varying(1024)")
.HasComment("详情描述。");
b.Property<string>("IpAddress")
.HasMaxLength(50)
.HasColumnType("character varying(50)")
.HasComment("操作 IP。");
b.Property<long>("MerchantId")
.HasColumnType("bigint")
.HasComment("商户标识。");
b.Property<long?>("OperatorId")
.HasColumnType("bigint")
.HasComment("操作人 ID。");
b.Property<string>("OperatorName")
.HasMaxLength(100)
.HasColumnType("character varying(100)")
.HasComment("操作人名称。");
b.Property<long>("TenantId")
.HasColumnType("bigint")
.HasComment("所属租户 ID。");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)")
.HasComment("标题。");
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("MerchantId", "CreatedAt");
b.HasIndex("TenantId", "CreatedAt");
b.HasIndex("TenantId", "MerchantId");
b.ToTable("merchant_audit_logs", null, t =>
{
t.HasComment("商户入驻审核日志。");
});
});
modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.MerchantChangeLog", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasComment("实体唯一标识。");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<string>("ChangeReason")
.HasMaxLength(512)
.HasColumnType("character varying(512)")
.HasComment("变更原因。");
b.Property<string>("ChangeType")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasComment("变更类型。");
b.Property<long?>("ChangedBy")
.HasColumnType("bigint")
.HasComment("变更人 ID。");
b.Property<string>("ChangedByName")
.HasMaxLength(100)
.HasColumnType("character varying(100)")
.HasComment("变更人名称。");
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>("FieldName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)")
.HasComment("变更字段名。");
b.Property<long>("MerchantId")
.HasColumnType("bigint")
.HasComment("商户标识。");
b.Property<string>("NewValue")
.HasColumnType("text")
.HasComment("变更后值。");
b.Property<string>("OldValue")
.HasColumnType("text")
.HasComment("变更前值。");
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("MerchantId", "CreatedAt");
b.HasIndex("TenantId", "CreatedAt");
b.ToTable("merchant_change_logs", null, t =>
{
t.HasComment("商户变更日志。");
});
});
modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.OperationLog", 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>("OperationType")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)")
.HasComment("操作类型BatchExtend, BatchRemind, StatusChange 等。");
b.Property<string>("OperatorId")
.HasMaxLength(64)
.HasColumnType("character varying(64)")
.HasComment("操作人ID。");
b.Property<string>("OperatorName")
.HasMaxLength(128)
.HasColumnType("character varying(128)")
.HasComment("操作人名称。");
b.Property<string>("Parameters")
.HasColumnType("text")
.HasComment("操作参数JSON。");
b.Property<string>("Result")
.HasColumnType("text")
.HasComment("操作结果JSON。");
b.Property<bool>("Success")
.HasColumnType("boolean")
.HasComment("是否成功。");
b.Property<string>("TargetIds")
.HasColumnType("text")
.HasComment("目标ID列表JSON。");
b.Property<string>("TargetType")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)")
.HasComment("目标类型Subscription, Bill 等。");
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("CreatedAt");
b.HasIndex("OperationType", "CreatedAt");
b.ToTable("operation_logs", null, t =>
{
t.HasComment("运营操作日志。");
});
});
modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.TenantAuditLog", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasComment("实体唯一标识。");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<int>("Action")
.HasColumnType("integer")
.HasComment("操作类型。");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone")
.HasComment("创建时间UTC。");
b.Property<long?>("CreatedBy")
.HasColumnType("bigint")
.HasComment("创建人用户标识,匿名或系统操作时为 null。");
b.Property<int?>("CurrentStatus")
.HasColumnType("integer")
.HasComment("新状态。");
b.Property<DateTime?>("DeletedAt")
.HasColumnType("timestamp with time zone")
.HasComment("软删除时间UTC未删除时为 null。");
b.Property<long?>("DeletedBy")
.HasColumnType("bigint")
.HasComment("删除人用户标识(软删除),未删除时为 null。");
b.Property<string>("Description")
.HasMaxLength(1024)
.HasColumnType("character varying(1024)")
.HasComment("详细描述。");
b.Property<long?>("OperatorId")
.HasColumnType("bigint")
.HasComment("操作人 ID。");
b.Property<string>("OperatorName")
.HasMaxLength(64)
.HasColumnType("character varying(64)")
.HasComment("操作人名称。");
b.Property<int?>("PreviousStatus")
.HasColumnType("integer")
.HasComment("原状态。");
b.Property<long>("TenantId")
.HasColumnType("bigint")
.HasComment("关联的租户标识。");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)")
.HasComment("日志标题。");
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");
b.ToTable("tenant_audit_logs", null, t =>
{
t.HasComment("租户运营审核日志。");
});
});
modelBuilder.Entity("TakeoutSaaS.Infrastructure.Logs.Persistence.OperationLogInboxMessage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasComment("实体唯一标识。");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<DateTime>("ConsumedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("MessageId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("MessageId")
.IsUnique();
b.ToTable("operation_log_inbox_messages", (string)null);
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,141 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace TakeoutSaaS.Infrastructure.Migrations.LogsDb
{
/// <inheritdoc />
public partial class AddMerchantManagementLogs : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Title",
table: "merchant_audit_logs",
type: "character varying(200)",
maxLength: 200,
nullable: false,
comment: "标题。",
oldClrType: typeof(string),
oldType: "character varying(128)",
oldMaxLength: 128,
oldComment: "标题。");
migrationBuilder.AlterColumn<string>(
name: "OperatorName",
table: "merchant_audit_logs",
type: "character varying(100)",
maxLength: 100,
nullable: true,
comment: "操作人名称。",
oldClrType: typeof(string),
oldType: "character varying(64)",
oldMaxLength: 64,
oldNullable: true,
oldComment: "操作人名称。");
migrationBuilder.AddColumn<string>(
name: "IpAddress",
table: "merchant_audit_logs",
type: "character varying(50)",
maxLength: 50,
nullable: true,
comment: "操作 IP。");
migrationBuilder.CreateTable(
name: "merchant_change_logs",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false, comment: "实体唯一标识。")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
MerchantId = table.Column<long>(type: "bigint", nullable: false, comment: "商户标识。"),
FieldName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false, comment: "变更字段名。"),
OldValue = table.Column<string>(type: "text", nullable: true, comment: "变更前值。"),
NewValue = table.Column<string>(type: "text", nullable: true, comment: "变更后值。"),
ChangeType = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false, comment: "变更类型。"),
ChangedBy = table.Column<long>(type: "bigint", nullable: true, comment: "变更人 ID。"),
ChangedByName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true, comment: "变更人名称。"),
ChangeReason = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true, comment: "变更原因。"),
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_merchant_change_logs", x => x.Id);
},
comment: "商户变更日志。");
migrationBuilder.CreateIndex(
name: "IX_merchant_audit_logs_MerchantId_CreatedAt",
table: "merchant_audit_logs",
columns: new[] { "MerchantId", "CreatedAt" });
migrationBuilder.CreateIndex(
name: "IX_merchant_audit_logs_TenantId_CreatedAt",
table: "merchant_audit_logs",
columns: new[] { "TenantId", "CreatedAt" });
migrationBuilder.CreateIndex(
name: "IX_merchant_change_logs_MerchantId_CreatedAt",
table: "merchant_change_logs",
columns: new[] { "MerchantId", "CreatedAt" });
migrationBuilder.CreateIndex(
name: "IX_merchant_change_logs_TenantId_CreatedAt",
table: "merchant_change_logs",
columns: new[] { "TenantId", "CreatedAt" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "merchant_change_logs");
migrationBuilder.DropIndex(
name: "IX_merchant_audit_logs_MerchantId_CreatedAt",
table: "merchant_audit_logs");
migrationBuilder.DropIndex(
name: "IX_merchant_audit_logs_TenantId_CreatedAt",
table: "merchant_audit_logs");
migrationBuilder.DropColumn(
name: "IpAddress",
table: "merchant_audit_logs");
migrationBuilder.AlterColumn<string>(
name: "Title",
table: "merchant_audit_logs",
type: "character varying(128)",
maxLength: 128,
nullable: false,
comment: "标题。",
oldClrType: typeof(string),
oldType: "character varying(200)",
oldMaxLength: 200,
oldComment: "标题。");
migrationBuilder.AlterColumn<string>(
name: "OperatorName",
table: "merchant_audit_logs",
type: "character varying(64)",
maxLength: 64,
nullable: true,
comment: "操作人名称。",
oldClrType: typeof(string),
oldType: "character varying(100)",
oldMaxLength: 100,
oldNullable: true,
oldComment: "操作人名称。");
}
}
}

View File

@@ -17,7 +17,7 @@ namespace TakeoutSaaS.Infrastructure.Migrations.LogsDb
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.0")
.HasAnnotation("ProductVersion", "10.0.1")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@@ -124,6 +124,11 @@ namespace TakeoutSaaS.Infrastructure.Migrations.LogsDb
.HasColumnType("character varying(1024)")
.HasComment("详情描述。");
b.Property<string>("IpAddress")
.HasMaxLength(50)
.HasColumnType("character varying(50)")
.HasComment("操作 IP。");
b.Property<long>("MerchantId")
.HasColumnType("bigint")
.HasComment("商户标识。");
@@ -133,8 +138,8 @@ namespace TakeoutSaaS.Infrastructure.Migrations.LogsDb
.HasComment("操作人 ID。");
b.Property<string>("OperatorName")
.HasMaxLength(64)
.HasColumnType("character varying(64)")
.HasMaxLength(100)
.HasColumnType("character varying(100)")
.HasComment("操作人名称。");
b.Property<long>("TenantId")
@@ -143,8 +148,8 @@ namespace TakeoutSaaS.Infrastructure.Migrations.LogsDb
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)")
.HasMaxLength(200)
.HasColumnType("character varying(200)")
.HasComment("标题。");
b.Property<DateTime?>("UpdatedAt")
@@ -157,6 +162,10 @@ namespace TakeoutSaaS.Infrastructure.Migrations.LogsDb
b.HasKey("Id");
b.HasIndex("MerchantId", "CreatedAt");
b.HasIndex("TenantId", "CreatedAt");
b.HasIndex("TenantId", "MerchantId");
b.ToTable("merchant_audit_logs", null, t =>
@@ -165,6 +174,93 @@ namespace TakeoutSaaS.Infrastructure.Migrations.LogsDb
});
});
modelBuilder.Entity("TakeoutSaaS.Domain.Merchants.Entities.MerchantChangeLog", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasComment("实体唯一标识。");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<string>("ChangeReason")
.HasMaxLength(512)
.HasColumnType("character varying(512)")
.HasComment("变更原因。");
b.Property<string>("ChangeType")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasComment("变更类型。");
b.Property<long?>("ChangedBy")
.HasColumnType("bigint")
.HasComment("变更人 ID。");
b.Property<string>("ChangedByName")
.HasMaxLength(100)
.HasColumnType("character varying(100)")
.HasComment("变更人名称。");
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>("FieldName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)")
.HasComment("变更字段名。");
b.Property<long>("MerchantId")
.HasColumnType("bigint")
.HasComment("商户标识。");
b.Property<string>("NewValue")
.HasColumnType("text")
.HasComment("变更后值。");
b.Property<string>("OldValue")
.HasColumnType("text")
.HasComment("变更前值。");
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("MerchantId", "CreatedAt");
b.HasIndex("TenantId", "CreatedAt");
b.ToTable("merchant_change_logs", null, t =>
{
t.HasComment("商户变更日志。");
});
});
modelBuilder.Entity("TakeoutSaaS.Domain.Tenants.Entities.OperationLog", b =>
{
b.Property<long>("Id")

View File

@@ -17,7 +17,7 @@ namespace TakeoutSaaS.Infrastructure.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.0")
.HasAnnotation("ProductVersion", "10.0.1")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@@ -2373,6 +2373,14 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("character varying(256)")
.HasComment("详细地址。");
b.Property<DateTime?>("ApprovedAt")
.HasColumnType("timestamp with time zone")
.HasComment("审核通过时间。");
b.Property<long?>("ApprovedBy")
.HasColumnType("bigint")
.HasComment("审核通过人。");
b.Property<string>("BrandAlias")
.HasMaxLength(64)
.HasColumnType("character varying(64)")
@@ -2402,6 +2410,23 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("character varying(64)")
.HasComment("所在城市。");
b.Property<DateTime?>("ClaimExpiresAt")
.HasColumnType("timestamp with time zone")
.HasComment("领取过期时间。");
b.Property<DateTime?>("ClaimedAt")
.HasColumnType("timestamp with time zone")
.HasComment("领取时间。");
b.Property<long?>("ClaimedBy")
.HasColumnType("bigint")
.HasComment("当前领取人。");
b.Property<string>("ClaimedByName")
.HasMaxLength(100)
.HasColumnType("character varying(100)")
.HasComment("当前领取人姓名。");
b.Property<string>("ContactEmail")
.HasMaxLength(128)
.HasColumnType("character varying(128)")
@@ -2434,6 +2459,21 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("character varying(64)")
.HasComment("所在区县。");
b.Property<DateTime?>("FrozenAt")
.HasColumnType("timestamp with time zone")
.HasComment("冻结时间。");
b.Property<string>("FrozenReason")
.HasMaxLength(500)
.HasColumnType("character varying(500)")
.HasComment("冻结原因。");
b.Property<bool>("IsFrozen")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false)
.HasComment("是否冻结业务。");
b.Property<DateTime?>("JoinedAt")
.HasColumnType("timestamp with time zone")
.HasComment("入驻时间。");
@@ -2442,6 +2482,10 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("timestamp with time zone")
.HasComment("最近一次审核时间。");
b.Property<long?>("LastReviewedBy")
.HasColumnType("bigint")
.HasComment("最近一次审核人。");
b.Property<double?>("Latitude")
.HasColumnType("double precision")
.HasComment("纬度信息。");
@@ -2459,6 +2503,10 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("double precision")
.HasComment("经度信息。");
b.Property<int?>("OperatingMode")
.HasColumnType("integer")
.HasComment("经营模式(同一主体/不同主体)。");
b.Property<string>("Province")
.HasMaxLength(64)
.HasColumnType("character varying(64)")
@@ -2469,6 +2517,13 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("character varying(512)")
.HasComment("审核备注或驳回原因。");
b.Property<byte[]>("RowVersion")
.IsConcurrencyToken()
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("bytea")
.HasComment("并发控制版本。");
b.Property<string>("ServicePhone")
.HasColumnType("text")
.HasComment("客服电话。");
@@ -2499,8 +2554,12 @@ namespace TakeoutSaaS.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("ClaimedBy");
b.HasIndex("TenantId");
b.HasIndex("TenantId", "Status");
b.ToTable("merchants", null, t =>
{
t.HasComment("商户主体信息,承载入驻和资质审核结果。");
@@ -4784,6 +4843,16 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("character varying(256)")
.HasComment("门店营业时段描述(备用字符串)。");
b.Property<string>("BusinessLicenseImageUrl")
.HasMaxLength(500)
.HasColumnType("character varying(500)")
.HasComment("门店营业执照图片地址(主体不一致模式使用)。");
b.Property<string>("BusinessLicenseNumber")
.HasMaxLength(50)
.HasColumnType("character varying(50)")
.HasComment("门店营业执照号(主体不一致模式使用)。");
b.Property<string>("City")
.HasMaxLength(64)
.HasColumnType("character varying(64)")
@@ -4837,6 +4906,11 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("double precision")
.HasComment("纬度。");
b.Property<string>("LegalRepresentative")
.HasMaxLength(100)
.HasColumnType("character varying(100)")
.HasComment("门店法人(主体不一致模式使用)。");
b.Property<double?>("Longitude")
.HasColumnType("double precision")
.HasComment("高德/腾讯地图经度。");
@@ -4866,6 +4940,11 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("character varying(64)")
.HasComment("所在省份。");
b.Property<string>("RegisteredAddress")
.HasMaxLength(500)
.HasColumnType("character varying(500)")
.HasComment("门店注册地址(主体不一致模式使用)。");
b.Property<int>("Status")
.HasColumnType("integer")
.HasComment("门店当前运营状态。");
@@ -4908,6 +4987,10 @@ namespace TakeoutSaaS.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("MerchantId", "BusinessLicenseNumber")
.IsUnique()
.HasFilter("\"BusinessLicenseNumber\" IS NOT NULL AND \"Status\" <> 3");
b.HasIndex("TenantId", "Code")
.IsUnique();
@@ -5704,6 +5787,10 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("character varying(128)")
.HasComment("租户全称或品牌名称。");
b.Property<int?>("OperatingMode")
.HasColumnType("integer")
.HasComment("经营模式(同一主体/不同主体)。");
b.Property<long?>("PrimaryOwnerUserId")
.HasColumnType("bigint")
.HasComment("系统内对应的租户所有者账号 ID。");
@@ -5806,6 +5893,18 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("timestamp with time zone")
.HasComment("失效时间UTC为空表示长期有效。");
b.Property<bool>("IsActive")
.HasColumnType("boolean")
.HasComment("是否启用(已弃用,迁移期保留)。");
b.Property<int>("Priority")
.HasColumnType("integer")
.HasComment("展示优先级,数值越大越靠前。");
b.Property<DateTime?>("PublishedAt")
.HasColumnType("timestamp with time zone")
.HasComment("实际发布时间UTC。");
b.Property<int>("PublisherScope")
.HasColumnType("integer")
.HasComment("发布者范围。");
@@ -5814,32 +5913,10 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("bigint")
.HasComment("发布者用户 ID平台或租户后台账号。");
b.Property<int>("Status")
.HasColumnType("integer")
.HasComment("公告状态。");
b.Property<DateTime?>("PublishedAt")
.HasColumnType("timestamp with time zone")
.HasComment("实际发布时间UTC。");
b.Property<DateTime?>("RevokedAt")
.HasColumnType("timestamp with time zone")
.HasComment("撤销时间UTC。");
b.Property<DateTime?>("ScheduledPublishAt")
.HasColumnType("timestamp with time zone")
.HasComment("预定发布时间UTC。");
b.Property<string>("TargetType")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)")
.HasComment("目标受众类型。");
b.Property<string>("TargetParameters")
.HasColumnType("text")
.HasComment("目标受众参数JSON。");
b.Property<byte[]>("RowVersion")
.IsConcurrencyToken()
.IsRequired()
@@ -5847,13 +5924,23 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("bytea")
.HasComment("并发控制字段。");
b.Property<bool>("IsActive")
.HasColumnType("boolean")
.HasComment("是否启用(已弃用,迁移期保留)。");
b.Property<DateTime?>("ScheduledPublishAt")
.HasColumnType("timestamp with time zone")
.HasComment("预定发布时间UTC)。");
b.Property<int>("Priority")
b.Property<int>("Status")
.HasColumnType("integer")
.HasComment("展示优先级,数值越大越靠前。");
.HasComment("公告状态。");
b.Property<string>("TargetParameters")
.HasColumnType("text")
.HasComment("目标受众参数JSON。");
b.Property<string>("TargetType")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)")
.HasComment("目标受众类型。");
b.Property<long>("TenantId")
.HasColumnType("bigint")
@@ -5875,15 +5962,15 @@ namespace TakeoutSaaS.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("Status", "EffectiveFrom")
.HasFilter("\"TenantId\" = 0");
b.HasIndex("TenantId", "AnnouncementType", "IsActive");
b.HasIndex("TenantId", "EffectiveFrom", "EffectiveTo");
b.HasIndex("TenantId", "Status", "EffectiveFrom");
b.HasIndex("Status", "EffectiveFrom")
.HasFilter("\"TenantId\" = 0");
b.ToTable("tenant_announcements", null, t =>
{
t.HasComment("租户公告。");