Bet.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. /**
  12. * @description: 分页数据
  13. * @return {*}
  14. *
  15. * @apiParam {String} [start_time] 开始时间
  16. * - 格式:`yyyy-mm-dd`
  17. * @apiParam {String} [end_time] 截止时间
  18. * - 格式:`yyyy-mm-dd`
  19. */
  20. function index()
  21. {
  22. try {
  23. $params = request()->validate([
  24. 'page' => ['nullable', 'integer', 'min:1'],
  25. 'limit' => ['nullable', 'integer', 'min:1'],
  26. 'member_id' => ['nullable', 'string'],
  27. 'keywords' => ['nullable', 'string', 'min:1'],
  28. 'issue_no' => ['nullable', 'string'],
  29. 'id' => ['nullable', 'string'],
  30. 'status' => ['nullable', 'integer', 'in:1,2'],
  31. 'username' => ['nullable', 'string', 'min:1'],
  32. 'start_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:end_time'],
  33. 'end_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:start_time'],
  34. ]);
  35. $result = BetService::paginate($params);
  36. } catch (ValidationException $e) {
  37. return $this->error(HttpStatus::VALIDATION_FAILED, $e->validator->errors()->first());
  38. } catch (Exception $e) {
  39. return $this->error(intval($e->getCode()));
  40. }
  41. return $this->success($result);
  42. }
  43. // 模拟下注
  44. public function fake()
  45. {
  46. BetService::fakeBet();
  47. return $this->success();
  48. }
  49. // /**
  50. // * @description: 修改|新增
  51. // * @return {*}
  52. // */
  53. // public function store()
  54. // {
  55. // // try {
  56. // $params = request()->all();
  57. // $validator = [
  58. // 'issue_no' => 'required|string|max:50|alpha_dash|unique:issues,issue_no',
  59. // 'winning_numbers' => 'nullable|string|max:100',
  60. // 'status' => 'nullable|string',
  61. // ];
  62. // request()->validate($validator);
  63. // $ret = BetService::submit($params);
  64. // if ($ret['code'] == BetService::NOT) {
  65. // return $this->error($ret['code'], $ret['msg']);
  66. // }
  67. // // } catch (ValidationException $e) {
  68. // // return $this->error(HttpStatus::VALIDATION_FAILED, '', $e->errors());
  69. // // } catch (Exception $e) {
  70. // // return $this->error(intval($e->getCode()));
  71. // // }
  72. // return $this->success([], $ret['msg']);
  73. // }
  74. // /**
  75. // * @description: 开始
  76. // * @return {*}
  77. // */
  78. // public function betting()
  79. // {
  80. // $id = request()->input('id');
  81. // if (!$id) {
  82. // return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');
  83. // }
  84. // $ret = BetService::betting($id);
  85. // if ($ret['code'] == BetService::NOT) {
  86. // return $this->error($ret['code'], $ret['msg']);
  87. // }
  88. // return $this->success([], $ret['msg']);
  89. // }
  90. // /**
  91. // * @description: 关闭
  92. // * @return {*}
  93. // */
  94. // public function close()
  95. // {
  96. // $id = request()->input('id');
  97. // if (!$id) {
  98. // return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');
  99. // }
  100. // $ret = BetService::closeBetting($id);
  101. // if ($ret['code'] == BetService::NOT) {
  102. // return $this->error($ret['code'], $ret['msg']);
  103. // }
  104. // return $this->success([], $ret['msg']);
  105. // }
  106. // /**
  107. // * @description: 开奖
  108. // * @return {*}
  109. // */
  110. // public function lotteryDraw()
  111. // {
  112. // $id = request()->input('id');
  113. // $winning_numbers = request()->input('winning_numbers');
  114. // $image = request()->input('image');
  115. // $combo = request()->input('combo');
  116. // if (!$id) {
  117. // return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');
  118. // }
  119. // if (!$winning_numbers) {
  120. // return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');
  121. // }
  122. // if(explode(',', $winning_numbers) < 3){
  123. // return $this->error(HttpStatus::VALIDATION_FAILED, '开奖号码格式错误');
  124. // }
  125. // $ret = BetService::lotteryDraw($id,$winning_numbers,$combo,$image);
  126. // if ($ret['code'] == BetService::NOT) {
  127. // return $this->error($ret['code'], $ret['msg']);
  128. // }
  129. // return $this->success([], $ret['msg']);
  130. // }
  131. // /**
  132. // * @description: 删除
  133. // */
  134. // public function destroy()
  135. // {
  136. // $id = request()->post('id');
  137. // // 示例:通过 ID 删除
  138. // $Bet= IssueService::findOne(['id' => $id]);
  139. // if (!$info) {
  140. // return $this->error(0, '期数不存在');
  141. // }
  142. // $info->delete();
  143. // return $this->success([], '删除成功');
  144. // }
  145. }