fix: support id-only overseas destinations

This commit is contained in:
2026-08-24 22:51:33 +08:00
parent 0e73a79479
commit 1e8d85c714
6 changed files with 39 additions and 13 deletions
@@ -56,9 +56,9 @@ function oceanDraft(context, suffix, master) {
}
}
async function ensureOceanBooking(context, suffix, master) {
if (context.createdResources?.oceanBooking?.id) {
const existingId = id(context.createdResources.oceanBooking.id)
async function ensureOceanBooking(context, suffix, master, preferredOceanBookingId = null) {
const existingId = id(preferredOceanBookingId || context.createdResources?.oceanBooking?.id)
if (existingId) {
const response = await request(context, 'GET', `${OCEAN}/${existingId}`)
const detail = context.apiSuccess(MODULE, '读取船期关联订舱真实柜次分配', response,
`oceanBookingId=${existingId}`, OPTIONS)
@@ -118,10 +118,10 @@ export async function run(context) {
const master = await resolveOceanBookingMaster(context, MODULE)
if (!master) return
const ocean = await ensureOceanBooking(context, suffix, master)
if (!ocean?.id) return
const flow = context.createdResources?.phase3Loading
|| context.createdResources?.phase3ContainerLoading
const ocean = await ensureOceanBooking(context, suffix, master, flow?.oceanBookingId)
if (!ocean?.id) return
const containerBookingId = ['COMPLETED', 'LOADED'].includes(flow?.finalStatus)
? id(flow.containerBookingId) : null
const knownAllocation = containerBookingId
@@ -503,6 +503,7 @@ test('downstream container consumers prefer the phase3Loading fixture', () => {
assert.doesNotMatch(serviceCenter, /链路承运商-/)
assert.doesNotMatch(serviceCenter, /customerName: `服务中心链路客户-/)
const schedules = source('./phase3-port-schedules.mjs')
assert.match(schedules, /ensureOceanBooking\(context, suffix, master, flow\?\.oceanBookingId\)/)
assert.match(schedules, /allocatedContainerBookingIds: \(detail\.containers \|\| \[\]\)/)
assert.match(schedules, /ocean\.allocatedContainerBookingIds\?\.includes\(containerBookingId\)/)
assert.match(schedules, /if \(containerBookingId && !knownAllocation\)/)