From d4166a75f89caf945b151a2d14dc566b1a0546f8 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Wed, 2 Sep 2026 02:39:56 +0800 Subject: [PATCH] fix: align merchant delivery contract --- .../order-management/api/deliveryOrders.ts | 34 +++++++++++++++++-- .../order-management/deliveryOrders.test.mjs | 13 ++++++- .../views/DeliveryOrderCreateView.vue | 12 ++++--- 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/src/modules/order-management/api/deliveryOrders.ts b/src/modules/order-management/api/deliveryOrders.ts index ab5515d..a745266 100644 --- a/src/modules/order-management/api/deliveryOrders.ts +++ b/src/modules/order-management/api/deliveryOrders.ts @@ -63,6 +63,30 @@ export interface DeliveryOrderDetail extends DeliveryRow { updatedAt?: string | null } +interface DeliveryOrderDetailResponse { + order: Omit + skus: DeliveryOrderItem[] + fees: DeliveryOrderFee[] + operations: Array<{ + id: string + operatedAt: string + operationNode: string + operatorName: string + result: string + }> +} + +export interface DeliveryTransferResult { + dispatchNo: string + outboundNo: string + outboundStatus: string + deliveryNo: string + deliveryStatus: string + palletCount: number + packageCount: number + replayed: boolean +} + export interface DeliveryQuery { page: number size: number @@ -107,16 +131,20 @@ export function listDeliveryOrders(params: DeliveryQuery) { } export function getDeliveryOrder(deliveryNo: string) { - return overseasApiRequest({ + return overseasApiRequest({ method: 'GET', url: `/merchant/v1/last-leg/delivery-orders/${encodeURIComponent(deliveryNo)}`, params: { page: 1, size: 200 }, - }) + }).then(({ order, skus, fees }) => ({ + ...order, + fees, + items: skus, + })) } export function createDeliveryOrder(payload: DeliveryTransferPayload) { const { dispatchNo, ...request } = payload - return overseasApiRequest({ + return overseasApiRequest({ method: 'POST', url: '/merchant/v1/last-leg/delivery-orders', params: { dispatchNo }, diff --git a/src/modules/order-management/deliveryOrders.test.mjs b/src/modules/order-management/deliveryOrders.test.mjs index fb925f0..f17b619 100644 --- a/src/modules/order-management/deliveryOrders.test.mjs +++ b/src/modules/order-management/deliveryOrders.test.mjs @@ -23,7 +23,9 @@ test('uses only authenticated merchant delivery endpoints without customer scope assert.match(apiSource, /method: 'POST'[\s\S]*url: '\/merchant\/v1\/last-leg\/delivery-orders'/) assert.match(apiSource, /const \{ dispatchNo, \.\.\.request \} = payload/) assert.match(apiSource, /params: \{ dispatchNo \}/) - assert.match(apiSource, /overseasApiRequest/) + assert.match(apiSource, /overseasApiRequest/) + assert.match(apiSource, /\.then\(\(\{ order, skus, fees \}\) => \(\{[\s\S]*\.\.\.order,[\s\S]*fees,[\s\S]*items: skus/) + assert.match(apiSource, /overseasApiRequest/) assert.doesNotMatch(apiSource, /customerId|tenantId|Record|mock|fallback/i) }) @@ -69,6 +71,15 @@ test('submits the complete create contract with stable retry idempotency and rec assert.match(createSource, /if \(!pendingIdempotencyKey\) pendingIdempotencyKey = crypto\.randomUUID\(\)/) assert.match(createSource, /createDeliveryOrder\(requestPayload\(\)\)/) assert.match(createSource, /fees: form\.fees\.map/) + assert.match(createSource, /if \(form\.fees\.length === 0\)/) + assert.match(createSource, /请至少添加一条费用明细/) + for (const value of ['FBA_PICKUP', 'CUSTOMER_PICKUP', 'TRUCK_PALLET', 'TRUCK_FLOOR', 'EXPRESS', 'OUTSOURCED', 'DEDICATED_TRUCK', 'LTL']) { + assert.match(createSource, new RegExp(`value="${value}"`)) + } + for (const value of ['ONE_PICKUP_ONE_DROP', 'ONE_PICKUP_MULTI_DROP', 'MULTI_PICKUP_ONE_DROP', 'MULTI_PICKUP_MULTI_DROP', 'WAREHOUSE_PICKUP', 'PALLET', 'FLOOR', 'MIXED']) { + assert.match(createSource, new RegExp(`value="${value}"`)) + } + assert.doesNotMatch(createSource, /value="(?:TRUCK|COURIER|SELF_PICKUP|DOOR_PICKUP|LOOSE_CARTON)"/) assert.match(createSource, /submitError\.value = error instanceof Error/) assert.match(createSource, /useUnsavedWorkRegistration/) assert.doesNotMatch(createSource, /customerId|tenantId|mock|fallback/i) diff --git a/src/modules/order-management/views/DeliveryOrderCreateView.vue b/src/modules/order-management/views/DeliveryOrderCreateView.vue index b93d56e..44bfbf3 100644 --- a/src/modules/order-management/views/DeliveryOrderCreateView.vue +++ b/src/modules/order-management/views/DeliveryOrderCreateView.vue @@ -71,6 +71,10 @@ function removeFee(index: number) { } function validateFees() { + if (form.fees.length === 0) { + ElMessage.warning('请至少添加一条费用明细') + return false + } const invalidIndex = form.fees.findIndex((fee) => !fee.feeType.trim() || !fee.currency.trim() || fee.amount <= 0) if (invalidIndex < 0) return true ElMessage.warning(`请完整填写第 ${invalidIndex + 1} 条费用的类型、币种和大于 0 的金额`) @@ -154,9 +158,9 @@ async function cancel() {
- - - + + +
@@ -185,7 +189,7 @@ async function cancel() { -
暂无费用明细,可按实际情况添加。
+
请至少添加一条费用明细后再提交。
取消提交创建