From d5f45eb9bd625d47dcdb63fb1a404ed57b163e7a Mon Sep 17 00:00:00 2001 From: yueyang <2495544247@qq.com> Date: Mon, 2 Nov 2026 16:14:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=BA=E6=97=A0=E7=A7=91=E7=9B=AEOA?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=A2=9E=E5=8A=A0=E8=B4=B9=E7=94=A8=E5=BD=92?= =?UTF-8?q?=E7=B1=BB=E5=85=9C=E5=BA=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/upstream_mirrors.php | 4 ++ .../DingProcessDetailMirrorSynchronizer.php | 6 ++ ...ingProcessDetailMirrorSynchronizerTest.php | 57 +++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/config/upstream_mirrors.php b/config/upstream_mirrors.php index f55fc65f..bec72c1e 100644 --- a/config/upstream_mirrors.php +++ b/config/upstream_mirrors.php @@ -51,6 +51,8 @@ return [ 'document_type' => '应付申请流程', 'detail_table' => '应付明细', 'detail_amount_fields' => ['付款金额'], + 'fallback_account_code' => '2202.01', + 'fallback_account_name' => '应付账款_供货商', 'payment_table' => '付款明细', 'payment_total_fields' => ['付款金额合计'], ], @@ -58,6 +60,8 @@ return [ 'document_type' => '线上代发业务报销', 'detail_table' => '收款费用明细', 'detail_amount_fields' => ['代发订单金额'], + 'fallback_account_code' => '1405.06', + 'fallback_account_name' => '库存商品_线上代发', 'payment_table' => '付款明细', ], 'PROC-C5159B8D-F412-4DF8-981D-64EBB8D03EB6' => [ diff --git a/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php b/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php index 58103eb1..b45607eb 100644 --- a/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php +++ b/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php @@ -1193,6 +1193,12 @@ class DingProcessDetailMirrorSynchronizer if ($accountName === '') { $accountName = trim((string) $this->scalarValue($fields['科目名称'] ?? null)); } + if ($accountCode === '') { + $accountCode = trim((string) ($process['fallback_account_code'] ?? '')); + } + if ($accountName === '') { + $accountName = trim((string) ($process['fallback_account_name'] ?? '')); + } $details[] = $this->detailRecord( $workflow, $process, diff --git a/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php b/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php index 83c13cec..d70b2508 100644 --- a/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php +++ b/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php @@ -345,6 +345,63 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase $this->assertContains('process-account-columns', $this->approvalClient->calls); } + public function test_process_fallback_account_keeps_legacy_rows_in_expense_summary(): void + { + config([ + 'upstream_mirrors.ding_process_details.processes.PROC-39DD70DE-DAB2-4A5F-B8F1-0B0B68BD0C88' => [ + 'document_type' => '应付申请流程', + 'detail_table' => '应付明细', + 'detail_amount_fields' => ['付款金额'], + 'fallback_account_code' => '2202.01', + 'fallback_account_name' => '应付账款_供货商', + 'payment_table' => '付款明细', + 'payment_total_fields' => ['付款金额合计'], + ], + ]); + $this->query->workflows = [[ + 'processInstanceId' => 'process-payable-no-account', + 'processCode' => 'PROC-39DD70DE-DAB2-4A5F-B8F1-0B0B68BD0C88', + 'businessId' => '202603090926000222573', + 'title' => '三洋木业合同月结预付款', + 'status' => 'COMPLETED', + 'result' => 'AGREE', + 'originatorUserId' => 'user-1', + 'joinAt' => '2026-03-09 09:26:00', + 'finishTime' => '2026-03-10 10:00:00', + ]]; + $this->query->scheme = [ + '应付明细' => json_encode([[ + 'rowValue' => [ + ['label' => '序号', 'value' => '1'], + ['label' => '类型', 'value' => '供应商货款-月结'], + ['label' => '用途', 'value' => '三洋木业合同月结预付款30%申请'], + ['label' => '付款金额', 'value' => '46800.00'], + ], + ]], JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR), + '付款明细' => json_encode([[ + 'rowValue' => [ + ['label' => '对应序号', 'value' => '1'], + ['label' => '付款金额', 'value' => '46800.00'], + ['label' => '打款时间', 'value' => '2026-03-10'], + ], + ]], JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR), + '付款金额合计' => 46800, + ]; + $this->approvalClient->valuesByInstance['process-payable-no-account'] = [ + '应付明细' => $this->query->scheme['应付明细'], + ]; + + $this->synchronizer->sync(true); + + $row = DB::connection('business_mirror') + ->table('ding_process_detail_mirror') + ->where('process_instance_id', 'process-payable-no-account') + ->first(); + $this->assertSame('2202.01', $row->account_code); + $this->assertSame('应付账款_供货商', $row->account_name); + $this->assertEqualsWithDelta(46800.0, (float) $row->amount, 0.001); + } + public function test_completed_workflow_uses_cashier_status_and_keeps_difference_separate(): void { $this->query->workflows = [[ -- 2.47.2