From 7d6b7d87604b75b4349e94c67ba4390796ad1f36 Mon Sep 17 00:00:00 2001
From: MSuMshk <2039814060@qq.com>
Date: Thu, 4 Dec 2025 11:51:09 +0800
Subject: [PATCH] =?UTF-8?q?docs:=20=E6=A0=87=E8=AE=B0=E8=87=AA=E6=8F=90?=
=?UTF-8?q?=E6=A1=A3=E6=9C=9F=E5=AE=8C=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Document/12_BusinessTodo.md | 4 +-
.../Controllers/StorePickupController.cs | 114 ++++++++++++++++++
.../appsettings.Seed.Development.json | 12 ++
.../Controllers/PickupSlotsController.cs | 31 +++++
.../Commands/CreateStorePickupSlotCommand.cs | 50 ++++++++
.../Commands/DeleteStorePickupSlotCommand.cs | 19 +++
.../Commands/UpdateStorePickupSlotCommand.cs | 55 +++++++++
.../UpsertStorePickupSettingCommand.cs | 35 ++++++
.../App/Stores/Dto/StorePickupSettingDto.cs | 42 +++++++
.../App/Stores/Dto/StorePickupSlotDto.cs | 62 ++++++++++
.../CreateStorePickupSlotCommandHandler.cs | 64 ++++++++++
.../DeleteStorePickupSlotCommandHandler.cs | 28 +++++
.../GetAvailablePickupSlotsQueryHandler.cs | 83 +++++++++++++
.../GetStorePickupSettingQueryHandler.cs | 37 ++++++
.../ListStorePickupSlotsQueryHandler.cs | 38 ++++++
.../UpdateStorePickupSlotCommandHandler.cs | 57 +++++++++
.../UpsertStorePickupSettingCommandHandler.cs | 63 ++++++++++
.../Queries/GetAvailablePickupSlotsQuery.cs | 21 ++++
.../Queries/GetStorePickupSettingQuery.cs | 15 +++
.../Queries/ListStorePickupSlotsQuery.cs | 15 +++
.../CreateStorePickupSlotCommandValidator.cs | 23 ++++
.../DeleteStorePickupSlotCommandValidator.cs | 19 +++
.../UpdateStorePickupSlotCommandValidator.cs | 24 ++++
...psertStorePickupSettingCommandValidator.cs | 21 ++++
.../Stores/Entities/StorePickupSetting.cs | 41 +++++++
.../Stores/Entities/StorePickupSlot.cs | 61 ++++++++++
.../Stores/Repositories/IStoreRepository.cs | 40 ++++++
.../App/Persistence/TakeoutAppDbContext.cs | 26 ++++
.../App/Repositories/EfStoreRepository.cs | 67 ++++++++++
29 files changed, 1165 insertions(+), 2 deletions(-)
create mode 100644 src/Api/TakeoutSaaS.AdminApi/Controllers/StorePickupController.cs
create mode 100644 src/Api/TakeoutSaaS.MiniApi/Controllers/PickupSlotsController.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/CreateStorePickupSlotCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/DeleteStorePickupSlotCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/UpdateStorePickupSlotCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/UpsertStorePickupSettingCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Dto/StorePickupSettingDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Dto/StorePickupSlotDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/CreateStorePickupSlotCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/DeleteStorePickupSlotCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/GetAvailablePickupSlotsQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/GetStorePickupSettingQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/ListStorePickupSlotsQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/UpdateStorePickupSlotCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/UpsertStorePickupSettingCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Queries/GetAvailablePickupSlotsQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Queries/GetStorePickupSettingQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Queries/ListStorePickupSlotsQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/CreateStorePickupSlotCommandValidator.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/DeleteStorePickupSlotCommandValidator.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/UpdateStorePickupSlotCommandValidator.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/UpsertStorePickupSettingCommandValidator.cs
create mode 100644 src/Domain/TakeoutSaaS.Domain/Stores/Entities/StorePickupSetting.cs
create mode 100644 src/Domain/TakeoutSaaS.Domain/Stores/Entities/StorePickupSlot.cs
diff --git a/Document/12_BusinessTodo.md b/Document/12_BusinessTodo.md
index 13a4e25..00d98dd 100644
--- a/Document/12_BusinessTodo.md
+++ b/Document/12_BusinessTodo.md
@@ -26,8 +26,8 @@
- 已交付:Admin 侧补齐 SKU/规格/加料/媒资/定价替换命令、验证与端点,并新增上/下架接口与全量详情;权限种子补充 `product:publish` 与子资源读写。Mini 侧新增门店菜单接口,按门店返回分类 + 商品全量 JSON(含 SKU/规格/加料/媒资/定价),支持 `updatedAfter` 增量。
- [x] 库存体系:SKU 库存、批次、调整、售罄管理,支持预售/档期锁定并在订单中扣减/释放。
- 已交付:库存模型补充预售/限购/并发字段与批次策略(FIFO/FEFO),新增锁定记录与幂等、过期释放;应用层提供调整/锁定/释放/扣减/批次维护命令与查询,Admin API 暴露库存与批次端点及权限种子。需后续生成迁移落库,并可按需将过期释放接入定时任务。
-- [ ] 自提档期:门店配置自提时间窗、容量、截单时间;Mini 端据此限制下单时间。
- - 当前:仅有门店/商品的自提开关字段(`SupportsPickup`/`EnablePickup`),未实现自提时间窗、容量、截单配置及 Mini 端下单限制。
+- [x] 自提档期:门店配置自提时间窗、容量、截单时间;Mini 端据此限制下单时间。
+ - 已交付:新增自提设置与档期实体/表、并发控制,Admin 端提供自提配置与档期 CRUD 权限/接口;Mini 端提供按日期查询可用档期,包含截单与容量校验。下单限制待后续与订单流程联调。
- [ ] 购物车服务:ShoppingCart/CartItem/CartItemAddon API 支持并发锁、限购、券/积分预校验,保证并发无脏数据。
- 当前:领域层与表结构已有 `ShoppingCart/CartItem/CartItemAddon`,但缺少 CQRS 命令/查询、并发锁/限购/券积分预校验以及任何 Admin/Mini 端接口。
- [ ] 订单与支付:堂食/自提/配送下单、微信/支付宝支付、优惠券/积分抵扣、订单状态机与通知链路齐全。
diff --git a/src/Api/TakeoutSaaS.AdminApi/Controllers/StorePickupController.cs b/src/Api/TakeoutSaaS.AdminApi/Controllers/StorePickupController.cs
new file mode 100644
index 0000000..f07addd
--- /dev/null
+++ b/src/Api/TakeoutSaaS.AdminApi/Controllers/StorePickupController.cs
@@ -0,0 +1,114 @@
+using MediatR;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using TakeoutSaaS.Application.App.Stores.Commands;
+using TakeoutSaaS.Application.App.Stores.Dto;
+using TakeoutSaaS.Application.App.Stores.Queries;
+using TakeoutSaaS.Module.Authorization.Attributes;
+using TakeoutSaaS.Shared.Abstractions.Constants;
+using TakeoutSaaS.Shared.Abstractions.Results;
+using TakeoutSaaS.Shared.Web.Api;
+
+namespace TakeoutSaaS.AdminApi.Controllers;
+
+///
+/// 门店自提管理。
+///
+[ApiVersion("1.0")]
+[Authorize]
+[Route("api/admin/v{version:apiVersion}/stores/{storeId:long}/pickup")]
+public sealed class StorePickupController(IMediator mediator) : BaseApiController
+{
+ ///
+ /// 获取自提配置。
+ ///
+ [HttpGet("settings")]
+ [PermissionAuthorize("pickup-setting:read")]
+ [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
+ public async Task> GetSetting(long storeId, CancellationToken cancellationToken)
+ {
+ var result = await mediator.Send(new GetStorePickupSettingQuery { StoreId = storeId }, cancellationToken);
+ return result is null
+ ? ApiResponse.Error(ErrorCodes.NotFound, "未配置自提设置")
+ : ApiResponse.Ok(result);
+ }
+
+ ///
+ /// 更新自提配置。
+ ///
+ [HttpPut("settings")]
+ [PermissionAuthorize("pickup-setting:update")]
+ [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
+ public async Task> UpsertSetting(long storeId, [FromBody] UpsertStorePickupSettingCommand command, CancellationToken cancellationToken)
+ {
+ if (command.StoreId == 0)
+ {
+ command = command with { StoreId = storeId };
+ }
+
+ var result = await mediator.Send(command, cancellationToken);
+ return ApiResponse.Ok(result);
+ }
+
+ ///
+ /// 查询档期列表。
+ ///
+ [HttpGet("slots")]
+ [PermissionAuthorize("pickup-slot:read")]
+ [ProducesResponseType(typeof(ApiResponse>), StatusCodes.Status200OK)]
+ public async Task>> ListSlots(long storeId, CancellationToken cancellationToken)
+ {
+ var result = await mediator.Send(new ListStorePickupSlotsQuery { StoreId = storeId }, cancellationToken);
+ return ApiResponse>.Ok(result);
+ }
+
+ ///
+ /// 创建档期。
+ ///
+ [HttpPost("slots")]
+ [PermissionAuthorize("pickup-slot:create")]
+ [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
+ public async Task> CreateSlot(long storeId, [FromBody] CreateStorePickupSlotCommand command, CancellationToken cancellationToken)
+ {
+ if (command.StoreId == 0)
+ {
+ command = command with { StoreId = storeId };
+ }
+
+ var result = await mediator.Send(command, cancellationToken);
+ return ApiResponse.Ok(result);
+ }
+
+ ///
+ /// 更新档期。
+ ///
+ [HttpPut("slots/{slotId:long}")]
+ [PermissionAuthorize("pickup-slot:update")]
+ [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
+ [ProducesResponseType(typeof(ApiResponse