This commit is contained in:
2026-08-15 11:51:15 +08:00
parent 46cb95db15
commit 08187363a1
16 changed files with 203 additions and 39 deletions
@@ -69,10 +69,15 @@ export function inspectOceanBookingIdentity(marker, resource, detail = null) {
export function truckAppointmentPayload(context, suffix, identity, version = 0) {
const supplier = context.createdResources?.truckSupplier || {}
const supplierId = id(supplier.supplierId)
const supplierName = id(supplier.supplierName)
const carrierSnapshot = supplierId && supplierName
? { carrierId: supplierId, carrierName: supplierName }
: {}
return {
outboundOrderId: null, oceanBookingId: identity.oceanBookingId, containerBookingId: null, loadingPlanId: null,
warehouseId: identity.warehouseId, customerId: identity.customerId, customerName: identity.customerName,
carrierId: supplier.supplierId || null, carrierName: supplier.supplierName || `承运商-${suffix}`, fleetContact: '车队联系人', fleetPhone: '13800000004',
...carrierSnapshot, fleetContact: '车队联系人', fleetPhone: '13800000004',
driverName: '司机验收', driverPhone: '13800000005', driverIdCard: null, vehicleNo: `粤B-${suffix.slice(-6)}`,
storeName: `门店-${suffix}`, storeContact: '门店联系人', storePhone: '13800000006', storeAddress: '深圳市南山区验收地址',
storeCity: '深圳市', storeZipcode: '518000', packageCount: 10, grossWeightKg: 100, volumeCbm: 2.5,
@@ -96,11 +101,12 @@ async function ensureTruckSupplier(context, suffix) {
const detailResponse = await request(context, 'GET', `/api/platform/v1/suppliers/${encodeURIComponent(supplierId)}?tenantId=0`)
supplier = data(detailResponse)
}
context.addStep(MODULE, '创建本轮有效拖车供应商', response,
Boolean(supplierId) && supplier?.category === 'TRUCKING' && supplier?.status === 'ACTIVE',
context.addStep(MODULE, '创建本轮有效拖车供应商(可选)', response,
!supplierId || (supplier?.category === 'TRUCKING' && supplier?.status === 'ACTIVE' && Boolean(supplier?.name)),
`supplierId=${supplierId || 'missing'}, category=${supplier?.category || 'missing'}, status=${supplier?.status || 'missing'}`, OPTIONS)
if (supplierId) context.createdResources.truckSupplier = {
marker: context.marker, supplierId, supplierName: supplier.name, finalStatus: 'ACTIVE', retained: true,
marker: context.marker, supplierId, supplierName: supplier.name || supplier.supplierName || null,
category: supplier.category, status: supplier.status, finalStatus: 'ACTIVE', retained: true,
}
return context.createdResources.truckSupplier || null
}
@@ -148,8 +154,7 @@ export async function run(context) {
}
const bookingIdentity = Object.freeze({ ...identityResult.identity })
const truckSupplier = await ensureTruckSupplier(context, suffix)
if (!truckSupplier) return
await ensureTruckSupplier(context, suffix)
const createResponse = await request(context, 'POST', BASE, truckAppointmentPayload(context, suffix, bookingIdentity)); const appointment = context.apiSuccess(MODULE, '创建隔离拖车预约', createResponse, '', OPTIONS)
const appointmentId = id(appointment?.id)