feat: 添加订单大厅看板 API(四列数据 + 统计 + 重连补偿 + 操作端点)
Some checks failed
Build and Deploy TenantApi + SkuWorker / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy TenantApi + SkuWorker / build-and-deploy (push) Has been cancelled
- 新增 OrderBoardCardDto、OrderBoardResultDto、OrderBoardStatsDto - 新增看板查询 Query + Handler(board/stats/pending-since) - IOrderRepository 扩展 GetActiveOrdersAsync、GetOrdersChangedSinceAsync - EfOrderRepository 实现看板查询方法 - 新增 OrderBoardController(GET board/stats/pending-since + POST accept/reject/complete/confirm) - 新增 RejectOrderRequest 契约
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using MediatR;
|
||||
using TakeoutSaaS.Application.App.Orders.Dto;
|
||||
using TakeoutSaaS.Application.App.Orders.Queries;
|
||||
using TakeoutSaaS.Domain.Orders.Enums;
|
||||
using TakeoutSaaS.Domain.Orders.Repositories;
|
||||
|
||||
namespace TakeoutSaaS.Application.App.Orders.Handlers;
|
||||
|
||||
/// <summary>
|
||||
/// 获取订单看板统计查询处理器。
|
||||
/// </summary>
|
||||
public sealed class GetOrderBoardStatsQueryHandler(IOrderRepository orderRepository)
|
||||
: IRequestHandler<GetOrderBoardStatsQuery, OrderBoardStatsDto>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public async Task<OrderBoardStatsDto> Handle(GetOrderBoardStatsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
// 1. 查询活跃订单
|
||||
var activeOrders = await orderRepository.GetActiveOrdersAsync(
|
||||
request.TenantId, request.StoreId, cancellationToken);
|
||||
|
||||
// 2. 查询今日所有订单
|
||||
var todayStart = DateTime.UtcNow.Date;
|
||||
var todayOrders = await orderRepository.GetOrdersChangedSinceAsync(
|
||||
request.TenantId, request.StoreId, todayStart, cancellationToken);
|
||||
|
||||
// 3. 统计各状态数量
|
||||
var allOrders = activeOrders.Concat(todayOrders).DistinctBy(o => o.Id).ToList();
|
||||
|
||||
return new OrderBoardStatsDto
|
||||
{
|
||||
TodayTotal = allOrders.Count,
|
||||
PendingCount = allOrders.Count(o => o.Status == OrderStatus.AwaitingPreparation),
|
||||
MakingCount = allOrders.Count(o => o.Status == OrderStatus.InProgress),
|
||||
DeliveringCount = allOrders.Count(o => o.Status == OrderStatus.Ready),
|
||||
CompletedCount = allOrders.Count(o => o.Status == OrderStatus.Completed)
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user