From 93141fbf0cdd0cedc359c5cfe81c256c53818cdb Mon Sep 17 00:00:00 2001
From: MSuMshk <2039814060@qq.com>
Date: Tue, 2 Dec 2025 10:19:35 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E7=AE=A1=E7=90=86=E7=AB=AF=E6=A0=B8?=
=?UTF-8?q?=E5=BF=83=E5=AE=9E=E4=BD=93CRUD=E8=A1=A5=E9=BD=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/DeliveriesController.cs | 108 ++++++++++++
.../Controllers/MerchantsController.cs | 32 ++++
.../Controllers/OrdersController.cs | 116 +++++++++++++
.../Controllers/PaymentsController.cs | 108 ++++++++++++
.../Controllers/ProductsController.cs | 109 ++++++++++++
.../Controllers/StoresController.cs | 108 ++++++++++++
.../Commands/CreateDeliveryOrderCommand.cs | 66 ++++++++
.../Commands/DeleteDeliveryOrderCommand.cs | 14 ++
.../Commands/UpdateDeliveryOrderCommand.cs | 71 ++++++++
.../App/Deliveries/Dto/DeliveryEventDto.cs | 43 +++++
.../App/Deliveries/Dto/DeliveryOrderDto.cs | 84 ++++++++++
.../CreateDeliveryOrderCommandHandler.cs | 69 ++++++++
.../DeleteDeliveryOrderCommandHandler.cs | 38 +++++
.../GetDeliveryOrderByIdQueryHandler.cs | 60 +++++++
.../SearchDeliveryOrdersQueryHandler.cs | 43 +++++
.../UpdateDeliveryOrderCommandHandler.cs | 79 +++++++++
.../Queries/GetDeliveryOrderByIdQuery.cs | 15 ++
.../Queries/SearchDeliveryOrdersQuery.cs | 21 +++
.../Commands/DeleteMerchantCommand.cs | 14 ++
.../Commands/UpdateMerchantCommand.cs | 51 ++++++
.../Handlers/DeleteMerchantCommandHandler.cs | 40 +++++
.../Handlers/UpdateMerchantCommandHandler.cs | 65 ++++++++
.../App/Orders/Commands/CreateOrderCommand.cs | 117 +++++++++++++
.../App/Orders/Commands/DeleteOrderCommand.cs | 14 ++
.../App/Orders/Commands/OrderItemRequest.cs | 52 ++++++
.../App/Orders/Commands/UpdateOrderCommand.cs | 117 +++++++++++++
.../App/Orders/Dto/OrderDto.cs | 141 ++++++++++++++++
.../App/Orders/Dto/OrderItemDto.cs | 68 ++++++++
.../App/Orders/Dto/OrderStatusHistoryDto.cs | 44 +++++
.../App/Orders/Dto/RefundRequestDto.cs | 58 +++++++
.../Handlers/CreateOrderCommandHandler.cs | 156 ++++++++++++++++++
.../Handlers/DeleteOrderCommandHandler.cs | 40 +++++
.../Handlers/GetOrderByIdQueryHandler.cs | 102 ++++++++++++
.../Handlers/SearchOrdersQueryHandler.cs | 65 ++++++++
.../Handlers/UpdateOrderCommandHandler.cs | 134 +++++++++++++++
.../App/Orders/Queries/GetOrderByIdQuery.cs | 15 ++
.../App/Orders/Queries/SearchOrdersQuery.cs | 32 ++++
.../Payments/Commands/CreatePaymentCommand.cs | 56 +++++++
.../Payments/Commands/DeletePaymentCommand.cs | 14 ++
.../Payments/Commands/UpdatePaymentCommand.cs | 61 +++++++
.../App/Payments/Dto/PaymentDto.cs | 74 +++++++++
.../App/Payments/Dto/PaymentRefundDto.cs | 49 ++++++
.../Handlers/CreatePaymentCommandHandler.cs | 66 ++++++++
.../Handlers/DeletePaymentCommandHandler.cs | 38 +++++
.../Handlers/GetPaymentByIdQueryHandler.cs | 59 +++++++
.../Handlers/SearchPaymentsQueryHandler.cs | 46 ++++++
.../Handlers/UpdatePaymentCommandHandler.cs | 76 +++++++++
.../Payments/Queries/GetPaymentByIdQuery.cs | 15 ++
.../Payments/Queries/SearchPaymentsQuery.cs | 21 +++
.../Products/Commands/CreateProductCommand.cs | 101 ++++++++++++
.../Products/Commands/DeleteProductCommand.cs | 14 ++
.../Products/Commands/UpdateProductCommand.cs | 106 ++++++++++++
.../App/Products/Dto/ProductDto.cs | 115 +++++++++++++
.../Handlers/CreateProductCommandHandler.cs | 77 +++++++++
.../Handlers/DeleteProductCommandHandler.cs | 40 +++++
.../Handlers/GetProductByIdQueryHandler.cs | 52 ++++++
.../Handlers/SearchProductsQueryHandler.cs | 57 +++++++
.../Handlers/UpdateProductCommandHandler.cs | 87 ++++++++++
.../Products/Queries/GetProductByIdQuery.cs | 15 ++
.../Products/Queries/SearchProductsQuery.cs | 26 +++
.../App/Stores/Commands/CreateStoreCommand.cs | 101 ++++++++++++
.../App/Stores/Commands/DeleteStoreCommand.cs | 14 ++
.../App/Stores/Commands/UpdateStoreCommand.cs | 106 ++++++++++++
.../App/Stores/Dto/StoreDto.cs | 114 +++++++++++++
.../Handlers/CreateStoreCommandHandler.cs | 77 +++++++++
.../Handlers/DeleteStoreCommandHandler.cs | 40 +++++
.../Handlers/GetStoreByIdQueryHandler.cs | 52 ++++++
.../Handlers/SearchStoresQueryHandler.cs | 59 +++++++
.../Handlers/UpdateStoreCommandHandler.cs | 87 ++++++++++
.../App/Stores/Queries/GetStoreByIdQuery.cs | 15 ++
.../App/Stores/Queries/SearchStoresQuery.cs | 21 +++
.../Repositories/IDeliveryRepository.cs | 6 +
.../Repositories/IPaymentRepository.cs | 6 +
.../App/Repositories/EfDeliveryRepository.cs | 23 +++
.../App/Repositories/EfPaymentRepository.cs | 18 ++
75 files changed, 4513 insertions(+)
create mode 100644 src/Api/TakeoutSaaS.AdminApi/Controllers/DeliveriesController.cs
create mode 100644 src/Api/TakeoutSaaS.AdminApi/Controllers/OrdersController.cs
create mode 100644 src/Api/TakeoutSaaS.AdminApi/Controllers/PaymentsController.cs
create mode 100644 src/Api/TakeoutSaaS.AdminApi/Controllers/ProductsController.cs
create mode 100644 src/Api/TakeoutSaaS.AdminApi/Controllers/StoresController.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Deliveries/Commands/CreateDeliveryOrderCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Deliveries/Commands/DeleteDeliveryOrderCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Deliveries/Commands/UpdateDeliveryOrderCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Deliveries/Dto/DeliveryEventDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Deliveries/Dto/DeliveryOrderDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Deliveries/Handlers/CreateDeliveryOrderCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Deliveries/Handlers/DeleteDeliveryOrderCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Deliveries/Handlers/GetDeliveryOrderByIdQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Deliveries/Handlers/SearchDeliveryOrdersQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Deliveries/Handlers/UpdateDeliveryOrderCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Deliveries/Queries/GetDeliveryOrderByIdQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Deliveries/Queries/SearchDeliveryOrdersQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Merchants/Commands/DeleteMerchantCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Merchants/Commands/UpdateMerchantCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Merchants/Handlers/DeleteMerchantCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Merchants/Handlers/UpdateMerchantCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Commands/CreateOrderCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Commands/DeleteOrderCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Commands/OrderItemRequest.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Commands/UpdateOrderCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Dto/OrderDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Dto/OrderItemDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Dto/OrderStatusHistoryDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Dto/RefundRequestDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Handlers/CreateOrderCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Handlers/DeleteOrderCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Handlers/GetOrderByIdQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Handlers/SearchOrdersQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Handlers/UpdateOrderCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Queries/GetOrderByIdQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Orders/Queries/SearchOrdersQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Payments/Commands/CreatePaymentCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Payments/Commands/DeletePaymentCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Payments/Commands/UpdatePaymentCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Payments/Dto/PaymentDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Payments/Dto/PaymentRefundDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Payments/Handlers/CreatePaymentCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Payments/Handlers/DeletePaymentCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Payments/Handlers/GetPaymentByIdQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Payments/Handlers/SearchPaymentsQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Payments/Handlers/UpdatePaymentCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Payments/Queries/GetPaymentByIdQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Payments/Queries/SearchPaymentsQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Products/Commands/CreateProductCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Products/Commands/DeleteProductCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Products/Commands/UpdateProductCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Products/Dto/ProductDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Products/Handlers/CreateProductCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Products/Handlers/DeleteProductCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Products/Handlers/GetProductByIdQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Products/Handlers/SearchProductsQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Products/Handlers/UpdateProductCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Products/Queries/GetProductByIdQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Products/Queries/SearchProductsQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/CreateStoreCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/DeleteStoreCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/UpdateStoreCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Dto/StoreDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/CreateStoreCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/DeleteStoreCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/GetStoreByIdQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/SearchStoresQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/UpdateStoreCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Queries/GetStoreByIdQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Queries/SearchStoresQuery.cs
diff --git a/src/Api/TakeoutSaaS.AdminApi/Controllers/DeliveriesController.cs b/src/Api/TakeoutSaaS.AdminApi/Controllers/DeliveriesController.cs
new file mode 100644
index 0000000..a36e2e2
--- /dev/null
+++ b/src/Api/TakeoutSaaS.AdminApi/Controllers/DeliveriesController.cs
@@ -0,0 +1,108 @@
+using MediatR;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using TakeoutSaaS.Application.App.Deliveries.Commands;
+using TakeoutSaaS.Application.App.Deliveries.Dto;
+using TakeoutSaaS.Application.App.Deliveries.Queries;
+using TakeoutSaaS.Domain.Deliveries.Enums;
+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}/deliveries")]
+public sealed class DeliveriesController : BaseApiController
+{
+ private readonly IMediator _mediator;
+
+ ///
+ /// 初始化控制器。
+ ///
+ public DeliveriesController(IMediator mediator)
+ {
+ _mediator = mediator;
+ }
+
+ ///
+ /// 创建配送单。
+ ///
+ [HttpPost]
+ [PermissionAuthorize("delivery:create")]
+ [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
+ public async Task> Create([FromBody] CreateDeliveryOrderCommand command, CancellationToken cancellationToken)
+ {
+ var result = await _mediator.Send(command, cancellationToken);
+ return ApiResponse.Ok(result);
+ }
+
+ ///
+ /// 查询配送单列表。
+ ///
+ [HttpGet]
+ [PermissionAuthorize("delivery:read")]
+ [ProducesResponseType(typeof(ApiResponse>), StatusCodes.Status200OK)]
+ public async Task>> List([FromQuery] long? orderId, [FromQuery] DeliveryStatus? status, CancellationToken cancellationToken)
+ {
+ var result = await _mediator.Send(new SearchDeliveryOrdersQuery
+ {
+ OrderId = orderId,
+ Status = status
+ }, cancellationToken);
+
+ return ApiResponse>.Ok(result);
+ }
+
+ ///
+ /// 获取配送单详情。
+ ///
+ [HttpGet("{deliveryOrderId:long}")]
+ [PermissionAuthorize("delivery:read")]
+ [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
+ [ProducesResponseType(typeof(ApiResponse