收紧客户端退税报关长ID契约
This commit is contained in:
@@ -12,6 +12,8 @@ test('maps only the frozen merchant container-customs contract', () => {
|
|||||||
assert.match(source, /orderId: string/)
|
assert.match(source, /orderId: string/)
|
||||||
assert.match(source, /documentId: string/)
|
assert.match(source, /documentId: string/)
|
||||||
assert.match(source, /loadingPlanId: 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.match(source, /url: `\/merchant\/v1\/customs\/orders\/\$\{encodedId\(orderId\)\}`/)
|
||||||
assert.doesNotMatch(source, /customs\/cases|MerchantCustomsCaseDetail|getMerchantCustomsByOrder/)
|
assert.doesNotMatch(source, /customs\/cases|MerchantCustomsCaseDetail|getMerchantCustomsByOrder/)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -73,13 +73,13 @@ export const MERCHANT_CUSTOMS_STATUS_LABELS: Record<MerchantCustomsStatus, strin
|
|||||||
|
|
||||||
const MAX_CUSTOMS_FILE_SIZE = 50 * 1024 * 1024
|
const MAX_CUSTOMS_FILE_SIZE = 50 * 1024 * 1024
|
||||||
|
|
||||||
function encodedId(value: number | string) {
|
function encodedId(value: string) {
|
||||||
return encodeURIComponent(String(value))
|
return encodeURIComponent(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function inboundQuery(inboundIds: Array<number | string>) {
|
function inboundQuery(inboundIds: string[]) {
|
||||||
const params = new URLSearchParams()
|
const params = new URLSearchParams()
|
||||||
inboundIds.map(String).forEach((id) => params.append('inboundIds', id))
|
inboundIds.forEach((id) => params.append('inboundIds', id))
|
||||||
return params.toString()
|
return params.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,14 +93,14 @@ export function validateMerchantCustomsFile(file: File) {
|
|||||||
if (file.size > MAX_CUSTOMS_FILE_SIZE) throw new Error('单个文件不能超过 50MB')
|
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>({
|
return apiRequest<MerchantCustomsContainer>({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: `/merchant/v1/customs/orders/${encodedId(orderId)}`,
|
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)
|
validateMerchantCustomsFile(file)
|
||||||
return apiRequest<MerchantCustomsDocument>({
|
return apiRequest<MerchantCustomsDocument>({
|
||||||
method: 'POST',
|
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)
|
validateMerchantCustomsFile(file)
|
||||||
const params = new URLSearchParams(inboundQuery(inboundIds))
|
const params = new URLSearchParams(inboundQuery(inboundIds))
|
||||||
params.set('expectedVersion', String(document.source.version))
|
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>({
|
return apiRequest<MerchantCustomsDocument>({
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
url: `/merchant/v1/customs/documents/${encodedId(document.documentId)}/inbounds`,
|
url: `/merchant/v1/customs/documents/${encodedId(document.documentId)}/inbounds`,
|
||||||
headers: { 'Idempotency-Key': createIdempotencyKey(`merchant-customs-scope-${document.documentId}`) },
|
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',
|
'/completion/download',
|
||||||
]) assert.match(customsApiSource, new RegExp(path.replaceAll('/', '\\/')))
|
]) assert.match(customsApiSource, new RegExp(path.replaceAll('/', '\\/')))
|
||||||
assert.match(customsApiSource, /MAX_CUSTOMS_FILE_SIZE = 50 \* 1024 \* 1024/)
|
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(customsApiSource, /requestId: error\.requestId/)
|
||||||
assert.match(customsDialogSource, /报关开始后仅可查看和下载,不提供退回或解锁/)
|
assert.match(customsDialogSource, /报关开始后仅可查看和下载,不提供退回或解锁/)
|
||||||
assert.match(customsDialogSource, /detail\.status === 'COMPLETED' && item\.completion/)
|
assert.match(customsDialogSource, /detail\.status === 'COMPLETED' && item\.completion/)
|
||||||
|
|||||||
Reference in New Issue
Block a user