2026-08-20 09:10:36 +08:00
|
|
|
import { overseasHttp } from '@/shared/api/overseasHttp'
|
|
|
|
|
import { unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
|
|
|
|
|
|
|
|
|
export interface OverseasPageResult<T> {
|
|
|
|
|
records: T[]
|
|
|
|
|
page: number
|
|
|
|
|
size: number
|
|
|
|
|
total: number
|
|
|
|
|
pages: number
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-24 16:57:25 +08:00
|
|
|
export type OverseasPagePayload<T> = Omit<OverseasPageResult<T>, 'page' | 'size' | 'total' | 'pages'> & {
|
|
|
|
|
page: number | string
|
|
|
|
|
size: number | string
|
|
|
|
|
total: number | string
|
|
|
|
|
pages: number | string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function normalizeOverseasPage<T>(value: OverseasPagePayload<T>): OverseasPageResult<T> {
|
|
|
|
|
return { ...value, page: Number(value.page), size: Number(value.size), total: Number(value.total), pages: Number(value.pages) }
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-20 09:10:36 +08:00
|
|
|
export interface LastMileOrderQuery {
|
|
|
|
|
page: number
|
|
|
|
|
size: number
|
|
|
|
|
orderNo?: string
|
2026-08-21 17:20:40 +08:00
|
|
|
orderType?: string
|
2026-08-20 09:10:36 +08:00
|
|
|
inboundCode?: string
|
|
|
|
|
containerNo?: string
|
2026-08-21 17:20:40 +08:00
|
|
|
currentStatus?: string
|
2026-08-20 09:10:36 +08:00
|
|
|
status?: string
|
2026-08-21 17:20:40 +08:00
|
|
|
warehouse?: string
|
2026-08-21 11:20:09 +08:00
|
|
|
sourceOrderNo?: string
|
|
|
|
|
transferWarehouseCode?: string
|
|
|
|
|
abnormal?: boolean
|
|
|
|
|
detained?: boolean
|
|
|
|
|
createdFrom?: string
|
|
|
|
|
createdTo?: string
|
2026-08-20 09:10:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface LastMileOrderSummaryDto {
|
|
|
|
|
id: string
|
2026-08-21 11:20:09 +08:00
|
|
|
customerId: string
|
2026-08-20 09:10:36 +08:00
|
|
|
orderNo: string
|
|
|
|
|
orderType?: string | null
|
2026-08-22 12:24:15 +08:00
|
|
|
orderTypeName?: string | null
|
2026-08-20 09:10:36 +08:00
|
|
|
inboundCode?: string | null
|
|
|
|
|
sourceOrderNo?: string | null
|
2026-08-21 11:20:09 +08:00
|
|
|
sourceInboundId?: string | null
|
2026-08-20 09:10:36 +08:00
|
|
|
customerName?: string | null
|
|
|
|
|
overseasWarehouseName?: string | null
|
|
|
|
|
transferWarehouseName?: string | null
|
2026-08-21 11:20:09 +08:00
|
|
|
transferWarehouseId?: string | null
|
|
|
|
|
transferWarehouseCode?: string | null
|
2026-08-20 09:10:36 +08:00
|
|
|
fbaWarehouseCode?: string | null
|
|
|
|
|
containerNo?: string | null
|
|
|
|
|
containerStatus?: string | null
|
|
|
|
|
abnormal?: boolean | null
|
|
|
|
|
detained?: boolean | null
|
|
|
|
|
palletCount?: number | null
|
|
|
|
|
packageCount?: number | null
|
|
|
|
|
volumeCbm?: number | null
|
|
|
|
|
productQuantity?: number | null
|
|
|
|
|
volumeWeightKg?: number | null
|
|
|
|
|
estimatedArrivalAt?: string | null
|
|
|
|
|
actualArrivalAt?: string | null
|
|
|
|
|
estimatedWarehouseAt?: string | null
|
|
|
|
|
inboundOrderNo?: string | null
|
2026-08-21 11:20:09 +08:00
|
|
|
/** Legacy read-only association retained for compatibility; absent from current service DTO. */
|
2026-08-20 09:10:36 +08:00
|
|
|
deliveryOrderNo?: string | null
|
2026-08-21 11:20:09 +08:00
|
|
|
outboundOrderNo?: string | null
|
2026-08-20 09:10:36 +08:00
|
|
|
relabelOrderNo?: string | null
|
|
|
|
|
relabelStatus?: string | null
|
|
|
|
|
palletMergeFlag?: string | null
|
|
|
|
|
currentStatus?: string | null
|
|
|
|
|
privateRemark?: string | null
|
|
|
|
|
customerRemark?: string | null
|
|
|
|
|
warehouseRemark?: string | null
|
2026-08-22 12:24:15 +08:00
|
|
|
createdAt?: string | null
|
2026-08-20 09:10:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface LastMileOrderDto extends LastMileOrderSummaryDto {
|
|
|
|
|
customerId: string
|
|
|
|
|
sourceOrderNo?: string | null
|
|
|
|
|
subOrderStatus?: string | null
|
|
|
|
|
updatedAt?: string | null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface LastMileCargoDto {
|
|
|
|
|
id: string
|
|
|
|
|
skuCode?: string | null
|
|
|
|
|
productNameZh?: string | null
|
|
|
|
|
productNameEn?: string | null
|
|
|
|
|
packageCount?: number | null
|
|
|
|
|
productQuantity?: number | null
|
|
|
|
|
palletCount?: number | null
|
|
|
|
|
grossWeightKg?: number | null
|
|
|
|
|
dimensionalWeightKg?: number | null
|
|
|
|
|
volumeCbm?: number | null
|
|
|
|
|
destinationWarehouseName?: string | null
|
|
|
|
|
fbaTrackingNo?: string | null
|
|
|
|
|
shipmentNo?: string | null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface LastMileStatusHistoryDto {
|
|
|
|
|
id: string
|
|
|
|
|
fromStatus?: string | null
|
|
|
|
|
toStatus?: string | null
|
|
|
|
|
remark?: string | null
|
|
|
|
|
createdAt?: string | null
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-26 11:10:22 +08:00
|
|
|
export interface LastMileFeeDto {
|
|
|
|
|
id: string
|
|
|
|
|
customerId: string
|
|
|
|
|
orderId: string
|
|
|
|
|
feeItem: string
|
|
|
|
|
currency: string
|
|
|
|
|
amount: number
|
|
|
|
|
status: string
|
|
|
|
|
supplierDescription?: string | null
|
|
|
|
|
createdBy: string
|
|
|
|
|
createdAt: string
|
|
|
|
|
updatedAt: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface LastMileOperationDto {
|
|
|
|
|
id: string
|
|
|
|
|
operationNode: string
|
|
|
|
|
operatorName: string
|
|
|
|
|
result: string
|
|
|
|
|
createdAt: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface CreateLastMileFeePayload {
|
|
|
|
|
feeItem: string
|
|
|
|
|
currency: string
|
|
|
|
|
amount: number
|
|
|
|
|
status: string
|
|
|
|
|
supplierDescription?: string
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-21 11:20:09 +08:00
|
|
|
export interface TransferDestinationPayload {
|
|
|
|
|
orderIds: string[]
|
|
|
|
|
warehouseId: string
|
|
|
|
|
warehouseCode: string
|
|
|
|
|
warehouseName: string
|
|
|
|
|
remark?: string
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-21 17:20:40 +08:00
|
|
|
export interface ConvertInboundPlanPayload {
|
|
|
|
|
orderId: string
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-20 09:10:36 +08:00
|
|
|
export interface LastMileOrderDetailDto {
|
|
|
|
|
order: LastMileOrderDto
|
|
|
|
|
cargo: LastMileCargoDto[]
|
|
|
|
|
statusHistory: LastMileStatusHistoryDto[]
|
2026-08-26 11:10:22 +08:00
|
|
|
fees: LastMileFeeDto[]
|
|
|
|
|
operationHistory: LastMileOperationDto[]
|
2026-08-20 09:10:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function listLastMileOrders(query: LastMileOrderQuery) {
|
2026-08-24 16:57:25 +08:00
|
|
|
const response = await overseasHttp.get<ApiEnvelope<OverseasPagePayload<LastMileOrderSummaryDto>>, ApiEnvelope<OverseasPagePayload<LastMileOrderSummaryDto>>>(
|
2026-08-20 09:10:36 +08:00
|
|
|
'/platform/v1/last-leg/orders',
|
2026-08-21 11:20:09 +08:00
|
|
|
{ params: query },
|
2026-08-20 09:10:36 +08:00
|
|
|
)
|
2026-08-24 16:57:25 +08:00
|
|
|
return normalizeOverseasPage(unwrapApiResponse(response))
|
2026-08-20 09:10:36 +08:00
|
|
|
}
|
|
|
|
|
|
2026-08-21 11:20:09 +08:00
|
|
|
export async function getLastMileOrder(orderId: string) {
|
2026-08-20 09:10:36 +08:00
|
|
|
const response = await overseasHttp.get<ApiEnvelope<LastMileOrderDetailDto>, ApiEnvelope<LastMileOrderDetailDto>>(
|
|
|
|
|
`/platform/v1/last-leg/orders/${encodeURIComponent(orderId)}`,
|
2026-08-21 11:20:09 +08:00
|
|
|
)
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-26 11:10:22 +08:00
|
|
|
export async function createLastMileOrderFee(orderId: string, payload: CreateLastMileFeePayload) {
|
|
|
|
|
const response = await overseasHttp.post<ApiEnvelope<LastMileFeeDto>, ApiEnvelope<LastMileFeeDto>>(
|
|
|
|
|
`/platform/v1/last-leg/orders/${encodeURIComponent(orderId)}/fees`, payload,
|
|
|
|
|
)
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-21 11:20:09 +08:00
|
|
|
export async function transferLastMileOrders(payload: TransferDestinationPayload) {
|
|
|
|
|
const response = await overseasHttp.put<ApiEnvelope<number>, ApiEnvelope<number>>(
|
|
|
|
|
'/platform/v1/last-leg/orders/destination', payload,
|
2026-08-20 09:10:36 +08:00
|
|
|
)
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|
2026-08-21 17:20:40 +08:00
|
|
|
|
|
|
|
|
export async function convertLastMileOrderToInboundPlan(payload: ConvertInboundPlanPayload) {
|
|
|
|
|
const response = await overseasHttp.post<ApiEnvelope<unknown>, ApiEnvelope<unknown>>(
|
|
|
|
|
'/platform/v1/last-leg/inbound-plans/convert', payload,
|
|
|
|
|
)
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|