功能:奖励金币改为独立弹窗(展示额度信息)

- 点击「送金币」按钮打开独立弹窗,不再内联在用户名片中
- 弹窗展示 4 格额度信息:单次上限、单日上限、今日已发、剩余额度
- 新增 GET /command/reward-quota 接口(rewardQuota 方法)
  返回当前操作人实时额度,超管返回全部不限
- 发放成功后页面内实时更新今日已发/剩余额度,无需刷新
- 移除原内联奖励面板,action 改为调用全局 openRewardModal()
This commit is contained in:
2026-03-01 11:50:12 +08:00
parent 3d30d7e811
commit 21cabb08c9
4 changed files with 193 additions and 37 deletions

View File

@@ -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 = 不限
]);
}
/**
* 权限检查:管理员是否可对目标用户执行指定操作
*