This commit is contained in:
2026-09-14 12:00:48 +08:00
parent fb66d9200a
commit e55ab73e61
11 changed files with 288 additions and 9 deletions
@@ -172,6 +172,11 @@ export async function run(context) {
trace(updated.response), OPTIONS)
if (!success(updated.response)) return
const bol = await context.requestOverseasBinary('GET', `${DISPATCH_BASE}/${encodeURIComponent(dispatchNo)}/prints/bol`)
context.addStep(MODULE, '排车BOL下载为真实PDF而非JSON错误', bol,
bol.http === 200 && /application\/pdf/i.test(bol.contentType || '')
&& new TextDecoder().decode(bol.bytes?.slice(0, 5)) === '%PDF-', trace(bol), OPTIONS)
const transferBody = {
idempotencyKey: key(context, 'TRANSFER'), plannedDeliveryAt: new Date(Date.now() + 172_800_000).toISOString(),
deliveryMethod: 'TRUCK_PALLET', waybillNo: `${context.marker}-WAYBILL`.slice(0, 64),
@@ -192,6 +197,21 @@ export async function run(context) {
`outboundNo=${outboundNo || 'missing'}, deliveryNo=${deliveryNo || 'missing'}; ${trace(transferred.response)}`, OPTIONS)
if (!success(transferred.response) || !outboundNo || !deliveryNo) return
Object.assign(context.createdResources.phase5OverseasFulfillment, { outboundNo, deliveryNo })
const adminReplay = await platform(context, 'POST', '后台转派送复用客户已创建的同一出库派送单',
`${DISPATCH_BASE}/${encodeURIComponent(dispatchNo)}/transfer-delivery`, transferBody)
context.assert(MODULE, '后台与客户转派送共享同一业务事实', adminReplay.response,
adminReplay.data?.replayed === true && id(adminReplay.data?.outboundNo) === outboundNo
&& id(adminReplay.data?.deliveryNo) === deliveryNo, trace(adminReplay.response), OPTIONS)
const lockedItem = updated.data?.items?.[0]
if (lockedItem?.id) {
const deniedRemove = await context.requestOverseas('DELETE',
`${DISPATCH_BASE}/${encodeURIComponent(dispatchNo)}/items/${encodeURIComponent(id(lockedItem.id))}`)
context.addStep(MODULE, '已生成出库单禁止移除排车托盘', deniedRemove, conflict(deniedRemove), trace(deniedRemove), OPTIONS)
const stable = await platform(context, 'GET', '移除拒绝后回查排车托盘零漂移', `${DISPATCH_BASE}/${encodeURIComponent(dispatchNo)}`)
context.assert(MODULE, '移除失败不改变箱数和托盘身份', stable.response,
Number(stable.data?.packageCount) === Number(updated.data?.packageCount)
&& JSON.stringify(stable.data?.items?.map(item => id(item.id))) === JSON.stringify(updated.data?.items?.map(item => id(item.id))), trace(stable.response), OPTIONS)
} else blocker(context, '转派送后移除门禁前置', '本轮排车缺少真实明细ID')
const transferReplay = await merchant(context, merchantToken, 'POST', '客户创建派送同键重放',
query(MERCHANT_DELIVERY_BASE, { dispatchNo }), transferBody)
context.assert(MODULE, '转派送重放复用同一业务单据', transferReplay.response,