feat: 增强管理员功能与数据处理
- 在多个控制器中引入 agent_node_id,以支持基于代理节点的权限和数据过滤。 - 更新 AdminRole 和 AdminUser 模型,新增角色范围和代理节点相关功能,提升角色管理的灵活性。 - 在请求验证中添加 agent_node_id 字段,确保 API 接口支持代理节点的相关操作。 - 优化 LotterySettings 服务,支持批量写入设置,提升配置管理的效率。 - 更新仪表板和报告服务,增强数据统计功能,确保管理员能够获取更全面的统计信息。
This commit is contained in:
@@ -13,6 +13,9 @@ final class AdminReportDailyProfitController extends Controller
|
||||
{
|
||||
public function __invoke(AdminReportQueryRequest $request, AdminReportQueryService $service): JsonResponse
|
||||
{
|
||||
$admin = $request->lotteryAdmin();
|
||||
abort_if($admin === null, 401);
|
||||
|
||||
$validated = $request->validated();
|
||||
$p = AdminApiList::readPaging($request);
|
||||
$range = $service->resolveDateRange($validated);
|
||||
@@ -22,6 +25,7 @@ final class AdminReportDailyProfitController extends Controller
|
||||
$range['date_to'],
|
||||
$p['page'],
|
||||
$p['perPage'],
|
||||
$admin,
|
||||
);
|
||||
|
||||
return AdminApiList::json($paginator, static fn (array $row): array => $row);
|
||||
|
||||
@@ -13,6 +13,9 @@ final class AdminReportPlayDimensionController extends Controller
|
||||
{
|
||||
public function __invoke(AdminReportQueryRequest $request, AdminReportQueryService $service): JsonResponse
|
||||
{
|
||||
$admin = $request->lotteryAdmin();
|
||||
abort_if($admin === null, 401);
|
||||
|
||||
$validated = $request->validated();
|
||||
$p = AdminApiList::readPaging($request);
|
||||
$range = $service->resolveDateRange($validated);
|
||||
@@ -24,6 +27,7 @@ final class AdminReportPlayDimensionController extends Controller
|
||||
$range['date_to'],
|
||||
$p['page'],
|
||||
$p['perPage'],
|
||||
$admin,
|
||||
);
|
||||
|
||||
return AdminApiList::json($paginator, static function (object $row): array {
|
||||
|
||||
@@ -13,10 +13,14 @@ final class AdminReportPlayerWinLossController extends Controller
|
||||
{
|
||||
public function __invoke(AdminReportQueryRequest $request, AdminReportQueryService $service): JsonResponse
|
||||
{
|
||||
$admin = $request->lotteryAdmin();
|
||||
abort_if($admin === null, 401);
|
||||
|
||||
$validated = $request->validated();
|
||||
$p = AdminApiList::readPaging($request);
|
||||
$range = $service->resolveDateRange($validated);
|
||||
$playerId = isset($validated['player_id']) ? (int) $validated['player_id'] : null;
|
||||
$agentNodeId = isset($validated['agent_node_id']) ? (int) $validated['agent_node_id'] : null;
|
||||
|
||||
$paginator = $service->playerWinLossPaginated(
|
||||
$playerId,
|
||||
@@ -24,11 +28,16 @@ final class AdminReportPlayerWinLossController extends Controller
|
||||
$range['date_to'],
|
||||
$p['page'],
|
||||
$p['perPage'],
|
||||
$admin,
|
||||
$agentNodeId > 0 ? $agentNodeId : null,
|
||||
);
|
||||
|
||||
return AdminApiList::json($paginator, static function (object $row): array {
|
||||
return [
|
||||
'player_id' => (int) $row->player_id,
|
||||
'agent_node_id' => isset($row->agent_node_id) ? (int) $row->agent_node_id : null,
|
||||
'agent_code' => isset($row->agent_code) ? (string) $row->agent_code : null,
|
||||
'agent_name' => isset($row->agent_name) ? (string) $row->agent_name : null,
|
||||
'username' => $row->username !== null ? (string) $row->username : 'player#'.(int) $row->player_id,
|
||||
'total_bet_minor' => (int) $row->total_bet_minor,
|
||||
'total_payout_minor' => (int) $row->total_payout_minor,
|
||||
|
||||
@@ -13,6 +13,9 @@ final class AdminReportRebateCommissionController extends Controller
|
||||
{
|
||||
public function __invoke(AdminReportQueryRequest $request, AdminReportQueryService $service): JsonResponse
|
||||
{
|
||||
$admin = $request->lotteryAdmin();
|
||||
abort_if($admin === null, 401);
|
||||
|
||||
$validated = $request->validated();
|
||||
$p = AdminApiList::readPaging($request);
|
||||
$range = $service->resolveDateRange($validated);
|
||||
@@ -24,6 +27,7 @@ final class AdminReportRebateCommissionController extends Controller
|
||||
$range['date_to'],
|
||||
$p['page'],
|
||||
$p['perPage'],
|
||||
$admin,
|
||||
);
|
||||
|
||||
return AdminApiList::json($paginator, static function (object $row): array {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Admin\Reports;
|
||||
|
||||
use App\Models\AdminUser;
|
||||
use App\Models\ReportJob;
|
||||
use App\Services\Admin\AdminReportJobService;
|
||||
use App\Services\Admin\AdminReportQueryService;
|
||||
@@ -29,7 +30,8 @@ final class ReportJobDownloadController
|
||||
$dateTo,
|
||||
);
|
||||
$filename = $label.'_'.$pathSuffix.'.'.$report_job->export_format;
|
||||
$rows = $service->reportRows((string) $report_job->report_type, $filterJson);
|
||||
$scopedAdmin = AdminUser::query()->find((int) $report_job->admin_user_id);
|
||||
$rows = $service->reportRows((string) $report_job->report_type, $filterJson, $scopedAdmin);
|
||||
|
||||
if ((string) $report_job->export_format === 'xlsx') {
|
||||
return $spreadsheetExporter->streamDownload($rows, $filename);
|
||||
|
||||
Reference in New Issue
Block a user