fix(consignment): 兼容历史整单履约的赠送操作
无占用记录时按库存绑定工单兜底;前端无 allocation/share 时不再传 workOrderId,修复卖家提交赠送截图的订单占用报错。
This commit is contained in:
@@ -63,6 +63,7 @@ import type {
|
||||
} from '@/types/consignment'
|
||||
import type { UploadedFile } from '@/types/worker-platform'
|
||||
import { DEFAULT_CONSIGNMENT_INTAKE_FIELDS, buildSpecItemName } from '@/utils/consignment-spec'
|
||||
import { resolveConsignmentActionTarget } from '@/utils/consignment-action-target'
|
||||
import { buildConsignmentCategoryGroups } from '@/utils/consignment-category-tree'
|
||||
import { formatConsignmentContactSupporter } from '@/utils/consignment-contact'
|
||||
import { formatGiftCooldownRemaining } from '@/utils/consignment-cooldown'
|
||||
@@ -757,14 +758,6 @@ export default function WorkerConsignmentPage() {
|
||||
return null
|
||||
}
|
||||
|
||||
function resolveActionTarget(item: WorkerConsignmentRecord) {
|
||||
return {
|
||||
workOrderId: item.workOrderId,
|
||||
shareId: item.shareId ?? null,
|
||||
allocationId: item.allocationId ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
function handleConfirmFriend(item: WorkerConsignmentRecord) {
|
||||
const submissionId = resolveActionSubmissionId(item)
|
||||
if (submissionId == null) return
|
||||
@@ -789,7 +782,10 @@ export default function WorkerConsignmentPage() {
|
||||
centered: true,
|
||||
onOk: async () => {
|
||||
try {
|
||||
await confirmWorkerConsignmentFriendAdded(submissionId, resolveActionTarget(item))
|
||||
await confirmWorkerConsignmentFriendAdded(
|
||||
submissionId,
|
||||
resolveConsignmentActionTarget(item),
|
||||
)
|
||||
message.success('已确认加好友,赠送冷却开始')
|
||||
await myConsignmentsQuery.refetch()
|
||||
} catch (err: any) {
|
||||
@@ -831,7 +827,7 @@ export default function WorkerConsignmentPage() {
|
||||
...(note ? { note } : {}),
|
||||
}
|
||||
await submitWorkerConsignmentGiftEvidence(submissionId, {
|
||||
...resolveActionTarget(evidenceItem),
|
||||
...resolveConsignmentActionTarget(evidenceItem),
|
||||
...payload,
|
||||
})
|
||||
message.success('赠送截图已提交,等待客服验收')
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user