feat: complete customer overseas business flows

This commit is contained in:
2026-09-04 12:41:58 +08:00
parent 2a7e042420
commit 0957324fb0
18 changed files with 840 additions and 38 deletions
@@ -0,0 +1,164 @@
import { overseasApiRequest } from '@/api/overseasHttp'
export interface PageResult<T> {
records: T[]
page: number
size: number
total: number
pages: number
}
export type CrossBorderBusinessKind = 'procurement' | 'trucking' | 'looseboard'
export interface BusinessOrderQuery {
page: number
size: number
orderNo?: string
status?: string
routeKeyword?: string
productName?: string
purchaseCategory?: string
transportType?: string
transportMode?: string
requestedFrom?: string
requestedTo?: string
createdFrom?: string
createdTo?: string
}
export interface ProcurementSummary {
orderNo: string
purchaseCategory: string
productName: string
productSpecification: string | null
purchaseQuantity: number
budgetUnitPrice: number | null
currency: string | null
inboundQuantity: number
outboundQuantity: number
inventoryQuantity: number
status: string
version: number
createdAt: string
updatedAt: string
}
export interface ProcurementDetail {
summary: ProcurementSummary
productUrl: string | null
receivingAddress: string | null
contactName: string
contactPhone: string
domesticCarrier: string | null
domesticTrackingNo: string | null
overseasCarrier: string | null
overseasTrackingNo: string | null
estimatedArrivalAt: string | null
remark: string | null
reviewRemark: string | null
}
export interface ProcurementCreate {
purchaseCategory: string
productName: string
productSpecification?: string
productUrl?: string
purchaseQuantity: number
budgetUnitPrice?: number
currency?: string
receivingAddress?: string
contactName: string
contactPhone: string
remark?: string
idempotencyKey: string
}
export interface TransportSummary {
orderNo: string
transportType: string
transportMode?: string
palletRequired?: string
origin: string
destination: string
containerType: string | null
palletCount?: number
packageCount: number
totalWeightKg: number
totalVolumeCbm: number
budgetAmount: number | null
currency: string | null
contactName: string | null
contactInfo: string | null
requestedDate: string | null
status: string
version: number
createdAt: string
updatedAt: string
}
export interface TransportDetail {
summary: TransportSummary
originAddress: string | null
destinationAddress: string | null
remark: string | null
}
export interface TransportCreate {
transportType: string
transportMode?: string
palletRequired?: string
origin: string
originAddress?: string
destination: string
destinationAddress?: string
containerType?: string
palletCount?: number
packageCount: number
totalWeightKg: number
totalVolumeCbm: number
budgetAmount?: number
currency?: string
contactName?: string
contactInfo?: string
requestedDate?: string
remark?: string
idempotencyKey: string
}
export interface TransportUpdate extends Omit<TransportCreate, 'idempotencyKey'> {
version: number
}
const endpointByKind: Record<CrossBorderBusinessKind, string> = {
procurement: '/merchant/v1/last-leg/overseas-procurements',
trucking: '/merchant/v1/last-leg/us-truck-orders',
looseboard: '/merchant/v1/last-leg/local-looseboard-orders',
}
function normalizePage<T>(data: PageResult<T>): PageResult<T> {
return { ...data, page: Number(data.page), size: Number(data.size), total: Number(data.total), pages: Number(data.pages) }
}
export function listBusinessOrders<T>(kind: CrossBorderBusinessKind, params: BusinessOrderQuery) {
return overseasApiRequest<PageResult<T>>({ method: 'GET', url: endpointByKind[kind], params }).then(normalizePage)
}
export function getBusinessOrder<T>(kind: CrossBorderBusinessKind, orderNo: string) {
return overseasApiRequest<T>({ method: 'GET', url: `${endpointByKind[kind]}/${encodeURIComponent(orderNo)}` })
}
export function createProcurement(payload: ProcurementCreate) {
return overseasApiRequest<ProcurementDetail>({ method: 'POST', url: endpointByKind.procurement, data: payload })
}
export function createTransport(kind: 'trucking' | 'looseboard', payload: TransportCreate) {
return overseasApiRequest<TransportDetail>({ method: 'POST', url: endpointByKind[kind], data: payload })
}
export function updateTransport(kind: 'trucking' | 'looseboard', orderNo: string, payload: TransportUpdate) {
return overseasApiRequest<TransportDetail>({
method: kind === 'trucking' ? 'PATCH' : 'PUT',
url: `${endpointByKind[kind]}/${encodeURIComponent(orderNo)}`,
data: payload,
})
}