- 在多个控制器中更新玩家相关数据的查询,新增 'nickname' 字段以增强玩家信息的完整性。 - 在 AdminDashboardSnapshotBuilder 中引入平台风险统计,提供锁定金额和使用百分比的概览。 - 更新 AdminReportQueryService 以返回更详细的统计数据,包括总投注、总中奖和总派彩金额。 - 增强测试用例以验证新增字段和统计功能的准确性。
54 lines
1.7 KiB
PHP
54 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1\Admin\Player;
|
|
|
|
use App\Models\Player;
|
|
use Illuminate\Http\Request;
|
|
use App\Support\ApiResponse;
|
|
use Illuminate\Http\JsonResponse;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Support\AdminApiList;
|
|
use App\Support\AdminSiteScope;
|
|
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);
|
|
|
|
$p = AdminApiList::readPaging($request);
|
|
$keyword = trim((string) $request->query('keyword', ''));
|
|
$status = $request->query('status');
|
|
$siteCode = $request->query('site_code');
|
|
|
|
$q = Player::query()
|
|
->with(['wallets' => static fn ($wq) => $wq->orderBy('wallet_type')->orderBy('currency_code')])
|
|
->orderByDesc('id');
|
|
|
|
AdminSiteScope::applyPlayerFilters(
|
|
$q,
|
|
$admin,
|
|
is_string($siteCode) ? $siteCode : null,
|
|
);
|
|
|
|
if ($keyword !== '') {
|
|
$term = '%'.addcslashes($keyword, '%_\\').'%';
|
|
$q->where(static function ($sub) use ($term): void {
|
|
$sub->where('site_player_id', 'like', $term)
|
|
->orWhere('username', 'like', $term);
|
|
});
|
|
}
|
|
|
|
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));
|
|
}
|
|
}
|