Bet.php 5.1 KB

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