1. 新增完整的后台玩家管理CRUD接口,包括列表、创建、详情、更新、删除 2. 新增转账订单冲正和人工处理功能,支持待对账订单状态变更 3. 扩展钱包流水和转账订单的状态支持,新增reversed、manually_processed等状态 4. 新增玩家API数据统一输出类,标准化玩家信息返回格式
44 lines
1.4 KiB
PHP
44 lines
1.4 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\PlayerApiPresenter;
|
|
|
|
/** GET /api/v1/admin/players */
|
|
final class AdminPlayerIndexController extends Controller
|
|
{
|
|
public function __invoke(Request $request): JsonResponse
|
|
{
|
|
$p = AdminApiList::readPaging($request);
|
|
$keyword = trim((string) $request->query('keyword', ''));
|
|
$status = $request->query('status');
|
|
|
|
$q = Player::query()
|
|
->with(['wallets' => static fn ($wq) => $wq->orderBy('wallet_type')->orderBy('currency_code')])
|
|
->orderByDesc('id');
|
|
|
|
if ($keyword !== '') {
|
|
$term = '%'.addcslashes($keyword, '%_\\').'%';
|
|
$q->where(static function ($sub) use ($term): void {
|
|
$sub->where('site_player_id', 'like', $term)
|
|
->orWhere('username', 'like', $term)
|
|
->orWhere('nickname', '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));
|
|
}
|
|
}
|