Merge branch 'dev' of http://8.163.30.128:10082/html/admin-web into dev
This commit is contained in:
@@ -18,11 +18,23 @@ describe('delivery order API', () => {
|
||||
})
|
||||
|
||||
it('loads an encoded detail in its explicit customer scope', async () => {
|
||||
vi.mocked(overseasHttp.get).mockResolvedValue({ code: '200', data: { order: { deliveryNo: 'DEL/1' }, skus: [], fees: [], operations: [] } })
|
||||
vi.mocked(overseasHttp.get).mockResolvedValue({ code: '200', data: { order: { deliveryNo: 'DEL/1', version: '0' }, skus: [], fees: [], operations: [] } })
|
||||
await getDeliveryOrder('DEL/1', '1001')
|
||||
expect(overseasHttp.get).toHaveBeenCalledWith('/platform/v1/last-leg/delivery-orders/DEL%2F1', { params: { customerId: '1001', page: 1, size: 200 } })
|
||||
})
|
||||
|
||||
it.each(['0', '7', '9007199254740991'])('reads Java Long version %s for status editing', async version => {
|
||||
vi.mocked(overseasHttp.get).mockResolvedValue({ code: '200', data: { order: { version, id: '2097515131537313794' } } })
|
||||
const detail = await getDeliveryOrder('DEL/1', '1001')
|
||||
expect(detail.order.version).toBe(Number(version))
|
||||
expect(detail.order.id).toBe('2097515131537313794')
|
||||
})
|
||||
|
||||
it.each([null, undefined, '', ' ', '-1', '1.5', '9007199254740992', -1])('rejects invalid version %s', async version => {
|
||||
vi.mocked(overseasHttp.get).mockResolvedValue({ code: '200', data: { order: { version } } })
|
||||
await expect(getDeliveryOrder('DEL/1', '1001')).rejects.toThrow('派送单缺少有效版本')
|
||||
})
|
||||
|
||||
it('loads return options and marks a return in the explicit customer scope', async () => {
|
||||
vi.mocked(overseasHttp.get).mockResolvedValue({ code: '200', data: [{ inboundOrderId: '9', inboundCode: 'IN-1' }] })
|
||||
await listDeliveryReturnInboundOptions('DEL/1', '1001')
|
||||
|
||||
@@ -97,7 +97,15 @@ 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, page: 1, size: 200 } },
|
||||
)
|
||||
return unwrapApiResponse(response)
|
||||
const detail = unwrapApiResponse(response)
|
||||
// Java Long values are serialized as decimal strings, including the version.
|
||||
const rawVersion: unknown = detail.order.version
|
||||
const version = typeof rawVersion === 'string' && /^(0|[1-9]\d*)$/.test(rawVersion)
|
||||
? Number(rawVersion) : rawVersion
|
||||
if (typeof version !== 'number' || !Number.isSafeInteger(version) || version < 0) {
|
||||
throw new Error('派送单缺少有效版本,请刷新后重试')
|
||||
}
|
||||
return { ...detail, order: { ...detail.order, version } }
|
||||
}
|
||||
|
||||
export async function listDeliveryReturnInboundOptions(deliveryNo: string, customerId: string) {
|
||||
|
||||
@@ -81,7 +81,7 @@ describe('dispatch overseas API', () => {
|
||||
|
||||
it('transfers to delivery only by dispatchNo without customerId', async () => {
|
||||
vi.mocked(overseasHttp.post).mockResolvedValue({ code: '200', message: 'success', data: { dispatchNo: 'PC/1', outboundNo: 'OUT-1', deliveryNo: 'DEL-1' } })
|
||||
const payload = { idempotencyKey: 'transfer-1', plannedDeliveryAt: '2026-09-01T10:00:00', deliveryMethod: 'TRUCK_PALLET', pickupMethod: 'WAREHOUSE_PICKUP', loadingType: 'PALLET', fees: [{ feeType: 'DELIVERY_FEE', currency: 'USD', amount: 10 }] }
|
||||
const payload = { idempotencyKey: 'transfer-1', plannedDeliveryAt: '2026-09-01T10:00:00', deliveryMethod: 'TRUCK_PALLET', pickupMethod: 'WAREHOUSE_PICKUP', loadingType: 'PALLET', fees: [{ feeType: 'DELIVERY_FEE', feeName: '派送费用', direction: 'RECEIVABLE' as const, currency: 'USD' as const, amount: 10 }] }
|
||||
await transferDispatchToDelivery('PC/1', payload)
|
||||
expect(overseasHttp.post).toHaveBeenCalledWith('/platform/v1/last-leg/dispatches/PC%2F1/transfer-delivery', payload)
|
||||
})
|
||||
|
||||
@@ -214,7 +214,11 @@ export interface TransferDeliveryPayload {
|
||||
appointmentAccount?: string
|
||||
sellerName?: string
|
||||
remark?: string
|
||||
fees: Array<{ feeType: string; currency: string; amount: number; remark?: string }>
|
||||
fees: Array<{ feeType: string; feeName: string; direction: 'RECEIVABLE' | 'PAYABLE'; currency: 'CNY' | 'USD'; amount: number
|
||||
supplierId?: string; supplierName?: string; supplierCategory?: string; settlementMode?: 'ON_ACCOUNT' | 'DIRECT_PAID'
|
||||
paidAt?: string; paymentMethod?: 'ONLINE' | 'BANK_TRANSFER' | 'CASH' | 'OTHER'; paymentReferenceNo?: string
|
||||
paymentVoucherFileIds?: string[]; chargeableQuantity?: number; quantityUnit?: string; unitPrice?: number
|
||||
periodStart?: string; periodEnd?: string; remark?: string }>
|
||||
palletCartonMarks?: Record<string, string[]>
|
||||
}
|
||||
export async function transferDispatchToDelivery(dispatchNo: string, payload: TransferDeliveryPayload) {
|
||||
|
||||
@@ -125,17 +125,14 @@ export interface LastMileStatusHistoryDto {
|
||||
}
|
||||
|
||||
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
|
||||
id: string; sourceFeeId: string; sourceVersion: number; customerId: string; orderId?: string | null
|
||||
feeItemCode: string; feeItemName: string; direction: 'RECEIVABLE' | 'PAYABLE'
|
||||
currency: 'CNY'; amount: number; originalCurrency: 'CNY' | 'USD'; originalAmount: number
|
||||
exchangeRate: number; exchangeRateMonth: string; reviewStatus: 'DRAFT' | 'PENDING' | 'APPROVED' | 'REJECTED'
|
||||
publicationStatus: string; sourceStatus: string; supplierId?: string | null; supplierName?: string | null
|
||||
settlementMode?: 'ON_ACCOUNT' | 'DIRECT_PAID' | null; businessDate: string
|
||||
chargeableQuantity?: number | null; quantityUnit?: string | null; unitPrice?: number | null
|
||||
periodStart?: string | null; periodEnd?: string | null; createdAt: string; updatedAt: string
|
||||
}
|
||||
|
||||
export interface LastMileOperationDto {
|
||||
@@ -147,11 +144,11 @@ export interface LastMileOperationDto {
|
||||
}
|
||||
|
||||
export interface CreateLastMileFeePayload {
|
||||
feeItem: string
|
||||
currency: string
|
||||
amount: number
|
||||
status: string
|
||||
supplierDescription?: string
|
||||
feeItemCode: string; feeItemName: string; direction: 'RECEIVABLE' | 'PAYABLE'; currency: 'CNY' | 'USD'
|
||||
amount: number; businessDate: string; supplierId?: string; supplierName?: string; supplierCategory?: string
|
||||
settlementMode?: 'ON_ACCOUNT' | 'DIRECT_PAID'; paidAt?: string; paymentMethod?: 'ONLINE' | 'BANK_TRANSFER' | 'CASH' | 'OTHER'
|
||||
paymentReferenceNo?: string; paymentVoucherFileIds?: string[]; chargeableQuantity?: number
|
||||
quantityUnit?: string; unitPrice?: number; periodStart?: string; periodEnd?: string
|
||||
}
|
||||
|
||||
export interface TransferDestinationPayload {
|
||||
@@ -378,6 +375,7 @@ export async function downloadLastMileOrders(query: Partial<LastMileOrderQuery>)
|
||||
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,
|
||||
{ headers: { 'Idempotency-Key': `last-mile-fee-${orderId}-${Date.now()}-${Math.random().toString(36).slice(2)}` } },
|
||||
)
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user