fix: 显示OA出纳节点当前审批人 #774

Merged
yueyang merged 1 commits from fix/yueyang-oa-cashier-approver into main 2026-10-29 22:03:24 +08:00
2 changed files with 45 additions and 6 deletions

View File

@ -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)) {

View File

@ -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 = [[