From b4512c76f2e754cd2784b9d91a1df508d716218a Mon Sep 17 00:00:00 2001 From: renshen <1005457301@qq.com> Date: Tue, 17 Nov 2026 00:06:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=8C=E4=BC=91=E6=97=A5=E5=8A=A0?= =?UTF-8?q?=E7=8F=AD=E6=89=93=E5=8D=A1=E4=B8=8D=E8=AE=A1=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=89=A3=E5=88=86=20(#1215)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DingAttendanceMirrorRepository.php | 22 +++++++++++++++---- .../pages/other/log-statistics.blade.php | 2 +- tests/Feature/Business/PagesTest.php | 1 + .../DingAttendanceMirrorRepositoryTest.php | 17 +++++++++++++- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/modules/EcommerceFinance/Repositories/DingAttendanceMirrorRepository.php b/modules/EcommerceFinance/Repositories/DingAttendanceMirrorRepository.php index 87f6f6a3..6bc00edd 100644 --- a/modules/EcommerceFinance/Repositories/DingAttendanceMirrorRepository.php +++ b/modules/EcommerceFinance/Repositories/DingAttendanceMirrorRepository.php @@ -283,15 +283,29 @@ class DingAttendanceMirrorRepository $rows = $this->connection->table(self::SCHEDULE_TABLE) ->whereIn('user_id', $userIds) ->whereBetween('work_date', [$from, $to]) - ->where('is_rest', 'N') - ->get(['user_id', 'work_date']); + ->get(['user_id', 'work_date', 'is_rest']); - $dates = []; + $statuses = []; foreach ($rows as $row) { $userId = trim((string) ($row->user_id ?? '')); $date = Carbon::parse($row->work_date)->toDateString(); if ($userId !== '' && $date !== '') { - $dates[$userId][$date] = true; + $statuses[$userId][$date] ??= ['work' => false, 'rest' => false]; + if ((string) $row->is_rest === 'Y') { + $statuses[$userId][$date]['rest'] = true; + } else { + $statuses[$userId][$date]['work'] = true; + } + } + } + + $dates = []; + foreach ($statuses as $userId => $userDates) { + foreach ($userDates as $date => $status) { + // 公司休息日出现加班打卡时,钉钉会额外生成 is_rest=N 记录;仍按休息日处理。 + if ($status['work'] && ! $status['rest']) { + $dates[$userId][$date] = true; + } } } diff --git a/resources/views/business/pages/other/log-statistics.blade.php b/resources/views/business/pages/other/log-statistics.blade.php index 46f55cca..8e4bdc5d 100644 --- a/resources/views/business/pages/other/log-statistics.blade.php +++ b/resources/views/business/pages/other/log-statistics.blade.php @@ -382,7 +382,7 @@