test: extend eight-business acceptance flows and offline contracts

This commit is contained in:
2026-10-22 15:41:50 +08:00
parent 86889d7e0e
commit 080ca600e6
33 changed files with 1285 additions and 101 deletions
@@ -1,4 +1,7 @@
import { verifyWarehouseTransferReview } from './warehouse-transfer-review.mjs'
import { allocateWarehouseTransfer } from './warehouse-transfer-allocation.mjs'
import { outboundWarehouseTransfer } from './warehouse-transfer-outbound.mjs'
import { receiveWarehouseTransfer } from './warehouse-transfer-receipt.mjs'
import { verifyCargoDiscardFulfillment } from './cargo-discard-fulfillment.mjs'
import { createPicker, disablePicker, resolvePickerAccess } from './phase4-overseas-pda.mjs'
import { fundRelabelWallet } from './phase4-overseas-pda-operations.mjs'
@@ -171,9 +174,9 @@ async function verifyRelabel(context, token, order) {
try {
if (!picker?.token) throw new Error('贴标后续未取得本仓PDA会话')
await verifyClientRelabelFulfillment(context, { proof, merchantToken: token, pdaToken: picker.token })
context.addCoverageGap(MODULE, 'client-relabel-delivery', '客户原贴标申请的排车至交付',
'原申请已完成PDA贴标和客户确认,后续必须使用本申请targetPalletIds接履约,不能借其他换标单结果',
'not-implemented', { blocking: false })
if (!context.options?.modules?.includes('phase5-overseas-fulfillment')) context.addCoverageGap(MODULE, 'client-relabel-delivery', '客户原贴标申请的排车至交付',
'当前定向范围仅到客户确认;完整默认链继续使用本申请targetPalletIds排车并签收,不能借其他换标单结果',
'fixture', { blocking: false })
} finally {
if (picker?.membershipId) await disablePicker(context, picker, 94)
}
@@ -260,7 +263,30 @@ async function verifyTransfer(context, token, orders) {
&& detail.data?.outboundAt == null && Array.isArray(detail.data?.allocations) && detail.data.allocations.length === 0,
`status=${detail.data?.status || 'missing'}, allocations=${detail.data?.allocations?.length ?? 'missing'}; ${trace(detail.response)}`, OPTIONS)
context.createdResources.phase4OverseasClientServices.transferNo = transferNo
return verifyWarehouseTransferReview(context, token, order.row.customerId, body, transferNo)
if (!await verifyWarehouseTransferReview(context, token, order.row.customerId, body, transferNo)) return false
const transferProof = context.createdResources.phase4OverseasClientServices.transferFulfillment = {
marker: context.marker, customerId: id(order.row.customerId), warehouseId: id(order.row.overseasWarehouseId),
transferNo, inboundCode: order.row.inboundCode, skuCode: cargo.skuCode, status: 'APPROVED',
}
await allocateWarehouseTransfer(context, { proof: transferProof, merchantToken: token })
const relabelProof = transferProof.relabelFulfillment = {
marker: context.marker, relabelNo: transferProof.relabelNo, customerId: transferProof.customerId,
warehouseId: transferProof.warehouseId, sourceOrderNo: transferNo,
sourcePositionId: transferProof.sourcePositionId, sourcePalletNo: transferProof.sourcePalletNo,
status: 'PENDING_REVIEW',
}
const access = await resolvePickerAccess(context)
if (!access) throw new Error('转运换标后续缺少有效PDA角色')
const picker = await createPicker(context, 96, transferProof.warehouseId, access)
try {
if (!picker?.token) throw new Error('转运换标未取得本仓PDA会话')
await verifyClientRelabelFulfillment(context, { proof: relabelProof, transferProof, merchantToken: token, pdaToken: picker.token })
} finally {
if (picker?.membershipId) await disablePicker(context, picker, 96)
}
await outboundWarehouseTransfer(context, { proof: transferProof, merchantToken: token })
await receiveWarehouseTransfer(context, { proof: transferProof, merchantToken: token })
return true
}
export async function verifyDiscard(context, token, markerOrders) {
@@ -425,7 +451,7 @@ async function runWithSession(context, token) {
context.createdResources.phase4OverseasClientServices = {
marker: context.marker, relabelNo: null, transferNo: null, discardNo: null,
finalStatuses: { relabel: null, transfer: null, discard: null },
cleanup: 'Relabel ready for dispatch; transfer review fixtures retained; discard PDA execution and customer confirmation retained; no dispatch or delivery action is invoked',
cleanup: '保留原贴标申请、转运分配换标出入库及废弃完成证据;不自动删除业务数据;贴标排车签收由后续模块执行',
}
for (const [name, path] of [['贴标', RELABEL], ['仓储转运', TRANSFER], ['货物废弃', DISCARD]]) {
@@ -448,7 +474,7 @@ async function runWithSession(context, token) {
const discardDone = await verifyDiscard(context, token, orders)
context.createdResources.phase4OverseasClientServices.finalStatuses = {
relabel: relabelDone ? 'READY_FOR_OUTBOUND' : null,
transfer: transferDone ? 'APPROVED' : null,
transfer: transferDone ? context.createdResources.phase4OverseasClientServices.transferFulfillment?.status ?? null : null,
discard: discardDone ? 'COMPLETED' : null,
}
}