feat: confirm container inbound plans

This commit is contained in:
2026-09-09 00:44:07 +08:00
parent 695db084e2
commit cf8727a809
5 changed files with 243 additions and 27 deletions
@@ -114,11 +114,17 @@ describe('last-mile order overseas API', () => {
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([])
await expect(convertLastMileContainerToInboundPlans({
sourceContainerBookingId: '2092873463568597001',
snapshotVersion: 9,
snapshotHash: 'a'.repeat(64),
}, 'container-plan-idempotency-key')).resolves.toEqual([])
expect(overseasHttp.post).toHaveBeenCalledTimes(1)
expect(overseasHttp.post).toHaveBeenCalledWith('/platform/v1/last-leg/inbound-plans/convert-container', {
sourceContainerBookingId: '2092873463568597001',
})
snapshotVersion: 9,
snapshotHash: 'a'.repeat(64),
}, { headers: { 'Idempotency-Key': 'container-plan-idempotency-key' } })
})
it('loads server-side container progress with pagination and filters', async () => {
@@ -210,6 +210,8 @@ export interface ContainerPlanProgressDetailDto {
export interface ConvertContainerInboundPlanPayload {
sourceContainerBookingId: string
snapshotVersion: number
snapshotHash: string
}
export type ContainerInboundPlanPreviewReadiness = 'READY' | 'PLANNED' | 'BLOCKED'
@@ -460,9 +462,10 @@ export async function getContainerInboundPlanPreview(sourceContainerBookingId: s
return unwrapApiResponse(response)
}
export async function convertLastMileContainerToInboundPlans(payload: ConvertContainerInboundPlanPayload) {
export async function convertLastMileContainerToInboundPlans(payload: ConvertContainerInboundPlanPayload, idempotencyKey: string) {
const response = await overseasHttp.post<ApiEnvelope<InboundPlanDetailDto[]>, ApiEnvelope<InboundPlanDetailDto[]>>(
'/platform/v1/last-leg/inbound-plans/convert-container', payload,
{ headers: { 'Idempotency-Key': idempotencyKey } },
)
return unwrapApiResponse(response)
}