diff --git a/app/Http/Controllers/AdminCommandController.php b/app/Http/Controllers/AdminCommandController.php index ce0babb..4b02c65 100644 --- a/app/Http/Controllers/AdminCommandController.php +++ b/app/Http/Controllers/AdminCommandController.php @@ -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); } } diff --git a/resources/views/admin/positions/index.blade.php b/resources/views/admin/positions/index.blade.php index 57d83cd..d1affc4 100644 --- a/resources/views/admin/positions/index.blade.php +++ b/resources/views/admin/positions/index.blade.php @@ -120,7 +120,8 @@ 等级 人数上限 当前在职 - 奖励上限 + 单次上限 + 单日上限 任命权 @php $superLvl = (int) \App\Models\Sysparam::getValue('superlevel', '100'); @endphp @if (Auth::user()->user_level >= $superLvl) @@ -150,7 +151,24 @@ - {{ $pos->max_reward ? number_format($pos->max_reward) . '金币' : '不限' }} + @if ($pos->max_reward === null) + 不限 + @elseif ($pos->max_reward === 0) + 禁止 + @else + {{ number_format($pos->max_reward) }} + @endif + + + @if ($pos->daily_reward_limit === null) + 不限 + @elseif ($pos->daily_reward_limit === 0) + 禁止 + @else + {{ number_format($pos->daily_reward_limit) }} + @endif @if (count($appointableIds) > 0)