修复接单大厅价格物化遗漏

This commit is contained in:
yml
2026-11-15 00:21:04 +08:00
parent e77f96ee3c
commit 2f03b96634
6 changed files with 237 additions and 10 deletions
@@ -285,6 +285,12 @@ export async function returnAssignedWorkOrderToHall(input: {
Number(wallet?.frozen_deposit_amount || 0),
)
// 所有重新进入大厅的路径都必须先物化当前模板价和成本版本;
// 直接更新为 open 会被迁移 163 的数据库闸门拒绝。
await assertWorkOrderHallPriceReadyWithClient(client, input.workOrderId, {
now: input.now,
actorName: input.actorName || '',
})
await client.query(
`
UPDATE work_orders
@@ -678,6 +678,11 @@ export async function settleOverdueWorkOrder(input: {
// 重匹配不再进入内部匹配池:超时结算后先回到待抢单,由超时服务立即试一次自动匹配。
const targetStatus = isRematch || input.policy === 'reopen' ? 'open' : 'cancelled'
if (targetStatus === 'open') {
await assertWorkOrderHallPriceReadyWithClient(client, input.workOrderId, {
now: input.now,
})
}
await client.query(
`
@@ -783,16 +783,13 @@ export async function recomputeWorkOrderSharingStatusWithClient(
const nextStatus =
allocated >= total && joinedCount === 0 && submittedCount > 0 ? 'pending_acceptance' : 'open'
// 已全是 accepted 且母单已验收时不再回退(上面的终态分支已挡住)
if (allocated === 0 && acceptedCount === 0 && workOrder.status === 'open') {
return workOrder
}
if (String(workOrder.status || '') === nextStatus) {
return workOrder
}
// 即使母单仍为 open,份额取消/减少也会增加未拼数量,必须重新按当前模板价物化。
if (nextStatus === 'open') {
await assertWorkOrderHallPriceReadyWithClient(client, workOrderId, { now })
}
if (String(workOrder.status || '') === nextStatus) {
return getWorkOrderByIdWithClient(client, workOrderId)
}
const hallQueueAssignments = options.preserveHallQueue
? ''