This commit is contained in:
2026-08-27 16:34:32 +08:00
parent 690f386bff
commit a90d5fbe39
9 changed files with 226 additions and 61 deletions
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { overseasHttp } from '@/shared/api/overseasHttp'
import { convertLastMileOrderToInboundPlan, getLastMileOrder, listLastMileOrders, transferLastMileOrders } from './lastMileOrders'
import { convertLastMileContainerToInboundPlans, convertLastMileOrderToInboundPlan, getLastMileOrder, listLastMileOrders, transferLastMileOrders } from './lastMileOrders'
vi.mock('@/shared/api/overseasHttp', () => ({ overseasHttp: { get: vi.fn(), put: vi.fn(), post: vi.fn() } }))
@@ -8,7 +8,7 @@ describe('last-mile order overseas API', () => {
beforeEach(() => vi.mocked(overseasHttp.get).mockReset())
it('loads all platform orders without a customer scope', async () => {
const record = { id: '190000000000000099', customerId: '190000000000000001', customerName: '华远贸易', orderNo: 'LMO-260827-0001' }
const record = { id: '190000000000000099', customerId: '190000000000000001', sourceContainerBookingId: '190000000000000088', customerName: '华远贸易', orderNo: 'LMO-260827-0001' }
vi.mocked(overseasHttp.get).mockResolvedValue({ code: '200', message: 'success', data: { records: [record], page: '2', size: '20', total: '1', pages: '1' } })
await expect(listLastMileOrders({ page: 2, size: 20, orderType: 'FIRST_LEG', currentStatus: 'PENDING_ASSIGNMENT', warehouse: 'LAX' })).resolves.toEqual({ records: [record], page: 2, size: 20, total: 1, pages: 1 })
expect(overseasHttp.get).toHaveBeenCalledWith('/platform/v1/last-leg/orders', {
@@ -55,4 +55,13 @@ describe('last-mile order overseas API', () => {
orderId: '190000000000000099', customerId: '190000000000000001',
})
})
it('uses one atomic container request without looping individual conversions', async () => {
vi.mocked(overseasHttp.post).mockResolvedValue({ code: '200', message: 'success', data: [] })
await expect(convertLastMileContainerToInboundPlans({ sourceContainerBookingId: '2092873463568597001' })).resolves.toEqual([])
expect(overseasHttp.post).toHaveBeenCalledTimes(1)
expect(overseasHttp.post).toHaveBeenCalledWith('/platform/v1/last-leg/inbound-plans/convert-container', {
sourceContainerBookingId: '2092873463568597001',
})
})
})
@@ -1,5 +1,6 @@
import { overseasHttp } from '@/shared/api/overseasHttp'
import { unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
import type { InboundPlanDetailDto } from './inboundPlans'
export interface OverseasPageResult<T> {
records: T[]
@@ -41,6 +42,7 @@ export interface LastMileOrderQuery {
export interface LastMileOrderSummaryDto {
id: string
customerId: string
sourceContainerBookingId?: string | null
orderNo: string
orderType?: string | null
orderTypeName?: string | null
@@ -153,6 +155,10 @@ export interface ConvertInboundPlanPayload {
customerId: string
}
export interface ConvertContainerInboundPlanPayload {
sourceContainerBookingId: string
}
export interface LastMileOrderDetailDto {
order: LastMileOrderDto
cargo: LastMileCargoDto[]
@@ -196,3 +202,10 @@ export async function convertLastMileOrderToInboundPlan(payload: ConvertInboundP
)
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,
)
return unwrapApiResponse(response)
}