fix(acceptance): select booking agents by carrier

This commit is contained in:
2026-09-02 16:38:44 +08:00
parent 1b1f2718b3
commit a8c71fef12
5 changed files with 35 additions and 17 deletions
@@ -52,6 +52,19 @@ export async function resolveOceanBookingMaster(context, module) {
return master
}
export async function resolveOceanBookingAgent(context, module, carrierCode, options = {}) {
const normalizedCarrierCode = text(carrierCode).toUpperCase()
const response = await context.request('GET',
`/api/platform/v1/ocean-bookings/booking-agents?carrierCode=${encodeURIComponent(normalizedCarrierCode)}`)
const candidates = context.apiSuccess(module, '按船司读取可用订舱代理', response,
`carrierCode=${normalizedCarrierCode}`, options)
const selected = (Array.isArray(candidates) ? candidates : []).find((item) =>
text(item?.supplierId) && text(item?.name))
context.assert(module, '订舱代理已由服务端按船司关联过滤', response,
Boolean(selected), `carrierCode=${normalizedCarrierCode}`, options)
return selected ? { id: text(selected.supplierId), name: text(selected.name) } : null
}
export function oceanBookingDraft(context, suffix, master, labels = {}) {
const { channelName: _readOnlyChannelName, warehouseName: _readOnlyWarehouseName, ...writableMaster } = master
const normalizedSuffix = text(suffix).replace(/[^A-Za-z0-9]/g, '').slice(-32) || 'BOOKING'