fix: 双休日加班打卡不计日志扣分 (#1215)
This commit is contained in:
parent
8a62fdea39
commit
b4512c76f2
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -382,7 +382,7 @@
|
||||
<span class="material-icons-outlined" aria-hidden="true">rule</span>
|
||||
<div>
|
||||
<strong>日志漏写扣分规则</strong>
|
||||
<span>第 1 次漏写扣 10 分,第 2 次扣 20 分,第 3 次扣 40 分,之后每次在上一次基础上翻倍并累计。只统计已经超过“次日 12:00”截止时间,且钉钉排班标记为工作日的日期;公司排班休息日不扣分。</span>
|
||||
<span>第 1 次漏写扣 10 分,第 2 次扣 20 分,第 3 次扣 40 分,之后每次在上一次基础上翻倍并累计。只统计已经超过“次日 12:00”截止时间,且公司排班标记为工作日、又没有请假或休息记录的日期;公司双休日的加班打卡不需要写日志,不扣分。</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -193,6 +193,7 @@ class PagesTest extends FeatureTestCase
|
||||
->assertSeeText('排班休息、请假等免提交日期不统计')
|
||||
->assertSee('data-worklog-penalty-rule', false)
|
||||
->assertSeeText('日志漏写扣分规则')
|
||||
->assertSeeText('公司双休日的加班打卡不需要写日志,不扣分')
|
||||
->assertSeeText('qyapi_report_query')
|
||||
->assertSeeText('前往钉钉开通')
|
||||
->assertSeeText('2026-11-03')
|
||||
|
||||
@ -110,6 +110,21 @@ class DingAttendanceMirrorRepositoryTest extends TestCase
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
[
|
||||
'schedule_id' => 'schedule-overtime',
|
||||
'user_id' => 'changyi',
|
||||
'user_name' => '常仪',
|
||||
'work_date' => '2026-11-08',
|
||||
'group_id' => 967215034,
|
||||
'class_id' => null,
|
||||
'is_rest' => 'N',
|
||||
'check_status' => 'Checked',
|
||||
'time_changed' => false,
|
||||
'source_payload' => '{}',
|
||||
'synced_at' => $now,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
], ['changyi'], '2026-11-07', '2026-11-08');
|
||||
|
||||
$workDates = $repository->scheduledWorkDatesForUsers(['changyi'], '2026-11-07', '2026-11-08');
|
||||
@ -119,7 +134,7 @@ class DingAttendanceMirrorRepositoryTest extends TestCase
|
||||
[['userid' => 'changyi', 'name' => '常仪']],
|
||||
$repository->scheduledMembersBetween('2026-11-07', '2026-11-08'),
|
||||
);
|
||||
$this->assertSame(2, $db->table('ding_attendance_schedule_records')->count());
|
||||
$this->assertSame(3, $db->table('ding_attendance_schedule_records')->count());
|
||||
$this->assertFalse($repository->scheduleReady());
|
||||
|
||||
$db->table('business_mirror_table_states')->insert([
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user