- 在多个控制器中引入 agent_node_id,以支持基于代理节点的权限和数据过滤。 - 更新 AdminRole 和 AdminUser 模型,新增角色范围和代理节点相关功能,提升角色管理的灵活性。 - 在请求验证中添加 agent_node_id 字段,确保 API 接口支持代理节点的相关操作。 - 优化 LotterySettings 服务,支持批量写入设置,提升配置管理的效率。 - 更新仪表板和报告服务,增强数据统计功能,确保管理员能够获取更全面的统计信息。
78 lines
3.0 KiB
PHP
78 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1\Admin\Settlement;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Support\AdminApiList;
|
|
use App\Support\AdminSiteScope;
|
|
use App\Support\AgentNodeApiPresenter;
|
|
use App\Models\SettlementBatch;
|
|
use Illuminate\Http\JsonResponse;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\TicketSettlementDetail;
|
|
|
|
/**
|
|
* GET /api/v1/admin/settlement-batches/{batch}/details — 该批次下注单结算明细分页。
|
|
*/
|
|
final class AdminSettlementBatchDetailsController extends Controller
|
|
{
|
|
public function __invoke(Request $request, SettlementBatch $batch): JsonResponse
|
|
{
|
|
$admin = $request->lotteryAdmin();
|
|
abort_if($admin === null, 401);
|
|
|
|
$p = AdminApiList::readPaging($request);
|
|
$agentNodeId = $request->integer('agent_node_id') ?: null;
|
|
|
|
$detailQuery = TicketSettlementDetail::query()
|
|
->where('settlement_batch_id', $batch->id)
|
|
->with([
|
|
'ticketItem:id,ticket_no,play_code,player_id',
|
|
'ticketItem.player:id,site_code,username,nickname,site_player_id,agent_node_id',
|
|
'ticketItem.player.agentNode:id,code,name',
|
|
'ticketItem.order:id,currency_code',
|
|
]);
|
|
|
|
if (! $admin->isSuperAdmin() || ($agentNodeId !== null && $agentNodeId > 0)) {
|
|
$detailQuery->whereHas('ticketItem.player', static function ($playerQuery) use ($admin, $agentNodeId): void {
|
|
AdminSiteScope::applyPlayerFilters(
|
|
$playerQuery,
|
|
$admin,
|
|
null,
|
|
$agentNodeId !== null && $agentNodeId > 0 ? $agentNodeId : null,
|
|
);
|
|
});
|
|
}
|
|
|
|
$paginator = $detailQuery
|
|
->orderBy('id')
|
|
->paginate($p['perPage'], ['*'], 'page', $p['page']);
|
|
|
|
return AdminApiList::jsonWith($paginator, function ($row) {
|
|
/** @var TicketSettlementDetail $row */
|
|
$item = $row->ticketItem;
|
|
$player = $item?->player;
|
|
$order = $item?->order;
|
|
|
|
return [
|
|
'id' => (int) $row->id,
|
|
'ticket_item_id' => (int) $row->ticket_item_id,
|
|
...AgentNodeApiPresenter::embed($player?->agentNode),
|
|
'ticket_no' => $item?->ticket_no,
|
|
'play_code' => $item?->play_code,
|
|
'currency_code' => $order?->currency_code,
|
|
'player_id' => $item?->player_id,
|
|
'site_code' => $player?->site_code,
|
|
'site_player_id' => $player?->site_player_id,
|
|
'username' => $player?->username,
|
|
'nickname' => $player?->nickname,
|
|
'matched_prize_tier' => $row->matched_prize_tier,
|
|
'win_amount' => (int) $row->win_amount,
|
|
'jackpot_allocation_amount' => (int) $row->jackpot_allocation_amount,
|
|
'match_detail_json' => $row->match_detail_json,
|
|
'created_at' => $row->created_at?->toIso8601String(),
|
|
];
|
|
}, ['batch_id' => (int) $batch->id]);
|
|
}
|
|
}
|