- 添加ensureSuperAdmin方法,限制管理员设置操作权限 - 在AdminSettingController接口中新增权限检查,防止非超级管理员操作 - AdminPlayerIndexController新增direct agent筛选支持 - AdminPlayerUpdateController新增对信用玩家默认币别变更的拒绝逻辑 - 新增WalletSettlementBillsController,实现玩家信用盘账期账单摘要接口 - AgentProfileService调整,新增返点限额和分享比例自动下调机制,保持子代理及玩家配置不超父级 - AgentProfileService增加can_grant_extra_rebate权限继承限制,阻止无权限代理开启 - AgentSettlementPeriodCloseService增加玩家账单回水信用释放逻辑,确保信用额度同步 - PlayerCreditService新增释放账单回水对应信用逻辑,维护账期信用一致性 - TicketPlacementService和TicketPreviewService新增信用玩家投注币别匹配校验,防止币别不符 - PlayerLedgerLogsService优化信用额度计算,增加可用额度上下限限制,防止负值和超限 - 调整后台管理导航,仅超管可见设置入口,强化权限隔离 - 路由新增玩家信用账单查询接口 - 补充多项AgentProfile相关单元测试覆盖额度限制、返点继承、返点下调场景及权限限制 - 增加站点管理员登录测试,验证系统设置菜单不可见,提升用户权限体验
78 lines
2.6 KiB
PHP
78 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1\Admin\Player;
|
|
|
|
use App\Models\Player;
|
|
use Illuminate\Http\Request;
|
|
use App\Lottery\ErrorCode;
|
|
use App\Support\ApiMessage;
|
|
use App\Support\ApiResponse;
|
|
use Illuminate\Http\JsonResponse;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Support\AdminApiList;
|
|
use App\Support\AdminScopePolicy;
|
|
use App\Support\PlayerApiPresenter;
|
|
|
|
/** GET /api/v1/admin/players */
|
|
final class AdminPlayerIndexController extends Controller
|
|
{
|
|
public function __invoke(Request $request): JsonResponse
|
|
{
|
|
$admin = $request->lotteryAdmin();
|
|
abort_if($admin === null, 401);
|
|
|
|
if (
|
|
! $admin->isSuperAdmin()
|
|
&& ! $admin->hasPermissionCode('service.players.view')
|
|
&& ! $admin->hasPermissionCode('service.players.manage')
|
|
) {
|
|
return ApiMessage::errorResponse(
|
|
$request,
|
|
'admin.permission_denied',
|
|
ErrorCode::AdminForbidden->value,
|
|
null,
|
|
403,
|
|
);
|
|
}
|
|
|
|
$p = AdminApiList::readPaging($request);
|
|
$keyword = trim((string) $request->query('keyword', ''));
|
|
$status = $request->query('status');
|
|
$agentScope = trim((string) $request->query('agent_scope', ''));
|
|
$scope = AdminScopePolicy::resolveContext($request, $admin);
|
|
|
|
$q = Player::query()
|
|
->with([
|
|
'wallets' => static fn ($wq) => $wq->orderBy('wallet_type')->orderBy('currency_code'),
|
|
'agentNode:id,code,name',
|
|
])
|
|
->orderByDesc('id');
|
|
|
|
AdminScopePolicy::applyPlayerFilters($q, $scope);
|
|
|
|
if ($agentScope === 'direct' && $scope->effectiveRequestedAgentNodeId() !== null) {
|
|
$q->where('agent_node_id', $scope->effectiveRequestedAgentNodeId());
|
|
}
|
|
|
|
if ($keyword !== '') {
|
|
$term = '%'.addcslashes($keyword, '%_\\').'%';
|
|
$q->where(static function ($sub) use ($term, $keyword): void {
|
|
$sub->where('site_player_id', 'like', $term)
|
|
->orWhere('username', 'like', $term)
|
|
->orWhere('nickname', 'like', $term);
|
|
if (ctype_digit($keyword)) {
|
|
$sub->orWhere('id', (int) $keyword);
|
|
}
|
|
});
|
|
}
|
|
|
|
if ($status !== null && $status !== '') {
|
|
$q->where('status', (int) $status);
|
|
}
|
|
|
|
$paginator = $q->paginate($p['perPage'], ['*'], 'page', $p['page']);
|
|
|
|
return AdminApiList::json($paginator, fn (Player $player): array => PlayerApiPresenter::listItem($player));
|
|
}
|
|
}
|