feat: 完善头程审核与计费信息
This commit is contained in:
@@ -3,6 +3,7 @@ import { http } from '@/shared/api/http'
|
||||
import {
|
||||
approvePlatformUnifiedOrder,
|
||||
batchApprovePlatformUnifiedOrders,
|
||||
getPlatformUnifiedOrderBatchApprovalPreview,
|
||||
addPlatformUnifiedOrderNote,
|
||||
getPlatformUnifiedOrder,
|
||||
downloadPlatformProductImage,
|
||||
@@ -134,11 +135,39 @@ describe('unified orders API contract', () => {
|
||||
} })
|
||||
|
||||
await expect(batchApprovePlatformUnifiedOrders('2089176869176389634', [
|
||||
'2089223263733518337', '2089223263733518338',
|
||||
{ orderId: '2089223263733518337', orderVersion: 3 },
|
||||
{ orderId: '2089223263733518338', orderVersion: 8 },
|
||||
])).resolves.toMatchObject({ successCount: 1, failureCount: 1 })
|
||||
expect(http.post).toHaveBeenCalledWith(
|
||||
'/platform/v1/orders/first-leg/batch-approve',
|
||||
{ orderIds: ['2089223263733518337', '2089223263733518338'] },
|
||||
{ items: [
|
||||
{ orderId: '2089223263733518337', orderVersion: 3 },
|
||||
{ orderId: '2089223263733518338', orderVersion: 8 },
|
||||
] },
|
||||
{ params: { tenantId: '2089176869176389634' } },
|
||||
)
|
||||
})
|
||||
|
||||
it('loads one batch-review preview with Chinese goods and normalizes long IDs', async () => {
|
||||
vi.mocked(http.post).mockResolvedValue({ data: {
|
||||
total: 1,
|
||||
approvableCount: 1,
|
||||
items: [{
|
||||
orderId: '2089223263733518337', orderVersion: '3', inboundCode: 'NYEXX2609080001',
|
||||
customerId: '2089176869176389634', customerName: '测试客户', chineseGoodsNames: [' 蓝牙音箱 ', ''],
|
||||
channelCode: 'NY_EXX', channelName: '纽约海运', destinationWarehouseCode: 'ONT8',
|
||||
destinationWarehouseName: 'ONT8 亚马逊仓', canApprove: true, blockReason: null,
|
||||
}],
|
||||
} })
|
||||
const items = [{ orderId: '2089223263733518337', orderVersion: 3 }]
|
||||
|
||||
await expect(getPlatformUnifiedOrderBatchApprovalPreview('2089176869176389634', items)).resolves.toMatchObject({
|
||||
total: 1, approvableCount: 1,
|
||||
items: [{ orderId: '2089223263733518337', orderVersion: 3, chineseGoodsNames: ['蓝牙音箱'] }],
|
||||
})
|
||||
expect(http.post).toHaveBeenCalledWith(
|
||||
'/platform/v1/orders/first-leg/batch-review-preview',
|
||||
{ items },
|
||||
{ params: { tenantId: '2089176869176389634' } },
|
||||
)
|
||||
})
|
||||
|
||||
@@ -540,10 +540,59 @@ export interface UnifiedOrderBatchApprovalResult {
|
||||
failedOrders: Array<{ orderId: number | string; code: string; message: string }>
|
||||
}
|
||||
|
||||
export function batchApprovePlatformUnifiedOrders(tenantId: string, orderIds: string[]) {
|
||||
export interface UnifiedOrderBatchReviewItem {
|
||||
orderId: string
|
||||
orderVersion: number
|
||||
}
|
||||
|
||||
export interface UnifiedOrderBatchApprovalPreviewItem extends UnifiedOrderBatchReviewItem {
|
||||
inboundCode: string | null
|
||||
customerId: string | null
|
||||
customerName: string | null
|
||||
chineseGoodsNames: string[]
|
||||
channelCode: string | null
|
||||
channelName: string | null
|
||||
destinationWarehouseCode: string | null
|
||||
destinationWarehouseName: string | null
|
||||
canApprove: boolean
|
||||
blockReason: string | null
|
||||
}
|
||||
|
||||
export interface UnifiedOrderBatchApprovalPreview {
|
||||
total: number
|
||||
approvableCount: number
|
||||
items: UnifiedOrderBatchApprovalPreviewItem[]
|
||||
}
|
||||
|
||||
function normalizeBatchApprovalPreview(result: UnifiedOrderBatchApprovalPreview): UnifiedOrderBatchApprovalPreview {
|
||||
return {
|
||||
...result,
|
||||
total: integer(result.total, 0),
|
||||
approvableCount: integer(result.approvableCount, 0),
|
||||
items: (result.items || []).map((item) => ({
|
||||
...item,
|
||||
orderId: String(item.orderId),
|
||||
orderVersion: integer(item.orderVersion, 0),
|
||||
customerId: id(item.customerId),
|
||||
chineseGoodsNames: (item.chineseGoodsNames || []).map((name) => name.trim()).filter(Boolean),
|
||||
canApprove: Boolean(item.canApprove),
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
export async function getPlatformUnifiedOrderBatchApprovalPreview(tenantId: string, items: UnifiedOrderBatchReviewItem[]) {
|
||||
const response = await http.post<ApiEnvelope<UnifiedOrderBatchApprovalPreview>, ApiEnvelope<UnifiedOrderBatchApprovalPreview>>(
|
||||
'/platform/v1/orders/first-leg/batch-review-preview',
|
||||
{ items },
|
||||
{ params: { tenantId } },
|
||||
)
|
||||
return normalizeBatchApprovalPreview(unwrapApiResponse(response))
|
||||
}
|
||||
|
||||
export function batchApprovePlatformUnifiedOrders(tenantId: string, items: UnifiedOrderBatchReviewItem[]) {
|
||||
return http.post<ApiEnvelope<UnifiedOrderBatchApprovalResult>, ApiEnvelope<UnifiedOrderBatchApprovalResult>>(
|
||||
'/platform/v1/orders/first-leg/batch-approve',
|
||||
{ orderIds },
|
||||
{ items },
|
||||
{ params: { tenantId } },
|
||||
).then(unwrapApiResponse)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user