优化:奖励弹窗加宽+4列额度+最近10条记录+确认按钮醒目
- 弹窗宽度 320→520px(max-width:95vw 自适应) - 额度四格改为一行4列(单次上限/单日上限/今日已发/剩余额度) - 确认按钮改为橙红渐变+投影,视觉更突出 - 输入框下方显示最近10条发放记录(目标/金额/时间) - 发放成功后实时在历史列表头部插入新纪录 - rewardQuota 接口统一返回 recent_rewards(最近10条)
This commit is contained in:
@@ -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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user