Files
admin-web/src/modules/overseas-warehouse/api/inboundOrders.ts
T

124 lines
4.3 KiB
TypeScript

import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
import { normalizeOverseasPage, type OverseasPagePayload } from './lastMileOrders'
export interface InboundOrderQuery {
page: number
size: number
planNo?: string
inboundCode?: string
lxCode?: 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
lxCode?: string | null
orderType?: string | null
overseasWarehouseId?: string | null
overseasWarehouseCode?: string | null
overseasWarehouseName?: string | null
warehouseId?: string | null
warehouseCode?: string | null
warehouseName?: string | null
fbaWarehouseCode?: string | null
customerName?: string | null
packageCount?: number | null
pickedPackageCount?: number | null
grossWeightKg?: number | null
netWeightKg?: number | null
volumeCbm?: number | null
palletCount?: number | null
assigned?: boolean | null
mergeAllowed?: boolean | null
urgent?: boolean | null
status?: string | null
appointmentNo?: string | null
appointmentStatus?: string | null
appointmentAt?: string | null
expectedLoadingAt?: string | null
dispatchStatus?: string | null
createdAt?: string | null
version?: number | null
}
export interface BatchFbaAppointmentPayload {
lineIds: string[]
appointmentNo: string
appointmentAt: string
appointmentEndAt?: string | null
expectedLoadingAt: string
appointmentStatus: 'PENDING' | 'SUCCESS' | 'FAILED' | 'CANCELLED'
appointmentRemark?: string
}
export interface FbaAppointmentDto {
version: number
id: string
appointmentNo: string
appointmentAt: string
appointmentEndAt?: string | null
expectedLoadingAt: string
appointmentStatus: string
appointmentRemark?: string | null
selectedCount: number
fbaWarehouseCode: string
items: Array<{ customerId: string; id: string; planId: string; lineId: string; orderId: string; inboundCode: string; fbaWarehouseCode: string }>
}
export type UpdateFbaAppointmentPayload = Omit<BatchFbaAppointmentPayload, 'lineIds' | 'appointmentNo'> & { version: number }
export async function listFbaAppointmentCalendar(query: { from: string; to: string }, signal?: AbortSignal) {
const response = await http.get<ApiEnvelope<FbaAppointmentDto[]>, ApiEnvelope<FbaAppointmentDto[]>>(
'/platform/v1/last-leg/inbound-plans/fba-appointments/calendar', { params: query, signal },
)
return unwrapApiResponse(response)
}
export async function listInboundOrders(query: InboundOrderQuery) {
const response = await http.get<ApiEnvelope<OverseasPagePayload<InboundOrderSummaryDto>>, ApiEnvelope<OverseasPagePayload<InboundOrderSummaryDto>>>(
'/platform/v1/last-leg/inbound-plans', { params: query },
)
return normalizeOverseasPage(unwrapApiResponse(response))
}
export async function createFbaAppointment(payload: BatchFbaAppointmentPayload) {
const response = await http.post<ApiEnvelope<FbaAppointmentDto>, ApiEnvelope<FbaAppointmentDto>>(
'/platform/v1/last-leg/inbound-plans/fba-appointments/batch', payload,
)
return unwrapApiResponse(response)
}
export async function getFbaAppointment(appointmentNo: string) {
const response = await http.get<ApiEnvelope<FbaAppointmentDto>, ApiEnvelope<FbaAppointmentDto>>(
`/platform/v1/last-leg/inbound-plans/fba-appointments/${encodeURIComponent(appointmentNo)}`,
)
return unwrapApiResponse(response)
}
export async function updateFbaAppointment(appointmentNo: string, payload: UpdateFbaAppointmentPayload) {
const response = await http.put<ApiEnvelope<FbaAppointmentDto>, ApiEnvelope<FbaAppointmentDto>>(
`/platform/v1/last-leg/inbound-plans/fba-appointments/${encodeURIComponent(appointmentNo)}`,
payload,
)
return unwrapApiResponse(response)
}
export async function updateInboundPlan(planNo: string, payload: { customerId: string; overseasWarehouseId: string; warehouseCode?: string; warehouseName?: string; version: number }) {
const response = await http.put<ApiEnvelope<InboundOrderSummaryDto>, ApiEnvelope<InboundOrderSummaryDto>>(
`/platform/v1/last-leg/inbound-plans/${encodeURIComponent(planNo)}`, payload,
)
return unwrapApiResponse(response)
}