收紧客户端退税报关长ID契约

This commit is contained in:
2026-08-28 17:27:12 +08:00
parent 6a445bbb8f
commit a10ee73ba9
3 changed files with 12 additions and 10 deletions
@@ -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/)
})
+9 -9
View File
@@ -73,13 +73,13 @@ export const MERCHANT_CUSTOMS_STATUS_LABELS: Record<MerchantCustomsStatus, strin
const MAX_CUSTOMS_FILE_SIZE = 50 * 1024 * 1024
function encodedId(value: number | string) {
return encodeURIComponent(String(value))
function encodedId(value: string) {
return encodeURIComponent(value)
}
function inboundQuery(inboundIds: Array<number | string>) {
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<MerchantCustomsContainer>({
method: 'GET',
url: `/merchant/v1/customs/orders/${encodedId(orderId)}`,
})
}
export function uploadMerchantCustomsDocument(planId: number | string, inboundIds: Array<number | string>, file: File) {
export function uploadMerchantCustomsDocument(planId: string, inboundIds: string[], file: File) {
validateMerchantCustomsFile(file)
return apiRequest<MerchantCustomsDocument>({
method: 'POST',
@@ -111,7 +111,7 @@ export function uploadMerchantCustomsDocument(planId: number | string, inboundId
})
}
export function replaceMerchantCustomsDocument(document: MerchantCustomsDocument, inboundIds: Array<number | string>, 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<number | string>) {
export function updateMerchantCustomsDocumentInbounds(document: MerchantCustomsDocument, inboundIds: string[]) {
return apiRequest<MerchantCustomsDocument>({
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 },
})
}
@@ -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/)