Bet.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. return $this->success();
  39. }
  40. // /**
  41. // * 修改|新增
  42. // *
  43. // */
  44. // public function store()
  45. // {
  46. // // try {
  47. // $params = request()->all();
  48. // $validator = [
  49. // 'issue_no' => 'required|string|max:50|alpha_dash|unique:issues,issue_no',
  50. // 'winning_numbers' => 'nullable|string|max:100',
  51. // 'status' => 'nullable|string',
  52. // ];
  53. // request()->validate($validator);
  54. // $ret = BetService::submit($params);
  55. // if ($ret['code'] == BetService::NOT) {
  56. // return $this->error($ret['code'], $ret['msg']);
  57. // }
  58. // // } catch (ValidationException $e) {
  59. // // return $this->error(HttpStatus::VALIDATION_FAILED, '', $e->errors());
  60. // // } catch (Exception $e) {
  61. // // return $this->error(intval($e->getCode()));
  62. // // }
  63. // return $this->success([], $ret['msg']);
  64. // }
  65. // /**
  66. // *开始
  67. // *
  68. // */
  69. // public function betting()
  70. // {
  71. // $id = request()->input('id');
  72. // if (!$id) {
  73. // return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');
  74. // }
  75. // $ret = BetService::betting($id);
  76. // if ($ret['code'] == BetService::NOT) {
  77. // return $this->error($ret['code'], $ret['msg']);
  78. // }
  79. // return $this->success([], $ret['msg']);
  80. // }
  81. // /**
  82. // * 关闭
  83. // *
  84. // */
  85. // public function close()
  86. // {
  87. // $id = request()->input('id');
  88. // if (!$id) {
  89. // return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');
  90. // }
  91. // $ret = BetService::closeBetting($id);
  92. // if ($ret['code'] == BetService::NOT) {
  93. // return $this->error($ret['code'], $ret['msg']);
  94. // }
  95. // return $this->success([], $ret['msg']);
  96. // }
  97. // /**
  98. // * 开奖
  99. // *
  100. // */
  101. // public function lotteryDraw()
  102. // {
  103. // $id = request()->input('id');
  104. // $winning_numbers = request()->input('winning_numbers');
  105. // $image = request()->input('image');
  106. // $combo = request()->input('combo');
  107. // if (!$id) {
  108. // return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');
  109. // }
  110. // if (!$winning_numbers) {
  111. // return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');
  112. // }
  113. // if(explode(',', $winning_numbers) < 3){
  114. // return $this->error(HttpStatus::VALIDATION_FAILED, '开奖号码格式错误');
  115. // }
  116. // $ret = BetService::lotteryDraw($id,$winning_numbers,$combo,$image);
  117. // if ($ret['code'] == BetService::NOT) {
  118. // return $this->error($ret['code'], $ret['msg']);
  119. // }
  120. // return $this->success([], $ret['msg']);
  121. // }
  122. // /**
  123. // * 删除
  124. // */
  125. // public function destroy()
  126. // {
  127. // $id = request()->post('id');
  128. // // 示例:通过 ID 删除
  129. // $Bet= IssueService::findOne(['id' => $id]);
  130. // if (!$info) {
  131. // return $this->error(0, '期数不存在');
  132. // }
  133. // $info->delete();
  134. // return $this->success([], '删除成功');
  135. // }
  136. }