test(acceptance): reuse fixed customers and align native fulfillment flows

This commit is contained in:
2026-10-23 04:48:02 +08:00
parent b92f7fe991
commit 139f6b1932
51 changed files with 1076 additions and 228 deletions
@@ -4,6 +4,7 @@ export const PROCUREMENT_REQUIRED_AVAILABLE_BALANCE = '3.00'
const PLATFORM = '/api/platform/v1/last-leg/overseas-procurements'
const MERCHANT = '/api/merchant/v1/last-leg/overseas-procurements'
const clone = value => value == null ? value : structuredClone(value)
const version = value => /^(0|[1-9]\d*)$/.test(String(value)) && Number.isSafeInteger(Number(value)) ? Number(value) : NaN
const cents = value => {
const match = /^(\d+)(?:\.(\d{1,2}))?$/.exec(String(value))
if (!match) throw new Error('钱包金额缺失或精度异常')
@@ -48,11 +49,11 @@ export async function verifyProcurementSample(context, inputs) {
detail = await request('GET', path(), undefined, '回查采购聚合详情')
await check('采购聚合仍属于原客户原单且版本有效', detail?.customerView?.order?.orderNo === proof.orderNo
&& detail.customerView.order.customerId === customerId
&& Number.isSafeInteger(detail.customerView.order.version) && detail.customerView.order.version >= 0)
&& Number.isSafeInteger(version(detail.customerView.order.version)))
return detail
}
async function command(operation, values = {}, replay = false) {
const body = { version: detail.customerView.order.version, idempotencyKey: key(operation.replaceAll('/', '-')), reason: context.marker, ...values }
const body = { version: version(detail.customerView.order.version), idempotencyKey: key(operation.replaceAll('/', '-')), reason: context.marker, ...values }
await request('POST', path(operation), body, operation)
if (replay) await request('POST', path(operation), body, `${operation} 原请求重放`)
await read(); return body
@@ -84,7 +85,7 @@ export async function verifyProcurementSample(context, inputs) {
const repeated = await request('POST', MERCHANT, create, '客户同键重放', inputs.customerToken)
await check('重放没有新建采购单', repeated?.order?.orderNo === proof.orderNo && repeated.order.customerId === customerId)
await read()
await request('POST', path('review'), { version: detail.customerView.order.version, idempotencyKey: key('review'), decision: 'APPROVE', purchaseWarehouseId: String(inputs.warehouseId), remark: context.marker }, '审核通过并确定收货仓')
await request('POST', path('review'), { version: version(detail.customerView.order.version), idempotencyKey: key('review'), decision: 'APPROVE', purchaseWarehouseId: String(inputs.warehouseId), remark: context.marker }, '审核通过并确定收货仓')
await read()
const purchaseFile = await inputs.upload(proof.orderNo, 'PURCHASE')
const voucher = await inputs.upload(proof.orderNo, 'VOUCHER')