From 4ba5a88fc2e5bbebdc72c921827068b2528815a9 Mon Sep 17 00:00:00 2001 From: lkddi Date: Sun, 1 Mar 2026 11:55:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E5=A5=96=E5=8A=B1?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E5=8A=A0=E5=AE=BD+4=E5=88=97=E9=A2=9D?= =?UTF-8?q?=E5=BA=A6+=E6=9C=80=E8=BF=9110=E6=9D=A1=E8=AE=B0=E5=BD=95+?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=8C=89=E9=92=AE=E9=86=92=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 弹窗宽度 320→520px(max-width:95vw 自适应) - 额度四格改为一行4列(单次上限/单日上限/今日已发/剩余额度) - 确认按钮改为橙红渐变+投影,视觉更突出 - 输入框下方显示最近10条发放记录(目标/金额/时间) - 发放成功后实时在历史列表头部插入新纪录 - rewardQuota 接口统一返回 recent_rewards(最近10条) --- .../Controllers/AdminCommandController.php | 33 +++++-- .../chat/partials/user-actions.blade.php | 87 +++++++++++++------ 2 files changed, 87 insertions(+), 33 deletions(-) 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 条记录 --}} +
+
+ 📋 最近发放记录 +
+
加载中…
+
暂无记录
+
+ +
+