This commit is contained in:
2026-08-14 18:50:07 +08:00
parent 9b36978448
commit 10d3390bb1
17 changed files with 461 additions and 61 deletions
@@ -1,4 +1,25 @@
function text(value) { return value == null ? '' : String(value).trim() }
const PLATFORM_CHANNELS = '/api/platform/v1/ocean-bookings/channels'
export async function publishPlatformLogisticsChannels(context, originWarehouseId, module) {
const warehouseId = text(originWarehouseId)
const sourcePath = `${PLATFORM_CHANNELS}?originWarehouseId=${encodeURIComponent(warehouseId)}`
const response = await context.request('GET', sourcePath)
const data = context.apiSuccess(module, '按起运仓查询平台正式物流渠道', response,
`originWarehouseId=${warehouseId}`, { scenario: 'ocean-booking-channel-catalog', deploymentBlocker: true })
const channels = (Array.isArray(data) ? data : []).flatMap((value) => {
const channelCode = text(value?.channelCode)
const channelName = text(value?.channelName)
return channelCode && channelName ? [{ channelCode, channelName }] : []
})
const resource = { marker: context.marker, originWarehouseId: warehouseId, sourcePath, channels }
context.createdResources.platformLogisticsChannels = resource
context.assert(module, '平台渠道目录归属本轮起运仓且不含空渠道', response,
Boolean(warehouseId) && channels.length > 0,
`originWarehouseId=${warehouseId}, channels=${channels.map((value) => value.channelCode).join('|') || 'none'}`,
{ scenario: 'ocean-booking-channel-catalog', deploymentBlocker: true })
return resource
}
export async function resolveOceanBookingMaster(context, module) {
const resources = context.createdResources || {}
@@ -32,8 +53,9 @@ export async function resolveOceanBookingMaster(context, module) {
}
export function oceanBookingDraft(context, suffix, master, labels = {}) {
const { channelName: _readOnlyChannelName, ...writableMaster } = master
return {
...master,
...writableMaster,
shippingCompanyId: null, shippingCompanyName: labels.shippingCompanyName || `验收船公司-${suffix}`,
bookingAgentId: null, bookingAgentName: labels.bookingAgentName || `验收代理-${suffix}`,
vesselName: labels.vesselName, voyageNo: labels.voyageNo,