feat: add dropship fulfillment producer chain

This commit is contained in:
2026-08-25 08:40:27 +08:00
parent c218bfad6b
commit 4839243f21
35 changed files with 389 additions and 53 deletions
@@ -17,25 +17,32 @@ test('order fixture defaults to FBA and accepts only the explicit OVERSEAS varia
const orders = read('orders.mjs')
assert.match(orders, /warehouseType=\$\{encodeURIComponent\(destinationType\)\}/)
assert.match(orders, /destinationType: master\.destinationType/)
assert.match(orders, /fulfillmentType: String\(context\.context\?\.orderFulfillmentType \|\| 'STANDARD'\)/)
assert.match(orders, /destinationType,\s*\n\s*\}\)/)
assert.doesNotMatch(orders, /const fbaResponse =/)
})
test('producer collector requires one FBA, one OVERSEAS and a third distinct container', () => {
test('producer collector requires dropship FBA, standard FBA, OVERSEAS and a fourth distinct container', () => {
const common = { marker: 'RUN-1', eventType: 'FIRST_LEG_LOADING_PLAN_COMPLETED', sourceStatus: 'LOADED' }
const fba = { ...common, eventKey: 'FBA-EVENT', destinationType: 'FBA', containerNo: 'FBA-001' }
const dropship = { ...common, eventKey: 'DROP-EVENT', destinationType: 'FBA',
fulfillmentType: 'ONE_CLICK_DROPSHIP', containerNo: 'DROP-001' }
const fba = { ...common, eventKey: 'FBA-EVENT', destinationType: 'FBA',
fulfillmentType: 'STANDARD', containerNo: 'FBA-001' }
const overseasPrimary = { ...common, eventKey: 'OS-EVENT-1', destinationType: 'OVERSEAS', containerNo: 'OS-001' }
const secondary = { ...common, eventKey: 'FBA-EVENT-2', destinationType: 'FBA', containerNo: 'FBA-002' }
const one = collectPhase4InboundProducerFixture(null, fba)
const two = collectPhase4InboundProducerFixture(one, overseasPrimary)
const ready = collectPhase4InboundProducerFixture(two, secondary)
const one = collectPhase4InboundProducerFixture(null, dropship)
const two = collectPhase4InboundProducerFixture(one, fba)
const three = collectPhase4InboundProducerFixture(two, overseasPrimary)
const ready = collectPhase4InboundProducerFixture(three, secondary)
assert.equal(one.readiness.readyForPhase4Pda, false)
assert.equal(two.readiness.readyForPhase4Pda, false)
assert.equal(three.readiness.readyForPhase4Pda, false)
assert.equal(ready.readiness.readyForPhase4Pda, true)
assert.equal(ready.readiness.fbaContainerCount, 2)
assert.equal(ready.readiness.fbaContainerCount, 3)
assert.equal(ready.readiness.overseasContainerCount, 1)
assert.equal(ready.readiness.distinctContainerCount, 3)
assert.equal(ready.byDestinationType.FBA[1].eventKey, 'FBA-EVENT-2')
assert.equal(ready.readiness.dropshipContainerCount, 1)
assert.equal(ready.readiness.distinctContainerCount, 4)
assert.equal(ready.byDestinationType.FBA[2].eventKey, 'FBA-EVENT-2')
})
test('same event key is idempotently replaced and another marker starts a new matrix', () => {
@@ -49,6 +56,7 @@ test('same event key is idempotently replaced and another marker starts a new ma
assert.equal(nextRun.containers.length, 1)
assert.equal(nextRun.marker, 'RUN-2')
assert.deepEqual(nextRun.requiredEntryOrchestration, [
'DROPSHIP-FBA: public order fulfillmentType -> inbound-measurement -> phase3-loading -> phase3-loading-finalize -> overseas PDA',
'FBA: orders -> inbound-measurement -> phase3-loading -> phase3-customs -> phase3-loading-finalize',
'OVERSEAS-PRIMARY: orders -> inbound-measurement -> phase3-loading -> phase3-customs -> phase3-loading-finalize',
'SECONDARY(FBA|OVERSEAS): orders -> inbound-measurement -> phase3-loading -> phase3-customs -> phase3-loading-finalize',
@@ -61,7 +69,14 @@ test('measurement and loading pass destination identity into the LOADED producer
const finalize = read('phase3-loading-finalize.mjs')
assert.match(measurement, /destinationType: context\.createdResources\?\.orders\?\.destinationType/)
assert.match(loading, /destinationType: initial\?\.summary\?\.destinationType \|\| source\?\.destinationType/)
assert.match(loading, /fulfillmentType: source\?\.fulfillmentType \|\| 'STANDARD'/)
assert.match(finalize, /destinationType: fixture\.destinationType \|\| null/)
assert.match(finalize, /fulfillmentType: fixture\.fulfillmentType \|\| 'STANDARD'/)
assert.match(finalize, /resourceKey: `\$\{context\.marker\}:\$\{fixture\.destinationType \|\| 'UNKNOWN'\}:\$\{fixture\.containerNo \|\| containerBookingId\}`/)
assert.match(finalize, /phase4InboundProducerFixtures = collectPhase4InboundProducerFixture/)
const entry = read('../admin-test-env-acceptance.mjs')
assert.match(entry, /runPhase4ProducerVariant\('DROPSHIP-PRIMARY', 'FBA', 'ONE_CLICK_DROPSHIP'\)/)
assert.match(entry, /orderFulfillmentType/)
const pda = read('phase4-overseas-pda.mjs')
assert.match(pda, /find\(\(item\) => item\?\.fulfillmentType === 'ONE_CLICK_DROPSHIP'\)/)
})