This commit is contained in:
2026-09-20 19:08:42 +08:00
parent 8ada2ef673
commit bf99bf9048
7 changed files with 124 additions and 48 deletions
@@ -235,12 +235,15 @@ export async function completeReturnRelabel(context, merchantToken, pdaToken, re
for (const [index, source] of sources.entries()) {
const target = await command(pdaToken, 'POST', '生成本轮带目的仓换标托盘', `${pallets}/relabel-pallet-label`,
{ relabelNo, idempotencyKey: key(context, `RETURN-PALLET-${index}`) })
const from = await command(pdaToken, 'POST', '回查来源托盘版本', `${pallets}/resolve`, { code: source.palletCode })
const to = await command(pdaToken, 'POST', '回查目标托盘版本', `${pallets}/resolve`, { code: target.palletCode })
const from = await command(pdaToken, 'POST', '回查来源托盘版本', `${pallets}/pallets/resolve`, { code: source.palletCode })
const to = await command(pdaToken, 'POST', '回查目标托盘版本', `${pallets}/pallets/resolve`, { code: target.palletCode })
require('组托仅使用本轮任务箱唛', source.cartonMarks?.length > 0
&& source.cartonMarks.every(mark => task.items.some(item => item.cartonMark === mark)))
const body = { relabelNo, source: { palletCode: from.palletCode, expectedVersion: Number(from.palletVersion) },
target: { palletCode: to.palletCode, expectedVersion: Number(to.palletVersion) },
actualSource: { positionId: source.positionId, expectedPositionVersion: Number(source.positionVersion),
packages: task.items.filter(item => source.cartonMarks.includes(item.cartonMark))
.reduce((sum, item) => sum + Number(item.expectedPackages), 0) },
cartonMarks: source.cartonMarks, idempotencyKey: key(context, `RETURN-BIND-${index}`), reason: context.marker }
const bound = await command(pdaToken, 'POST', '退货换标按实际数量绑定目标托盘', `${pallets}/relabel-disassemble`, body)
const replay = await command(pdaToken, 'POST', '退货换标组托原键重放', `${pallets}/relabel-disassemble`, body)
@@ -17,10 +17,16 @@ test('return relabel lifecycle requires review, quantities, binding, photo and c
calls.push({ method, path, body, token })
let data = task
if (path.endsWith('/status')) data = { application: { relabelNo: 'RL-1', status: 'PENDING_PROCESSING' } }
if (path.endsWith('/relabel-sources')) data = [{ palletCode: 'OLD', cartonMarks: ['BOX'] }]
if (path.endsWith('/relabel-sources')) data = [{ positionId: '12', positionVersion: 0, palletCode: 'OLD', cartonMarks: ['BOX'] }]
if (path.endsWith('/relabel-pallet-label')) data = { palletCode: 'NEW' }
if (path.endsWith('/resolve')) data = { palletCode: body.code, palletVersion: 1 }
if (path.endsWith('/relabel-disassemble')) data = { status: 'COMPLETED', operationId: '9', replayed: true }
if (path.endsWith('/resolve')) {
assert.equal(path, '/api/pda/v1/last-leg/pallet-operations/pallets/resolve')
data = { palletCode: body.code, palletVersion: 1 }
}
if (path.endsWith('/relabel-disassemble')) {
assert.deepEqual(body.actualSource, { positionId: '12', expectedPositionVersion: 0, packages: 1 })
data = { status: 'COMPLETED', operationId: '9', replayed: true }
}
if (path.endsWith('/RL-1/complete')) data = { applicationStatus: 'CUSTOMER_CONFIRM_PENDING' }
if (path.endsWith('/confirm-completion')) data = { application: { relabelNo: 'RL-1', status: 'COMPLETED' } }
if (path.endsWith('/return-orders/RT-1')) data = { order: { status: 'COMPLETED', relabelNo: 'RL-1', relabelStatus: 'COMPLETED' } }