import { overseasHttp } from '@/shared/api/overseasHttp' import { unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http' import type { OverseasPageResult } from './lastMileOrders' export interface InboundOrderQuery { customerId: string page: number size: number planNo?: string inboundCode?: string status?: string warehouse?: string fbaWarehouseCode?: string appointmentStatus?: string dispatchStatus?: string createdFrom?: string createdTo?: string } export interface InboundOrderSummaryDto { lineId: string planId: string planNo: string customerId: string orderId: string inboundCode?: string | null orderType?: string | null warehouseId?: string | null warehouseCode?: string | null warehouseName?: string | null fbaWarehouseCode?: string | null customerName?: string | null packageCount?: number | null volumeCbm?: number | null palletCount?: number | null status?: string | null appointmentNo?: string | null appointmentStatus?: string | null appointmentAt?: string | null expectedLoadingAt?: string | null dispatchStatus?: string | null createdAt?: string | null } export interface BatchFbaAppointmentPayload { customerId: string lineIds: string[] appointmentNo: string appointmentAt: string expectedLoadingAt: string appointmentStatus: 'PENDING' | 'SUCCESS' | 'FAILED' | 'CANCELLED' appointmentRemark?: string } export interface FbaAppointmentDto { id: string customerId: string appointmentNo: string appointmentAt: string expectedLoadingAt: string appointmentStatus: string appointmentRemark?: string | null selectedCount: number fbaWarehouseCode: string items: Array<{ id: string; planId: string; lineId: string; orderId: string; inboundCode: string; fbaWarehouseCode: string }> } export type UpdateFbaAppointmentPayload = Omit export async function listInboundOrders(query: InboundOrderQuery) { const { customerId, ...params } = query const response = await overseasHttp.get>, ApiEnvelope>>( '/platform/v1/last-leg/inbound-plans', { params: { customerId, ...params } }, ) return unwrapApiResponse(response) } export async function createFbaAppointment(payload: BatchFbaAppointmentPayload) { const response = await overseasHttp.post, ApiEnvelope>( '/platform/v1/last-leg/inbound-plans/fba-appointments/batch', payload, ) return unwrapApiResponse(response) } export async function getFbaAppointment(customerId: string, appointmentNo: string) { const response = await overseasHttp.get, ApiEnvelope>( `/platform/v1/last-leg/inbound-plans/fba-appointments/${encodeURIComponent(appointmentNo)}`, { params: { customerId } }, ) return unwrapApiResponse(response) } export async function updateFbaAppointment(appointmentNo: string, payload: UpdateFbaAppointmentPayload) { const response = await overseasHttp.put, ApiEnvelope>( `/platform/v1/last-leg/inbound-plans/fba-appointments/${encodeURIComponent(appointmentNo)}`, payload, ) return unwrapApiResponse(response) }