fix(worker): 整单指派拼单订单无法验收

- 前端:拼单订单整单指派给本人时放行验收
- 后端:整单指派清掉 sharing_enabled;已有有效份额则拒绝
This commit is contained in:
2026-11-02 12:02:24 +08:00
parent a9e2de443e
commit db3f477ab3
5 changed files with 151 additions and 2 deletions
@@ -0,0 +1,24 @@
/**
* 打手验收前置判断:拼单订单缺份额时是否应该拦截。
*
* 管理端「指派打手」是整单指派,不会创建 work_order_shares;
* 这类订单虽然 sharing.enabled=true,但接单人就是当前打手,
* 必须按整单验收放行,否则会被前端防呆误拦。
*/
export type AcceptanceShareGuardInput = {
shareCount: number
sharingEnabled: boolean
assignedWorkerId: number | null | undefined
currentWorkerId: number
}
export function shouldBlockAcceptanceForMissingShares(input: AcceptanceShareGuardInput): boolean {
if (input.shareCount > 0) return false
if (input.sharingEnabled !== true) return false
const currentWorkerId = Number(input.currentWorkerId || 0)
// 本地会话里拿不到打手 ID 时保持旧行为,避免误放行。
if (!Number.isFinite(currentWorkerId) || currentWorkerId <= 0) return true
return Number(input.assignedWorkerId || 0) !== currentWorkerId
}