diff --git a/src/modules/first-leg/api/customs.test.mjs b/src/modules/first-leg/api/customs.test.mjs index 1178ea2..2e780ee 100644 --- a/src/modules/first-leg/api/customs.test.mjs +++ b/src/modules/first-leg/api/customs.test.mjs @@ -12,6 +12,8 @@ test('maps only the frozen merchant container-customs contract', () => { assert.match(source, /orderId: string/) assert.match(source, /documentId: string/) assert.match(source, /loadingPlanId: string/) + assert.match(source, /getMerchantCustomsForOrder\(orderId: string\)/) + assert.doesNotMatch(source, /number \| string/) assert.match(source, /url: `\/merchant\/v1\/customs\/orders\/\$\{encodedId\(orderId\)\}`/) assert.doesNotMatch(source, /customs\/cases|MerchantCustomsCaseDetail|getMerchantCustomsByOrder/) }) diff --git a/src/modules/first-leg/api/customs.ts b/src/modules/first-leg/api/customs.ts index ea26674..6e7d15f 100644 --- a/src/modules/first-leg/api/customs.ts +++ b/src/modules/first-leg/api/customs.ts @@ -73,13 +73,13 @@ export const MERCHANT_CUSTOMS_STATUS_LABELS: Record) { +function inboundQuery(inboundIds: string[]) { const params = new URLSearchParams() - inboundIds.map(String).forEach((id) => params.append('inboundIds', id)) + inboundIds.forEach((id) => params.append('inboundIds', id)) return params.toString() } @@ -93,14 +93,14 @@ export function validateMerchantCustomsFile(file: File) { if (file.size > MAX_CUSTOMS_FILE_SIZE) throw new Error('单个文件不能超过 50MB') } -export function getMerchantCustomsForOrder(orderId: number | string) { +export function getMerchantCustomsForOrder(orderId: string) { return apiRequest({ method: 'GET', url: `/merchant/v1/customs/orders/${encodedId(orderId)}`, }) } -export function uploadMerchantCustomsDocument(planId: number | string, inboundIds: Array, file: File) { +export function uploadMerchantCustomsDocument(planId: string, inboundIds: string[], file: File) { validateMerchantCustomsFile(file) return apiRequest({ method: 'POST', @@ -111,7 +111,7 @@ export function uploadMerchantCustomsDocument(planId: number | string, inboundId }) } -export function replaceMerchantCustomsDocument(document: MerchantCustomsDocument, inboundIds: Array, file: File) { +export function replaceMerchantCustomsDocument(document: MerchantCustomsDocument, inboundIds: string[], file: File) { validateMerchantCustomsFile(file) const params = new URLSearchParams(inboundQuery(inboundIds)) params.set('expectedVersion', String(document.source.version)) @@ -124,12 +124,12 @@ export function replaceMerchantCustomsDocument(document: MerchantCustomsDocument }) } -export function updateMerchantCustomsDocumentInbounds(document: MerchantCustomsDocument, inboundIds: Array) { +export function updateMerchantCustomsDocumentInbounds(document: MerchantCustomsDocument, inboundIds: string[]) { return apiRequest({ method: 'PUT', url: `/merchant/v1/customs/documents/${encodedId(document.documentId)}/inbounds`, headers: { 'Idempotency-Key': createIdempotencyKey(`merchant-customs-scope-${document.documentId}`) }, - data: { inboundIds: inboundIds.map(String), expectedVersion: document.source.version }, + data: { inboundIds, expectedVersion: document.source.version }, }) } diff --git a/src/modules/first-leg/views/FirstLegOrdersView.test.mjs b/src/modules/first-leg/views/FirstLegOrdersView.test.mjs index a74f1bd..b395768 100644 --- a/src/modules/first-leg/views/FirstLegOrdersView.test.mjs +++ b/src/modules/first-leg/views/FirstLegOrdersView.test.mjs @@ -512,7 +512,7 @@ test('supports the frozen customs document workflow and customer-safe downloads' '/completion/download', ]) assert.match(customsApiSource, new RegExp(path.replaceAll('/', '\\/'))) assert.match(customsApiSource, /MAX_CUSTOMS_FILE_SIZE = 50 \* 1024 \* 1024/) - assert.match(customsApiSource, /inboundIds: inboundIds\.map\(String\)/) + assert.match(customsApiSource, /data: \{ inboundIds, expectedVersion: document\.source\.version \}/) assert.match(customsApiSource, /requestId: error\.requestId/) assert.match(customsDialogSource, /报关开始后仅可查看和下载,不提供退回或解锁/) assert.match(customsDialogSource, /detail\.status === 'COMPLETED' && item\.completion/)