MemberController.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Http\Controllers\agent;
  3. use App\Http\Controllers\AgentApiController;
  4. use App\Services\Agent\AgentMemberService;
  5. use Illuminate\Http\Request;
  6. class MemberController extends AgentApiController
  7. {
  8. public function index(Request $request, AgentMemberService $service)
  9. {
  10. return $this->execute(fn() => $service->paginate($this->currentAgent(), $this->validateList($request)));
  11. }
  12. public function finance(Request $request, AgentMemberService $service)
  13. {
  14. return $this->execute(fn() => $service->finance($this->currentAgent(), $this->validateList($request)));
  15. }
  16. public function bets(Request $request, AgentMemberService $service)
  17. {
  18. return $this->execute(function () use ($request, $service) {
  19. $data = $request->validate([
  20. 'page' => ['nullable', 'integer', 'min:1'], 'limit' => ['nullable', 'integer', 'min:1', 'max:100'],
  21. 'source' => ['nullable', 'in:pc28,sport,jisu,lhc,third'], 'member_id' => ['nullable', 'string', 'max:64'],
  22. 'username' => ['nullable', 'string', 'max:128'], 'status' => ['nullable', 'integer'],
  23. 'start_date' => ['nullable', 'date_format:Y-m-d'], 'end_date' => ['nullable', 'date_format:Y-m-d', 'after_or_equal:start_date'],
  24. ]);
  25. return $service->bets($this->currentAgent(), $data);
  26. });
  27. }
  28. private function validateList(Request $request): array
  29. {
  30. return $request->validate([
  31. 'page' => ['nullable', 'integer', 'min:1'], 'limit' => ['nullable', 'integer', 'min:1', 'max:100'],
  32. 'keyword' => ['nullable', 'string', 'max:128'], 'agent_id' => ['nullable', 'integer'],
  33. 'status' => ['nullable', 'integer'], 'start_date' => ['nullable', 'date_format:Y-m-d'],
  34. 'end_date' => ['nullable', 'date_format:Y-m-d', 'after_or_equal:start_date'],
  35. ]);
  36. }
  37. }