feat: 添加 SignalR 客户端与订单大厅 API 模块
All checks were successful
Build and Deploy TenantUI / build-and-deploy (push) Successful in 1m59s

- 安装 @microsoft/signalr 依赖
- 新增 useSignalR Hook(自动重连 + 断线补偿回调)
- 新增订单大厅 API 模块(board/stats/pending-since + 接单/拒单/出餐/确认)
This commit is contained in:
2026-02-27 13:12:04 +08:00
parent 2e510a8fa7
commit 42bf54a52c
4 changed files with 315 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
/**
* 文件职责:订单大厅(看板)接口与类型定义。
*/
import { requestClient } from '#/api/request';
/** 订单看板卡片。 */
export interface OrderBoardCard {
acceptedAt?: null | string;
channel: number;
createdAt: string;
customerName?: null | string;
customerPhone?: null | string;
deliveryType: number;
id: string;
isUrged: boolean;
itemsSummary?: null | string;
orderNo: string;
paidAmount: number;
queueNumber?: null | string;
readyAt?: null | string;
status: number;
storeId: string;
tableNo?: null | string;
urgeCount: number;
}
/** 订单看板结果(四列)。 */
export interface OrderBoardResult {
completed: OrderBoardCard[];
delivering: OrderBoardCard[];
making: OrderBoardCard[];
pending: OrderBoardCard[];
}
/** 订单看板统计。 */
export interface OrderBoardStats {
completedCount: number;
deliveringCount: number;
makingCount: number;
pendingCount: number;
todayTotal: number;
}
/** 获取完整看板数据。 */
export async function getOrderBoardApi(params: {
channel?: string;
storeId: string;
}) {
return requestClient.get<OrderBoardResult>('/order-board/board', { params });
}
/** 获取看板统计。 */
export async function getOrderBoardStatsApi(params: { storeId: string }) {
return requestClient.get<OrderBoardStats>('/order-board/stats', { params });
}
/** 重连补偿拉取。 */
export async function getPendingSinceApi(params: {
since: string;
storeId: string;
}) {
return requestClient.get<OrderBoardCard[]>('/order-board/pending-since', {
params,
});
}
/** 接单。 */
export async function acceptOrderApi(orderId: string) {
return requestClient.post<OrderBoardCard>(
`/order-board/${orderId}/accept`,
{},
);
}
/** 拒单。 */
export async function rejectOrderApi(
orderId: string,
data: { reason: string },
) {
return requestClient.post<OrderBoardCard>(
`/order-board/${orderId}/reject`,
data,
);
}
/** 出餐完成。 */
export async function completePreparationApi(orderId: string) {
return requestClient.post<OrderBoardCard>(
`/order-board/${orderId}/complete-preparation`,
{},
);
}
/** 确认送达/取餐。 */
export async function confirmDeliveryApi(orderId: string) {
return requestClient.post<OrderBoardCard>(
`/order-board/${orderId}/confirm-delivery`,
{},
);
}