Bet.php 4.4 KB

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