execute(function () use ($request) { $fields = 'available_balance,created_at,last_active_time,frozen_balance,yuebao,total_consume,wager_required,wager_completed,wager_remaining,third_game_total_balance'; $search = $request->validate([ 'page' => ['nullable', 'integer', 'min:1'], 'limit' => ['nullable', 'integer', 'min:1', 'max:100'], 'member_id' => ['nullable', 'string', 'min:1'], 'account' => ['nullable', 'string', 'min:1'], 'like_first_name' => ['nullable', 'string', 'min:1'], 'username' => ['nullable', 'string', 'min:1'], 'register_ip' => ['nullable', 'string', 'min:1'], 'level' => ['nullable'], 'is_online' => ['nullable', 'boolean'], 'sort_field' => ['nullable', 'string', 'in:' . $fields], 'sort_order' => ['nullable', 'string', 'in:asc,desc'], 'start_time' => ['nullable', 'date_format:Y-m-d', 'required_with:end_time'], 'end_time' => ['nullable', 'date_format:Y-m-d', 'required_with:start_time'], ]); $search['agent_id'] = (int) $this->currentAgent()->id; $result = UserService::paginate($search, $search['sort_order'] ?? 'desc', $search['sort_field'] ?? 'created_at'); foreach ($result['data'] as $user) { // 去掉总后台专用字段:后台备注、实名、找回密钥、推荐人(可能属于其他代理)。 $user->makeHidden(self::HIDDEN_USER_FIELDS)->unsetRelation('agent'); $user->wallet?->setVisible(self::WALLET_FIELDS); } return $result; }); } public function dailyReport(Request $request, MemberDailyReportService $reports) { return $this->execute(function () use ($request, $reports) { $data = $request->validate([ 'page' => ['nullable', 'integer', 'min:1'], 'limit' => ['nullable', 'integer', 'min:1', 'max:100'], 'start_date' => ['nullable', 'date_format:Y-m-d'], 'end_date' => ['nullable', 'date_format:Y-m-d', 'after_or_equal:start_date'], 'member_id' => ['nullable', 'string', 'max:64'], 'username' => ['nullable', 'string', 'max:128'], ]); return $reports->paginate($data, $this->currentAgent()); }); } public function finance(Request $request, AgentMemberService $service) { return $this->execute(fn() => $service->finance($this->currentAgent(), $this->validateList($request))); } public function bets(Request $request, AgentMemberService $service) { return $this->execute(function () use ($request, $service) { $data = $request->validate([ 'page' => ['nullable', 'integer', 'min:1'], 'limit' => ['nullable', 'integer', 'min:1', 'max:100'], 'source' => ['nullable', 'in:pc28,sport,jisu,lhc,third'], 'member_id' => ['nullable', 'string', 'max:64'], 'username' => ['nullable', 'string', 'max:128'], 'status' => ['nullable', 'integer'], 'start_date' => ['nullable', 'date_format:Y-m-d'], 'end_date' => ['nullable', 'date_format:Y-m-d', 'after_or_equal:start_date'], ]); return $service->bets($this->currentAgent(), $data); }); } private function validateList(Request $request): array { return $request->validate([ 'page' => ['nullable', 'integer', 'min:1'], 'limit' => ['nullable', 'integer', 'min:1', 'max:100'], 'keyword' => ['nullable', 'string', 'max:128'], 'agent_id' => ['nullable', 'integer'], 'status' => ['nullable', 'integer'], 'start_date' => ['nullable', 'date_format:Y-m-d'], 'end_date' => ['nullable', 'date_format:Y-m-d', 'after_or_equal:start_date'], ]); } }