完成门店管理后端接口与任务
This commit is contained in:
@@ -25,6 +25,7 @@ using TakeoutSaaS.Shared.Abstractions.Ids;
|
||||
using TakeoutSaaS.Shared.Abstractions.Security;
|
||||
using TakeoutSaaS.Shared.Abstractions.Tenancy;
|
||||
using TakeoutSaaS.Infrastructure.App.Persistence.Configurations;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace TakeoutSaaS.Infrastructure.App.Persistence;
|
||||
|
||||
@@ -35,8 +36,9 @@ public sealed class TakeoutAppDbContext(
|
||||
DbContextOptions<TakeoutAppDbContext> options,
|
||||
ITenantProvider tenantProvider,
|
||||
ICurrentUserAccessor? currentUserAccessor = null,
|
||||
IIdGenerator? idGenerator = null)
|
||||
: TenantAwareDbContext(options, tenantProvider, currentUserAccessor, idGenerator)
|
||||
IIdGenerator? idGenerator = null,
|
||||
IHttpContextAccessor? httpContextAccessor = null)
|
||||
: TenantAwareDbContext(options, tenantProvider, currentUserAccessor, idGenerator, httpContextAccessor)
|
||||
{
|
||||
/// <summary>
|
||||
/// 租户聚合根。
|
||||
@@ -123,6 +125,18 @@ public sealed class TakeoutAppDbContext(
|
||||
/// </summary>
|
||||
public DbSet<Store> Stores => Set<Store>();
|
||||
/// <summary>
|
||||
/// 门店费用配置。
|
||||
/// </summary>
|
||||
public DbSet<StoreFee> StoreFees => Set<StoreFee>();
|
||||
/// <summary>
|
||||
/// 门店资质证照。
|
||||
/// </summary>
|
||||
public DbSet<StoreQualification> StoreQualifications => Set<StoreQualification>();
|
||||
/// <summary>
|
||||
/// 门店审核记录。
|
||||
/// </summary>
|
||||
public DbSet<StoreAuditRecord> StoreAuditRecords => Set<StoreAuditRecord>();
|
||||
/// <summary>
|
||||
/// 门店营业时间。
|
||||
/// </summary>
|
||||
public DbSet<StoreBusinessHour> StoreBusinessHours => Set<StoreBusinessHour>();
|
||||
@@ -392,6 +406,9 @@ public sealed class TakeoutAppDbContext(
|
||||
ConfigureMerchantContract(modelBuilder.Entity<MerchantContract>());
|
||||
ConfigureMerchantStaff(modelBuilder.Entity<MerchantStaff>());
|
||||
ConfigureMerchantCategory(modelBuilder.Entity<MerchantCategory>());
|
||||
ConfigureStoreFee(modelBuilder.Entity<StoreFee>());
|
||||
ConfigureStoreQualification(modelBuilder.Entity<StoreQualification>());
|
||||
ConfigureStoreAuditRecord(modelBuilder.Entity<StoreAuditRecord>());
|
||||
ConfigureStoreBusinessHour(modelBuilder.Entity<StoreBusinessHour>());
|
||||
ConfigureStoreHoliday(modelBuilder.Entity<StoreHoliday>());
|
||||
ConfigureStoreDeliveryZone(modelBuilder.Entity<StoreDeliveryZone>());
|
||||
@@ -559,6 +576,14 @@ public sealed class TakeoutAppDbContext(
|
||||
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.SignboardImageUrl).HasMaxLength(500);
|
||||
builder.Property(x => x.OwnershipType).HasConversion<int>();
|
||||
builder.Property(x => x.AuditStatus).HasConversion<int>();
|
||||
builder.Property(x => x.BusinessStatus).HasConversion<int>();
|
||||
builder.Property(x => x.ClosureReason).HasConversion<int?>();
|
||||
builder.Property(x => x.ClosureReasonText).HasMaxLength(500);
|
||||
builder.Property(x => x.RejectionReason).HasMaxLength(500);
|
||||
builder.Property(x => x.ForceCloseReason).HasMaxLength(500);
|
||||
builder.Property(x => x.Province).HasMaxLength(64);
|
||||
builder.Property(x => x.City).HasMaxLength(64);
|
||||
builder.Property(x => x.District).HasMaxLength(64);
|
||||
@@ -568,11 +593,61 @@ 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.TenantId, x.AuditStatus });
|
||||
builder.HasIndex(x => new { x.TenantId, x.BusinessStatus });
|
||||
builder.HasIndex(x => new { x.TenantId, x.OwnershipType });
|
||||
builder.HasIndex(x => new { x.Longitude, x.Latitude })
|
||||
.HasFilter("\"Longitude\" IS NOT NULL AND \"Latitude\" IS NOT NULL");
|
||||
builder.HasIndex(x => new { x.MerchantId, x.BusinessLicenseNumber })
|
||||
.IsUnique()
|
||||
.HasFilter("\"BusinessLicenseNumber\" IS NOT NULL AND \"Status\" <> 3");
|
||||
}
|
||||
|
||||
private static void ConfigureStoreFee(EntityTypeBuilder<StoreFee> builder)
|
||||
{
|
||||
builder.ToTable("store_fees");
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.Property(x => x.StoreId).IsRequired();
|
||||
builder.Property(x => x.MinimumOrderAmount).HasPrecision(10, 2);
|
||||
builder.Property(x => x.BaseDeliveryFee).HasPrecision(10, 2);
|
||||
builder.Property(x => x.PackagingFeeMode).HasConversion<int>();
|
||||
builder.Property(x => x.FixedPackagingFee).HasPrecision(10, 2);
|
||||
builder.Property(x => x.FreeDeliveryThreshold).HasPrecision(10, 2);
|
||||
builder.HasIndex(x => new { x.TenantId, x.StoreId }).IsUnique();
|
||||
builder.HasIndex(x => x.TenantId);
|
||||
}
|
||||
|
||||
private static void ConfigureStoreQualification(EntityTypeBuilder<StoreQualification> builder)
|
||||
{
|
||||
builder.ToTable("store_qualifications");
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.Property(x => x.StoreId).IsRequired();
|
||||
builder.Property(x => x.QualificationType).HasConversion<int>();
|
||||
builder.Property(x => x.FileUrl).HasMaxLength(500).IsRequired();
|
||||
builder.Property(x => x.DocumentNumber).HasMaxLength(100);
|
||||
builder.Property(x => x.SortOrder).HasDefaultValue(100);
|
||||
builder.HasIndex(x => new { x.TenantId, x.StoreId });
|
||||
builder.HasIndex(x => x.ExpiresAt)
|
||||
.HasFilter("\"ExpiresAt\" IS NOT NULL");
|
||||
builder.Ignore(x => x.IsExpired);
|
||||
builder.Ignore(x => x.IsExpiringSoon);
|
||||
}
|
||||
|
||||
private static void ConfigureStoreAuditRecord(EntityTypeBuilder<StoreAuditRecord> builder)
|
||||
{
|
||||
builder.ToTable("store_audit_records");
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.Property(x => x.StoreId).IsRequired();
|
||||
builder.Property(x => x.Action).HasConversion<int>();
|
||||
builder.Property(x => x.PreviousStatus).HasConversion<int?>();
|
||||
builder.Property(x => x.NewStatus).HasConversion<int>();
|
||||
builder.Property(x => x.OperatorName).HasMaxLength(100).IsRequired();
|
||||
builder.Property(x => x.RejectionReason).HasMaxLength(500);
|
||||
builder.Property(x => x.Remarks).HasMaxLength(1000);
|
||||
builder.HasIndex(x => new { x.TenantId, x.StoreId });
|
||||
builder.HasIndex(x => x.CreatedAt);
|
||||
}
|
||||
|
||||
private static void ConfigureProductCategory(EntityTypeBuilder<ProductCategory> builder)
|
||||
{
|
||||
builder.ToTable("product_categories");
|
||||
|
||||
Reference in New Issue
Block a user