feat: 任命/撤销通知系统 + 用户名片UI优化
- 任命/撤销事件增加 type 字段区分类型 - 任命:全屏礼花 + 紫色弹窗 + 紫色系统消息 - 撤销:灰色弹窗 + 灰色系统消息,无礼花 - 消息分发:操作者/被操作者显示在私聊面板,其他人显示在公屏 - 系统消息加随机鼓励语(各5条轮换) - ChatStateService 修复 Redis key 前缀扫描问题(getAllActiveRoomIds) - 用户名片折叠优化:管理员视野、职务履历均可折叠 - 管理操作 + 职务操作合并为「🔧 管理操作」折叠区 - 悄悄话改为「🎁 送礼物」按钮,礼物面板内联展开
This commit is contained in:
79
app/Http/Controllers/DutyHallController.php
Normal file
79
app/Http/Controllers/DutyHallController.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:勤务台页面控制器
|
||||
* 左侧五个子菜单:任职列表、日榜、周榜、月榜、总榜
|
||||
* 路由:GET /duty-hall?tab=roster|day|week|month|all
|
||||
*
|
||||
* @author ChatRoom Laravel
|
||||
*
|
||||
* @version 1.1.0
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Department;
|
||||
use App\Models\PositionDutyLog;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class DutyHallController extends Controller
|
||||
{
|
||||
/**
|
||||
* 勤务台主页(根据 tab 切换内容)
|
||||
*/
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$tab = $request->input('tab', 'roster');
|
||||
|
||||
// ── 任职列表:按部门→职务展示全部(含空缺) ────────────────────
|
||||
$currentStaff = null;
|
||||
if ($tab === 'roster') {
|
||||
$currentStaff = Department::query()
|
||||
->with([
|
||||
'positions' => fn ($q) => $q->orderByDesc('rank'),
|
||||
'positions.activeUserPositions.user',
|
||||
])
|
||||
->orderByDesc('rank')
|
||||
->get();
|
||||
}
|
||||
|
||||
// ── 日/周/月/总榜:勤务时长排行 ──────────────────────────────────
|
||||
$leaderboard = null;
|
||||
if (in_array($tab, ['day', 'week', 'month', 'all'])) {
|
||||
$query = PositionDutyLog::query()
|
||||
->selectRaw('user_id, SUM(duration_seconds) as total_seconds, COUNT(*) as checkin_count');
|
||||
|
||||
// 按时间段过滤
|
||||
match ($tab) {
|
||||
'day' => $query->whereDate('login_at', today()),
|
||||
'week' => $query->whereBetween('login_at', [now()->startOfWeek(), now()->endOfWeek()]),
|
||||
'month' => $query->whereYear('login_at', now()->year)->whereMonth('login_at', now()->month),
|
||||
'all' => null, // 不加时间限制
|
||||
};
|
||||
|
||||
$leaderboard = $query
|
||||
->groupBy('user_id')
|
||||
->orderByDesc('total_seconds')
|
||||
->limit(20)
|
||||
->with('user')
|
||||
->get();
|
||||
}
|
||||
|
||||
// 各榜标签配置
|
||||
$tabs = [
|
||||
'roster' => ['label' => '任职列表', 'icon' => '🏛️'],
|
||||
'day' => ['label' => '日榜', 'icon' => '☀️'],
|
||||
'week' => ['label' => '周榜', 'icon' => '📆'],
|
||||
'month' => ['label' => '月榜', 'icon' => '🗓️'],
|
||||
'all' => ['label' => '总榜', 'icon' => '🏆'],
|
||||
];
|
||||
|
||||
return view('duty-hall.index', compact(
|
||||
'tab',
|
||||
'tabs',
|
||||
'currentStaff',
|
||||
'leaderboard',
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user