fix(consignment): 兼容历史整单履约的赠送操作

无占用记录时按库存绑定工单兜底;前端无 allocation/share 时不再传 workOrderId,修复卖家提交赠送截图的订单占用报错。
This commit is contained in:
2026-11-13 15:09:40 +08:00
parent 1f3c98c071
commit dd0c56c265
6 changed files with 162 additions and 11 deletions
@@ -0,0 +1,29 @@
export type ConsignmentActionTargetInput = {
workOrderId?: number | null
shareId?: number | null
allocationId?: number | null
}
export type ConsignmentActionTarget = {
workOrderId?: number | null
shareId?: number | null
allocationId?: number | null
}
/**
* 卖家侧操作定位参数。
*
* 有 allocation/share 时按新占用模型传参;历史整单履约没有占用记录,
* 这时不要传 workOrderId,让后端回退到库存自身的 bound_work_order_id。
*/
export function resolveConsignmentActionTarget(
item: ConsignmentActionTargetInput,
): ConsignmentActionTarget {
const hasAllocationTarget = Number(item.allocationId || 0) > 0 || Number(item.shareId || 0) > 0
if (!hasAllocationTarget) return {}
return {
workOrderId: item.workOrderId ?? null,
shareId: item.shareId ?? null,
allocationId: item.allocationId ?? null,
}
}