完善拼单状态与份额验收流程

This commit is contained in:
yml2213
2026-08-18 18:02:43 +08:00
parent 052b99b05f
commit ee79195f47
17 changed files with 1143 additions and 196 deletions
@@ -20,6 +20,7 @@ import { getAdminDashboardSummary } from '../admin/admin-dashboard-service.js'
import { mapAdminOrderListItem } from '../admin/admin-order-read-helpers.js'
import { mapAdminTaskListItem } from '../admin/admin-task-read-helpers.js'
import {
isWorkOrderSharingFilled,
mapFinanceRequest,
mapWorkOrderAdmin,
mapWorkOrderForWorker,
@@ -256,7 +257,19 @@ async function publishWorkOrderSnapshots(input: {
const adminSnapshot = {
...mapWorkOrderAdmin(workOrder),
pendingUnfreezeAmount: pendingUnfreezeByOrderId.get(workOrderId) || 0,
sharingProgress: { joinedQuantity, pendingSubmissionCount },
sharingProgress: {
joinedQuantity,
pendingSubmissionCount,
remainingQuantity: Math.max(
0,
Number(workOrder.sharing_total_quantity || 1) - joinedQuantity,
),
filled: isWorkOrderSharingFilled(
workOrder.sharing_enabled === true,
Number(workOrder.sharing_total_quantity || 1),
joinedQuantity,
),
},
}
publishRealtimeEvent({
@@ -269,11 +282,16 @@ async function publishWorkOrderSnapshots(input: {
})
if (input.hallChanged) {
const sharingFilled = isWorkOrderSharingFilled(
workOrder.sharing_enabled === true,
Number(workOrder.sharing_total_quantity || 1),
joinedQuantity,
)
publishRealtimeEvent({
type: 'work_order.changed',
entityId: workOrderId,
scopes: ['worker_hall'],
operation: workOrder.status === 'open' ? 'upsert' : 'remove',
operation: workOrder.status === 'open' && !sharingFilled ? 'upsert' : 'remove',
data: mapWorkerHallWorkOrder(workOrder, shares),
broadcastWorkers: true,
})