test(phase3): satisfy finalization fixture gates
This commit is contained in:
@@ -68,6 +68,35 @@ async function request(context, method, path, body, headers = {}, token = contex
|
||||
}
|
||||
}
|
||||
|
||||
async function ensureCompletionEvidence(context, tenantId, inboundId, keyBase) {
|
||||
const png = Uint8Array.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,6,0,0,0,31,21,196,137,0,0,0,13,73,68,65,84,8,215,99,248,207,192,240,31,0,5,0,1,255,137,153,61,29,0,0,0,0,73,69,78,68,174,66,96,130])
|
||||
for (const evidenceType of ['PHOTO_STEP_1', 'PHOTO_STEP_2', 'PHOTO_STEP_3', 'PHOTO_STEP_4', 'SEAL']) {
|
||||
const uploadPath = `/api/platform/v1/files/loading-evidence/${tenantId}/${inboundId}?evidenceType=${encodeURIComponent(evidenceType)}`
|
||||
const form = new FormData()
|
||||
form.append('file', new Blob([png], { type: 'image/png' }), `${keyBase}-${evidenceType}.png`)
|
||||
const rawUpload = await fetch(`${context.options.gateway}${uploadPath}`, {
|
||||
method: 'POST', headers: { Accept: 'application/json', Authorization: `Bearer ${context.token}` },
|
||||
body: form, signal: AbortSignal.timeout(60_000),
|
||||
})
|
||||
const uploadBody = await rawUpload.json()
|
||||
const upload = { method: 'POST', path: uploadPath, http: rawUpload.status, body: uploadBody,
|
||||
requestId: uploadBody?.requestId || rawUpload.headers.get('x-request-id'),
|
||||
traceId: uploadBody?.traceId || rawUpload.headers.get('x-trace-id') }
|
||||
const file = context.apiSuccess(MODULE, `${keyBase} 上传 ${evidenceType} 装柜证据`, upload, '', OPTIONS)
|
||||
const fileId = id(file?.id || file?.fileId)
|
||||
if (!fileId) return false
|
||||
const bind = await request(context, 'POST',
|
||||
`/api/platform/v1/inbounds/${inboundId}/loading/evidence?tenantId=${encodeURIComponent(tenantId)}`, {
|
||||
expectedVersion: 0, evidenceType, fileId,
|
||||
sealNo: evidenceType === 'SEAL' ? `SEAL-${keyBase}`.slice(0, 64) : null,
|
||||
remark: context.marker,
|
||||
}, { 'Idempotency-Key': `${keyBase}-evidence-${evidenceType}`.slice(0, 128) })
|
||||
const bound = context.apiSuccess(MODULE, `${keyBase} 绑定 ${evidenceType} 装柜证据`, bind, '', OPTIONS)
|
||||
if (!bound) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function treePath(orderId, tenantId) {
|
||||
return `/api/platform/v1/orders/${encodeURIComponent(orderId)}/fulfillment-tree?tenantId=${encodeURIComponent(tenantId)}`
|
||||
}
|
||||
@@ -378,6 +407,8 @@ async function loadOneFragment(context, state) {
|
||||
`HTTP=${differentReplay.http}, code=${codeOf(differentReplay)}, requestId=${differentReplay.requestId || 'missing'}, traceId=${differentReplay.traceId || 'missing'}`, OPTIONS)
|
||||
}
|
||||
|
||||
if (!await ensureCompletionEvidence(context, tenantId, id(candidate.inboundId), operationBase)) return null
|
||||
|
||||
const completePath = `${PDA}/tasks/${taskId}/complete`
|
||||
const completePayload = {
|
||||
expectedTaskVersion: Number(picked?.version), operationId: `${operationBase}-complete`.slice(0, 128),
|
||||
|
||||
Reference in New Issue
Block a user