feat(corporate-bank-account-payment-order): 基于原模板生成建行制单

这个提交包含在:
2026-08-03 01:18:10 +08:00
父节点 91564d6774
当前提交 23c3768c46
共修改 19 个文件,包含 713 行新增和 152 行删除
+9 -6
查看文件
@@ -718,12 +718,12 @@ function paymentOrderExportBlockers(batch) {
const add = (code, entityCode) => blockers.push({ code, ...(entityCode ? { entityCode } : {}) });
if (batch.status !== "reviewed") add("status_not_reviewed");
if (batch.entity_type !== "reimbursement") add("reimbursement_only");
if (batch.default_payment_channel !== "bank") add("bank_channel_required");
if (!batch.payment_account_snapshot_json) {
add("legacy_payment_account_snapshot_missing");
} else {
const payer = readPaymentAccountSnapshot(batch.payment_account_snapshot_json);
if (!payer) add("payment_account_snapshot_invalid");
if (!batch.payment_account_snapshot_json.accountNumberEncrypted) add("payer_account_unavailable");
if (payer && !payer.bankInstitutionCode) add("payer_bank_institution_missing");
else if (payer && payer.bankInstitutionCode !== "CCB") add("payer_bank_not_supported");
}
@@ -731,9 +731,14 @@ function paymentOrderExportBlockers(batch) {
for (const item of batch.items ?? []) {
const entityCode = normalizeSnapshotText(item.entity_code) ?? undefined;
const payee = item.snapshot_json?.payee;
if (resolveItemPaymentChannel(batch, item) !== "bank") add("bank_channel_required", entityCode);
if (!payee?.bankAccountEncrypted) add("legacy_payee_snapshot_missing", entityCode);
if (!payee?.bankInstitutionCode) add("payee_bank_institution_missing", entityCode);
else if (payee.bankInstitutionCode !== "CCB") add("payee_bank_not_supported", entityCode);
const safePayee = readSnapshotPayee(item.snapshot_json);
if (!safePayee?.name) add("payee_name_missing", entityCode);
if (!safePayee?.bankName) add("payee_bank_name_missing", entityCode);
if (!safePayee?.bankAccountMasked) add("payee_account_masked_missing", entityCode);
}
return blockers;
}
@@ -1581,11 +1586,9 @@ async function paymentBatchesRoutes(fastify) {
result = await fastify.prisma.$transaction(async (tx) => {
const batch = await lockBatchWithItems(tx, batchId);
await ensureBatchSourceDepartmentsEnabled(fastify, tx, batch);
if (batch.status !== "reviewed") {
throw buildValidationError({ status: "payment_order_requires_reviewed_batch" }, 409);
}
if (batch.entity_type !== "reimbursement") {
throw buildValidationError({ entityType: "payment_order_reimbursement_only" }, 409);
const blockers = paymentOrderExportBlockers(batch);
if (blockers.length) {
throw new PaymentOrderXlsError(blockers[0].code, { blockers });
}
const generated = generatePaymentOrderXls(fastify.config, batch);
const exportCount = Number(batch.payment_order_export_count ?? 0) + 1;