fix(procurement): read MySQL fulfillment timestamps with JDBC types
This commit is contained in:
@@ -54,9 +54,9 @@ function partnerWarehousePayload(context) {
|
||||
const suffix = String(context.marker || '').replace(/[^A-Za-z0-9]/g, '').slice(-20).toUpperCase()
|
||||
return {
|
||||
tenantId: 0, warehouseCode: `P4B-${suffix}`.slice(0, 50), warehouseName: `${context.marker} 采购合作仓`,
|
||||
warehouseType: 'OVERSEAS_PARTNER', countryCode: 'US', timezone: 'UTC-8', contactName: 'Phase4 QA',
|
||||
warehouseType: 'OVERSEAS', countryCode: 'US', timezone: 'UTC-8', contactName: 'Phase4 QA',
|
||||
contactPhone: '12135550177', contactEmail: null, status: 'ACTIVE', remark: `${context.marker}-procurement-fixture`,
|
||||
address: { addressType: 'WAREHOUSE', countryCode: 'US', stateProvince: 'California', city: 'Los Angeles',
|
||||
address: { addressType: 'OPERATING', countryCode: 'US', stateProvince: 'California', city: 'Los Angeles',
|
||||
district: 'Commerce', postalCode: '90040', addressLine1: '601 Procurement Partner Avenue', addressLine2: null,
|
||||
latitude: null, longitude: null },
|
||||
capabilities: [{ capabilityCode: 'RECEIVING', capabilityName: 'Receiving', enabled: true,
|
||||
|
||||
@@ -14,6 +14,12 @@ export function options(args) {
|
||||
if (value('--environment') !== 'TEST' || !/^[A-Za-z0-9-]{1,32}$/.test(runId) || !/^[1-9]\d*$/.test(warehouseId)) throw new Error('须显式指定 TEST、唯一 run-id 和已核对的有效收货仓')
|
||||
return { execute: true, runId, warehouseId }
|
||||
}
|
||||
export function accountForCustomer(data, customerId) {
|
||||
if (!Array.isArray(data)) throw new Error('Finance账户响应须为正式数组结构')
|
||||
const account = data.find(row => String(row.customerId) === String(customerId))
|
||||
if (!account) throw new Error('账户响应未包含本轮独立客户')
|
||||
return account
|
||||
}
|
||||
export async function execute(args = process.argv.slice(2), execArgs = process.execArgv) {
|
||||
const config = options(args)
|
||||
if (!config.execute) return { mode: 'PLAN', writes: ['创建独立客户并审核资质', '仅为本轮客户充值10元', '上传样品凭证和面单', '执行采购两箱完整正常流程'], sql: false, deploy: false, cleanup: '保留样本,退出自身会话;未知结果不自动重跑' }
|
||||
@@ -80,9 +86,7 @@ export async function execute(args = process.argv.slice(2), execArgs = process.e
|
||||
const customerId = String(fixture.tenantId), customerToken = await login(fixture.username,fixture.password,'customer')
|
||||
const readWallet = async () => {
|
||||
const page = requireSuccess(await context.request('GET',`/api/platform/finance/v1/accounts?page=1&pageSize=20&customerId=${customerId}`))
|
||||
const account = page.records?.find(row => String(row.customerId) === customerId)
|
||||
if (!account) throw new Error('本轮独立客户钱包尚未初始化')
|
||||
return account
|
||||
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`}))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { execute, options } from './procurement-sample-test-env.mjs'
|
||||
import { execute, options, accountForCustomer } from './procurement-sample-test-env.mjs'
|
||||
|
||||
test('default preview needs no credentials and performs no execution', async () => {
|
||||
const result = await execute([], [])
|
||||
@@ -15,3 +15,10 @@ test('execution rejects an absent or different environment file before login', a
|
||||
await assert.rejects(execute(args, []), /TEST 环境文件/)
|
||||
await assert.rejects(execute(args, ['--env-file=C:\\private\\production.env']), /TEST 环境文件/)
|
||||
})
|
||||
|
||||
test('Finance uses a data array and matches the exact customer without numeric coercion', () => {
|
||||
const row = { customerId:'9007199254740993', accountVersion:0, actualBalance:'0.00' }
|
||||
assert.equal(accountForCustomer([{ customerId:'9007199254740992' }, row], '9007199254740993'), row)
|
||||
assert.throws(() => accountForCustomer({ records:[row] }, row.customerId), /正式数组/)
|
||||
assert.throws(() => accountForCustomer([], row.customerId), /本轮独立客户/)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user