docs: 标记自提档期完成

This commit is contained in:
2025-12-04 11:51:09 +08:00
parent 2022d1c377
commit 7d6b7d8760
29 changed files with 1165 additions and 2 deletions

View File

@@ -62,6 +62,8 @@ public sealed class TakeoutAppDbContext(
public DbSet<StoreTableArea> StoreTableAreas => Set<StoreTableArea>();
public DbSet<StoreTable> StoreTables => Set<StoreTable>();
public DbSet<StoreEmployeeShift> StoreEmployeeShifts => Set<StoreEmployeeShift>();
public DbSet<StorePickupSetting> StorePickupSettings => Set<StorePickupSetting>();
public DbSet<StorePickupSlot> StorePickupSlots => Set<StorePickupSlot>();
public DbSet<ProductCategory> ProductCategories => Set<ProductCategory>();
public DbSet<Product> Products => Set<Product>();
@@ -159,6 +161,8 @@ public sealed class TakeoutAppDbContext(
ConfigureStoreTableArea(modelBuilder.Entity<StoreTableArea>());
ConfigureStoreTable(modelBuilder.Entity<StoreTable>());
ConfigureStoreEmployeeShift(modelBuilder.Entity<StoreEmployeeShift>());
ConfigureStorePickupSetting(modelBuilder.Entity<StorePickupSetting>());
ConfigureStorePickupSlot(modelBuilder.Entity<StorePickupSlot>());
ConfigureProductCategory(modelBuilder.Entity<ProductCategory>());
ConfigureProduct(modelBuilder.Entity<Product>());
ConfigureProductAttributeGroup(modelBuilder.Entity<ProductAttributeGroup>());
@@ -622,6 +626,28 @@ public sealed class TakeoutAppDbContext(
builder.HasIndex(x => new { x.TenantId, x.StoreId, x.ShiftDate, x.StaffId }).IsUnique();
}
private static void ConfigureStorePickupSetting(EntityTypeBuilder<StorePickupSetting> builder)
{
builder.ToTable("store_pickup_settings");
builder.HasKey(x => x.Id);
builder.Property(x => x.StoreId).IsRequired();
builder.Property(x => x.DefaultCutoffMinutes).HasDefaultValue(30);
builder.Property(x => x.RowVersion).IsRowVersion();
builder.HasIndex(x => new { x.TenantId, x.StoreId }).IsUnique();
}
private static void ConfigureStorePickupSlot(EntityTypeBuilder<StorePickupSlot> builder)
{
builder.ToTable("store_pickup_slots");
builder.HasKey(x => x.Id);
builder.Property(x => x.StoreId).IsRequired();
builder.Property(x => x.Name).HasMaxLength(64).IsRequired();
builder.Property(x => x.Weekdays).HasMaxLength(32).IsRequired();
builder.Property(x => x.CutoffMinutes).HasDefaultValue(30);
builder.Property(x => x.RowVersion).IsRowVersion();
builder.HasIndex(x => new { x.TenantId, x.StoreId, x.Name });
}
private static void ConfigureProductAttributeGroup(EntityTypeBuilder<ProductAttributeGroup> builder)
{
builder.ToTable("product_attribute_groups");

View File

@@ -1,3 +1,4 @@
using System;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using TakeoutSaaS.Domain.Stores.Entities;
@@ -154,6 +155,59 @@ public sealed class EfStoreRepository(TakeoutAppDbContext context) : IStoreRepos
.FirstOrDefaultAsync(cancellationToken);
}
/// <inheritdoc />
public Task<StorePickupSetting?> GetPickupSettingAsync(long storeId, long tenantId, CancellationToken cancellationToken = default)
{
return context.StorePickupSettings
.Where(x => x.TenantId == tenantId && x.StoreId == storeId)
.FirstOrDefaultAsync(cancellationToken);
}
/// <inheritdoc />
public Task AddPickupSettingAsync(StorePickupSetting setting, CancellationToken cancellationToken = default)
{
return context.StorePickupSettings.AddAsync(setting, cancellationToken).AsTask();
}
/// <inheritdoc />
public Task UpdatePickupSettingAsync(StorePickupSetting setting, CancellationToken cancellationToken = default)
{
context.StorePickupSettings.Update(setting);
return Task.CompletedTask;
}
/// <inheritdoc />
public async Task<IReadOnlyList<StorePickupSlot>> GetPickupSlotsAsync(long storeId, long tenantId, CancellationToken cancellationToken = default)
{
var slots = await context.StorePickupSlots
.AsNoTracking()
.Where(x => x.TenantId == tenantId && x.StoreId == storeId)
.OrderBy(x => x.StartTime)
.ToListAsync(cancellationToken);
return slots;
}
/// <inheritdoc />
public Task<StorePickupSlot?> FindPickupSlotByIdAsync(long slotId, long tenantId, CancellationToken cancellationToken = default)
{
return context.StorePickupSlots
.Where(x => x.TenantId == tenantId && x.Id == slotId)
.FirstOrDefaultAsync(cancellationToken);
}
/// <inheritdoc />
public Task AddPickupSlotsAsync(IEnumerable<StorePickupSlot> slots, CancellationToken cancellationToken = default)
{
return context.StorePickupSlots.AddRangeAsync(slots, cancellationToken);
}
/// <inheritdoc />
public Task UpdatePickupSlotAsync(StorePickupSlot slot, CancellationToken cancellationToken = default)
{
context.StorePickupSlots.Update(slot);
return Task.CompletedTask;
}
/// <inheritdoc />
public async Task<IReadOnlyList<StoreEmployeeShift>> GetShiftsAsync(long storeId, long tenantId, DateTime? from = null, DateTime? to = null, CancellationToken cancellationToken = default)
{
@@ -342,6 +396,19 @@ public sealed class EfStoreRepository(TakeoutAppDbContext context) : IStoreRepos
}
}
/// <inheritdoc />
public async Task DeletePickupSlotAsync(long slotId, long tenantId, CancellationToken cancellationToken = default)
{
var existing = await context.StorePickupSlots
.Where(x => x.TenantId == tenantId && x.Id == slotId)
.FirstOrDefaultAsync(cancellationToken);
if (existing != null)
{
context.StorePickupSlots.Remove(existing);
}
}
/// <inheritdoc />
public async Task DeleteShiftAsync(long shiftId, long tenantId, CancellationToken cancellationToken = default)
{