diff --git a/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php b/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php index e29d5ea3..d2d5dff5 100644 --- a/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php +++ b/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php @@ -1432,15 +1432,13 @@ class DingProcessDetailMirrorSynchronizer $startedAt = $this->taskDateTime($task['createTime'] ?? null); if ($status === 'RUNNING' && $name !== '') { $runningNames[$name] = true; - if (! $this->isCashierLabel($name) && $startedAt !== null + if ($startedAt !== null && ($runningStartedAt === null || $startedAt->lt($runningStartedAt))) { $runningStartedAt = $startedAt; } - if (! $this->isCashierLabel($name)) { - $approverName = $this->taskApproverName($task, $employees); - if ($approverName !== '') { - $runningApprovers[$approverName] = true; - } + $approverName = $this->taskApproverName($task, $employees); + if ($approverName !== '') { + $runningApprovers[$approverName] = true; } } if ($this->isCashierLabel($name)) { diff --git a/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php b/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php index 12768523..01af98cc 100644 --- a/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php +++ b/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php @@ -293,6 +293,47 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase ); } + public function test_running_cashier_task_resolves_specific_approver(): void + { + $this->query->workflows = [[ + 'processInstanceId' => 'process-running-cashier', + 'processCode' => 'PROC-ACF09A14-B094-46B1-A9E2-8BB1F4E1FDCF', + 'businessId' => '202610291850000052465', + 'title' => '苏木提交的种菜核销种菜报销流程', + 'status' => 'RUNNING', + 'result' => 'NONE', + 'originatorUserId' => 'user-1', + 'joinAt' => '2026-10-29 18:48:00', + ]]; + $this->query->scheme = [ + '收款费用明细' => json_encode([[ + 'rowValue' => [ + ['label' => '代发订单金额', 'value' => '100.00'], + ], + ]], JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR), + '收款合计' => 100, + '付款明细' => '[]', + ]; + $this->approvalClient->tasksByInstance['process-running-cashier'] = [[ + 'taskGroupName' => '出纳打款', + 'status' => 'RUNNING', + 'result' => 'NONE', + 'userId' => 'user-2', + 'createTime' => '2026-10-29T18:50Z', + 'finishTime' => '', + ]]; + + $this->synchronizer->sync(true); + + $row = DB::connection('business_mirror') + ->table('ding_process_detail_mirror') + ->where('business_id', '202610291850000052465') + ->first(); + $this->assertSame('出纳打款', $row->current_task_name); + $this->assertSame('王五', $row->current_approver_name); + $this->assertSame('2026-10-29 18:50:00', (string) $row->current_task_started_at); + } + public function test_validation_failure_keeps_the_previous_published_rows(): void { $this->query->workflows = [[