功能:全局奖励接收次数上限(职务管理页配置)
新增全局 sysparam 配置 reward_recipient_daily_max: - 控制每位用户单日内从所有职务持有者处累计接收奖励的最高次数 - 0 = 不限制 后端变更: - PositionController::saveRewardConfig() 保存配置 - POST admin/positions/reward-config 路由 - AdminCommandController::reward() 新增第④层校验: 全局次数上限(优先级低于职务级别的 recipient_daily_limit) 视图变更: - 职务管理页顶部加橙色配置卡片(行内表单,即改即存) - 显示当前全局配置值
This commit is contained in:
@@ -499,6 +499,22 @@ class AdminCommandController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
// ④ 全局系统级别:每位用户单日最多接收奖励次数(后台职务管理页统一配置)
|
||||
$globalMax = (int) Sysparam::getValue('reward_recipient_daily_max', '0');
|
||||
if ($globalMax > 0) {
|
||||
$globalCount = PositionAuthorityLog::where('target_user_id', $target->id)
|
||||
->where('action_type', 'reward')
|
||||
->whereDate('created_at', today())
|
||||
->count();
|
||||
|
||||
if ($globalCount >= $globalMax) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => "{$targetUsername} 今日已累计接收 {$globalCount} 次奖励,已达全局每日上限({$globalMax})",
|
||||
], 422);
|
||||
}
|
||||
}
|
||||
|
||||
// 发放金币(通过 UserCurrencyService 原子性更新 + 写流水)
|
||||
$this->currencyService->change(
|
||||
$target,
|
||||
|
||||
Reference in New Issue
Block a user