ThirdGameOrder.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Http\Controllers\admin;
  3. use App\Constants\HttpStatus;
  4. use App\Http\Controllers\Controller;
  5. use App\Services\ThirdGameOrderService;
  6. use Exception;
  7. use Illuminate\Http\JsonResponse;
  8. use Illuminate\Validation\ValidationException;
  9. class ThirdGameOrder extends Controller
  10. {
  11. public function index(ThirdGameOrderService $service): JsonResponse
  12. {
  13. try {
  14. $params = request()->validate([
  15. 'page' => ['nullable', 'integer', 'min:1'],
  16. 'limit' => ['nullable', 'integer', 'min:1', 'max:200'],
  17. 'user_id' => ['nullable', 'integer', 'min:1'],
  18. 'member_id' => ['nullable', 'string', 'max:64'],
  19. 'username' => ['nullable', 'string', 'max:128'],
  20. 'first_name' => ['nullable', 'string', 'max:128'],
  21. 'player_id' => ['nullable', 'string', 'max:32'],
  22. 'platform' => ['nullable', 'string', 'max:32'],
  23. 'game_order_id' => ['nullable', 'string', 'max:128'],
  24. 'game_type' => ['nullable', 'integer', 'in:1,2,3,4,5,6,7'],
  25. 'status' => ['nullable', 'integer', 'in:0,1,2,3'],
  26. 'start_time' => ['nullable', 'date_format:Y-m-d H:i:s', 'required_with:end_time'],
  27. 'end_time' => [
  28. 'nullable', 'date_format:Y-m-d H:i:s', 'required_with:start_time', 'after_or_equal:start_time',
  29. ],
  30. ]);
  31. $sync = $service->syncForList($params);
  32. $result = $service->paginate($params);
  33. $result['sync'] = $sync;
  34. return $this->success($result);
  35. } catch (ValidationException $e) {
  36. return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
  37. } catch (Exception $e) {
  38. return $this->error(HttpStatus::CUSTOM_ERROR, $e->getMessage());
  39. }
  40. }
  41. }