fix(acceptance): close overseas dropship pallet chain
This commit is contained in:
@@ -134,6 +134,20 @@ function inventorySignature(snapshot) {
|
||||
})))
|
||||
}
|
||||
|
||||
function channelGroup(channelCode) {
|
||||
const value = String(channelCode || '').toUpperCase()
|
||||
if (value.startsWith('EXX_')) return 'EXX'
|
||||
if (value.startsWith('MATSON_CLX_')) return 'MATSON_CLX'
|
||||
if (value.startsWith('MATSON_MAX_')) return 'MATSON_MAX'
|
||||
if (value.startsWith('HEDE_')) return 'HEDE'
|
||||
if (value.startsWith('OA_LA_') || value === 'OA_PARCEL') return 'OA_LA'
|
||||
if (value.startsWith('OA_CHICAGO_')) return 'OA_CHICAGO'
|
||||
if (value.startsWith('OA_HOUSTON_')) return 'OA_HOUSTON'
|
||||
if (value.startsWith('OA_SAVANNAH_')) return 'OA_SAVANNAH'
|
||||
if (value === 'OA_NEW_YORK_TRUCK') return value
|
||||
throw new Error(`unsupported smart-loading channel group: ${channelCode}`)
|
||||
}
|
||||
|
||||
function operationsSignature(operations) {
|
||||
return JSON.stringify((operations || []).map((operation) => ({
|
||||
id: id(operation?.id), operationId: operation?.operationId || null,
|
||||
@@ -225,12 +239,25 @@ export async function run(context) {
|
||||
const candidates = context.apiSuccess(MODULE, '查询本轮入库单柜次装柜候选', candidateResponse, '', OPTIONS)
|
||||
const inboundCandidates = Array.isArray(candidates) ? candidates.filter((item) => id(item.inboundId) === inboundId
|
||||
&& Number(item.availablePackageCount) > 0) : []
|
||||
const candidate = inboundCandidates[0]
|
||||
let candidate = inboundCandidates[0]
|
||||
let dropshipCandidates = []
|
||||
if (source?.fulfillmentType === 'ONE_CLICK_DROPSHIP') {
|
||||
const group = channelGroup(initial?.summary?.channelCode)
|
||||
const candidatePath = `${smartLoadingBase}/inbound-candidates?channelGroupCodes=${encodeURIComponent(group)}&warehouseId=${encodeURIComponent(warehouseId)}&customerId=${encodeURIComponent(tenantId)}&inboundCode=${encodeURIComponent(initial?.summary?.inboundCode || source?.inboundCode || '')}&orderStatuses=WAIT_SPLIT&page=1&size=20`
|
||||
const palletCandidatesResponse = await context.request('GET', candidatePath)
|
||||
const palletCandidatePage = context.apiSuccess(MODULE, '查询一件代发整托装柜候选', palletCandidatesResponse, '', OPTIONS)
|
||||
dropshipCandidates = Array.isArray(palletCandidatePage?.records)
|
||||
? palletCandidatePage.records.filter((item) => id(item.inboundId) === inboundId
|
||||
&& id(item.palletId) && item.unitType === 'SEALED_PALLET' && item.indivisible === true) : []
|
||||
candidate = dropshipCandidates[0]
|
||||
context.assert(MODULE, '一件代发候选只按已封托托盘返回', palletCandidatesResponse,
|
||||
dropshipCandidates.length > 0, `inboundId=${inboundId}, pallets=${dropshipCandidates.length}`, OPTIONS)
|
||||
}
|
||||
context.assert(MODULE, '柜次装柜候选与入库单、客户和仓库一致', candidateResponse,
|
||||
Boolean(candidate?.inboundDetailId) && id(candidate?.accountId) === tenantId
|
||||
&& id(candidate?.warehouseId) === warehouseId,
|
||||
`candidate=${Boolean(candidate)}, warehouseId=${warehouseId || 'missing'}`, OPTIONS)
|
||||
if (!candidate?.inboundDetailId || !warehouseId) return
|
||||
if ((!candidate?.inboundDetailId && !id(candidate?.palletId)) || !warehouseId) return
|
||||
|
||||
|
||||
const loadingPlanResponse = await request(context, 'GET',
|
||||
@@ -240,7 +267,7 @@ export async function run(context) {
|
||||
if (!loadingPlanId) return
|
||||
const dropshipAssignment = source?.fulfillmentType === 'ONE_CLICK_DROPSHIP'
|
||||
const initialAssignmentCount = dropshipAssignment
|
||||
? inboundCandidates.filter((item) => id(item.palletId) === id(candidate.palletId))
|
||||
? dropshipCandidates.filter((item) => id(item.palletId) === id(candidate.palletId))
|
||||
.reduce((total, item) => total + Number(item.availablePackageCount || 0), 0) : 1
|
||||
const assignmentPath = dropshipAssignment
|
||||
? `${smartLoadingBase}/plans/${loadingPlanId}/pallet-assignments`
|
||||
|
||||
Reference in New Issue
Block a user