This commit is contained in:
2026-10-22 11:56:47 +08:00
parent 5d71af1ac9
commit de96e47d74
71 changed files with 1296 additions and 332 deletions
+6 -2
View File
@@ -4,9 +4,13 @@ import { resolve, dirname } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
import { AcceptanceRun } from './admin-test-env-acceptance.mjs'
import { run as prepareCustomer } from './admin-test-env-modules/merchant-qualification-fixture.mjs'
import { verifyProcurementSample } from './admin-test-env-modules/procurement-sample-fulfillment.mjs'
import { verifyProcurementSample, PROCUREMENT_REQUIRED_AVAILABLE_BALANCE } from './admin-test-env-modules/procurement-sample-fulfillment.mjs'
const PNG = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=', 'base64')
export function requireExistingProcurementBalance(account) {
if (account?.availableBalance == null || !Number.isFinite(Number(account.availableBalance))
|| Number(account.availableBalance) < Number(PROCUREMENT_REQUIRED_AVAILABLE_BALANCE)) throw new Error(`采购样本需要至少 ${PROCUREMENT_REQUIRED_AVAILABLE_BALANCE} 元现有可用余额;禁止自动充值`)
}
export function options(args) {
const value = name => { const index = args.indexOf(name); return index < 0 ? '' : args[index + 1] || '' }
if (!args.includes('--execute')) return { execute: false }
@@ -89,7 +93,7 @@ export async function execute(args = process.argv.slice(2), execArgs = process.e
return accountForCustomer(page, customerId)
}
const before = await readWallet()
requireSuccess(await context.request('POST',`/api/platform/finance/v1/accounts/${customerId}/adjustments`,{ type:'RECHARGE', amount:'10.00', occurredDate:new Date().toISOString().slice(0,10), paymentMethod:'BANK_TRANSFER', referenceNo:context.marker, remark:context.marker, expectedAccountVersion:before.accountVersion },context.token,{'Idempotency-Key':`${context.marker}-fund`}))
requireExistingProcurementBalance(before)
const upload = async (orderNo,category) => requireSuccess(await context.requestMultipart('POST',`/api/platform/v1/last-leg/overseas-procurements/${encodeURIComponent(orderNo)}/files/${category}?customerId=${customerId}`,{ content:PNG,type:'image/png',name:`${category.toLowerCase()}.png` }))
report.status = 'RUNNING'; await checkpoint()
await verifyProcurementSample(context,{ marker:context.marker,customerId,customerName:fixture.tenantName,customerToken,warehouseId:config.warehouseId,readWallet,upload })