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,4 @@
import { findPricedOrderRouteAcrossOrigins } from './orders.mjs'
import { findPricedOrderRouteAcrossOrigins, freezeOrderCommand } from './orders.mjs'
const MODULE = 'order-inbound-status-fixtures'
const OPTIONS = { scenario: 'manual-order-inbound-status-matrix', deploymentBlocker: true }
@@ -117,17 +117,21 @@ async function createOrder(context, token, fixture, target) {
return orderId
}
async function transition(context, token, fixture, orderId, target, action) {
export async function transition(context, token, fixture, orderId, target, action) {
const merchantPath = `/api/merchant/v1/orders/first-leg/${query(orderId)}`
if (action === 'submit') {
const response = await merchantRequest(context, 'POST', `${merchantPath}/submit`, undefined, token,
{ 'Idempotency-Key': key(context, `${target}-submit`) })
const detail = context.apiSuccess(MODULE, `${target} 冻结提交版本`, await merchantRequest(context, 'GET', merchantPath, undefined, token))
const command = freezeOrderCommand(detail, key(context, `${target}-submit`))
const response = await merchantRequest(context, 'POST', `${merchantPath}/submit`, command.body, token, command.headers)
context.apiSuccess(MODULE, `${target} 样本提交订单`, response)
return
}
const platformPath = `/api/platform/v1/orders/first-leg/${query(orderId)}/${action}?tenantId=${query(fixture.tenantId)}`
const body = action === 'reject' || action === 'cancel' ? { reason: `${context.marker} 保留 ${target} 人工样本` } : undefined
const response = await context.request('POST', platformPath, body)
const command = action === 'cancel' ? freezeOrderCommand(context.apiSuccess(MODULE, `${target} 冻结取消版本`,
await context.request('GET', `/api/platform/v1/orders/first-leg/${query(orderId)}?tenantId=${query(fixture.tenantId)}`)),
key(context, `${target}-cancel`), body) : null
const response = await context.request('POST', platformPath, command?.body ?? body, context.token, command?.headers ?? {})
context.apiSuccess(MODULE, `${target} 样本执行 ${action}`, response)
}