import { overseasHttp } from '@/shared/api/overseasHttp' import { 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 overseasWarehouseName?: string | null destinationWarehouseId?: string | null destinationWarehouseCode?: string | null destinationWarehouseName?: string | null fbaWarehouseCode?: string | null packageCount?: 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 containerNo?: string | null status?: string | null lineCount: number palletCount: number totalVolumeCbm: number expectedPackageCount?: number pickedPackageCount?: number lines: Array<{ id: string; orderId: string; inboundCode?: string | null; fbaWarehouseCode?: string | null; destinationWarehouseId?: string | null; destinationWarehouseCode?: string | null; destinationWarehouseName?: string | 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; warehouseResourceLockId?: string | null; assignmentStatus?: string | null; lockedAt?: string | null; actualVolumeCbm?: number | null; actualPackageCount: number }> allocations: Array<{ lineId: string; palletId: string; 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 overseasHttp.get>, ApiEnvelope>>('/platform/v1/last-leg/inbound-plans', { params: { customerId, ...params } }))) } export async function getInboundPlan(planNo: string, customerId: string) { return unwrapApiResponse(await overseasHttp.get, ApiEnvelope>(`/platform/v1/last-leg/inbound-plans/${encodeURIComponent(planNo)}`, { params: { customerId } })) }