merge origin/dev and resolve frontend conflicts

This commit is contained in:
2026-09-08 20:33:45 +08:00
84 changed files with 3008 additions and 277 deletions
@@ -26,6 +26,8 @@ export interface InboundOrderSummaryDto {
inboundCode?: string | null
lxCode?: string | null
orderType?: string | null
overseasWarehouseCode?: string | null
overseasWarehouseName?: string | null
warehouseId?: string | null
warehouseCode?: string | null
warehouseName?: string | null
@@ -27,6 +27,7 @@ export interface InboundPlanSummaryDto {
inboundCode?: string | null
containerNo?: string | null
overseasWarehouseId?: string | null
overseasWarehouseCode?: string | null
overseasWarehouseName?: string | null
destinationWarehouseId?: string | null
destinationWarehouseCode?: string | null
@@ -47,6 +48,8 @@ export interface InboundPlanDetailDto {
customerId: string
sourceOrderId: string
containerNo?: string | null
overseasWarehouseCode?: string | null
overseasWarehouseName?: string | null
status?: string | null
lineCount: number
palletCount: number
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { overseasHttp } from '@/shared/api/overseasHttp'
import { convertLastMileContainerToInboundPlans, convertLastMileOrderToInboundPlan, downloadLastMileOrders, getContainerPlanProgress, getLastMileOrder, listContainerPlanProgress, listLastMileOrders, transferLastMileOrders } from './lastMileOrders'
import { changeContainerReceivingWarehouse, convertLastMileContainerToInboundPlans, createManualInboundPlan, downloadLastMileOrders, getContainerPlanProgress, getLastMileOrder, getLastMileOrderManualNodes, listContainerPlanProgress, listLastMileOrders, transferLastMileOrders, updateLastMileOrderHold, updateLastMileOrderManualNodes } from './lastMileOrders'
vi.mock('@/shared/api/overseasHttp', () => ({ overseasHttp: { get: vi.fn(), put: vi.fn(), post: vi.fn() } }))
@@ -84,12 +84,32 @@ describe('last-mile order overseas API', () => {
})
})
it('uses the inbound-plan conversion endpoint with the exact selected customer scope', async () => {
it('uses the manual inbound-plan endpoint with the complete form and idempotency evidence', async () => {
vi.mocked(overseasHttp.post).mockResolvedValue({ code: '200', message: 'success', data: {} })
await convertLastMileOrderToInboundPlan({ orderId: '190000000000000099', customerId: '190000000000000001' })
expect(overseasHttp.post).toHaveBeenCalledWith('/platform/v1/last-leg/inbound-plans/convert', {
orderId: '190000000000000099', customerId: '190000000000000001',
})
const payload = { orderId: '190000000000000099', customerId: '190000000000000001', expectedOrderVersion: 4,
plannedArrivalDate: '2026-09-08', palletCount: 8, palletType: 'STANDARD' as const,
assigned: false, mergeRequired: false, urgent: true, remark: '加急' }
await createManualInboundPlan(payload, 'plan-key-1')
expect(overseasHttp.post).toHaveBeenCalledWith('/platform/v1/last-leg/inbound-plans/manual', payload,
{ headers: { 'Idempotency-Key': 'plan-key-1' } })
expect(payload).not.toHaveProperty('inboundCode')
expect(payload).not.toHaveProperty('plannedWarehouseId')
expect(payload).not.toHaveProperty('plannedWarehouseCode')
expect(payload).not.toHaveProperty('plannedWarehouseName')
})
it('uses versioned idempotent order hold and complete manual-node snapshot endpoints', async () => {
vi.mocked(overseasHttp.put).mockResolvedValue({ code: '200', message: 'success', data: {} })
vi.mocked(overseasHttp.get).mockResolvedValue({ code: '200', message: 'success', data: { nodes: [] } })
await updateLastMileOrderHold('190000000000000099', { held: true, chargeable: true, reason: '海关查验', expectedVersion: 4 }, 'hold-key-1')
expect(overseasHttp.put).toHaveBeenLastCalledWith('/platform/v1/last-leg/orders/190000000000000099/hold',
{ held: true, chargeable: true, reason: '海关查验', expectedVersion: 4 }, { headers: { 'Idempotency-Key': 'hold-key-1' } })
await getLastMileOrderManualNodes('190000000000000099')
expect(overseasHttp.get).toHaveBeenLastCalledWith('/platform/v1/last-leg/orders/190000000000000099/manual-nodes')
const nodes = [{ nodeCode: 'ESTIMATED_ARRIVAL' as const, nodeAt: '2026-09-10T10:00:00' }]
await updateLastMileOrderManualNodes('190000000000000099', 5, nodes, 'node-key-1')
expect(overseasHttp.put).toHaveBeenLastCalledWith('/platform/v1/last-leg/orders/190000000000000099/manual-nodes',
{ expectedVersion: 5, nodes }, { headers: { 'Idempotency-Key': 'node-key-1' } })
})
it('uses one atomic container request without looping individual conversions', async () => {
@@ -128,4 +148,17 @@ describe('last-mile order overseas API', () => {
await expect(getContainerPlanProgress('2092873463568597001/unsafe')).resolves.toEqual(detail)
expect(overseasHttp.get).toHaveBeenCalledWith('/platform/v1/last-leg/orders/container-summaries/2092873463568597001%2Funsafe')
})
it('changes one whole container receiving warehouse with version and idempotency evidence', async () => {
const updated = { sourceContainerBookingId: '2092873463568597001', overseasWarehouseId: '9007199254740993' }
vi.mocked(overseasHttp.put).mockResolvedValue({ code: '200', message: 'success', data: updated })
await expect(changeContainerReceivingWarehouse('2092873463568597001/unsafe', {
overseasWarehouseId: '9007199254740993', expectedVersion: 7, remark: '改派洛杉矶接柜',
}, 'receiving-key-1')).resolves.toEqual(updated)
expect(overseasHttp.put).toHaveBeenCalledWith(
'/platform/v1/last-leg/orders/container-summaries/2092873463568597001%2Funsafe/receiving-warehouse',
{ overseasWarehouseId: '9007199254740993', expectedVersion: 7, remark: '改派洛杉矶接柜' },
{ headers: { 'Idempotency-Key': 'receiving-key-1' } },
)
})
})
@@ -52,6 +52,8 @@ export interface LastMileOrderSummaryDto {
sourceOrderNo?: string | null
sourceInboundId?: string | null
customerName?: string | null
overseasWarehouseId?: string | null
overseasWarehouseCode?: string | null
overseasWarehouseName?: string | null
transferWarehouseName?: string | null
transferWarehouseId?: string | null
@@ -61,6 +63,11 @@ export interface LastMileOrderSummaryDto {
containerStatus?: string | null
abnormal?: boolean | null
detained?: boolean | null
holdChargeable?: boolean | null
holdReason?: string | null
manualOverrideEnabled?: boolean | null
nodeSource?: 'CONTAINER' | 'MANUAL' | null
version?: number | null
palletCount?: number | null
packageCount?: number | null
volumeCbm?: number | null
@@ -155,11 +162,6 @@ export interface TransferDestinationPayload {
remark?: string
}
export interface ConvertInboundPlanPayload {
orderId: string
customerId: string
}
export interface ContainerPlanProgressQuery {
page: number
size: number
@@ -171,6 +173,12 @@ export interface ContainerPlanProgressQuery {
export interface ContainerPlanProgressSummaryDto {
sourceContainerBookingId: string
containerNo: string | null
overseasWarehouseId: string | null
overseasWarehouseCode: string | null
overseasWarehouseName: string | null
assignmentVersion: number
canChangeReceivingWarehouse: boolean
receivingWarehouseLockReason: string | null
totalOrderCount: number
inboundCodeCount: number
missingInboundCodeCount: number
@@ -204,8 +212,65 @@ export interface ConvertContainerInboundPlanPayload {
sourceContainerBookingId: string
}
export type ManualNodeCode =
| 'DOMESTIC_CUSTOMS_COMPLETED'
| 'ESTIMATED_DEPARTURE'
| 'ACTUAL_DEPARTURE'
| 'ESTIMATED_ARRIVAL'
| 'OVERSEAS_CUSTOMS_COMPLETED'
| 'ACTUAL_ARRIVAL_WAITING_UNLOAD'
| 'PICKUP_APPOINTED'
| 'UNLOADED'
export interface ManualInboundPlanPayload {
customerId: string
orderId: string
expectedOrderVersion: number
plannedArrivalDate: string
palletCount: number
palletType: 'STANDARD' | 'WOOD' | 'PAPER'
assigned: boolean
mergeRequired: boolean
urgent: boolean
remark?: string
}
export interface HoldLastMileOrderPayload {
held: boolean
chargeable: boolean
reason: string
expectedVersion: number
}
export interface HoldLastMileOrderResponse {
orderId: string
held: boolean
chargeable: boolean
reason?: string | null
version: number
}
export interface ManualNodeValue {
nodeCode: ManualNodeCode
nodeAt: string | null
}
export interface ManualNodesResponse {
orderId: string
manualOverrideEnabled: boolean
nodes: Array<ManualNodeValue & { source: 'MANUAL' }>
version: number
}
export interface ChangeContainerReceivingWarehousePayload {
overseasWarehouseId: string
expectedVersion: number
remark?: string
}
export interface LastMileOrderDetailDto {
order: LastMileOrderDto
manualNodes?: ManualNodesResponse['nodes']
cargo: LastMileCargoDto[]
statusHistory: LastMileStatusHistoryDto[]
fees: LastMileFeeDto[]
@@ -264,13 +329,6 @@ export async function transferLastMileOrders(payload: TransferDestinationPayload
return unwrapApiResponse(response)
}
export async function convertLastMileOrderToInboundPlan(payload: ConvertInboundPlanPayload) {
const response = await overseasHttp.post<ApiEnvelope<unknown>, ApiEnvelope<unknown>>(
'/platform/v1/last-leg/inbound-plans/convert', payload,
)
return unwrapApiResponse(response)
}
export async function listContainerPlanProgress(query: ContainerPlanProgressQuery): Promise<OverseasPageResult<ContainerPlanProgressSummaryDto>> {
const response = await overseasHttp.get<ApiEnvelope<OverseasPagePayload<ContainerPlanProgressSummaryDto>>, ApiEnvelope<OverseasPagePayload<ContainerPlanProgressSummaryDto>>>(
'/platform/v1/last-leg/orders/container-summaries',
@@ -286,6 +344,56 @@ export async function getContainerPlanProgress(sourceContainerBookingId: string)
return unwrapApiResponse(response)
}
export async function createManualInboundPlan(payload: ManualInboundPlanPayload, idempotencyKey: string) {
const response = await overseasHttp.post<ApiEnvelope<InboundPlanDetailDto>, ApiEnvelope<InboundPlanDetailDto>>(
'/platform/v1/last-leg/inbound-plans/manual', payload,
{ headers: { 'Idempotency-Key': idempotencyKey } },
)
return unwrapApiResponse(response)
}
export async function updateLastMileOrderHold(orderId: string, payload: HoldLastMileOrderPayload, idempotencyKey: string) {
const response = await overseasHttp.put<ApiEnvelope<HoldLastMileOrderResponse>, ApiEnvelope<HoldLastMileOrderResponse>>(
`/platform/v1/last-leg/orders/${encodeURIComponent(orderId)}/hold`, payload,
{ headers: { 'Idempotency-Key': idempotencyKey } },
)
return unwrapApiResponse(response)
}
export async function getLastMileOrderManualNodes(orderId: string) {
const response = await overseasHttp.get<ApiEnvelope<ManualNodesResponse>, ApiEnvelope<ManualNodesResponse>>(
`/platform/v1/last-leg/orders/${encodeURIComponent(orderId)}/manual-nodes`,
)
return unwrapApiResponse(response)
}
export async function updateLastMileOrderManualNodes(
orderId: string,
expectedVersion: number,
nodes: ManualNodeValue[],
idempotencyKey: string,
) {
const response = await overseasHttp.put<ApiEnvelope<ManualNodesResponse>, ApiEnvelope<ManualNodesResponse>>(
`/platform/v1/last-leg/orders/${encodeURIComponent(orderId)}/manual-nodes`,
{ expectedVersion, nodes },
{ headers: { 'Idempotency-Key': idempotencyKey } },
)
return unwrapApiResponse(response)
}
export async function changeContainerReceivingWarehouse(
sourceContainerBookingId: string,
payload: ChangeContainerReceivingWarehousePayload,
idempotencyKey: string,
) {
const response = await overseasHttp.put<ApiEnvelope<ContainerPlanProgressSummaryDto>, ApiEnvelope<ContainerPlanProgressSummaryDto>>(
`/platform/v1/last-leg/orders/container-summaries/${encodeURIComponent(sourceContainerBookingId)}/receiving-warehouse`,
payload,
{ headers: { 'Idempotency-Key': idempotencyKey } },
)
return unwrapApiResponse(response)
}
export async function convertLastMileContainerToInboundPlans(payload: ConvertContainerInboundPlanPayload) {
const response = await overseasHttp.post<ApiEnvelope<InboundPlanDetailDto[]>, ApiEnvelope<InboundPlanDetailDto[]>>(
'/platform/v1/last-leg/inbound-plans/convert-container', payload,
@@ -4,8 +4,19 @@ import { normalizeOverseasPage, type OverseasPagePayload } from './lastMileOrder
import type { DeliveryOrderRow } from './deliveryOrders'
export interface OutboundRow { id: string; outboundNo: string; dispatchNo?: string | null; overseasWarehouseId?: string | null; lxCodes?: string | null; status?: string | null; palletCount?: number | null; packageCount?: number | null; createdAt?: string | null }
export interface OutboundPalletRow { id: string; palletNo?: string | null; cartonMarks?: string | null; skuCode?: string | null; inboundCode?: string | null; packageCount?: number | null; pickedPackageCount?: number | null; status?: string | null }
export interface OutboundDetail { outbound: OutboundRow; delivery?: DeliveryOrderRow | null; pallets?: OutboundPalletRow[] }
export interface OutboundPalletRow {
id?: string | null
palletNo?: string | null
cartonMarks?: string | null
inboundCode?: string | null
destinationWarehouseCode?: string | null
destinationWarehouseName?: string | null
skuCode?: string | null
packageCount?: number | null
pickedPackageCount?: number | null
status?: string | null
}
export interface OutboundDetail { outbound: OutboundRow; pallets?: OutboundPalletRow[]; delivery?: DeliveryOrderRow | null }
export interface OutboundQuery { page: number; size: number; documentNo?: string; lxCode?: string; warehouseId?: string; status?: string }
export async function listOutbounds(query: OutboundQuery) {
const response = await overseasHttp.get<ApiEnvelope<OverseasPagePayload<OutboundRow>>, ApiEnvelope<OverseasPagePayload<OutboundRow>>>('/platform/v1/last-leg/outbound-orders', { params: query })