- 在多个控制器中将权限检查从 hasAdminPermission 更新为 hasPermissionCode,以增强权限管理的灵活性。 - 引入 AdminScopePolicy,优化基于代理节点的权限和数据过滤逻辑,确保管理员能够更精确地控制访问权限。 - 在请求验证中添加 agent_node_id 字段,确保 API 接口支持代理节点的相关操作。 - 更新 AdminUser 模型,新增 hasPermissionCode 方法,以支持更细粒度的权限检查。 - 优化审计日志记录逻辑,确保在处理请求时能够准确记录管理员的操作。
73 lines
2.9 KiB
PHP
73 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1\Admin\Settlement;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Support\AdminApiList;
|
|
use App\Support\AdminScopePolicy;
|
|
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);
|
|
$scope = AdminScopePolicy::resolveContext($request, $admin);
|
|
|
|
$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 (! $scope->isSuperAdmin() || $scope->effectiveRequestedAgentNodeId() !== null) {
|
|
$detailQuery->whereHas('ticketItem.player', function ($playerQuery) use ($scope): void {
|
|
AdminScopePolicy::applyPlayerFilters($playerQuery, $scope);
|
|
});
|
|
}
|
|
|
|
$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]);
|
|
}
|
|
}
|