修复勤务日榜时长膨胀:重建session时用now()而非旧in_time,补updated_at刷新防误关,视图标签改为所有
This commit is contained in:
@@ -293,13 +293,23 @@ class AutoSaveExp extends Command
|
||||
if ($openLog) {
|
||||
DB::table('position_duty_logs')
|
||||
->where('id', $openLog->id)
|
||||
->update(['duration_seconds' => DB::raw('GREATEST(0, TIMESTAMPDIFF(SECOND, login_at, NOW()))')]);
|
||||
->update([
|
||||
'duration_seconds' => DB::raw('GREATEST(0, TIMESTAMPDIFF(SECOND, login_at, NOW()))'),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// ② 今日无开放日志 → 新建(login_at 优先用今日进房时间,跨天则用 now())
|
||||
$loginAt = ($user->in_time && $user->in_time->isToday())
|
||||
// ② 今日无开放日志 → 新建
|
||||
// 若今日已有已关闭的日志(是重建场景),必须用 now(),防止重用旧 in_time 累积膨胀
|
||||
$hasClosedToday = PositionDutyLog::query()
|
||||
->where('user_id', $user->id)
|
||||
->whereDate('login_at', today())
|
||||
->whereNotNull('logout_at')
|
||||
->exists();
|
||||
|
||||
$loginAt = (! $hasClosedToday && $user->in_time && $user->in_time->isToday())
|
||||
? $user->in_time
|
||||
: now();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user