优化
This commit is contained in:
@@ -276,7 +276,28 @@ export async function run(context) {
|
||||
approved?.customsCase?.status === 'READY_TO_SUBMIT' && Number(approved?.customsCase?.version) === 4,
|
||||
`status=${approved?.customsCase?.status || 'missing'}, version=${approved?.customsCase?.version ?? 'missing'}`, OPTIONS)
|
||||
|
||||
const batchPayload = { customsAgentName: `代理-${suffix}`, externalReference: `EXT-${suffix}`,
|
||||
const supplierCreateResponse = await context.request('POST', '/api/platform/v1/suppliers?tenantId=0', {
|
||||
name: `报关代理-${context.marker}`.slice(0, 128), category: 'CUSTOMS', scope: null, region: '深圳',
|
||||
legalRepresentative: '验收法人', contactName: '报关联系人', phone: '13800000000',
|
||||
email: 'customs-acceptance@example.com', address: '深圳市验收地址',
|
||||
businessLicenseNo: `CUSTOMS${context.marker.replace(/\D/g, '')}`.slice(0, 64), licenseFileId: null,
|
||||
status: 'ACTIVE', settlementPeriod: 'MONTHLY_30', remark: context.marker,
|
||||
})
|
||||
const customsAgentId = id(context.apiSuccess(MODULE, '创建本轮正式 ACTIVE 报关代理供应商',
|
||||
supplierCreateResponse, `marker=${context.marker}`, OPTIONS))
|
||||
if (!customsAgentId) return
|
||||
const supplierDetailResponse = await context.request('GET',
|
||||
`/api/platform/v1/suppliers/${encodeURIComponent(customsAgentId)}?tenantId=0`)
|
||||
const customsAgent = context.apiSuccess(MODULE, '回查本轮报关代理供应商', supplierDetailResponse, '', OPTIONS)
|
||||
context.assert(MODULE, '代理提交使用本轮正式 CUSTOMS 供应商身份', supplierDetailResponse,
|
||||
id(customsAgent?.id) === customsAgentId && customsAgent?.status === 'ACTIVE'
|
||||
&& customsAgent?.category === 'CUSTOMS' && customsAgent?.remark === context.marker,
|
||||
`customsAgentId=${id(customsAgent?.id) || 'missing'}, customsAgentName=${customsAgent?.name || 'missing'}`, OPTIONS)
|
||||
if (id(customsAgent?.id) !== customsAgentId || customsAgent?.status !== 'ACTIVE'
|
||||
|| customsAgent?.category !== 'CUSTOMS') return
|
||||
context.createdResources.phase3CustomsSupplier = { marker: context.marker, supplierId: customsAgentId,
|
||||
supplierName: customsAgent.name, status: customsAgent.status }
|
||||
const batchPayload = { customsAgentId, externalReference: `EXT-${suffix}`,
|
||||
note: context.marker, expectedVersion: 4 }
|
||||
const batchResponse = await request(context, 'POST', `${PLATFORM}/cases/${caseId}/submission-batches`, batchPayload,
|
||||
context.token, { 'Idempotency-Key': key(context, 'batch') })
|
||||
@@ -298,7 +319,7 @@ export async function run(context) {
|
||||
`HTTP=${batchReplay.http}, code=${codeOf(batchReplay)}, batchId=${id(batchReplay.body?.data?.id) || 'missing'}`, OPTIONS)
|
||||
|
||||
const staleSubmit = await request(context, 'POST', `${PLATFORM}/cases/${caseId}/submission-batches`, {
|
||||
...batchPayload, customsAgentName: '不同请求',
|
||||
...batchPayload, externalReference: `EXT-DIFFERENT-${suffix}`,
|
||||
}, context.token, { 'Idempotency-Key': key(context, 'batch') })
|
||||
context.addStep(MODULE, '同一幂等键不同代理提交请求被拒绝', staleSubmit,
|
||||
staleSubmit.http === 200 && codeOf(staleSubmit) !== '200',
|
||||
|
||||
Reference in New Issue
Block a user