Files
admin-web/src/modules/overseas-warehouse/api/deliveryOrders.ts
T
2026-08-26 15:48:34 +08:00

89 lines
3.9 KiB
TypeScript

import { overseasHttp } from '@/shared/api/overseasHttp'
import { unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
import { normalizeOverseasPage, type OverseasPagePayload } from './lastMileOrders'
import type { ExceptionRelation } from './exceptionOrders'
export interface DeliveryOrderQuery {
page: number
size: number
customerId?: string
documentNo?: string
dispatchNo?: string
waybillNo?: string
warehouseId?: string
status?: string
vehiclePlate?: string
driverName?: string
deliveryMethod?: string
plannedFrom?: string
plannedTo?: string
}
export interface DeliveryOrderRow {
id: string
customerId: string
customerName?: string | null
deliveryNo: string
outboundNo: string
dispatchNo: string
overseasWarehouseId?: string | null
overseasWarehouseName?: string | null
status: string
waybillNo?: string | null
deliveryMethod?: string | null
carrierName?: string | null
pickupMethod?: string | null
loadingType?: string | null
vehicleType?: string | null
vehicleSize?: string | null
vehiclePlate?: string | null
driverName?: string | null
driverPhone?: string | null
appointmentAccount?: string | null
sellerName?: string | null
palletCount: number
packageCount: number
totalWeightKg?: number | null
totalVolumeCbm?: number | null
plannedDeliveryAt?: string | null
dispatchedAt?: string | null
expectedArrivalAt?: string | null
signedAt?: string | null
remark?: string | null
createdAt: string
}
export interface DeliverySkuRow { inboundCode?: string | null; customerName?: string | null; destinationWarehouseCode?: string | null; receivingAddress?: string | null; shipmentNo?: string | null; fbaTrackingNo?: string | null; skuCode?: string | null; productName?: string | null; packageCount: number; weightKg?: number | null; volumeCbm?: number | null }
export interface DeliveryFeeRow { id: string; feeDirection: string; feeType: string; currency: string; amount: number; remark?: string | null }
export interface DeliveryOperationRow { id: string; operatedAt: string; operationNode: string; operatorName?: string | null; result: string }
export interface DeliveryOrderDetail { order: DeliveryOrderRow; skus: DeliverySkuRow[]; fees: DeliveryFeeRow[]; operations: DeliveryOperationRow[] }
export async function listDeliveryOrders(query: DeliveryOrderQuery) {
const { customerId, ...params } = query
const response = await overseasHttp.get<ApiEnvelope<OverseasPagePayload<DeliveryOrderRow>>, ApiEnvelope<OverseasPagePayload<DeliveryOrderRow>>>(
'/platform/v1/last-leg/delivery-orders', { params: { ...params, ...(customerId ? { customerId } : {}) } },
)
return normalizeOverseasPage(unwrapApiResponse(response))
}
export async function getDeliveryOrder(deliveryNo: string, customerId: string) {
const response = await overseasHttp.get<ApiEnvelope<DeliveryOrderDetail>, ApiEnvelope<DeliveryOrderDetail>>(
`/platform/v1/last-leg/delivery-orders/${encodeURIComponent(deliveryNo)}`, { params: { customerId } },
)
return unwrapApiResponse(response)
}
export async function listDeliveryReturnInboundOptions(deliveryNo: string, customerId: string) {
const response = await overseasHttp.get<ApiEnvelope<ExceptionRelation[]>, ApiEnvelope<ExceptionRelation[]>>(
`/platform/v1/last-leg/delivery-orders/${encodeURIComponent(deliveryNo)}/return-inbound-options`, { params: { customerId } },
)
return unwrapApiResponse(response)
}
export async function markDeliveryReturn(deliveryNo: string, customerId: string, payload: { inboundOrderId: string; reason: string; returnDirection: string; returnLogisticsNo?: string; packageCount?: number; skuCode?: string }) {
const response = await overseasHttp.post<ApiEnvelope<{ id: string; exceptionNo: string; status: string }>, ApiEnvelope<{ id: string; exceptionNo: string; status: string }>>(
`/platform/v1/last-leg/delivery-orders/${encodeURIComponent(deliveryNo)}/mark-return`, payload, { params: { customerId } },
)
return unwrapApiResponse(response)
}