From 21cabb08c998ff04ff59df574ca9856b412f704a Mon Sep 17 00:00:00 2001 From: lkddi Date: Sun, 1 Mar 2026 11:50:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=9A=E5=A5=96=E5=8A=B1?= =?UTF-8?q?=E9=87=91=E5=B8=81=E6=94=B9=E4=B8=BA=E7=8B=AC=E7=AB=8B=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=EF=BC=88=E5=B1=95=E7=A4=BA=E9=A2=9D=E5=BA=A6=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 点击「送金币」按钮打开独立弹窗,不再内联在用户名片中 - 弹窗展示 4 格额度信息:单次上限、单日上限、今日已发、剩余额度 - 新增 GET /command/reward-quota 接口(rewardQuota 方法) 返回当前操作人实时额度,超管返回全部不限 - 发放成功后页面内实时更新今日已发/剩余额度,无需刷新 - 移除原内联奖励面板,action 改为调用全局 openRewardModal() --- .../Controllers/AdminCommandController.php | 50 +++++ resources/views/chat/frame.blade.php | 3 +- .../chat/partials/user-actions.blade.php | 176 ++++++++++++++---- routes/web.php | 1 + 4 files changed, 193 insertions(+), 37 deletions(-) diff --git a/app/Http/Controllers/AdminCommandController.php b/app/Http/Controllers/AdminCommandController.php index d2d9945..80b832b 100644 --- a/app/Http/Controllers/AdminCommandController.php +++ b/app/Http/Controllers/AdminCommandController.php @@ -567,6 +567,56 @@ class AdminCommandController extends Controller ]); } + /** + * 查询当前操作人的奖励额度信息(供发放弹窗展示) + * + * 返回字段: + * - max_once: 单次上限(null = 不限) + * - daily_limit: 单日发放总额上限(null = 不限) + * - today_sent: 今日已发放总额 + * - daily_remaining: 今日剩余可发放额度(null = 不限) + */ + public function rewardQuota(): \Illuminate\Http\JsonResponse + { + $admin = Auth::user(); + $isSuperAdmin = $admin->id === 1; + + if ($isSuperAdmin) { + return response()->json([ + 'max_once' => null, + 'daily_limit' => null, + 'today_sent' => 0, + 'daily_remaining' => null, + ]); + } + + $position = $admin->activePosition?->position; + if (! $position) { + return response()->json([ + 'max_once' => 0, + 'daily_limit' => null, + 'today_sent' => 0, + 'daily_remaining' => null, + ]); + } + + // 今日已发放总额(以 user_id 统计操作人自己的发放) + $todaySent = PositionAuthorityLog::where('user_id', $admin->id) + ->where('action_type', 'reward') + ->whereDate('created_at', today()) + ->sum('amount'); + + $dailyLimit = $position->daily_reward_limit; + $remaining = $dailyLimit !== null ? max(0, $dailyLimit - $todaySent) : null; + + return response()->json([ + 'max_once' => $position->max_reward, // null = 不限, 0 = 禁止, N = 有上限 + 'daily_limit' => $dailyLimit, // null = 不限 + 'today_sent' => (int) $todaySent, + 'daily_remaining' => $remaining, // null = 不限 + ]); + } + /** * 权限检查:管理员是否可对目标用户执行指定操作 * diff --git a/resources/views/chat/frame.blade.php b/resources/views/chat/frame.blade.php index 3ebfb73..818a30e 100644 --- a/resources/views/chat/frame.blade.php +++ b/resources/views/chat/frame.blade.php @@ -59,7 +59,8 @@ appointPositionsUrl: "{{ route('chat.appoint.positions') }}", appointUrl: "{{ route('chat.appoint.appoint') }}", revokeUrl: "{{ route('chat.appoint.revoke') }}", - rewardUrl: "{{ route('command.reward') }}" + rewardUrl: "{{ route('command.reward') }}", + rewardQuotaUrl: "{{ route('command.reward_quota') }}" }; @vite(['resources/css/app.css', 'resources/js/app.js', 'resources/js/chat.js']) diff --git a/resources/views/chat/partials/user-actions.blade.php b/resources/views/chat/partials/user-actions.blade.php index 6c75cd8..eb02e57 100644 --- a/resources/views/chat/partials/user-actions.blade.php +++ b/resources/views/chat/partials/user-actions.blade.php @@ -687,7 +687,7 @@ @@ -742,41 +742,6 @@ - - {{-- 内联奖励金币面板(仅职务持有者且有 max_reward 时可用) --}} -
- -
- 🪙 发放奖励金币 - - 单次上限: - 金币 - - -
- -
- - -
-

- 金币将直接发放给对方账户,本操作记入你的履职记录。 -

-
{{-- 管理操作 + 职务操作 合并折叠区 --}} @@ -910,3 +875,142 @@ + +{{-- ═══════════ 奖励金币独立弹窗 ═══════════ --}} +
+
+
+
+
+
🪙 发放奖励金币
+
+
+ +
+
+
加载额度信息…
+
+
+
单次上限
+
+
+
+
单日上限
+
+
+
+
今日已发
+
+
+
+
剩余额度
+
+
+
+
+
+
+ + +
+

+ 金币凭空产生并直接发放给对方,本操作记入你的履职记录。 +

+
+
+
+
+ + + diff --git a/routes/web.php b/routes/web.php index f803f1b..abeb876 100644 --- a/routes/web.php +++ b/routes/web.php @@ -113,6 +113,7 @@ Route::middleware(['chat.auth'])->group(function () { Route::post('/command/mute', [AdminCommandController::class, 'mute'])->name('command.mute'); Route::post('/command/freeze', [AdminCommandController::class, 'freeze'])->name('command.freeze'); Route::post('/command/reward', [AdminCommandController::class, 'reward'])->name('command.reward'); + Route::get('/command/reward-quota', [AdminCommandController::class, 'rewardQuota'])->name('command.reward_quota'); Route::get('/command/whispers/{username}', [AdminCommandController::class, 'viewWhispers'])->name('command.whispers'); Route::post('/command/announce', [AdminCommandController::class, 'announce'])->name('command.announce'); Route::post('/command/clear-screen', [AdminCommandController::class, 'clearScreen'])->name('command.clear_screen');