From 805fc38cf932d3c1f18dddc865905366f69ccd85 Mon Sep 17 00:00:00 2001 From: yueyang <2495544247@qq.com> Date: Thu, 19 Nov 2026 15:26:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20OA=E6=B5=81=E7=A8=8B=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E6=94=B6=E6=AC=BE=E4=BA=BA=E9=93=B6=E8=A1=8C=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=20(#1270)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...k_fields_to_ding_process_detail_mirror.php | 51 ++++++ docs/上游业务镜像清单.md | 2 +- .../Http/Controllers/ProcessDetails.php | 3 + .../DingProcessDetailMirrorImporter.php | 39 ++++- .../DingProcessDetailMirrorSynchronizer.php | 151 +++++++++++++++++- .../process-details-content.blade.php | 12 +- ...s-details-pending-payment-detail.blade.php | 8 +- .../Business/ProcessDetailsPageTest.php | 27 ++++ .../Console/ImportDingProcessDetailsTest.php | 43 +++++ .../Fixtures/ding_process_details_sample.csv | 10 +- ...ingProcessDetailMirrorSynchronizerTest.php | 9 ++ 11 files changed, 342 insertions(+), 13 deletions(-) create mode 100644 database/migrations/2026_11_19_160000_add_payee_bank_fields_to_ding_process_detail_mirror.php diff --git a/database/migrations/2026_11_19_160000_add_payee_bank_fields_to_ding_process_detail_mirror.php b/database/migrations/2026_11_19_160000_add_payee_bank_fields_to_ding_process_detail_mirror.php new file mode 100644 index 00000000..6151f512 --- /dev/null +++ b/database/migrations/2026_11_19_160000_add_payee_bank_fields_to_ding_process_detail_mirror.php @@ -0,0 +1,51 @@ +environment('testing') + || (string) config('system_database.mode', 'bootstrap') === 'bootstrap') { + return; + } + + $schema = Schema::connection($this->connection()); + if (! $schema->hasTable('ding_process_detail_mirror') + || $schema->hasColumn('ding_process_detail_mirror', 'payee_name')) { + return; + } + + $schema->table('ding_process_detail_mirror', function (Blueprint $table): void { + $table->string('payee_name', 255)->nullable()->after('paid_at'); + $table->string('payee_bank_name', 255)->nullable()->after('payee_name'); + $table->string('payee_bank_account', 100)->nullable()->after('payee_bank_name'); + }); + } + + public function down(): void + { + if (app()->environment('testing') + || (string) config('system_database.mode', 'bootstrap') === 'bootstrap') { + return; + } + + $schema = Schema::connection($this->connection()); + if (! $schema->hasTable('ding_process_detail_mirror') + || ! $schema->hasColumn('ding_process_detail_mirror', 'payee_name')) { + return; + } + + $schema->table('ding_process_detail_mirror', function (Blueprint $table): void { + $table->dropColumn(['payee_name', 'payee_bank_name', 'payee_bank_account']); + }); + } +}; diff --git a/docs/上游业务镜像清单.md b/docs/上游业务镜像清单.md index 0e328d32..61db10c5 100644 --- a/docs/上游业务镜像清单.md +++ b/docs/上游业务镜像清单.md @@ -43,7 +43,7 @@ | 已接入待首次同步 | 店铺营销账户余额的京东账户读取 `js_data_middle_platform.dbo.jd_jzt_finance_records` 镜像 `jsm_jd_jzt_finance_records`;按 `id` 稳定断点、`updated_at` 重叠增量,页面不直连上游。 | | 本次接入 | 普通商品资料的工作平台采购价格接入 `jiansun.dbo.pm_priceAdjustment`(镜像 `js_pm_price_adjustment`):按 `skuCode` 关联 `jst_sku.sku_id`,取 `effectTime` 不晚于当前时间的最新 `purchasePrice`,并在页面和导出中标记“工作平台价格”;源表没有可靠更新时间,按 `Id` 稳定键追加,首次全量完成前只显示普通商品自身采购价。 | | 待有效凭据后首次同步 | 普通商品当前成本价、商品类型和更新时间继续读取 `operations_replica.rpt.jst_sku`;`rpt.fys_skuCostPriceUpdate` 是一 SKU 一行的旧快照,不能充当变价历史。完整成本价变更仍读取聚水潭经典开放平台“商品操作日志查询”接口 `worklog.query`,只镜像操作内容含“采购价”的记录到 `jushuitan_cost_price_history_rows`;经典接口必须在服务器私有配置中使用同一应用的 `JUSHUITAN_PARTNER_ID / JUSHUITAN_PARTNER_KEY / JUSHUITAN_TOKEN`,不得把新开放平台的 App Key / App Secret / Access Token 混用。页面在首次同步完成前明确显示待同步或失败,不把 0 条解释为真实无历史。 | -| 本次接入 | 流程明细读取 `operations_replica/rpt.ding_Workflow + rpt.ding_WorkflowScheme` 的结构化审批主表、费用明细和付款明细,写入 `ding_process_detail_mirror`、`ding_process_payment_mirror` 与付款按明细行分摊的 `ding_process_payment_line_mirror`;主表的 `originatorDeptName` 作为发起人部门单独保留,费用明细行的“店铺”字段规范化写入 `store_name`。禁止先把明细表和付款表铺平成 CSV 后逐行求和;付款明细必须按“对应序号”关联到代表明细行,但合计始终读取独立付款事实。管理费用按分摊后的付款月份统计,跨月分笔付款不会把整张审批重复计入多月。每个纳入范围的源审批至少保留一条页面记录,没有费用金额的审批以空金额显示,不静默隐藏。首次全量先运行 `business-mirror:sync-ding-process-details --full --dry-run` 校验,再使用 `business-mirror:sync-ding-process-details --full` 发布;日常通过 `updateAt/createAt` 48 小时重叠增量同步。当前纳入日常报销、应付、线上代发、种菜、快递面单、固定资产、日常物品、样品、一次性采买、板材、工资、外贸费用和种菜充值等 14 个财务流程;发现新的明细流程编码时全量同步报错并保留上一版。 | +| 本次接入 | 流程明细读取 `operations_replica/rpt.ding_Workflow + rpt.ding_WorkflowScheme` 的结构化审批主表、费用明细和付款明细,写入 `ding_process_detail_mirror`、`ding_process_payment_mirror` 与付款按明细行分摊的 `ding_process_payment_line_mirror`;主表的 `originatorDeptName` 作为发起人部门单独保留,费用明细行的“店铺”字段规范化写入 `store_name`。审批表单表头的 `收款人全称 / 开户银行 / 银行账号` 分别写入 `payee_name / payee_bank_name / payee_bank_account`,同一审批下的每条费用明细继承对应值;行级或付款明细存在更具体值时优先使用。禁止先把明细表和付款表铺平成 CSV 后逐行求和;付款明细必须按“对应序号”关联到代表明细行,但合计始终读取独立付款事实。管理费用按分摊后的付款月份统计,跨月分笔付款不会把整张审批重复计入多月。每个纳入范围的源审批至少保留一条页面记录,没有费用金额的审批以空金额显示,不静默隐藏。首次全量先运行 `business-mirror:sync-ding-process-details --full --dry-run` 校验,再使用 `business-mirror:sync-ding-process-details --full` 发布;日常通过 `updateAt/createAt` 48 小时重叠增量同步。当前纳入日常报销、应付、线上代发、种菜、快递面单、固定资产、日常物品、样品、一次性采买、板材、工资、外贸费用和种菜充值等 14 个财务流程;发现新的明细流程编码时全量同步报错并保留上一版。 | | 本次接入 | 财务经营报表 › 管理费用使用 `oa_process_account_mapping` 保存流程科目映射;当前快照包含原工作簿 191 个科目和补充的 `5601.11.01 货代费`、`1221.07 种菜备用金`、`5602.11.03.19 AI阿里云软件费`,共 194 个科目,其中 37 个进费比科目和 126 个分摊规则。页面按打款时间提供整月选择并默认展示上个月 OA 流程中审批状态为“已完成”、涉及付款且出纳已打款的明细,不涉及付款或出纳未打款的数据不进入汇总,按费用大类和二级汇总进费比/不进费比/未映射金额,点击二级查看三级汇总与 9 列明细模板。审批完成时间写入 `ding_process_detail_mirror.approval_finished_at`,页面月份筛选使用 `ding_process_detail_mirror.paid_at`;钉钉副本把费用明细表保存为未命名字段时,按配置中的金额列识别包含该列的未命名表格组件,避免只抓到付款明细而漏掉费用科目和金额。明细行没有科目时,使用同一审批表单表头的 `科目编码 / 科目名称` 回填;行级科目始终优先。 | | 本次接入 | 订单利润的包材费、快递费、账单费用直接读取聚胜算订单利润页面接口 `pf.erp321.com/WebApi/PF/OrderSku/GetOrderSkuList`(支付/发货时间口径各分页抓取),导入 `ops_shengsuan_order_profit_rows`,页面按“店铺 + 线上/内部单号”原样回填,不把 0 或推算值写入缺口。异常订单再通过 `GetPfOrderDetList` 按每批最多 50 单抓取完整订单商品明细,保存至 `ops_shengsuan_order_profit_detail_snapshots`,包括全部订单字段、销售商品明细、退货商品明细和缺成本商品编码。主表抓取脚本为 `scripts/order-profit-shengsuan-sync.py`,明细补同步脚本为 `scripts/order-profit-shengsuan-details-sync.py`;导入命令分别为 `order-profit:import-shengsuan-rows`、`order-profit:import-shengsuan-details`。脚本依赖本机已登录胜算的 Chrome 调试窗口,不能由服务器容器直连页面。`成本/运费异常`按主表“商品成本或快递费任一为0/空”筛选,分别标记“成本异常”“运费异常”,并在订单下按具体商品编码展示缺成本条码,以发货时间为监控日期。 | diff --git a/modules/EcommerceFinance/Http/Controllers/ProcessDetails.php b/modules/EcommerceFinance/Http/Controllers/ProcessDetails.php index 81e48b8d..12a4e929 100644 --- a/modules/EcommerceFinance/Http/Controllers/ProcessDetails.php +++ b/modules/EcommerceFinance/Http/Controllers/ProcessDetails.php @@ -133,6 +133,9 @@ class ProcessDetails extends Controller $row['bank_amount'] ?? '', (string) ($row['payment_method'] ?? ''), (string) ($row['paid_at'] ?? ''), + (string) ($row['payee_name'] ?? ''), + (string) ($row['payee_bank_name'] ?? ''), + (string) ($row['payee_bank_account'] ?? ''), (string) ($row['payment_state'] ?? ''), isset($row['payment_difference']) ? number_format((float) $row['payment_difference'], 2, '.', '') diff --git a/modules/EcommerceFinance/Services/DingProcessDetailMirrorImporter.php b/modules/EcommerceFinance/Services/DingProcessDetailMirrorImporter.php index d6693333..e5701a71 100644 --- a/modules/EcommerceFinance/Services/DingProcessDetailMirrorImporter.php +++ b/modules/EcommerceFinance/Services/DingProcessDetailMirrorImporter.php @@ -13,7 +13,7 @@ class DingProcessDetailMirrorImporter public const DEFAULT_SCOPE = 'personal_permission'; - public const HEADERS = [ + public const REQUIRED_HEADERS = [ '序号', '审批编号', '发起人', @@ -31,6 +31,17 @@ class DingProcessDetailMirrorImporter '打款时间', ]; + public const OPTIONAL_HEADERS = [ + '收款人全称', + '开户银行', + '银行账号', + ]; + + public const HEADERS = [ + ...self::REQUIRED_HEADERS, + ...self::OPTIONAL_HEADERS, + ]; + private readonly ConnectionInterface $connection; public function __construct(DatabaseManager $database) @@ -97,6 +108,9 @@ class DingProcessDetailMirrorImporter 'bank_amount', 'payment_method', 'paid_at', + 'payee_name', + 'payee_bank_name', + 'payee_bank_account', 'source_scope', 'synced_at', 'updated_at', @@ -171,7 +185,7 @@ class DingProcessDetailMirrorImporter $header[0] = preg_replace('/^\xEF\xBB\xBF/', '', (string) $header[0]); $header = array_map(static fn (mixed $value): string => trim((string) $value), $header); - $missing = array_values(array_diff(self::HEADERS, $header)); + $missing = array_values(array_diff(self::REQUIRED_HEADERS, $header)); if ($missing !== []) { throw new RuntimeException('流程明细 CSV 缺少列:' . implode('、', $missing)); @@ -212,6 +226,9 @@ class DingProcessDetailMirrorImporter } $key = $businessId . '|' . (int) $lineNo; + $payeeNameIndex = $index['收款人全称'] ?? null; + $payeeBankNameIndex = $index['开户银行'] ?? null; + $payeeBankAccountIndex = $index['银行账号'] ?? null; $candidate = [ 'business_id' => mb_substr($businessId, 0, 32), 'line_no' => (int) $lineNo, @@ -230,6 +247,21 @@ class DingProcessDetailMirrorImporter 'bank_amount' => $this->decimal($data[$index['银行付款金额']] ?? null), 'payment_method' => mb_substr(trim((string) ($data[$index['付款方式']] ?? '')), 0, 50), 'paid_at' => mb_substr(trim((string) ($data[$index['打款时间']] ?? '')), 0, 50), + 'payee_name' => mb_substr( + trim((string) ($payeeNameIndex === null ? '' : ($data[$payeeNameIndex] ?? ''))), + 0, + 255, + ), + 'payee_bank_name' => mb_substr( + trim((string) ($payeeBankNameIndex === null ? '' : ($data[$payeeBankNameIndex] ?? ''))), + 0, + 255, + ), + 'payee_bank_account' => mb_substr( + trim((string) ($payeeBankAccountIndex === null ? '' : ($data[$payeeBankAccountIndex] ?? ''))), + 0, + 100, + ), 'source_scope' => $scope, 'synced_at' => $now, 'created_at' => $now, @@ -279,6 +311,9 @@ class DingProcessDetailMirrorImporter $score += is_numeric($row['bank_amount'] ?? null) && (float) $row['bank_amount'] !== 0.0 ? 2 : 0; $score += trim((string) ($row['paid_at'] ?? '')) !== '' && trim((string) ($row['paid_at'] ?? '')) !== '251' ? 1 : 0; + $score += trim((string) ($row['payee_name'] ?? '')) !== '' ? 1 : 0; + $score += trim((string) ($row['payee_bank_name'] ?? '')) !== '' ? 1 : 0; + $score += trim((string) ($row['payee_bank_account'] ?? '')) !== '' ? 1 : 0; return $score; } diff --git a/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php b/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php index 52f4d76a..d362f5e6 100644 --- a/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php +++ b/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php @@ -968,6 +968,9 @@ class DingProcessDetailMirrorSynchronizer '支付方式', '付款方式', '打款时间', + '收款人全称', + '开户银行', + '银行账号', ]; foreach ((array) config('upstream_mirrors.ding_process_details.processes', []) as $process) { foreach ([ @@ -1101,6 +1104,27 @@ class DingProcessDetailMirrorSynchronizer if ($workflowDetails === []) { $amount = $this->moneyFromFields($fields, (array) ($process['detail_amount_fields'] ?? [])); + $approvalFields = (array) ($approvalSnapshot['form_values'] ?? []); + $payeeName = $this->rowOrFieldValue( + [], + $fields, + ['收款人全称', '收款人名称', '收款人'], + ) ?: $this->rowOrFieldValue( + [], + $approvalFields, + ['收款人全称', '收款人名称', '收款人'], + ); + $payeeBankName = $this->rowOrFieldValue([], $fields, ['开户银行', '开户行']) + ?: $this->rowOrFieldValue([], $approvalFields, ['开户银行', '开户行']); + $payeeBankAccount = $this->rowOrFieldValue( + [], + $fields, + ['银行账号', '银行帐号', '银行卡号'], + ) ?: $this->rowOrFieldValue( + [], + $approvalFields, + ['银行账号', '银行帐号', '银行卡号'], + ); $workflowDetails[] = $this->detailRecord( $workflow, $process, @@ -1113,6 +1137,9 @@ class DingProcessDetailMirrorSynchronizer '', '', '', + $payeeName, + $payeeBankName, + $payeeBankAccount, $this->storeName([], $fields), $originator, $documentType, @@ -1295,6 +1322,34 @@ class DingProcessDetailMirrorSynchronizer $accountCode = trim((string) ($row['科目编码'] ?? '')); $accountName = trim((string) ($row['科目名称'] ?? '')); $storeName = $this->storeName($row, $fields); + $payeeName = $this->rowOrFieldValue( + $row, + $fields, + ['收款人全称', '收款人名称', '收款人'], + ); + $payeeBankName = $this->rowOrFieldValue($row, $fields, ['开户银行', '开户行']); + $payeeBankAccount = $this->rowOrFieldValue( + $row, + $fields, + ['银行账号', '银行帐号', '银行卡号'], + ); + if ($payeeName === '') { + $payeeName = $this->rowOrFieldValue( + [], + $approvalFields, + ['收款人全称', '收款人名称', '收款人'], + ); + } + if ($payeeBankName === '') { + $payeeBankName = $this->rowOrFieldValue([], $approvalFields, ['开户银行', '开户行']); + } + if ($payeeBankAccount === '') { + $payeeBankAccount = $this->rowOrFieldValue( + [], + $approvalFields, + ['银行账号', '银行帐号', '银行卡号'], + ); + } if ($accountCode === '') { $accountCode = trim((string) $this->scalarValue($fields['科目编码'] ?? null)); } @@ -1321,6 +1376,9 @@ class DingProcessDetailMirrorSynchronizer $accountName, $invoiceTitle, $cashierPaymentTitle, + $payeeName, + $payeeBankName, + $payeeBankAccount, $storeName, $originator, $documentType, @@ -1371,6 +1429,14 @@ class DingProcessDetailMirrorSynchronizer '开票抬头', '发票抬头', '出纳打款抬头', + '收款人全称', + '收款人名称', + '收款人', + '开户银行', + '开户行', + '银行账号', + '银行帐号', + '银行卡号', ] as $field) { if (trim((string) ($row[$field] ?? '')) === '' && trim((string) ($officialRow[$field] ?? '')) !== '') { @@ -1533,6 +1599,7 @@ class DingProcessDetailMirrorSynchronizer 'account_name' => mb_substr(trim((string) ($row['科目名称'] ?? '')), 0, 255), 'payment_method' => mb_substr(trim((string) ($row['付款方式'] ?? '')), 0, 50), 'paid_at' => mb_substr($paidAt, 0, 50), + ...$this->payeeFields($row, $fields), 'source_scope' => $scope, 'synced_at' => $now, 'created_at' => $now, @@ -1573,6 +1640,7 @@ class DingProcessDetailMirrorSynchronizer 0, 50, ), + ...$this->payeeFields([], $fields), 'source_scope' => $scope, 'synced_at' => $now, 'created_at' => $now, @@ -2064,6 +2132,19 @@ class DingProcessDetailMirrorSynchronizer $detail['bank_account_name'] = $this->joinUnique($group, 'account_name', 255); $detail['payment_method'] = $this->joinUnique($group, 'payment_method', 50); $detail['paid_at'] = $this->joinUnique($group, 'paid_at', 50); + if (trim((string) ($detail['payee_name'] ?? '')) === '') { + $detail['payee_name'] = $this->joinUnique($group, 'payee_name', 255); + } + if (trim((string) ($detail['payee_bank_name'] ?? '')) === '') { + $detail['payee_bank_name'] = $this->joinUnique($group, 'payee_bank_name', 255); + } + if (trim((string) ($detail['payee_bank_account'] ?? '')) === '') { + $detail['payee_bank_account'] = $this->joinUnique( + $group, + 'payee_bank_account', + 100, + ); + } } unset($detail); } @@ -2085,6 +2166,9 @@ class DingProcessDetailMirrorSynchronizer string $accountName, string $invoiceTitle, string $cashierPaymentTitle, + string $payeeName, + string $payeeBankName, + string $payeeBankAccount, string $storeName, string $originator, string $documentType, @@ -2138,6 +2222,9 @@ class DingProcessDetailMirrorSynchronizer 'bank_amount' => null, 'payment_method' => null, 'paid_at' => null, + 'payee_name' => mb_substr($payeeName, 0, 255), + 'payee_bank_name' => mb_substr($payeeBankName, 0, 255), + 'payee_bank_account' => mb_substr($payeeBankAccount, 0, 100), 'source_scope' => $scope, 'synced_at' => $now, 'created_at' => $now, @@ -2299,6 +2386,63 @@ class DingProcessDetailMirrorSynchronizer return ''; } + /** + * @param array $row + * @param array $fields + * @param list $names + */ + private function rowOrFieldValue(array $row, array $fields, array $names): string + { + foreach ($names as $name) { + if (array_key_exists($name, $row)) { + $value = trim((string) ($row[$name] ?? '')); + if ($value !== '') { + return $value; + } + } + + $fieldValue = $fields[$name] ?? null; + if (is_array($fieldValue) + && array_key_exists('value', $fieldValue) + && is_scalar($fieldValue['value'])) { + $value = trim((string) $fieldValue['value']); + } else { + $value = $this->scalarValue($fieldValue); + } + if ($value !== '') { + return $value; + } + } + + return ''; + } + + /** + * @param array $row + * @param array $fields + * @return array{payee_name:string,payee_bank_name:string,payee_bank_account:string} + */ + private function payeeFields(array $row, array $fields): array + { + return [ + 'payee_name' => mb_substr( + $this->rowOrFieldValue($row, $fields, ['收款人全称', '收款人名称', '收款人']), + 0, + 255, + ), + 'payee_bank_name' => mb_substr( + $this->rowOrFieldValue($row, $fields, ['开户银行', '开户行']), + 0, + 255, + ), + 'payee_bank_account' => mb_substr( + $this->rowOrFieldValue($row, $fields, ['银行账号', '银行帐号', '银行卡号']), + 0, + 100, + ), + ]; + } + /** * Store names are commonly nested JSON arrays in DingTalk table cells. * @@ -2458,7 +2602,12 @@ class DingProcessDetailMirrorSynchronizer return $row; }, $details); $payments = array_map(function (array $row): array { - unset($row['amount_cents']); + unset( + $row['amount_cents'], + $row['payee_name'], + $row['payee_bank_name'], + $row['payee_bank_account'], + ); return $row; }, $payments); diff --git a/resources/views/business/pages/financial-operations/process-details-content.blade.php b/resources/views/business/pages/financial-operations/process-details-content.blade.php index 61046103..4bbc697f 100644 --- a/resources/views/business/pages/financial-operations/process-details-content.blade.php +++ b/resources/views/business/pages/financial-operations/process-details-content.blade.php @@ -750,7 +750,7 @@ } .process-details-pending-detail__table { - min-width: 106rem; + min-width: 118rem; } .process-details-note-disclosure { @@ -825,7 +825,7 @@ .process-details-table { width: 100%; - min-width: 106rem; + min-width: 118rem; border-collapse: separate; border-spacing: 0; font-size: .78rem; @@ -1621,6 +1621,9 @@ 付款差额 付款方式 打款时间 + 收款人全称 + 开户银行 + 银行账号 @endif @@ -1703,11 +1706,14 @@ {{ $money($row->payment_difference) }} {{ $text($row->payment_method) }} {{ $text($row->paid_at) }} + {{ $text($row->payee_name ?? null) }} + {{ $text($row->payee_bank_name ?? null) }} + {{ $text($row->payee_bank_account ?? null) }} @endif @empty - + 当前筛选条件没有OA流程数据。可以调整月份、单据类型、状态或关键词后重试。 diff --git a/resources/views/business/pages/financial-operations/process-details-pending-payment-detail.blade.php b/resources/views/business/pages/financial-operations/process-details-pending-payment-detail.blade.php index 5e4fec93..3f72412e 100644 --- a/resources/views/business/pages/financial-operations/process-details-pending-payment-detail.blade.php +++ b/resources/views/business/pages/financial-operations/process-details-pending-payment-detail.blade.php @@ -109,6 +109,9 @@ 付款差额 付款方式 打款时间 + 收款人全称 + 开户银行 + 银行账号 @@ -141,10 +144,13 @@ {{ $money($row->payment_difference ?? null) }} {{ $text($row->payment_method ?? null) }} {{ $text($row->paid_at ?? null) }} + {{ $text($row->payee_name ?? null) }} + {{ $text($row->payee_bank_name ?? null) }} + {{ $text($row->payee_bank_account ?? null) }} @empty - + 当前审批人和筛选条件下没有待付款明细。 diff --git a/tests/Feature/Business/ProcessDetailsPageTest.php b/tests/Feature/Business/ProcessDetailsPageTest.php index 59654ade..e7059853 100644 --- a/tests/Feature/Business/ProcessDetailsPageTest.php +++ b/tests/Feature/Business/ProcessDetailsPageTest.php @@ -47,6 +47,9 @@ class ProcessDetailsPageTest extends FeatureTestCase 'payment_difference' => 0.00, 'payment_method' => '银行卡', 'paid_at' => '2026-01-02 00:00', + 'payee_name' => '沃曾朝', + 'payee_bank_name' => '江南农村商业银行', + 'payee_bank_account' => '623189110018550628', ], ], 'total' => 1, @@ -154,6 +157,12 @@ class ProcessDetailsPageTest extends FeatureTestCase ->assertDontSee('未核验') ->assertSee('付款明细金额', false) ->assertSee('付款差额', false) + ->assertSee('收款人全称', false) + ->assertSee('开户银行', false) + ->assertSee('银行账号', false) + ->assertSee('沃曾朝') + ->assertSee('江南农村商业银行') + ->assertSee('623189110018550628') ->assertDontSee('付款合计', false) ->assertDontSee('银行付款合计') ->assertSee('流程数据已超过 15 分钟未成功同步') @@ -434,6 +443,9 @@ class ProcessDetailsPageTest extends FeatureTestCase 'payment_difference' => 880.00, 'payment_method' => '', 'paid_at' => '', + 'payee_name' => '沃曾朝', + 'payee_bank_name' => '江南农村商业银行', + 'payee_bank_account' => '623189110018550628', ], ], 'total' => 1, @@ -470,6 +482,12 @@ class ProcessDetailsPageTest extends FeatureTestCase ->assertSee('发票抬头', false) ->assertSee('出纳打款抬头', false) ->assertSee('付款差额', false) + ->assertSee('收款人全称', false) + ->assertSee('开户银行', false) + ->assertSee('银行账号', false) + ->assertSee('沃曾朝') + ->assertSee('江南农村商业银行') + ->assertSee('623189110018550628') ->assertSee( 'href="' . e(url('/1/workspace/process-data/oa-process/pending-payment-summary') @@ -786,6 +804,9 @@ class ProcessDetailsPageTest extends FeatureTestCase 'bank_amount' => '100.00', 'payment_method' => '银行卡', 'paid_at' => '2026-01-02 00:00', + 'payee_name' => '沃曾朝', + 'payee_bank_name' => '江南农村商业银行', + 'payee_bank_account' => '623189110018550628', ]; }); $this->app->instance(DingProcessDetailMirrorRepository::class, $repository); @@ -817,6 +838,9 @@ class ProcessDetailsPageTest extends FeatureTestCase '银行付款金额', '付款方式', '打款时间', + '收款人全称', + '开户银行', + '银行账号', '付款状态', '付款差额', ], $header); @@ -829,6 +853,9 @@ class ProcessDetailsPageTest extends FeatureTestCase $this->assertStringContainsString('出纳打款抬头', $content); $this->assertStringContainsString('江苏简尚品牌管理有限公司', $content); $this->assertStringContainsString('常州欧伯娜家居有限公司', $content); + $this->assertStringContainsString('沃曾朝', $content); + $this->assertStringContainsString('江南农村商业银行', $content); + $this->assertStringContainsString('623189110018550628', $content); $this->assertStringContainsString('管理费用_办公费', $content); $this->assertStringContainsString('付款状态', $content); $this->assertStringContainsString('已付款', $content); diff --git a/tests/Feature/Console/ImportDingProcessDetailsTest.php b/tests/Feature/Console/ImportDingProcessDetailsTest.php index 402932a4..a4712f4b 100644 --- a/tests/Feature/Console/ImportDingProcessDetailsTest.php +++ b/tests/Feature/Console/ImportDingProcessDetailsTest.php @@ -71,6 +71,9 @@ class ImportDingProcessDetailsTest extends TestCase $this->assertSame('5602.04', $row->account_code); $this->assertSame('管理费用_办公费', $row->account_name); $this->assertEqualsWithDelta(100.0, (float) $row->amount, 0.001); + $this->assertSame('沃曾朝', $row->payee_name); + $this->assertSame('江南农村商业银行', $row->payee_bank_name); + $this->assertSame('623189110018550628', $row->payee_bank_account); $this->assertSame('202601', $row->business_month); $this->assertSame('personal_permission', $row->source_scope); @@ -151,6 +154,43 @@ class ImportDingProcessDetailsTest extends TestCase ->table('ding_process_detail_mirror')->count()); } + public function test_legacy_csv_without_payee_columns_remains_importable(): void + { + $path = tempnam(sys_get_temp_dir(), 'ding-process-legacy-'); + $handle = fopen($path, 'wb'); + fputcsv($handle, DingProcessDetailMirrorImporter::REQUIRED_HEADERS); + fputcsv($handle, [ + '1', + '202603011200000000003', + '王五', + '已完成', + '店铺日常报销', + '旧版流程文件', + '1', + '5601.01', + '销售费用', + '10.00', + '1002.01.003', + '银行-测试3', + '10.00', + '银行卡', + '2026-03-02 00:00', + ]); + fclose($handle); + $this->tempFiles[] = $path; + + $result = app(DingProcessDetailMirrorImporter::class) + ->import($path, 'personal_permission', true); + + $this->assertSame(1, $result['rows']); + $row = DB::connection('business_mirror') + ->table('ding_process_detail_mirror') + ->first(); + $this->assertSame('', $row->payee_name); + $this->assertSame('', $row->payee_bank_name); + $this->assertSame('', $row->payee_bank_account); + } + public function test_placeholder_rows_are_skipped_and_the_better_duplicate_wins(): void { $path = $this->makeCsv([ @@ -247,6 +287,9 @@ class ImportDingProcessDetailsTest extends TestCase $table->decimal('bank_amount', 18, 2)->nullable(); $table->string('payment_method', 50)->nullable(); $table->string('paid_at', 50)->nullable(); + $table->string('payee_name', 255)->nullable(); + $table->string('payee_bank_name', 255)->nullable(); + $table->string('payee_bank_account', 100)->nullable(); $table->string('source_scope', 40)->default('personal_permission')->index(); $table->dateTime('synced_at', 6); $table->timestamps(); diff --git a/tests/Fixtures/ding_process_details_sample.csv b/tests/Fixtures/ding_process_details_sample.csv index 64f7a2e4..0e19bf53 100644 --- a/tests/Fixtures/ding_process_details_sample.csv +++ b/tests/Fixtures/ding_process_details_sample.csv @@ -1,5 +1,5 @@ -序号,审批编号,发起人,状态,单据类型,用途/摘要,单据内行号,科目编码,科目名称,金额(元),银行科目编码,银行科目名称,银行付款金额,付款方式,打款时间 -1,202601011200000000001,张三,已完成,公摊日常报销,办公用品采购,1,5602.04,管理费用_办公费,100.00,1002.01.001,华夏银行-测试,100.00,银行卡,2026-01-02 00:00 -2,202601011200000000001,张三,已完成,公摊日常报销,交通费,2,5602.06,管理费用_交通费,50.50,1002.01.001,华夏银行-测试,50.50,银行卡,2026-01-02 00:00 -3,202602031200000000002,李四,审批中,应付申请流程,供应商货款,1,,,200.00,1002.01.002,银行-测试2,200.00,银行卡, -4,202602031200000000002,李四,审批中,应付申请流程,供应商货款,2,,,300.00,1002.01.002,银行-测试2,300.00,银行卡, +序号,审批编号,发起人,状态,单据类型,用途/摘要,单据内行号,科目编码,科目名称,金额(元),银行科目编码,银行科目名称,银行付款金额,付款方式,打款时间,收款人全称,开户银行,银行账号 +1,202601011200000000001,张三,已完成,公摊日常报销,办公用品采购,1,5602.04,管理费用_办公费,100.00,1002.01.001,华夏银行-测试,100.00,银行卡,2026-01-02 00:00,沃曾朝,江南农村商业银行,623189110018550628 +2,202601011200000000001,张三,已完成,公摊日常报销,交通费,2,5602.06,管理费用_交通费,50.50,1002.01.001,华夏银行-测试,50.50,银行卡,2026-01-02 00:00,沃曾朝,江南农村商业银行,623189110018550628 +3,202602031200000000002,李四,审批中,应付申请流程,供应商货款,1,,,200.00,1002.01.002,银行-测试2,200.00,银行卡,,,, +4,202602031200000000002,李四,审批中,应付申请流程,供应商货款,2,,,300.00,1002.01.002,银行-测试2,300.00,银行卡,,,, diff --git a/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php b/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php index 87c934f4..422c4c76 100644 --- a/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php +++ b/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php @@ -121,6 +121,9 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase ->first(); $this->assertSame('江苏简尚品牌管理有限公司', $firstDetail->invoice_title); $this->assertSame('常州欧伯娜家居有限公司', $firstDetail->cashier_payment_title); + $this->assertSame('沃曾朝', $firstDetail->payee_name); + $this->assertSame('江南农村商业银行', $firstDetail->payee_bank_name); + $this->assertSame('623189110018550628', $firstDetail->payee_bank_account); $summary = app(DingProcessDetailMirrorRepository::class) ->paginate(['status' => '已完成'], 1, 50)['summary']; @@ -1434,6 +1437,9 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase '收款费用明细' => json_encode($details, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR), '收款合计' => 1114.57, '付款明细' => json_encode($payment, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR), + '收款人全称' => '沃曾朝', + '开户银行' => '江南农村商业银行', + '银行账号' => '623189110018550628', ]; } @@ -1512,6 +1518,9 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase $table->decimal('bank_amount', 18, 2)->nullable(); $table->string('payment_method', 50)->nullable(); $table->string('paid_at', 50)->nullable(); + $table->string('payee_name', 255)->nullable(); + $table->string('payee_bank_name', 255)->nullable(); + $table->string('payee_bank_account', 100)->nullable(); $table->string('source_scope', 40); $table->dateTime('synced_at', 6); $table->timestamps();