This commit is contained in:
2026-10-27 17:44:41 +08:00
parent 57cd211973
commit db0e72daeb
37 changed files with 701 additions and 671 deletions
@@ -7,7 +7,6 @@ import { createHash } from 'node:crypto'
const MODULE = 'phase3-loading'
const OPTIONS = { scenario: 'phase3-split-preload-loading', deploymentBlocker: true }
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) }
@@ -41,31 +40,11 @@ function failure(response) {
}
function containerRecord(value) { return value?.container }
async function ensureMatsonSupplier(context, records) {
if (context.options?.fixedCustomerId) {
const { loadSupplier } = await import('./finance-full-fixtures.mjs')
const supplier = await loadSupplier(context, 'BOOKING', { carrierCode: 'MATSON' })
if (!supplier) throw new Error('缺少启用的 MATSON 订舱供应商,不创建或启用主档')
return supplier
}
const existing = records.find((value) => value?.id && value?.name === MATSON_SUPPLIER_NAME)
if (existing?.status === 'ACTIVE') return existing
if (existing?.id) {
const activatedResponse = await context.request('PATCH',
`/api/platform/v1/suppliers/${encodeURIComponent(id(existing.id))}/status?tenantId=0`, { status: 'ACTIVE' })
const activated = context.apiSuccess(MODULE, '启用稳定MATSON船司开发夹具', activatedResponse,
`supplierId=${id(existing.id)}`, OPTIONS)
return activated?.id ? activated : null
}
const createdResponse = await context.request('POST', '/api/platform/v1/suppliers?tenantId=0', {
name: MATSON_SUPPLIER_NAME, category: 'BOOKING', carrierCodes: ['MATSON'], region: '开发环境', legalRepresentative: '开发联调',
contactName: '开发联调', phone: '13800000000', email: 'matson-dev-fixture@example.com',
address: '开发环境稳定船司夹具', businessLicenseNo: 'DEV-CARRIER-MATSON', licenseFileId: null,
status: 'ACTIVE', settlementPeriod: 'MONTHLY_30', remark: '三四期开发环境HTTP验收稳定船司夹具',
})
const supplierId = id(context.apiSuccess(MODULE, '创建稳定MATSON船司开发夹具', createdResponse,
`name=${MATSON_SUPPLIER_NAME}`, OPTIONS))
return supplierId ? { id: supplierId, name: MATSON_SUPPLIER_NAME, status: 'ACTIVE' } : null
async function ensureMatsonSupplier(context) {
const { loadSupplier } = await import('./finance-full-fixtures.mjs')
const supplier = await loadSupplier(context, 'BOOKING', { carrierCode: 'MATSON' })
if (!supplier) throw new Error('缺少启用的 MATSON 订舱供应商,不创建或启用主档')
return supplier
}
export function stableLoadedCartonMarks(items) {
@@ -228,7 +207,7 @@ export async function run(context) {
'/api/platform/v1/suppliers?tenantId=0&category=BOOKING&page=1&size=200')
const supplierPage = context.apiSuccess(MODULE, '读取订舱代理与船司供应商事实源', supplierResponse, '', OPTIONS)
const supplierRecords = Array.isArray(supplierPage?.records) ? supplierPage.records : []
const supplier = await ensureMatsonSupplier(context, supplierRecords)
const supplier = await ensureMatsonSupplier(context)
context.assert(MODULE, '存在可用于发布订舱的 ACTIVE 订舱代理', supplierResponse,
Boolean(supplier?.id && supplier?.name), `supplierId=${id(supplier?.id) || 'missing'}`, OPTIONS)
if (!supplier?.id) return