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

修复:
- 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);
}
}
@@ -120,7 +120,8 @@
<th class="px-4 py-3 text-center">等级</th>
<th class="px-4 py-3 text-center">人数上限</th>
<th class="px-4 py-3 text-center">当前在职</th>
<th class="px-4 py-3 text-center">奖励上限</th>
<th class="px-4 py-3 text-center">单次上限</th>
<th class="px-4 py-3 text-center">单日上限</th>
<th class="px-4 py-3 text-center">任命权</th>
@php $superLvl = (int) \App\Models\Sysparam::getValue('superlevel', '100'); @endphp
@if (Auth::user()->user_level >= $superLvl)
@@ -150,7 +151,24 @@
</span>
</td>
<td class="px-4 py-3 text-center text-gray-600">
{{ $pos->max_reward ? number_format($pos->max_reward) . '金币' : '不限' }}
@if ($pos->max_reward === null)
<span class="text-gray-400 text-xs">不限</span>
@elseif ($pos->max_reward === 0)
<span class="text-xs text-red-500 font-bold">禁止</span>
@else
<span
class="text-xs font-mono text-amber-700">{{ number_format($pos->max_reward) }}</span>
@endif
</td>
<td class="px-4 py-3 text-center text-gray-600">
@if ($pos->daily_reward_limit === null)
<span class="text-gray-400 text-xs">不限</span>
@elseif ($pos->daily_reward_limit === 0)
<span class="text-xs text-red-500 font-bold">禁止</span>
@else
<span
class="text-xs font-mono text-indigo-700">{{ number_format($pos->daily_reward_limit) }}</span>
@endif
</td>
<td class="px-4 py-3 text-center">
@if (count($appointableIds) > 0)