fix(order): enforce versioned platform commands and submissions

This commit is contained in:
2026-10-02 23:14:24 +08:00
parent 25580dab86
commit c55ecabbfb
27 changed files with 540 additions and 74 deletions
@@ -1,4 +1,5 @@
import { loadOneFragment } from './phase3-order-splitting.mjs'
import { freezeOrderCommand } from './orders.mjs'
import { verifyPalletLabels } from './phase3-loading-finalize.mjs'
import { stableLoadedCartonMarks } from './phase3-loading.mjs'
import { awaitProducerConsumption, convertReceivingContainers, runReceiving, resolveSharedWarehouse,
@@ -247,9 +248,12 @@ export async function cancelUnloadedRemainder(context, proof, customerId, rootOr
'raw-approved-root/child; one-loaded-root/one-unloaded-remainder')
proof.snapshots.push({phase:'BEFORE_REMAINDER_CANCELLATION',...before,tree,childInbound:childInbound.summary})
const cancelPath = query(`/api/platform/v1/orders/first-leg/${childOrderId}/cancel`,{tenantId:customerId})
const cancelBody = {reason:`${context.context.f40BaseMarker} 未装柜余量取消验收`}
const cancelCommand = freezeOrderCommand({order:before.child.rawOrder}, `${context.context.f40BaseMarker}-cancel-remainder`.slice(0,128),
{reason:`${context.context.f40BaseMarker} 未装柜余量取消验收`})
proof.cancelCommand = cancelCommand
const cancelBody = cancelCommand.body
proof.currentStage = 'REMAINDER_CANCELLATION'
await api(context,'POST','正式取消未装柜 APPROVED 余量订单',cancelPath,cancelBody)
await api(context,'POST','正式取消未装柜 APPROVED 余量订单',cancelPath,cancelBody,context.token,cancelCommand.headers)
const after = await waitState(() => state(context,customerId,rootOrderId,childOrderId,rootInboundId),
validRemainderCancellationGate)
check(context,'F40 最后有效未装余量取消后根仅完成一次且子未签收',validRemainderCancellationGate(after),
@@ -268,9 +272,13 @@ export async function cancelUnloadedRemainder(context, proof, customerId, rootOr
value => exactCancelledRemainderOutboxProof(value,customerId,rootOrderId,childOrderId),30) : null
if (beforeOutbox) check(context,'F40 取消后唯一根完成Outbox且取消子完成Outbox为零',
exactCancelledRemainderOutboxProof(beforeOutbox,customerId,rootOrderId,childOrderId),'exact-root-one/cancelled-child-zero')
const replay = await context.request('POST',cancelPath,cancelBody)
check(context,'F40 取消重放按当前非幂等状态接口返回 A0409',
replay?.http === 200 && String(replay?.body?.code) === 'A0409','cancel-replay-conflict',replay)
const replay = await context.request('POST',cancelPath,cancelBody,context.token,cancelCommand.headers)
check(context,'F40 原键原版本取消重放成功',success(replay),'cancel-original-key-replay',replay)
const conflict = await context.request('POST',cancelPath,{...cancelBody,reason:`${cancelBody.reason}-conflict`},context.token,cancelCommand.headers)
check(context,'F40 原键不同取消载荷返回 A0409',conflict?.http === 200 && String(conflict?.body?.code) === 'A0409','cancel-payload-conflict',conflict)
const duplicate = freezeOrderCommand({order:after.child.rawOrder}, `${context.context.f40BaseMarker}-cancel-new-key`.slice(0,128), {reason:cancelBody.reason})
const rejected = await context.request('POST',cancelPath,duplicate.body,context.token,duplicate.headers)
check(context,'F40 新键重复取消返回 A0409',rejected?.http === 200 && String(rejected?.body?.code) === 'A0409','cancel-new-key-conflict',rejected)
const stable = await state(context,customerId,rootOrderId,childOrderId,rootInboundId)
const replayTree = await api(context,'GET','取消重放后回查原履约树',treePath)
check(context,'F40 取消重放订单版本历史根摘要及履约台账零变化',