fix(acceptance): complete overseas fulfillment closure

This commit is contained in:
2026-09-09 00:25:34 +08:00
parent 094d9c1e81
commit 7e76fed728
12 changed files with 70 additions and 27 deletions
+13 -1
View File
@@ -1387,6 +1387,8 @@ export class AcceptanceRun {
internalRemark: fixtureOrder.internalRemark,
cargoRemark: fixtureOrder.cargoRemark,
taxMode: fixtureOrder.taxMode || null,
finalStatus: fixture.finalStatus,
processStatus: fixture.processStatus,
requireInventoryMutation: requireSharedOverflow,
} : { marker: originalMarker, sourceMarker: fixtureMarker, failed: true }
const incrementalMarker = `${originalMarker}-LOAD${suffix}-INC`
@@ -1468,7 +1470,7 @@ export class AcceptanceRun {
const variantMarker = `${matrixMarker}-P4-${label}`
const contextKeys = ['orderDestinationType', 'orderFulfillmentType', 'phase4ProducerMatrixMarker']
const createdKeys = [
'phase3Loading', 'phase3LoadingCompletedProducer', 'phase3ContainerDocuments', 'orchestrationFixtures', 'oceanBooking',
'phase3Loading', 'phase3LoadingCompletedProducer', 'phase3ContainerDocuments', 'orchestrationFixtures', 'inboundFees', 'oceanBooking',
'phase3CustomsSupplier', 'phase3Customs', 'serviceCenterFlow', 'portSchedule',
'phase3OutboundDispatch', 'phase3CarrierScheduleQuery', 'phase4CarrierPickupReady',
]
@@ -1493,6 +1495,16 @@ export class AcceptanceRun {
// run; repeating it for every producer is unsafe for a populated shared warehouse and can
// become impossible when the bounded isolation guard refuses bulk location mutations.
restoreFixture = await this.preparePhase3LoadingFixture('', false)
if (fulfillmentType === 'ONE_CLICK_DROPSHIP') {
const measuredFixture = this.createdResources.inboundMeasurement
this.createdResources.inboundMeasurement = this.createdResources.orchestrationFixtures?.phase3Loading
try {
const inboundFees = await import(new URL('./admin-test-env-modules/inbound-fees.mjs', import.meta.url))
await this.executeModule(`inbound-fees-phase4-${label}`, () => inboundFees.run(this))
} finally {
this.createdResources.inboundMeasurement = measuredFixture
}
}
const loading = await import(new URL('./admin-test-env-modules/phase3-loading.mjs', import.meta.url))
await this.executeModule(`phase3-loading-phase4-${label}`, () => loading.run(this))
const finalize = await import(new URL('./admin-test-env-modules/phase3-loading-finalize.mjs', import.meta.url))
@@ -8,9 +8,9 @@ import { normalizeModuleOrder } from '../admin-test-env-acceptance.mjs'
const source = readFileSync(new URL('./phase3-container-documents.mjs', import.meta.url), 'utf8')
const entry = readFileSync(new URL('../admin-test-env-acceptance.mjs', import.meta.url), 'utf8')
test('three generic container documents are frozen and customs stays on customs-v1', () => {
test('two container operational documents are frozen and customs stays on customs-v1', () => {
assert.deepEqual(DOCUMENT_TYPES, [
'DESTINATION_CLEARANCE', 'DELIVERY_ORDER', 'PICKUP_ORDER',
'DESTINATION_CLEARANCE', 'DELIVERY_ORDER',
])
for (const token of [
'/clearance/document/upload', '/clearance/complete',
@@ -28,11 +28,11 @@ test('document lifecycle is fail-closed, traceable and covers replay, hash confl
]) assert.ok(source.includes(token), token)
})
test('focused pickup-ready chain orders documents before outbound and candidate visibility', () => {
test('focused pickup-ready dependencies reach outbound and candidate visibility', () => {
const modules = normalizeModuleOrder(['phase4-overseas-pda'])
const required = [
'phase3-loading-finalize', 'phase3-container-documents', 'phase3-customs',
'phase3-outbound-dispatch', 'phase3-carrier-schedule-queries',
'phase3-loading-finalize', 'phase3-customs', 'phase3-outbound-dispatch',
'phase3-carrier-schedule-queries',
'phase4-carrier-pickup-ready', 'phase4-overseas-pda',
]
for (const module of required) assert.ok(modules.includes(module), module)
@@ -3,7 +3,7 @@ const OPTIONS = { scenario: 'phase3-container-operational-documents', deployment
const CONTAINERS = '/api/platform/v1/containers'
export const DOCUMENT_TYPES = Object.freeze([
'DESTINATION_CLEARANCE', 'DELIVERY_ORDER', 'PICKUP_ORDER',
'DESTINATION_CLEARANCE', 'DELIVERY_ORDER',
])
function id(value) { return value == null ? '' : String(value) }
@@ -114,7 +114,7 @@ export async function run(context) {
readPath: `${CONTAINERS}/${containerId}/clearance`,
completePath: `${CONTAINERS}/${containerId}/clearance/complete`,
},
...['DELIVERY_ORDER', 'PICKUP_ORDER'].map((type) => ({
...['DELIVERY_ORDER'].map((type) => ({
type,
uploadPath: `${CONTAINERS}/${containerId}/documents/${type}/upload`,
readPath: `${CONTAINERS}/${containerId}/documents/${type}`,
@@ -254,7 +254,7 @@ export async function run(context) {
dropshipCandidates.length > 0, `inboundId=${inboundId}, pallets=${dropshipCandidates.length}`, OPTIONS)
}
context.assert(MODULE, '柜次装柜候选与入库单、客户和仓库一致', candidateResponse,
Boolean(candidate?.inboundDetailId) && id(candidate?.accountId) === tenantId
Boolean(candidate?.inboundDetailId || id(candidate?.palletId)) && id(candidate?.accountId) === tenantId
&& id(candidate?.warehouseId) === warehouseId,
`candidate=${Boolean(candidate)}, warehouseId=${warehouseId || 'missing'}`, OPTIONS)
if ((!candidate?.inboundDetailId && !id(candidate?.palletId)) || !warehouseId) return
@@ -85,10 +85,12 @@ test('measurement and loading pass destination identity into the LOADED producer
assert.match(entry, /runPhase4ProducerVariant\('DROPSHIP-PRIMARY', 'FBA', 'ONE_CLICK_DROPSHIP', true\)/)
assert.match(entry, /orderFulfillmentType/)
assert.match(entry, /fulfillmentType: fixtureOrder\.fulfillmentType \|\| 'STANDARD'/)
assert.match(entry, /inbound-fees-phase4-/)
assert.match(entry, /createdResources\.inboundMeasurement = this\.createdResources\.orchestrationFixtures\?\.phase3Loading/)
assert.match(entry, /skuCodes: Array\.isArray\(fixtureOrder\.skuCodes\) \? fixtureOrder\.skuCodes : \[\]/)
assert.match(entry, /skuLines: Array\.isArray\(fixtureOrder\.skuLines\) \? fixtureOrder\.skuLines : \[\]/)
const pda = read('phase4-overseas-pda.mjs')
assert.match(loading, /inbound-assignments/)
assert.match(loading, /pallet-assignments/)
assert.match(loading, /canonicalPickItems\.map/)
assert.match(loading, /pickedPackageCount: Number\(item\.plannedPackageCount\)/)
assert.match(loading, /const dropshipWholePallet = source\?\.fulfillmentType === 'ONE_CLICK_DROPSHIP'/)
@@ -31,6 +31,8 @@ test('phase-five module covers dispatch edit, transfer, PDA pick/depart and deli
assert.match(source, /READY_TO_DEPART/)
assert.match(source, /OUTBOUNDED/)
assert.match(source, /DELIVERING/)
assert.match(source, /expectedVersion: deliveryVersion/)
assert.match(source, /status: 'DELIVERED', expectedVersion: completeVersion/)
})
test('phase-five module proves the client delivery create, list and nested detail contract', () => {
@@ -250,13 +250,30 @@ export async function run(context) {
outbound.data?.outbound?.outboundNo === outboundNo && outbound.data?.outbound?.status === 'OUTBOUNDED',
trace(outbound.response), OPTIONS)
const deliveryBeforeStatus = await platform(context, 'GET', '读取派送状态更新即时版本',
query(`${LASTLEG_BASE}/delivery-orders/${encodeURIComponent(deliveryNo)}`, { customerId }))
const deliveryVersion = Number(deliveryBeforeStatus.data?.order?.version)
context.assert(MODULE, '派送详情提供状态乐观锁版本', deliveryBeforeStatus.response,
Number.isInteger(deliveryVersion) && deliveryVersion >= 0,
`version=${deliveryBeforeStatus.data?.order?.version ?? 'missing'}; ${trace(deliveryBeforeStatus.response)}`, OPTIONS)
if (!Number.isInteger(deliveryVersion) || deliveryVersion < 0) return
const delivering = await platform(context, 'PUT', '派送单推进配送中',
query(`${LASTLEG_BASE}/delivery-orders/${encodeURIComponent(deliveryNo)}/status`, { customerId }),
{ status: 'DELIVERING', remark: `${context.marker}-delivering` })
{ status: 'DELIVERING', expectedVersion: deliveryVersion, remark: `${context.marker}-delivering` })
context.assert(MODULE, '派送状态进入DELIVERING', delivering.response,
delivering.data?.deliveryStatus === 'DELIVERING', trace(delivering.response), OPTIONS)
if (!success(delivering.response)) return
const deliveryBeforeComplete = await platform(context, 'GET', '读取派送完成即时版本',
query(`${LASTLEG_BASE}/delivery-orders/${encodeURIComponent(deliveryNo)}`, { customerId }))
const completeVersion = Number(deliveryBeforeComplete.data?.order?.version)
context.assert(MODULE, '配送中详情版本已递增', deliveryBeforeComplete.response,
Number.isInteger(completeVersion) && completeVersion > deliveryVersion,
`before=${deliveryVersion}, after=${deliveryBeforeComplete.data?.order?.version ?? 'missing'}; ${trace(deliveryBeforeComplete.response)}`,
OPTIONS)
if (!Number.isInteger(completeVersion) || completeVersion <= deliveryVersion) return
const completed = await platform(context, 'POST', '确认派送完成并生成客户回访',
query(`${LASTLEG_BASE}/delivery-orders/${encodeURIComponent(deliveryNo)}/complete`, { customerId }))
query(`${LASTLEG_BASE}/delivery-orders/${encodeURIComponent(deliveryNo)}/complete`, { customerId }),
{ status: 'DELIVERED', expectedVersion: completeVersion, remark: `${context.marker}-delivered` })
const visitId = id(completed.data?.visitId)
context.assert(MODULE, '派送完成生成PENDING回访记录', completed.response,
completed.data?.deliveryStatus === 'DELIVERED' && completed.data?.visitStatus === 'PENDING'
@@ -264,7 +281,8 @@ export async function run(context) {
if (!success(completed.response) || !visitId) return
context.createdResources.phase5OverseasFulfillment.visitId = visitId
const completeReplay = await platform(context, 'POST', '确认派送完成重复调用',
query(`${LASTLEG_BASE}/delivery-orders/${encodeURIComponent(deliveryNo)}/complete`, { customerId }))
query(`${LASTLEG_BASE}/delivery-orders/${encodeURIComponent(deliveryNo)}/complete`, { customerId }),
{ status: 'DELIVERED', expectedVersion: completeVersion, remark: `${context.marker}-delivered` })
context.assert(MODULE, '派送完成重放复用同一回访', completeReplay.response,
completeReplay.data?.replayed === true && id(completeReplay.data?.visitId) === visitId,
trace(completeReplay.response), OPTIONS)
@@ -163,6 +163,8 @@ test('PDA entry expands the real phase-three producer chain and builds an FBA/OV
assert.match(source, /runPhase4ProducerVariant\('SECONDARY', 'FBA', 'STANDARD', false\)/)
assert.match(source, /runUntilPickupReady\(this\)/)
const variant = source.slice(source.indexOf('async runPhase4ProducerVariant'), source.indexOf('async ensurePhase4PdaProducerMatrix'))
assert.ok(variant.indexOf('inbound-fees-phase4-') < variant.indexOf('phase3-loading-phase4-'))
assert.match(variant, /fulfillmentType === 'ONE_CLICK_DROPSHIP'/)
assert.ok(variant.indexOf('phase3-outbound-dispatch-phase4-') < variant.indexOf('phase3-container-documents-phase4-'))
assert.ok(variant.indexOf('phase3-container-documents-phase4-') < variant.indexOf('phase3-carrier-schedule-queries-phase4-'))
assert.match(source, /\['phase3-container-documents', \['phase3-outbound-dispatch'\]\]/)