test: strengthen customs and fulfillment acceptance boundaries

This commit is contained in:
2026-09-30 12:58:15 +08:00
parent 125ca34ba4
commit 80632ba409
13 changed files with 1616 additions and 40 deletions
@@ -13,6 +13,11 @@ const MATSON_SUPPLIER_NAME = 'MATSON 开发联调船司'
const LATE_CONTAINER_GATE_ONLY = process.env.LATE_CONTAINER_GATE_ONLY === '1'
function id(value) { return value == null ? '' : String(value) }
export function loadingBookingCustomerFields(scope = 'CUSTOMER', customerId, customerName) {
if (scope === 'PLATFORM') return {}
if (scope !== 'CUSTOMER') throw new Error('三期订舱范围必须明确为 CUSTOMER 或 PLATFORM')
return { customerId, customerName }
}
export function markerSuffix(marker) {
const value = String(marker || '')
const digits = value.replace(/\D/g, '').slice(-8).padStart(8, '0')
@@ -201,7 +206,8 @@ export async function run(context) {
supplierId: id(shippingCarrier.id), name: shippingCarrier.name, status: 'ACTIVE', stableDevFixture: true,
}
const bookingDraft = {
customerId: tenantId, customerName: initial?.summary?.customerName,
...loadingBookingCustomerFields(context.context?.phase3LoadingBookingScope, tenantId,
initial?.summary?.customerName),
warehouseId,
channelCode: channelGroup(initial?.summary?.channelCode),
billOfLadingNo: `P3BL-${suffix}`.slice(0, 128),
@@ -569,6 +575,13 @@ export async function run(context) {
{ expectedVersion: 0, data: bookingDraft },
{ 'Idempotency-Key': `${context.marker}-p3-booking-create`.slice(0, 128) })
const bookingDraftResponse = context.apiSuccess(MODULE, '创建三期 DRAFT 订舱(不生成真实柜)', bookingCreateResponse, '', OPTIONS)
if (context.context?.phase3LoadingBookingScope === 'PLATFORM') {
const platformScoped = bookingDraftResponse?.oceanBooking?.customerId == null
&& bookingDraftResponse?.oceanBooking?.customerName == null
context.assert(MODULE, '多客户混柜使用未绑定单一客户的平台订舱', bookingCreateResponse,
platformScoped, 'scope=PLATFORM', OPTIONS)
if (!platformScoped) return
}
const bookingId = id(bookingDraftResponse?.oceanBooking?.id)
const draftVersion = Number(bookingDraftResponse?.oceanBooking?.version)
context.assert(MODULE, '三期 DRAFT 订舱返回稳定身份和初始版本', bookingCreateResponse,
@@ -646,6 +659,12 @@ export async function run(context) {
&& id(linked?.oceanBookingId) === bookingId,
`containerBookingId=${containerBookingId}, loadingPlanId=${loadingPlanId}`, OPTIONS)
if (id(linked?.id) !== containerBookingId) return
if (context.context?.phase3LoadingBookingScope === 'PLATFORM') {
const platformScoped = linked?.customerId == null && linked?.customerName == null
context.assert(MODULE, '平台订舱关联后原柜保持跨客户装柜范围', linkResponse,
platformScoped, 'scope=PLATFORM', OPTIONS)
if (!platformScoped) return
}
context.assert(MODULE, '三期订舱 RELEASED 后保持模拟柜关联身份和运输快照', releaseResponse,
bookingConfirmed?.oceanBooking?.status === 'RELEASED'