Bet.php 4.5 KB

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