- 在多个控制器中更新权限检查逻辑,确保管理员能够更灵活地管理代理和玩家。 - 在 AdminPlayerStoreController 中引入对玩家创建能力的验证,确保只有具备相应权限的管理员能够创建玩家。 - 更新请求验证逻辑,新增 credit_limit、rebate_rate 和 extra_rebate_rate 字段,以支持更细粒度的玩家管理。 - 在 AgentNodeProfileController 中添加对父代理能力授予的验证,确保子代理的权限在父代理范围内。 - 引入 AgentProfileFieldRules 以简化代理资料更新请求的规则定义,提升代码复用性。
93 lines
2.7 KiB
PHP
93 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use App\Models\AdminUser;
|
|
use Illuminate\Database\Query\Builder;
|
|
|
|
/** 代理账单按管理员可访问站点过滤。 */
|
|
final class AdminAgentSettlementScope
|
|
{
|
|
public static function applyToPeriodsQuery(Builder $query, AdminUser $admin, string $periodsAlias = 'settlement_periods'): void
|
|
{
|
|
$siteIds = $admin->accessibleAdminSiteIds();
|
|
if ($siteIds === null) {
|
|
return;
|
|
}
|
|
|
|
if ($siteIds === []) {
|
|
$query->whereRaw('0 = 1');
|
|
|
|
return;
|
|
}
|
|
|
|
$query->whereIn($periodsAlias.'.admin_site_id', $siteIds);
|
|
}
|
|
|
|
public static function applyToBillsQuery(Builder $query, AdminUser $admin, string $billsAlias = 'settlement_bills'): void
|
|
{
|
|
$siteIds = $admin->accessibleAdminSiteIds();
|
|
if ($siteIds === null) {
|
|
return;
|
|
}
|
|
|
|
if ($siteIds === []) {
|
|
$query->whereRaw('0 = 1');
|
|
|
|
return;
|
|
}
|
|
|
|
$query->whereExists(function (Builder $sub) use ($siteIds, $billsAlias): void {
|
|
$sub->selectRaw('1')
|
|
->from('settlement_periods')
|
|
->whereColumn('settlement_periods.id', $billsAlias.'.settlement_period_id')
|
|
->whereIn('settlement_periods.admin_site_id', $siteIds);
|
|
});
|
|
}
|
|
|
|
public static function periodAccessible(AdminUser $admin, int $settlementPeriodId): bool
|
|
{
|
|
$siteIds = $admin->accessibleAdminSiteIds();
|
|
if ($siteIds === null) {
|
|
return true;
|
|
}
|
|
|
|
if ($siteIds === []) {
|
|
return false;
|
|
}
|
|
|
|
return \Illuminate\Support\Facades\DB::table('settlement_periods')
|
|
->where('id', $settlementPeriodId)
|
|
->whereIn('admin_site_id', $siteIds)
|
|
->exists();
|
|
}
|
|
|
|
public static function siteAccessible(AdminUser $admin, int $adminSiteId): bool
|
|
{
|
|
$siteIds = $admin->accessibleAdminSiteIds();
|
|
if ($siteIds === null) {
|
|
return true;
|
|
}
|
|
|
|
return in_array($adminSiteId, $siteIds, true);
|
|
}
|
|
|
|
public static function billAccessible(AdminUser $admin, int $settlementBillId): bool
|
|
{
|
|
$siteIds = $admin->accessibleAdminSiteIds();
|
|
if ($siteIds === null) {
|
|
return true;
|
|
}
|
|
|
|
if ($siteIds === []) {
|
|
return false;
|
|
}
|
|
|
|
return \Illuminate\Support\Facades\DB::table('settlement_bills')
|
|
->join('settlement_periods', 'settlement_periods.id', '=', 'settlement_bills.settlement_period_id')
|
|
->where('settlement_bills.id', $settlementBillId)
|
|
->whereIn('settlement_periods.admin_site_id', $siteIds)
|
|
->exists();
|
|
}
|
|
}
|