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
+3 -1
View File
@@ -416,8 +416,10 @@ export async function executeCandidates({ candidates, limit, concurrency = 1, st
entry.orderNo = draft.order.orderNo
entry.declarationVerified = true
if (['pending-review', 'wait-split'].includes(stage)) {
if (!Number.isSafeInteger(draft.order.version) || draft.order.version < 0) throw Error('SUBMIT_VERSION_MISSING')
entry.submitCommand = { body: { expectedVersion: draft.order.version }, headers: { 'Idempotency-Key': `${marker}-submit` } }
entry.stage = 'submit'; await save()
await api('POST', `${clientPath}/submit`, undefined, merchant, { 'Idempotency-Key': `${marker}-submit` })
await api('POST', `${clientPath}/submit`, entry.submitCommand.body, merchant, entry.submitCommand.headers)
}
if (stage === 'pending-review') {
const submitted = await api('GET', clientPath, undefined, merchant)