diff --git a/app/Http/Controllers/AdminCommandController.php b/app/Http/Controllers/AdminCommandController.php index 80b832b..a38309a 100644 --- a/app/Http/Controllers/AdminCommandController.php +++ b/app/Http/Controllers/AdminCommandController.php @@ -581,12 +581,29 @@ class AdminCommandController extends Controller $admin = Auth::user(); $isSuperAdmin = $admin->id === 1; + // 最近 10 条本人发放记录(含目标用户名) + $recent = PositionAuthorityLog::with('targetUser:id,username') + ->where('user_id', $admin->id) + ->where('action_type', 'reward') + ->latest() + ->limit(10) + ->get() + ->map(fn ($log) => [ + 'target' => $log->targetUser?->username ?? '未知', + 'amount' => $log->amount, + 'created_at' => $log->created_at?->format('m-d H:i'), + ]); + if ($isSuperAdmin) { return response()->json([ 'max_once' => null, 'daily_limit' => null, - 'today_sent' => 0, + 'today_sent' => (int) PositionAuthorityLog::where('user_id', $admin->id) + ->where('action_type', 'reward') + ->whereDate('created_at', today()) + ->sum('amount'), 'daily_remaining' => null, + 'recent_rewards' => $recent, ]); } @@ -597,11 +614,12 @@ class AdminCommandController extends Controller 'daily_limit' => null, 'today_sent' => 0, 'daily_remaining' => null, + 'recent_rewards' => $recent, ]); } - // 今日已发放总额(以 user_id 统计操作人自己的发放) - $todaySent = PositionAuthorityLog::where('user_id', $admin->id) + // 今日已发放总额 + $todaySent = (int) PositionAuthorityLog::where('user_id', $admin->id) ->where('action_type', 'reward') ->whereDate('created_at', today()) ->sum('amount'); @@ -610,10 +628,11 @@ class AdminCommandController extends Controller $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 = 不限 + 'max_once' => $position->max_reward, + 'daily_limit' => $dailyLimit, + 'today_sent' => $todaySent, + 'daily_remaining' => $remaining, + 'recent_rewards' => $recent, ]); } diff --git a/resources/views/chat/partials/user-actions.blade.php b/resources/views/chat/partials/user-actions.blade.php index eb02e57..849d9ed 100644 --- a/resources/views/chat/partials/user-actions.blade.php +++ b/resources/views/chat/partials/user-actions.blade.php @@ -884,7 +884,7 @@ amount: '', sending: false, loading: false, - quota: { max_once: null, daily_limit: null, today_sent: 0, daily_remaining: null }, + quota: { max_once: null, daily_limit: null, today_sent: 0, daily_remaining: null, recent_rewards: [] }, fmt(v) { if (v === null) return '不限'; @@ -903,7 +903,8 @@ headers: { 'Accept': 'application/json' } }); this.quota = await res.json(); - } catch { this.quota = { max_once: null, daily_limit: null, today_sent: 0, daily_remaining: null }; } + if (!this.quota.recent_rewards) this.quota.recent_rewards = []; + } catch { this.quota = { max_once: null, daily_limit: null, today_sent: 0, daily_remaining: null, recent_rewards: [] }; } this.loading = false; }, @@ -912,7 +913,7 @@ const amt = parseInt(this.amount, 10); if (!amt || amt <= 0) { alert('请输入有效金额'); return; } const maxOnce = window.chatContext?.myMaxReward; - if (maxOnce === 0) { alert('你的职务没有奖励发放权限'); return; } + if (maxOnce === 0) { alert('你的职务没有奖励发放权限'); return; } if (maxOnce > 0 && amt > maxOnce) { alert('超出单次上限 ' + maxOnce + ' 金币'); return; } this.sending = true; try { @@ -931,6 +932,14 @@ if (this.quota.daily_remaining !== null) { this.quota.daily_remaining = Math.max(0, this.quota.daily_remaining - amt); } + // 在历史记录头部插入 + const now = new Date(); + const mm = String(now.getMonth()+1).padStart(2,'0'); + const dd = String(now.getDate()).padStart(2,'0'); + const hh = String(now.getHours()).padStart(2,'0'); + const mi = String(now.getMinutes()).padStart(2,'0'); + this.quota.recent_rewards.unshift({ target: this.targetUsername, amount: amt, created_at: mm+'-'+dd+' '+hh+':'+mi }); + if (this.quota.recent_rewards.length > 10) this.quota.recent_rewards.pop(); this.amount = ''; alert(data.message); } else { @@ -943,59 +952,85 @@
-
-
🪙 发放奖励金币
-
+
🪙 发放奖励金币
+
+ style="background:rgba(255,255,255,.25); border:none; color:#fff; width:30px; height:30px; + border-radius:50%; cursor:pointer; font-size:18px; line-height:30px; text-align:center;">×
-
+ {{-- 额度四格(一行4列) --}} +
加载额度信息…
-
+
单次上限
-
+
单日上限
-
+
今日已发
-
+
剩余额度
-
+
-
-
+ {{-- 输入区 --}} +
+
+ style="flex:1; height:44px; padding:0 14px; border:2px solid #fcd34d; + border-radius:10px; font-size:15px; color:#92400e; outline:none; box-sizing:border-box;">
-

+

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

+ {{-- 最近 10 条记录 --}} +
+
+ 📋 最近发放记录 +
+
加载中…
+
暂无记录
+
+ +
+