修复+改进:职务奖励次数上限和后台列表展示

修复:
- recipient_daily_limit 统计逻辑修正:移除 user_id 过滤,
  改为统计今日所有职务持有者对同一接收者的累计发放次数
  (上限含义:该用户今日最多从所有职务人员处收到 N 次奖励)

改进:
- 后台职务列表新增「单日上限」列显示 daily_reward_limit
- 「奖励上限」列改名为「单次上限」更准确
- 两列均支持 null(不限)/ 0(禁止)/ 数值 三种状态区分显示
This commit is contained in:
2026-03-01 11:16:22 +08:00
parent 41d4acdd72
commit a145c6fc0a
2 changed files with 24 additions and 7 deletions
@@ -469,7 +469,7 @@ class AdminCommandController extends Controller
// ② 操作人单日累计上限校验
if ($position->daily_reward_limit) {
$todayTotal = PositionAuthorityLog::where('user_id', $admin->id)
$todayTotal = PositionAuthorityLog::where('target_user_id', $target->id)
->where('action_type', 'reward')
->whereDate('created_at', today())
->sum('amount');
@@ -484,10 +484,9 @@ class AdminCommandController extends Controller
}
}
// ③ 同一接收者每日次数上限校验
// ③ 同一接收者每日次数上限校验(统计今日所有职务持有者对该用户的累计发放次数)
if ($position->recipient_daily_limit) {
$recipientCount = PositionAuthorityLog::where('user_id', $admin->id)
->where('target_user_id', $target->id)
$recipientCount = PositionAuthorityLog::where('target_user_id', $target->id)
->where('action_type', 'reward')
->whereDate('created_at', today())
->count();
@@ -495,7 +494,7 @@ class AdminCommandController extends Controller
if ($recipientCount >= $position->recipient_daily_limit) {
return response()->json([
'status' => 'error',
'message' => "今日已对 {$targetUsername} 发放 {$position->recipient_daily_limit} 次奖励,已达上限",
'message' => "{$targetUsername} 今日已由全体职务人员累计发放 {$recipientCount} 次奖励,已达每日上限({$position->recipient_daily_limit}",
], 422);
}
}