优化
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { overseasHttp } from '@/shared/api/overseasHttp'
|
||||
import { convertLastMileContainerToInboundPlans, convertLastMileOrderToInboundPlan, getLastMileOrder, listLastMileOrders, transferLastMileOrders } from './lastMileOrders'
|
||||
import { convertLastMileContainerToInboundPlans, convertLastMileOrderToInboundPlan, getLastMileOrder, listLastMileOrders, listPendingContainerSummaries, transferLastMileOrders } from './lastMileOrders'
|
||||
|
||||
vi.mock('@/shared/api/overseasHttp', () => ({ overseasHttp: { get: vi.fn(), put: vi.fn(), post: vi.fn() } }))
|
||||
|
||||
describe('last-mile order overseas API', () => {
|
||||
beforeEach(() => vi.mocked(overseasHttp.get).mockReset())
|
||||
beforeEach(() => {
|
||||
vi.mocked(overseasHttp.get).mockReset()
|
||||
vi.mocked(overseasHttp.put).mockReset()
|
||||
vi.mocked(overseasHttp.post).mockReset()
|
||||
})
|
||||
|
||||
it('loads all platform orders without a customer scope', async () => {
|
||||
const record = { id: '190000000000000099', customerId: '190000000000000001', sourceContainerBookingId: '190000000000000088', customerName: '华远贸易', orderNo: 'LMO-260827-0001' }
|
||||
@@ -64,4 +68,25 @@ describe('last-mile order overseas API', () => {
|
||||
sourceContainerBookingId: '2092873463568597001',
|
||||
})
|
||||
})
|
||||
|
||||
it('loads server-side pending container summaries with pagination and filters', async () => {
|
||||
const record = {
|
||||
sourceContainerBookingId: '2092873463568597001', containerNo: 'CONT-15', orderCount: 15,
|
||||
inboundCodeCount: 15, customerCount: 3, totalPackageCount: 150, totalPalletCount: 30,
|
||||
totalVolumeCbm: 45.5, eligible: true,
|
||||
}
|
||||
vi.mocked(overseasHttp.get).mockResolvedValue({
|
||||
code: '200', message: 'success', data: { records: [record], page: '2', size: '10', total: '21', pages: '3' },
|
||||
})
|
||||
await expect(listPendingContainerSummaries({
|
||||
page: 2, size: 10, containerNo: 'CONT-15',
|
||||
createdFrom: '2026-08-01T00:00:00', createdTo: '2026-08-31T23:59:59',
|
||||
})).resolves.toEqual({ records: [record], page: 2, size: 10, total: 21, pages: 3 })
|
||||
expect(overseasHttp.get).toHaveBeenCalledWith('/platform/v1/last-leg/orders/container-summaries', {
|
||||
params: {
|
||||
page: 2, size: 10, containerNo: 'CONT-15',
|
||||
createdFrom: '2026-08-01T00:00:00', createdTo: '2026-08-31T23:59:59',
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -155,6 +155,27 @@ export interface ConvertInboundPlanPayload {
|
||||
customerId: string
|
||||
}
|
||||
|
||||
export interface PendingContainerSummaryQuery {
|
||||
page: number
|
||||
size: number
|
||||
containerNo?: string
|
||||
createdFrom?: string
|
||||
createdTo?: string
|
||||
}
|
||||
|
||||
export interface PendingContainerSummaryDto {
|
||||
sourceContainerBookingId: string
|
||||
containerNo: string | null
|
||||
orderCount: number
|
||||
inboundCodeCount: number
|
||||
customerCount: number
|
||||
totalPackageCount: number
|
||||
totalPalletCount: number
|
||||
totalVolumeCbm: number
|
||||
eligible: boolean
|
||||
ineligibleReason?: string | null
|
||||
}
|
||||
|
||||
export interface ConvertContainerInboundPlanPayload {
|
||||
sourceContainerBookingId: string
|
||||
}
|
||||
@@ -203,6 +224,14 @@ export async function convertLastMileOrderToInboundPlan(payload: ConvertInboundP
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
export async function listPendingContainerSummaries(query: PendingContainerSummaryQuery): Promise<OverseasPageResult<PendingContainerSummaryDto>> {
|
||||
const response = await overseasHttp.get<ApiEnvelope<OverseasPagePayload<PendingContainerSummaryDto>>, ApiEnvelope<OverseasPagePayload<PendingContainerSummaryDto>>>(
|
||||
'/platform/v1/last-leg/orders/container-summaries',
|
||||
{ params: query },
|
||||
)
|
||||
return normalizeOverseasPage(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,
|
||||
|
||||
Reference in New Issue
Block a user