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 @@ + +{{-- ═══════════ 奖励金币独立弹窗 ═══════════ --}} +