test: carry frozen sku receipts into pda acceptance
This commit is contained in:
@@ -175,31 +175,42 @@ async function awaitProducerCandidates(context, token, producers) {
|
||||
return ready
|
||||
}
|
||||
|
||||
function skuFixtures(context) {
|
||||
function skuFixtures(context, producer) {
|
||||
const frozenLines = Array.isArray(producer?.skuLines)
|
||||
? producer.skuLines
|
||||
.map((line) => ({ skuCode: id(line?.skuCode), packageCount: Number(line?.packageCount) }))
|
||||
.filter((line) => nonBlank(line.skuCode) && Number.isInteger(line.packageCount) && line.packageCount > 0)
|
||||
: []
|
||||
if (frozenLines.length) return frozenLines
|
||||
const frozen = Array.isArray(producer?.skuCodes)
|
||||
? producer.skuCodes.map(id).filter(nonBlank)
|
||||
: []
|
||||
if (frozen.length) return [...new Set(frozen)].map((skuCode) => ({ skuCode, packageCount: 1 }))
|
||||
const boxes = context.createdResources?.orders?.boxTypes
|
||||
const orchestration = context.createdResources?.orchestrationFixtures || {}
|
||||
const markers = [context.marker, orchestration.phase3Loading?.sourceMarker,
|
||||
orchestration.phase3LoadingIncremental?.sourceMarker].filter(nonBlank)
|
||||
return Array.isArray(boxes)
|
||||
? [...new Set(markers.flatMap((marker) => boxes.map((boxType) => `SKU-${boxType}-${marker}`.slice(0, 64))))]
|
||||
.map((skuCode) => ({ skuCode, packageCount: 1 }))
|
||||
: []
|
||||
}
|
||||
|
||||
async function receiveFba(context, token, inbound, pallet) {
|
||||
const skus = skuFixtures(context)
|
||||
async function receiveFba(context, token, inbound, pallet, producer) {
|
||||
const skus = skuFixtures(context, producer)
|
||||
if (!skus.length) {
|
||||
blockerGap(context, `FBA入仓码${inbound.inboundCode} SKU`, '本轮订单 fixture 未交接冻结 SKU,无法安全猜测实收 SKU')
|
||||
return false
|
||||
}
|
||||
let accepted = 0
|
||||
for (const [index, skuCode] of skus.entries()) {
|
||||
for (const [index, sku] of skus.entries()) {
|
||||
const { skuCode, packageCount } = sku
|
||||
const resolvedResponse = await context.requestOverseas('POST',
|
||||
'/api/pda/v1/last-leg/receiving-containers/current/skus/resolve', { skuCode }, {}, token)
|
||||
const resolvable = success(resolvedResponse) || notFound(resolvedResponse)
|
||||
context.addStep(MODULE, `解析FBA SKU候选 ${index + 1}`, resolvedResponse, resolvable, trace(resolvedResponse), OPTIONS)
|
||||
const resolved = { response: resolvedResponse, data: success(resolvedResponse) ? resolvedResponse.body?.data : null }
|
||||
if (!success(resolved.response) || resolved.data?.inboundCode !== inbound.inboundCode || resolved.data?.destinationType !== 'FBA') continue
|
||||
const packageCount = skuCode.includes('-LOAD-INC') ? 2 : 1
|
||||
const body = { inboundCode: inbound.inboundCode, skuCode, palletCode: pallet.palletCode,
|
||||
packageCount, idempotencyKey: key(context, 'fba-bulk', skuCode) }
|
||||
const first = await pda(context, token, 'POST', `FBA SKU ${skuCode}按箱数实收`, '/api/pda/v1/last-leg/receiving-containers/current/receipts/bulk', body)
|
||||
@@ -350,7 +361,9 @@ async function runReceiving(context, token, secondaryToken, merchantToken, prefe
|
||||
cartonMark: context.createdResources?.inboundMeasurement?.boxCode || 'MODE-REJECT-FBA',
|
||||
palletCode: pallets.get(firstFba.inboundCode).palletCode, idempotencyKey: key(context, 'fba-carton-forbidden'),
|
||||
}, (response) => conflictMessage(response, /FBA.*bulk|bulk.*FBA/i))
|
||||
for (const inbound of fbaInbounds) await receiveFba(context, token, inbound, pallets.get(inbound.inboundCode))
|
||||
for (const inbound of fbaInbounds) {
|
||||
await receiveFba(context, token, inbound, pallets.get(inbound.inboundCode), preferredProducer)
|
||||
}
|
||||
} else if (preferredProducer?.destinationType !== 'OVERSEAS') {
|
||||
blockerGap(context, 'FBA SKU按箱数链', '当前FBA柜没有带真实托盘的 FBA 入仓码')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user