Bet.php 1.5 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\BetService;
  6. use Illuminate\Support\Facades\DB;
  7. use Illuminate\Validation\ValidationException;
  8. use Exception;
  9. class Bet extends Controller
  10. {
  11. function index()
  12. {
  13. try {
  14. $params = request()->validate([
  15. 'page' => ['nullable', 'integer', 'min:1'],
  16. 'limit' => ['nullable', 'integer', 'min:1'],
  17. 'member_id' => ['nullable', 'string'],
  18. 'keywords' => ['nullable', 'string', 'min:1'],
  19. 'issue_no' => ['nullable', 'string'],
  20. 'id' => ['nullable', 'string'],
  21. 'status' => ['nullable', 'integer', 'in:1,2'],
  22. 'username' => ['nullable', 'string', 'min:1'],
  23. 'start_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:end_time'],
  24. 'end_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:start_time'],
  25. 'is_winner'=>['nullable','integer','in:0,1'],
  26. ]);
  27. $result = BetService::paginate($params);
  28. } catch (ValidationException $e) {
  29. return $this->error(HttpStatus::VALIDATION_FAILED, $e->validator->errors()->first());
  30. } catch (Exception $e) {
  31. return $this->error(intval($e->getCode()));
  32. }
  33. return $this->success($result);
  34. }
  35. // 模拟下注
  36. public function fake()
  37. {
  38. BetService::randomVirtualBetting(3);
  39. return $this->success();
  40. }
  41. }