60 行
1.9 KiB
JavaScript
60 行
1.9 KiB
JavaScript
const path = require("node:path");
|
|
const { spawnSync } = require("node:child_process");
|
|
|
|
const { encryptStringOrThrow } = require("../src/services/crypto");
|
|
const { generatePaymentOrderXls } = require("../src/services/paymentOrderXls");
|
|
|
|
const fieldEncryptionKey = Buffer.alloc(32, 7).toString("base64");
|
|
const config = { fieldEncryptionKey };
|
|
const encrypt = (value) => encryptStringOrThrow(config, value);
|
|
const syntheticAccounts = [
|
|
"6222000000000012345",
|
|
"6222000000000023456",
|
|
"6222000000000034567",
|
|
"6222000000000045678",
|
|
];
|
|
|
|
const generated = generatePaymentOrderXls(config, {
|
|
batch_no: "PB-20260802-001",
|
|
payment_account_snapshot_json: {
|
|
bankInstitutionCode: "CCB",
|
|
accountName: "合成测试公司",
|
|
bankName: "中国建设银行",
|
|
accountNumberEncrypted: encrypt("6217000000000012345"),
|
|
},
|
|
items: syntheticAccounts.map((account, index) => ({
|
|
id: String(index + 1),
|
|
entity_code: `BX-20260802-${String(index + 1).padStart(4, "0")}`,
|
|
amount: `${index + 1}.20`,
|
|
snapshot_json: {
|
|
payee: {
|
|
name: `合成员工${index + 1}`,
|
|
bankName: "中国建设银行",
|
|
bankInstitutionCode: "CCB",
|
|
bankAccountEncrypted: encrypt(account),
|
|
},
|
|
},
|
|
})),
|
|
});
|
|
|
|
const pythonBin = process.env.PAYMENT_ORDER_PYTHON_BIN ?? "python3";
|
|
const verifier = spawnSync(pythonBin, [path.resolve(__dirname, "verify-payment-order-xls.py")], {
|
|
input: generated.buffer,
|
|
encoding: "utf8",
|
|
maxBuffer: 16 * 1024 * 1024,
|
|
timeout: 15_000,
|
|
env: {
|
|
PATH: path.isAbsolute(pythonBin) ? path.dirname(pythonBin) : "/usr/local/bin:/usr/bin:/bin",
|
|
LANG: "C.UTF-8",
|
|
PYTHONDONTWRITEBYTECODE: "1",
|
|
PYTHONNOUSERSITE: "1",
|
|
},
|
|
});
|
|
|
|
if (verifier.status !== 0 || verifier.error) {
|
|
process.stderr.write(verifier.stderr || "[payment-order-xls][FAIL] verifier unavailable\n");
|
|
process.exitCode = 1;
|
|
} else {
|
|
process.stdout.write(verifier.stdout);
|
|
}
|