Merge branch 'release/test' of http://git.buggoglobal.com/html/admin-web into dev
This commit is contained in:
@@ -170,40 +170,6 @@ export async function releaseDispatchDraft(draftToken: string) {
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
export interface DispatchPdaPositionDto { id: number; balanceId?: number | null; availablePackages: number; allocatedPackages: number; pickedPackages: number }
|
||||
export interface DispatchPdaItemDto {
|
||||
dispatchItemId: number
|
||||
palletNo?: string | null
|
||||
destinationWarehouseCode?: string | null
|
||||
destinationWarehouseName?: string | null
|
||||
fbaWarehouseCode?: string | null
|
||||
warehouseRouteLabel?: string | null
|
||||
scheduledPackages: number
|
||||
pickedPackages: number
|
||||
positions: DispatchPdaPositionDto[]
|
||||
}
|
||||
export interface DispatchPdaTaskDto { id: number; taskNo: string; dispatchNo: string; vehiclePlate?: string | null; warehouseId?: string | null; status: string; items: DispatchPdaItemDto[] }
|
||||
export interface DispatchPdaPushPayload { idempotencyKey: string; operatorId?: string; operatorName?: string; warehouseId?: string }
|
||||
export interface DispatchPdaPickPayload { positionId: number; packages: number; productQuantity: number; idempotencyKey: string; remark?: string; warehouseId?: string }
|
||||
export interface DispatchPdaCompletePayload { idempotencyKey: string; reason: string }
|
||||
|
||||
export async function pushDispatchPda(dispatchNo: string, payload: DispatchPdaPushPayload) {
|
||||
const response = await overseasHttp.post<ApiEnvelope<DispatchPdaTaskDto>, ApiEnvelope<DispatchPdaTaskDto>>(`/pda/v1/last-leg/dispatches/${encodeURIComponent(dispatchNo)}/push`, payload)
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
export async function getDispatchPdaTask(dispatchNo: string) {
|
||||
const response = await overseasHttp.get<ApiEnvelope<DispatchPdaTaskDto>, ApiEnvelope<DispatchPdaTaskDto>>(`/pda/v1/last-leg/dispatches/${encodeURIComponent(dispatchNo)}`)
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
export async function pickDispatchPda(dispatchNo: string, itemId: number, payload: DispatchPdaPickPayload) {
|
||||
const response = await overseasHttp.post<ApiEnvelope<unknown>, ApiEnvelope<unknown>>(`/pda/v1/last-leg/dispatches/${encodeURIComponent(dispatchNo)}/items/${itemId}/pick`, payload)
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
export async function completeDispatchPda(dispatchNo: string, payload: DispatchPdaCompletePayload) {
|
||||
const response = await overseasHttp.post<ApiEnvelope<unknown>, ApiEnvelope<unknown>>(`/pda/v1/last-leg/dispatches/${encodeURIComponent(dispatchNo)}/complete`, payload)
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
export interface TransferDeliveryResult { dispatchNo: string; outboundNo: string; outboundStatus: string; deliveryNo: string; deliveryStatus: string; palletCount: number; packageCount: number; replayed: boolean }
|
||||
export interface TransferDeliveryPayload {
|
||||
idempotencyKey: string
|
||||
|
||||
@@ -27,4 +27,11 @@ describe('overseas inventory API', () => {
|
||||
expect(overseasHttp.get).toHaveBeenNthCalledWith(1, '/platform/v1/last-leg/inventory/balances/190000000000000099/positions', { params: {} })
|
||||
expect(overseasHttp.get).toHaveBeenNthCalledWith(2, '/platform/v1/last-leg/inventory/ledger', { params: { page: 1, size: 20, skuCode: 'SKU-1' } })
|
||||
})
|
||||
|
||||
it('passes the inbound code as a business filter and preserves the returned customer name', async () => {
|
||||
const record = { id: '2093539779795795969', customerId: '2093539779795795970', customerName: '华远贸易', inboundCode: 'NYEXX2608300001', beforePackages: 0, deltaPackages: 2, afterPackages: 2 }
|
||||
vi.mocked(overseasHttp.get).mockResolvedValue({ code: '200', data: { records: [record], page: 1, size: 20, total: 1, pages: 1 } })
|
||||
await expect(listInventoryLedger({ page: 1, size: 20, inboundCode: 'NYEXX2608300001', customerName: '华远贸易' })).resolves.toMatchObject({ records: [record] })
|
||||
expect(overseasHttp.get).toHaveBeenCalledWith('/platform/v1/last-leg/inventory/ledger', { params: { page: 1, size: 20, inboundCode: 'NYEXX2608300001', customerName: '华远贸易' } })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -68,6 +68,7 @@ export interface InventoryPositionDto {
|
||||
export interface InventoryLedgerDto {
|
||||
id: string
|
||||
customerId: string
|
||||
customerName?: string | null
|
||||
overseasWarehouseId?: string | null
|
||||
destinationWarehouseCode?: string | null
|
||||
inboundOrderId?: string | null
|
||||
@@ -142,6 +143,7 @@ export async function listInventoryPositions(
|
||||
export interface InventoryLedgerQuery {
|
||||
page: number
|
||||
size: number
|
||||
customerName?: string
|
||||
overseasWarehouseId?: string
|
||||
destinationWarehouseCode?: string
|
||||
businessType?: string
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { overseasHttp } from '@/shared/api/overseasHttp'
|
||||
import { convertLastMileOrderToInboundPlan, downloadLastMileOrders, getLastMileOrder, listLastMileOrders, setLastMileOrderDetained, setLastMileOrderPalletMergeBatch, setLastMileOrderPalletMergeRequired, transferLastMileOrders } from './lastMileOrders'
|
||||
import { convertLastMileContainerToInboundPlans, convertLastMileOrderToInboundPlan, downloadLastMileOrders, getContainerPlanProgress, getLastMileOrder, listContainerPlanProgress, listLastMileOrders, 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 () => {
|
||||
vi.mocked(overseasHttp.get).mockResolvedValue({ code: '200', message: 'success', data: { records: [], page: '2', size: '20', total: '0', pages: '0' } })
|
||||
await expect(listLastMileOrders({ page: 2, size: 20, orderType: 'FIRST_LEG', currentStatus: 'PENDING_ASSIGNMENT', warehouse: 'LAX' })).resolves.toEqual({ records: [], page: 2, size: 20, total: 0, pages: 0 })
|
||||
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', {
|
||||
params: { page: 2, size: 20, orderType: 'FIRST_LEG', currentStatus: 'PENDING_ASSIGNMENT', warehouse: 'LAX' },
|
||||
})
|
||||
@@ -79,34 +84,48 @@ describe('last-mile order overseas API', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('uses the order hold endpoint with the required operation remark', async () => {
|
||||
vi.mocked(overseasHttp.put).mockResolvedValue({ code: '200', message: 'success', data: null })
|
||||
await setLastMileOrderDetained('190000000000000099', { detained: true, remark: '等待质检确认' })
|
||||
expect(overseasHttp.put).toHaveBeenCalledWith('/platform/v1/last-leg/orders/190000000000000099/detained', {
|
||||
detained: true, remark: '等待质检确认',
|
||||
})
|
||||
})
|
||||
|
||||
it('marks an order for a PDA pallet-merge reminder', async () => {
|
||||
vi.mocked(overseasHttp.put).mockResolvedValue({ code: '200', message: 'success', data: null })
|
||||
await setLastMileOrderPalletMergeRequired('190000000000000099', { palletMergeRequired: true })
|
||||
expect(overseasHttp.put).toHaveBeenCalledWith('/platform/v1/last-leg/orders/190000000000000099/pallet-merge-required', {
|
||||
palletMergeRequired: true,
|
||||
})
|
||||
})
|
||||
|
||||
it('marks selected orders as one visible pallet-merge group', async () => {
|
||||
vi.mocked(overseasHttp.put).mockResolvedValue({ code: '200', message: 'success', data: null })
|
||||
await setLastMileOrderPalletMergeBatch(['11', '12'], true)
|
||||
expect(overseasHttp.put).toHaveBeenCalledWith('/platform/v1/last-leg/orders/pallet-merge-required/batch', {
|
||||
orderIds: ['11', '12'], palletMergeRequired: true,
|
||||
})
|
||||
})
|
||||
|
||||
it('uses the inbound-plan conversion endpoint without customerId', async () => {
|
||||
it('uses the inbound-plan conversion endpoint with the exact selected customer scope', async () => {
|
||||
vi.mocked(overseasHttp.post).mockResolvedValue({ code: '200', message: 'success', data: {} })
|
||||
await convertLastMileOrderToInboundPlan({ orderId: '190000000000000099' })
|
||||
expect(overseasHttp.post).toHaveBeenCalledWith('/platform/v1/last-leg/inbound-plans/convert', { orderId: '190000000000000099' })
|
||||
expect(JSON.stringify(vi.mocked(overseasHttp.post).mock.calls[0]?.[1])).not.toContain('customerId')
|
||||
await convertLastMileOrderToInboundPlan({ orderId: '190000000000000099', customerId: '190000000000000001' })
|
||||
expect(overseasHttp.post).toHaveBeenCalledWith('/platform/v1/last-leg/inbound-plans/convert', {
|
||||
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',
|
||||
})
|
||||
})
|
||||
|
||||
it('loads server-side container progress with pagination and filters', async () => {
|
||||
const record = {
|
||||
sourceContainerBookingId: '2092873463568597001', containerNo: 'CONT-15', totalOrderCount: 15,
|
||||
inboundCodeCount: 13, missingInboundCodeCount: 2, planCount: 10, plannedInboundCodeCount: 10,
|
||||
pendingPlanCount: 5, plannedArrivalAt: '2026-09-01T08:00:00', allPlansReady: false, blockingReason: '存在2票缺少入仓码',
|
||||
}
|
||||
vi.mocked(overseasHttp.get).mockResolvedValue({
|
||||
code: '200', message: 'success', data: { records: [record], page: '2', size: '10', total: '21', pages: '3' },
|
||||
})
|
||||
await expect(listContainerPlanProgress({
|
||||
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',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('loads one container detail with the encoded stable long id', async () => {
|
||||
const detail = { summary: { sourceContainerBookingId: '2092873463568597001' }, orders: [] }
|
||||
vi.mocked(overseasHttp.get).mockResolvedValue({ code: '200', message: 'success', data: detail })
|
||||
await expect(getContainerPlanProgress('2092873463568597001/unsafe')).resolves.toEqual(detail)
|
||||
expect(overseasHttp.get).toHaveBeenCalledWith('/platform/v1/last-leg/orders/container-summaries/2092873463568597001%2Funsafe')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { overseasHttp } from '@/shared/api/overseasHttp'
|
||||
import { ApiResponseError, 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,15 +155,51 @@ export interface TransferDestinationPayload {
|
||||
|
||||
export interface ConvertInboundPlanPayload {
|
||||
orderId: string
|
||||
customerId: string
|
||||
}
|
||||
|
||||
export interface SetLastMileOrderDetainedPayload {
|
||||
detained: boolean
|
||||
remark: string
|
||||
export interface ContainerPlanProgressQuery {
|
||||
page: number
|
||||
size: number
|
||||
containerNo?: string
|
||||
createdFrom?: string
|
||||
createdTo?: string
|
||||
}
|
||||
|
||||
export interface SetLastMileOrderPalletMergePayload {
|
||||
palletMergeRequired: boolean
|
||||
export interface ContainerPlanProgressSummaryDto {
|
||||
sourceContainerBookingId: string
|
||||
containerNo: string | null
|
||||
totalOrderCount: number
|
||||
inboundCodeCount: number
|
||||
missingInboundCodeCount: number
|
||||
planCount: number
|
||||
plannedInboundCodeCount: number
|
||||
pendingPlanCount: number
|
||||
plannedArrivalAt: string | null
|
||||
allPlansReady: boolean
|
||||
blockingReason: string | null
|
||||
}
|
||||
|
||||
export interface ContainerPlanProgressItemDto {
|
||||
orderId: string
|
||||
customerId: string
|
||||
orderNo: string | null
|
||||
inboundCode: string | null
|
||||
orderStatus: string
|
||||
planId: string | null
|
||||
planNo: string | null
|
||||
planStatus: string | null
|
||||
planValid: boolean
|
||||
plannedArrivalAt: string | null
|
||||
}
|
||||
|
||||
export interface ContainerPlanProgressDetailDto {
|
||||
summary: ContainerPlanProgressSummaryDto
|
||||
orders: ContainerPlanProgressItemDto[]
|
||||
}
|
||||
|
||||
export interface ConvertContainerInboundPlanPayload {
|
||||
sourceContainerBookingId: string
|
||||
}
|
||||
|
||||
export interface LastMileOrderDetailDto {
|
||||
@@ -231,23 +269,24 @@ export async function convertLastMileOrderToInboundPlan(payload: ConvertInboundP
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
export async function setLastMileOrderDetained(orderId: string, payload: SetLastMileOrderDetainedPayload) {
|
||||
const response = await overseasHttp.put<ApiEnvelope<void>, ApiEnvelope<void>>(
|
||||
`/platform/v1/last-leg/orders/${encodeURIComponent(orderId)}/detained`, payload,
|
||||
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',
|
||||
{ params: query },
|
||||
)
|
||||
return normalizeOverseasPage(unwrapApiResponse(response))
|
||||
}
|
||||
|
||||
export async function getContainerPlanProgress(sourceContainerBookingId: string) {
|
||||
const response = await overseasHttp.get<ApiEnvelope<ContainerPlanProgressDetailDto>, ApiEnvelope<ContainerPlanProgressDetailDto>>(
|
||||
`/platform/v1/last-leg/orders/container-summaries/${encodeURIComponent(sourceContainerBookingId)}`,
|
||||
)
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
export async function setLastMileOrderPalletMergeRequired(orderId: string, payload: SetLastMileOrderPalletMergePayload) {
|
||||
const response = await overseasHttp.put<ApiEnvelope<void>, ApiEnvelope<void>>(
|
||||
`/platform/v1/last-leg/orders/${encodeURIComponent(orderId)}/pallet-merge-required`, payload,
|
||||
)
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
export async function setLastMileOrderPalletMergeBatch(orderIds: string[], palletMergeRequired: boolean) {
|
||||
const response = await overseasHttp.put<ApiEnvelope<void>, ApiEnvelope<void>>(
|
||||
'/platform/v1/last-leg/orders/pallet-merge-required/batch', { orderIds, palletMergeRequired },
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user