优化
This commit is contained in:
@@ -2,6 +2,7 @@ import { verifyReceivedOrderHold } from './phase4-tail-order-controls.mjs'
|
||||
import { verifyPdaWarehouseRevocation } from './unified-pda-session-revocation.mjs'
|
||||
|
||||
const MODULE = 'phase4-overseas-pda-operations'
|
||||
export const RELABEL_CHARGE_AMOUNT = 0.01
|
||||
const SCENARIO = 'phase4-overseas-pda-p2-p5'
|
||||
const OPTIONS = { scenario: SCENARIO, deploymentBlocker: true }
|
||||
const PNG = Uint8Array.from(Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=', 'base64'))
|
||||
@@ -63,7 +64,7 @@ async function poll(action, predicate, attempts = 60) {
|
||||
return { result, attempts }
|
||||
}
|
||||
|
||||
async function fundRelabelWallet(context, customerId) {
|
||||
export async function fundRelabelWallet(context, customerId) {
|
||||
const accountResponse = await context.request('GET',
|
||||
`/api/platform/finance/v1/accounts?page=1&pageSize=20&customerId=${encodeURIComponent(customerId)}`)
|
||||
const account = success(accountResponse)
|
||||
@@ -71,6 +72,13 @@ async function fundRelabelWallet(context, customerId) {
|
||||
context.addStep(MODULE, 'P5读取本轮客户钱包版本', accountResponse,
|
||||
Boolean(account) && Number.isInteger(Number(account.accountVersion)), trace(accountResponse), OPTIONS)
|
||||
if (!account) return false
|
||||
if (context.options?.fixedCustomerId) {
|
||||
const sufficient = account.availableBalance != null && Number.isFinite(Number(account.availableBalance))
|
||||
&& Number(account.availableBalance) >= RELABEL_CHARGE_AMOUNT
|
||||
context.addStep(MODULE, '复用已有可用余额;不足时禁止自动充值', accountResponse,
|
||||
sufficient, `availableBalance=${account.availableBalance ?? 'missing'}`, OPTIONS)
|
||||
return sufficient
|
||||
}
|
||||
const recharge = await context.request('POST',
|
||||
`/api/platform/finance/v1/accounts/${encodeURIComponent(customerId)}/adjustments`, {
|
||||
type: 'RECHARGE', amount: 1, occurredDate: new Date().toISOString().slice(0, 10),
|
||||
@@ -415,7 +423,7 @@ async function verifyRelabel(context, token, merchantToken, fixture) {
|
||||
const createBody = {
|
||||
customerOrderNo: String(customerOrderNo).slice(0, 128), operationWarehouseId: id(fixture.overseasWarehouseId),
|
||||
labelDeadline: new Date(Date.now() + 7 * 86400000).toISOString().slice(0, 19),
|
||||
contactName: 'PDA换标验收', contactPhone: '13800000006', chargeAmount: 0.01, remark: context.marker,
|
||||
contactName: 'PDA换标验收', contactPhone: '13800000006', chargeAmount: RELABEL_CHARGE_AMOUNT, remark: context.marker,
|
||||
idempotencyKey: key(context, 'RELABEL-CREATE'),
|
||||
deliveryMethod: 'TRUCK', printShippingLabel: false,
|
||||
items: sourceLines.map(({ source, position, packageCount }, index) => {
|
||||
|
||||
Reference in New Issue
Block a user