修复:勤务日榜在线时长统计虚高(142小时)+ UI文字调整

Bug修复:
- closeDutyLog 增加 whereDate 限制,只关闭今日日志,历史遗留记录置0,避免跨天时长被计入榜单
- tickDutyLog(ChatController/AutoSaveExp)找不到今日开放日志时不再盲目新建,避免同一 login_at 产生几十条重复记录后 SUM 叠加导致虚假142小时
- AppointmentService 撤职时 closeDutyLog 同步增加今日/历史遗留区分处理

UI调整:
- 登录页版权文字「飘落的流星」→「流星」
- 后台布局标题「飘落流星 控制台」→「控制台」
- 后台侧边栏移除非超管查看各模块时的「(只读)」标注
This commit is contained in:
2026-03-01 22:55:55 +08:00
parent 6fa42b90d5
commit e21f049643
6 changed files with 55 additions and 34 deletions
+7 -7
View File
@@ -283,6 +283,7 @@ class AutoSaveExp extends Command
return;
}
// ① 今日未关闭的开放日志 → 刷新时长
$openLog = PositionDutyLog::query()
->where('user_id', $user->id)
->whereNull('logout_at')
@@ -290,7 +291,6 @@ class AutoSaveExp extends Command
->first();
if ($openLog) {
// 绕过模型 castinteger),使用 DB::table 直接执行 SQL 表达式
DB::table('position_duty_logs')
->where('id', $openLog->id)
->update(['duration_seconds' => DB::raw('GREATEST(0, TIMESTAMPDIFF(SECOND, login_at, NOW()))')]);
@@ -298,17 +298,17 @@ class AutoSaveExp extends Command
return;
}
// 今日无日志,新建:取进房时间为 login_at(防止时长丢失
$loginAt = $user->in_time && $user->in_time->isToday()
// 今日无开放日志 → 新建(login_at 优先用今日进房时间,跨天则用 now()
$loginAt = ($user->in_time && $user->in_time->isToday())
? $user->in_time
: now();
PositionDutyLog::create([
'user_id' => $user->id,
'user_id' => $user->id,
'user_position_id' => $activeUP->id,
'login_at' => $loginAt,
'ip_address' => '0.0.0.0', // 定时任务无 HTTP 请求,占位符
'room_id' => $roomId,
'login_at' => $loginAt,
'ip_address' => '0.0.0.0',
'room_id' => $roomId,
]);
}
}