|
|
|
@@ -202,27 +202,40 @@ async function receiveFba(context, token, inbound, pallet) {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function receiveOverseas(context, token, inbound, pallet, producerCartonMark = null) {
|
|
|
|
|
const cartonMark = producerCartonMark || context.createdResources?.inboundMeasurement?.boxCode
|
|
|
|
|
if (!nonBlank(cartonMark)) {
|
|
|
|
|
blockerGap(context, `OVERSEAS入仓码${inbound.inboundCode}逐箱`, '缺少本轮冻结箱唛,逐箱实收不能使用伪造箱号')
|
|
|
|
|
async function receiveOverseas(context, token, inbounds, pallets, producerCartonMarks = []) {
|
|
|
|
|
const cartonMarks = [...new Set((Array.isArray(producerCartonMarks) ? producerCartonMarks : [producerCartonMarks])
|
|
|
|
|
.map(id).filter(nonBlank))]
|
|
|
|
|
if (!cartonMarks.length) {
|
|
|
|
|
blockerGap(context, 'OVERSEAS逐箱链', '缺少本轮PDA任务冻结箱唛,逐箱实收不能使用伪造箱号')
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
const resolved = await pda(context, token, 'POST', '解析OVERSEAS冻结箱唛', '/api/pda/v1/last-leg/receiving-containers/current/cartons/resolve', { cartonMark })
|
|
|
|
|
if (!success(resolved.response) || resolved.data?.inboundCode !== inbound.inboundCode) {
|
|
|
|
|
blockerGap(context, `OVERSEAS入仓码${inbound.inboundCode}箱唛归属`, `冻结箱唛未解析到目标入仓码;cartonMark=${cartonMark}`, 'fixture-mismatch', resolved.response)
|
|
|
|
|
return false
|
|
|
|
|
for (const [index, cartonMark] of cartonMarks.entries()) {
|
|
|
|
|
const resolved = await pda(context, token, 'POST', `解析OVERSEAS冻结箱唛${index + 1}`,
|
|
|
|
|
'/api/pda/v1/last-leg/receiving-containers/current/cartons/resolve', { cartonMark })
|
|
|
|
|
const inbound = inbounds.find((item) => item.inboundCode === resolved.data?.inboundCode)
|
|
|
|
|
const pallet = inbound ? pallets.get(inbound.inboundCode) : null
|
|
|
|
|
if (!success(resolved.response) || !inbound || !pallet) {
|
|
|
|
|
blockerGap(context, `OVERSEAS箱唛${cartonMark}归属`,
|
|
|
|
|
`冻结箱唛未解析到带真实托盘的本柜入仓码;inboundCode=${resolved.data?.inboundCode || 'missing'}`,
|
|
|
|
|
'fixture-mismatch', resolved.response)
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
const body = { cartonMark, palletCode: pallet.palletCode,
|
|
|
|
|
idempotencyKey: key(context, 'overseas-carton', cartonMark) }
|
|
|
|
|
const first = await pda(context, token, 'POST', `OVERSEAS逐箱实收${index + 1}`,
|
|
|
|
|
'/api/pda/v1/last-leg/receiving-containers/current/receipts/carton', body)
|
|
|
|
|
if (!success(first.response)) return false
|
|
|
|
|
const replay = await pda(context, token, 'POST', `OVERSEAS逐箱${index + 1}同键同载荷重放`,
|
|
|
|
|
'/api/pda/v1/last-leg/receiving-containers/current/receipts/carton', body)
|
|
|
|
|
context.assert(MODULE, `OVERSEAS逐箱${index + 1}幂等结果一致`, replay.response,
|
|
|
|
|
success(replay.response) && JSON.stringify(replay.data) === JSON.stringify(first.data), trace(replay.response), OPTIONS)
|
|
|
|
|
await expected(context, token, 'POST', `OVERSEAS逐箱${index + 1}同键异载荷冲突`,
|
|
|
|
|
'/api/pda/v1/last-leg/receiving-containers/current/receipts/carton',
|
|
|
|
|
{ ...body, palletCode: `${pallet.palletCode}-MUTATED` }, conflict)
|
|
|
|
|
await expected(context, token, 'POST', `OVERSEAS重复箱新键被拒绝${index + 1}`,
|
|
|
|
|
'/api/pda/v1/last-leg/receiving-containers/current/receipts/carton',
|
|
|
|
|
{ ...body, idempotencyKey: key(context, 'overseas-duplicate', cartonMark) }, conflict)
|
|
|
|
|
}
|
|
|
|
|
const body = { cartonMark, palletCode: pallet.palletCode, idempotencyKey: key(context, 'overseas-carton') }
|
|
|
|
|
const first = await pda(context, token, 'POST', 'OVERSEAS逐箱实收', '/api/pda/v1/last-leg/receiving-containers/current/receipts/carton', body)
|
|
|
|
|
if (!success(first.response)) return false
|
|
|
|
|
const replay = await pda(context, token, 'POST', 'OVERSEAS逐箱同键同载荷重放', '/api/pda/v1/last-leg/receiving-containers/current/receipts/carton', body)
|
|
|
|
|
context.assert(MODULE, 'OVERSEAS逐箱幂等结果一致', replay.response,
|
|
|
|
|
success(replay.response) && JSON.stringify(replay.data) === JSON.stringify(first.data), trace(replay.response), OPTIONS)
|
|
|
|
|
await expected(context, token, 'POST', 'OVERSEAS逐箱同键异载荷冲突', '/api/pda/v1/last-leg/receiving-containers/current/receipts/carton',
|
|
|
|
|
{ ...body, palletCode: `${pallet.palletCode}-MUTATED` }, conflict)
|
|
|
|
|
await expected(context, token, 'POST', 'OVERSEAS重复箱新键被拒绝', '/api/pda/v1/last-leg/receiving-containers/current/receipts/carton',
|
|
|
|
|
{ ...body, idempotencyKey: key(context, 'overseas-duplicate') }, conflict)
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -312,7 +325,7 @@ async function runReceiving(context, token, secondaryToken, merchantToken, prefe
|
|
|
|
|
success(resolved.response) && resolved.data?.compatible === true && resolved.data?.destinationType === inbound.destinationType, trace(resolved.response), OPTIONS)
|
|
|
|
|
}
|
|
|
|
|
const fbaInbounds = current.data.inbounds.filter((item) => item.destinationType === 'FBA')
|
|
|
|
|
const overseasInbound = current.data.inbounds.find((item) => item.destinationType === 'OVERSEAS')
|
|
|
|
|
const overseasInbounds = current.data.inbounds.filter((item) => item.destinationType === 'OVERSEAS')
|
|
|
|
|
if (fbaInbounds.length && fbaInbounds.every((item) => pallets.has(item.inboundCode))) {
|
|
|
|
|
const firstFba = fbaInbounds[0]
|
|
|
|
|
await expected(context, token, 'POST', 'FBA模式硬拒绝逐箱收货', '/api/pda/v1/last-leg/receiving-containers/current/receipts/carton', {
|
|
|
|
@@ -323,13 +336,15 @@ async function runReceiving(context, token, secondaryToken, merchantToken, prefe
|
|
|
|
|
} else if (preferredProducer?.destinationType !== 'OVERSEAS') {
|
|
|
|
|
blockerGap(context, 'FBA SKU按箱数链', '当前FBA柜没有带真实托盘的 FBA 入仓码')
|
|
|
|
|
}
|
|
|
|
|
if (overseasInbound && pallets.has(overseasInbound.inboundCode)) {
|
|
|
|
|
const pallet = pallets.get(overseasInbound.inboundCode)
|
|
|
|
|
if (overseasInbounds.length && overseasInbounds.every((item) => pallets.has(item.inboundCode))) {
|
|
|
|
|
const firstOverseas = overseasInbounds[0]
|
|
|
|
|
const pallet = pallets.get(firstOverseas.inboundCode)
|
|
|
|
|
await expected(context, token, 'POST', 'OVERSEAS模式硬拒绝批量收货', '/api/pda/v1/last-leg/receiving-containers/current/receipts/bulk', {
|
|
|
|
|
inboundCode: overseasInbound.inboundCode, skuCode: 'MODE-REJECT', palletCode: pallet.palletCode,
|
|
|
|
|
inboundCode: firstOverseas.inboundCode, skuCode: 'MODE-REJECT', palletCode: pallet.palletCode,
|
|
|
|
|
packageCount: 1, idempotencyKey: key(context, 'overseas-bulk-forbidden'),
|
|
|
|
|
}, (response) => conflictMessage(response, /OVERSEAS.*carton|bulk.*forbidden/i))
|
|
|
|
|
await receiveOverseas(context, token, overseasInbound, pallet, preferredProducer?.cartonMark)
|
|
|
|
|
await receiveOverseas(context, token, overseasInbounds, pallets,
|
|
|
|
|
preferredProducer?.cartonMarks?.length ? preferredProducer.cartonMarks : [preferredProducer?.cartonMark])
|
|
|
|
|
} else if (preferredProducer?.destinationType !== 'FBA') {
|
|
|
|
|
blockerGap(context, 'OVERSEAS逐箱链', '当前OVERSEAS柜没有带真实冻结箱唛与托盘的 OVERSEAS 入仓码')
|
|
|
|
|
}
|
|
|
|
|