2026-08-25 20:57:51 +08:00
|
|
|
import { overseasHttp } from '@/shared/api/overseasHttp'
|
|
|
|
|
import { unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
|
|
|
|
import { normalizeOverseasPage, type OverseasPagePayload } from './lastMileOrders'
|
2026-09-01 14:23:53 +08:00
|
|
|
import type { DeliveryOrderRow } from './deliveryOrders'
|
2026-08-25 20:57:51 +08:00
|
|
|
|
2026-09-06 15:53:48 +08:00
|
|
|
export interface OutboundRow { id: string; outboundNo: string; dispatchNo?: string | null; overseasWarehouseId?: string | null; lxCodes?: string | null; status?: string | null; palletCount?: number | null; packageCount?: number | null; createdAt?: string | null }
|
2026-09-07 20:29:31 +08:00
|
|
|
export interface OutboundPalletRow {
|
2026-09-08 20:33:45 +08:00
|
|
|
id?: string | null
|
2026-09-07 20:29:31 +08:00
|
|
|
palletNo?: string | null
|
2026-09-08 20:33:45 +08:00
|
|
|
cartonMarks?: string | null
|
2026-09-07 20:29:31 +08:00
|
|
|
inboundCode?: string | null
|
|
|
|
|
destinationWarehouseCode?: string | null
|
|
|
|
|
destinationWarehouseName?: string | null
|
|
|
|
|
skuCode?: string | null
|
|
|
|
|
packageCount?: number | null
|
2026-09-08 20:33:45 +08:00
|
|
|
pickedPackageCount?: number | null
|
|
|
|
|
status?: string | null
|
2026-09-07 20:29:31 +08:00
|
|
|
}
|
2026-09-08 20:33:45 +08:00
|
|
|
export interface OutboundDetail { outbound: OutboundRow; pallets?: OutboundPalletRow[]; delivery?: DeliveryOrderRow | null }
|
2026-09-06 15:53:48 +08:00
|
|
|
export interface OutboundQuery { page: number; size: number; documentNo?: string; lxCode?: string; warehouseId?: string; status?: string }
|
2026-08-25 20:57:51 +08:00
|
|
|
export async function listOutbounds(query: OutboundQuery) {
|
|
|
|
|
const response = await overseasHttp.get<ApiEnvelope<OverseasPagePayload<OutboundRow>>, ApiEnvelope<OverseasPagePayload<OutboundRow>>>('/platform/v1/last-leg/outbound-orders', { params: query })
|
|
|
|
|
return normalizeOverseasPage(unwrapApiResponse(response))
|
|
|
|
|
}
|
2026-09-01 14:23:53 +08:00
|
|
|
export async function getOutbound(outboundNo: string) {
|
|
|
|
|
const response = await overseasHttp.get<ApiEnvelope<OutboundDetail>, ApiEnvelope<OutboundDetail>>(`/platform/v1/last-leg/outbound-orders/${encodeURIComponent(outboundNo)}`)
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|
2026-09-08 20:27:47 +08:00
|
|
|
export async function createOneClickDropshipOutbound(customerId: string, payload: { recipient: string; items: Array<{ inventoryPositionId: string; packages: number; sku?: string; cartonMarks?: string[] }>; remark?: string; idempotencyKey: string }) {
|
2026-08-25 20:57:51 +08:00
|
|
|
const response = await overseasHttp.post<ApiEnvelope<OutboundRow>, ApiEnvelope<OutboundRow>>('/platform/v1/last-leg/outbound-orders/one-click-dropship', payload, { params: { customerId } })
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|
2026-09-01 14:23:53 +08:00
|
|
|
export async function cancelOutbound(outboundNo: string, reason: string) {
|
|
|
|
|
const response = await overseasHttp.post<ApiEnvelope<null>, ApiEnvelope<null>>(`/platform/v1/last-leg/outbound-orders/${encodeURIComponent(outboundNo)}/cancel`, { reason })
|
2026-08-26 15:48:34 +08:00
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|