From 4c746d488da3c9ed2e5e3b78d3a6a3e07b90e643 Mon Sep 17 00:00:00 2001 From: yueyang <2495544247@qq.com> Date: Thu, 29 Oct 2026 22:14:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A5=E5=85=A8OA=E5=AE=A1=E6=89=B9?= =?UTF-8?q?=E4=B8=AD=E6=B5=81=E7=A8=8B=E5=BD=93=E5=89=8D=E5=8A=9E=E7=90=86?= =?UTF-8?q?=E4=BA=BA=20(#775)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DingProcessDetailMirrorSynchronizer.php | 2 +- ...ingProcessDetailMirrorSynchronizerTest.php | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php b/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php index d2d5dff5..4d496e63 100644 --- a/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php +++ b/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php @@ -948,7 +948,7 @@ class DingProcessDetailMirrorSynchronizer ); $needsCashierApi = $this->needsCashierApi($process, $workflow); $approvalSnapshot = null; - if ($needsPaymentApi || $needsCashierApi) { + if ($needsPaymentApi || $needsCashierApi || $status === '审批中') { $approvalSnapshot = $this->approvalApiSnapshot($workflow); } if ($needsPaymentApi && $approvalSnapshot !== null) { diff --git a/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php b/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php index 01af98cc..2f2ec1de 100644 --- a/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php +++ b/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php @@ -334,6 +334,55 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase $this->assertSame('2026-10-29 18:50:00', (string) $row->current_task_started_at); } + public function test_running_workflow_without_payment_fields_resolves_current_task_and_approver(): void + { + config([ + 'upstream_mirrors.ding_process_details.processes.PROC-ACF09A14-B094-46B1-A9E2-8BB1F4E1FDCF' => [ + 'document_type' => '种菜核销', + 'detail_table' => '收款费用明细', + 'detail_amount_fields' => ['代发订单金额'], + 'amount_total_fields' => ['收款合计'], + ], + ]); + $this->query->workflows = [[ + 'processInstanceId' => 'process-running-without-payment', + 'processCode' => 'PROC-ACF09A14-B094-46B1-A9E2-8BB1F4E1FDCF', + 'businessId' => '202610291915000052466', + 'title' => '苏木提交的种菜核销种菜报销流程', + 'status' => 'RUNNING', + 'result' => 'NONE', + 'originatorUserId' => 'user-1', + 'joinAt' => '2026-10-29 19:15:00', + ]]; + $this->query->scheme = [ + '收款费用明细' => json_encode([[ + 'rowValue' => [ + ['label' => '代发订单金额', 'value' => '100.00'], + ], + ]], JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR), + '收款合计' => 100, + ]; + $this->approvalClient->tasksByInstance['process-running-without-payment'] = [[ + 'taskGroupName' => '行政核价', + 'status' => 'RUNNING', + 'result' => 'NONE', + 'userId' => 'user-2', + 'createTime' => '2026-10-29T19:20Z', + 'finishTime' => '', + ]]; + + $this->synchronizer->sync(true); + + $row = DB::connection('business_mirror') + ->table('ding_process_detail_mirror') + ->where('business_id', '202610291915000052466') + ->first(); + $this->assertSame('行政核价', $row->current_task_name); + $this->assertSame('王五', $row->current_approver_name); + $this->assertSame('2026-10-29 19:20:00', (string) $row->current_task_started_at); + $this->assertSame('not_applicable', $row->payment_source_state); + } + public function test_validation_failure_keeps_the_previous_published_rows(): void { $this->query->workflows = [[