This commit is contained in:
2026-08-04 12:01:05 +08:00
parent f533024501
commit 3877af0b72
9 changed files with 182 additions and 181 deletions
@@ -33,9 +33,11 @@ test('sends backend-required channel, customs, destination and cargo fields', ()
assert.match(storeSource, new RegExp(field))
}
assert.match(storeSource, /containerMode: draft\.transportMode === 'FCL' \? 'FULL_CONTAINER'/)
assert.match(storeSource, /customerId: draft\.shipperPartyId/)
assert.match(storeSource, /customerName: customerName\.trim\(\) \|\| draft\.shipperPartySnapshot\.name/)
assert.doesNotMatch(storeSource, /customerId: draft\.shipperPartyId/)
assert.match(storeSource, /customerName: customerName\.trim\(\)/)
assert.match(storeSource, /destinationWarehouseId: draft\.destinationType === 'PRIVATE' \? undefined : draft\.destinationWarehouseId/)
assert.match(storeSource, /draft\.pickupMethod === 'PICKUP'.*draft\.shipperPartySnapshot/s)
assert.match(storeSource, /draft\.destinationType === 'PRIVATE'.*draft\.consigneePartySnapshot/s)
})
test('separates domestic receiving warehouses from public destinations', () => {
+19 -9
View File
@@ -67,12 +67,22 @@ function partyPayload(snapshot: FirstLegPartySnapshot): FirstLegOrderPartyPayloa
}
function savePayload(draft: FirstLegOrderDraft, warehouse: ClientWarehouse, customerName: string): FirstLegOrderSaveRequest {
if (!draft.shipperPartySnapshot || !draft.consigneePartySnapshot) throw new Error('请完整填写收发货信息')
const sender = draft.pickupMethod === 'PICKUP' && draft.shipperPartySnapshot
? partyPayload({
...draft.shipperPartySnapshot,
name: draft.shipperPartySnapshot.name || customerName.trim() || '客户',
countryRegion: draft.shipperPartySnapshot.countryRegion || 'CN',
})
: undefined
const receiver = draft.destinationType === 'PRIVATE' && draft.consigneePartySnapshot
? partyPayload({
...draft.consigneePartySnapshot,
name: draft.destinationWarehouseName,
countryRegion: draft.destinationCountryCode.trim().toUpperCase(),
})
: undefined
return {
// 后端把 customerId 作为订单主往来单位校验并以服务端名称覆盖 customerName;
// 当前商户下单以所选发货单位作为主往来单位,收发货详情仍分别保存订单快照。
customerId: draft.shipperPartyId,
customerName: customerName.trim() || draft.shipperPartySnapshot.name,
customerName: customerName.trim(),
transportMode: apiTransport(draft),
tradeTerm: draft.tradeTerm || undefined,
destinationCountryCode: draft.destinationCountryCode.trim().toUpperCase(),
@@ -80,8 +90,8 @@ function savePayload(draft: FirstLegOrderDraft, warehouse: ClientWarehouse, cust
destinationWarehouseName: draft.destinationWarehouseName,
expectedShipDate: draft.expectedDepartureDate || undefined,
customerRemark: draft.customerRemark || undefined,
sender: partyPayload(draft.shipperPartySnapshot),
receiver: partyPayload(draft.consigneePartySnapshot),
sender,
receiver,
cargoes: draft.items.map((item) => ({
cargoName: item.cargoNameCn,
cargoNameEn: item.cargoNameEn || undefined,
@@ -107,8 +117,8 @@ function savePayload(draft: FirstLegOrderDraft, warehouse: ClientWarehouse, cust
containerMode: draft.transportMode === 'FCL' ? 'FULL_CONTAINER' : draft.transportMode === 'LCL' ? 'LCL' : undefined,
customsInspection: draft.customsInspection,
destinationType: draft.destinationType,
amazonWarehouseCode: draft.amazonWarehouseCode || undefined,
shipmentId: draft.shipmentId || undefined,
amazonWarehouseCode: draft.destinationType === 'FBA' ? draft.amazonWarehouseCode || undefined : undefined,
shipmentId: draft.destinationType === 'FBA' ? draft.shipmentId || undefined : undefined,
referenceId: draft.referenceNo || undefined,
}
}