功能:全局奖励接收次数上限(职务管理页配置)
新增全局 sysparam 配置 reward_recipient_daily_max: - 控制每位用户单日内从所有职务持有者处累计接收奖励的最高次数 - 0 = 不限制 后端变更: - PositionController::saveRewardConfig() 保存配置 - POST admin/positions/reward-config 路由 - AdminCommandController::reward() 新增第④层校验: 全局次数上限(优先级低于职务级别的 recipient_daily_limit) 视图变更: - 职务管理页顶部加橙色配置卡片(行内表单,即改即存) - 显示当前全局配置值
This commit is contained in:
@@ -15,6 +15,7 @@ namespace App\Http\Controllers\Admin;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Department;
|
||||
use App\Models\Position;
|
||||
use App\Models\Sysparam;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
@@ -34,7 +35,10 @@ class PositionController extends Controller
|
||||
// 全部职务(供任命白名单多选框使用)
|
||||
$allPositions = Position::with('department')->orderByDesc('rank')->get();
|
||||
|
||||
return view('admin.positions.index', compact('departments', 'allPositions'));
|
||||
// 全局奖励接收次数上限(0 = 不限)
|
||||
$globalRecipientDailyMax = (int) Sysparam::getValue('reward_recipient_daily_max', '0');
|
||||
|
||||
return view('admin.positions.index', compact('departments', 'allPositions', 'globalRecipientDailyMax'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,6 +72,36 @@ class PositionController extends Controller
|
||||
return redirect()->route('admin.positions.index')->with('success', "职务【{$data['name']}】创建成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存全局奖励金币接收次数上限
|
||||
*
|
||||
* 控制每位用户单日内可从所有职务持有者处累计接收奖励的最高次数。
|
||||
* 0 表示不限制,保存到 sysparam 表中(key: reward_recipient_daily_max)。
|
||||
*/
|
||||
public function saveRewardConfig(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'reward_recipient_daily_max' => 'required|integer|min:0|max:9999',
|
||||
]);
|
||||
|
||||
$value = (string) $request->integer('reward_recipient_daily_max');
|
||||
|
||||
Sysparam::updateOrCreate(
|
||||
['alias' => 'reward_recipient_daily_max'],
|
||||
[
|
||||
'body' => $value,
|
||||
'guidetxt' => '用户单日最多接收奖励金币次数(0=不限,统计所有职务持有者的发放总次数)',
|
||||
]
|
||||
);
|
||||
|
||||
Sysparam::clearCache('reward_recipient_daily_max');
|
||||
|
||||
$label = $value === '0' ? '不限' : "{$value} 次";
|
||||
|
||||
return redirect()->route('admin.positions.index')
|
||||
->with('success', "全局接收次数上限已更新为:{$label}");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新职务(含任命白名单同步)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user