Files
admin-web/src/modules/overseas-warehouse/api/inboundPlans.ts
T
2026-09-29 17:56:00 +08:00

107 lines
4.6 KiB
TypeScript

import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
import { normalizeOverseasPage, type OverseasPagePayload } from './lastMileOrders'
export interface InboundPlanQuery {
customerId: string
page: number
size: number
planNo?: string
inboundCode?: string
status?: string
overseasWarehouseId?: string
destinationWarehouseCode?: string
fbaWarehouseCode?: string
appointmentStatus?: string
createdFrom?: string
createdTo?: string
}
export interface InboundPlanSummaryDto {
id: string
planNo: string
sourceOrderId: string
customerId: string
customerName?: string | null
orderType?: string | null
inboundCode?: string | null
containerNo?: string | null
overseasWarehouseId?: string | null
overseasWarehouseCode?: string | null
overseasWarehouseName?: string | null
destinationWarehouseId?: string | null
destinationWarehouseCode?: string | null
destinationWarehouseName?: string | null
fbaWarehouseCode?: string | null
packageCount?: number | null
grossWeightKg?: number | null
netWeightKg?: number | null
totalVolumeCbm?: number | null
palletCount?: number | null
status?: string | null
appointmentStatus?: string | null
createdAt?: string | null
updatedAt?: string | null
}
export interface InboundPlanDetailDto {
id: string
planNo: string
customerId: string
sourceOrderId: string
sourceOrderNo?: string | null
customerName?: string | null
orderType?: string | null
containerNo?: string | null
overseasWarehouseId?: string | null
overseasWarehouseCode?: string | null
overseasWarehouseName?: string | null
status?: string | null
lineCount: number
palletCount: number
totalGrossWeightKg: number
totalNetWeightKg: number
totalVolumeCbm: number
expectedPackageCount?: number
pickedPackageCount?: number
createdAt?: string | null
updatedAt?: string | null
remark?: string | null
lines: Array<{ id: string; orderId: string; inboundCode?: string | null; fbaWarehouseCode?: string | null; destinationWarehouseId?: string | null; destinationWarehouseCode?: string | null; destinationWarehouseName?: string | null; grossWeightKg?: number | null; netWeightKg?: number | null; volumeCbm?: number | null; requiredPackageCount: number; plannedPalletCount: number }>
pallets: Array<{ id: string; palletNo?: string | null; destinationWarehouseId?: string | null; destinationWarehouseCode?: string | null; destinationWarehouseName?: string | null; capacityCbm?: number | null; allocatedVolumeCbm?: number | null; sequenceNo: number; warehousePalletId?: string | null; warehouseLocationId?: string | null; warehouseLocationCode?: string | null; warehouseLocationType?: string | null; warehouseLocationStatus?: string | null; sharedOverflow?: boolean | null; assignmentStatus?: string | null; lockedAt?: string | null; actualVolumeCbm?: number | null; actualPackageCount: number; version?: number }>
allocations: Array<{ lineId: string; palletId: string; palletNo: string; palletOwnerPlanNo: string; palletOwnedByCurrentPlan: boolean; allocatedVolumeCbm?: number | null; plannedPackageCount: number; countedPackageCount: number; pickedPackageCount: number; actualVolumeCbm?: number | null; status?: string | null; version: number }>
}
export async function listInboundPlans(query: InboundPlanQuery) {
const { customerId, ...params } = query
return normalizeOverseasPage(unwrapApiResponse(await http.get<ApiEnvelope<OverseasPagePayload<InboundPlanSummaryDto>>, ApiEnvelope<OverseasPagePayload<InboundPlanSummaryDto>>>('/platform/v1/last-leg/inbound-plans', { params: { customerId, ...params } })))
}
export async function getInboundPlan(planNo: string, customerId: string) {
return unwrapApiResponse(await http.get<ApiEnvelope<InboundPlanDetailDto>, ApiEnvelope<InboundPlanDetailDto>>(`/platform/v1/last-leg/inbound-plans/${encodeURIComponent(planNo)}`, { params: { customerId } }))
}
export interface PlatformInventoryMoveRequest {
overseasWarehouseId: string
sourcePalletCode: string
targetLocationCode: string
expectedPalletVersion: number
reason: string
idempotencyKey: string
}
export interface PlatformInventoryMoveResult {
commandId: string
status: string
canMove?: boolean
blockReason?: string | null
sourceLocationCode?: string | null
targetLocationCode?: string | null
sharedOverflow?: boolean | null
}
export async function moveInboundPallet(payload: PlatformInventoryMoveRequest) {
const response = await http.post<ApiEnvelope<PlatformInventoryMoveResult>, ApiEnvelope<PlatformInventoryMoveResult>>('/platform/v1/last-leg/inventory-moves', payload, { headers: { 'Idempotency-Key': payload.idempotencyKey } })
return unwrapApiResponse(response)
}