大厅与后台工单列表改为精确补丁并支持抢单确认

This commit is contained in:
yml2213
2026-08-22 09:30:38 +08:00
parent 1f7ff016df
commit ed81122047
7 changed files with 103 additions and 10 deletions
@@ -1,5 +1,7 @@
import type { Response } from 'express'
import { WORK_ORDER_STATUS } from '../../domain/work-order-status.js'
import {
getWorkerFinanceRequestById,
getWorkerUserById,
@@ -292,13 +294,26 @@ async function publishWorkOrderSnapshots(input: {
})
if (input.hallChanged) {
// 携带快照的精确事件让客户端原地增删缓存行,避免整页刷新导致抢单误点。
const hallVisible =
workOrder.status === WORK_ORDER_STATUS.OPEN &&
!isWorkOrderSharingFilled(
workOrder.sharing_enabled === true,
Number(workOrder.sharing_total_quantity || 1),
joinedQuantity,
)
publishRealtimeEvent({
type: 'work_order.changed',
entityId: workOrderId,
scopes: ['worker_hall'],
// 队首补位可能影响多张订单,客户端需要重新读取大厅快照。
operation: 'refresh',
data: { workOrderId },
operation: hallVisible ? 'upsert' : 'remove',
data: hallVisible
? {
...mapWorkOrderForWorker(workOrder, { depositFreeAmount: 0 }),
requiredDepositAmount: Number(workOrder.required_deposit_amount || 0),
sharingProgress: { joinedQuantity, pendingSubmissionCount },
}
: { workOrderId },
broadcastWorkers: true,
})
}