Issue.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. namespace App\Http\Controllers\api;
  3. use App\Models\Cao;
  4. use App\Models\Prediction;
  5. use App\Services\IssueService;
  6. use Illuminate\Validation\ValidationException;
  7. use Exception;
  8. class Issue extends BaseController
  9. {
  10. /**
  11. * @api {get} /issue/prediction 预测
  12. * @apiGroup Issue
  13. * @apiVersion 1.0.0
  14. *
  15. * @apiSuccess {int} code
  16. * @apiSuccess {int} timestamp
  17. * @apiSuccess {String} msg
  18. * @apiSuccess {Object} data
  19. *
  20. * @apiParam {int} [page=1]
  21. * @apiParam {int} [limit=10]
  22. */
  23. function prediction()
  24. {
  25. try {
  26. request()->validate([
  27. 'page' => ['nullable', 'integer', 'min:1'],
  28. 'limit' => ['nullable', 'integer', 'min:1']
  29. ]);
  30. $page = request()->input('page', 1);
  31. $limit = request()->input('limit', 10);
  32. $list = Prediction::forPage($page, $limit)
  33. ->orderByDesc('issue_no')
  34. ->get();
  35. } catch (ValidationException $e) {
  36. return $this->error($e->validator->errors()->first());
  37. } catch (Exception $e) {
  38. return $this->error($e->getMessage());
  39. }
  40. return $this->success($list);
  41. }
  42. /**
  43. * @api {get} /issue/countdown 倒计时
  44. * @apiGroup Issue
  45. * @apiVersion 1.0.0
  46. *
  47. * @apiSuccess {int} code
  48. * @apiSuccess {int} timestamp
  49. * @apiSuccess {String} msg
  50. * @apiSuccess {Object} data
  51. * @apiSuccess {String} data.issue_no 期号
  52. * @apiSuccess {int} data.current_time 当前时间
  53. * @apiSuccess {int} data.end_time 结束时间
  54. * @apiSuccess {Object} data.winnings 开奖结果
  55. *
  56. */
  57. public function countdown()
  58. {
  59. $data1 = \App\Models\Issue::where('status', 1)->orderByDesc('issue_no')->first();
  60. $data2 = \App\Models\Issue::where('status', 3)->orderByDesc('issue_no')->first();
  61. $winnings = explode(',', $data2->winning_numbers);
  62. $winnings = array_map('intval', $winnings);
  63. $award = IssueService::award($winnings);
  64. $arr['sum'] = array_sum($winnings);
  65. $arr['a'] = $winnings[0];
  66. $arr['b'] = $winnings[1];
  67. $arr['c'] = $winnings[2];
  68. $arr['size'] = in_array('大', $award) ? '大' : "小";
  69. $arr['odd_or_even'] = in_array('单', $award) ? '单' : "双";
  70. $arr['issue_no'] = $data2->issue_no;
  71. $data = [
  72. 'issue_no' => $data1->issue_no,
  73. 'current_time' => time(),
  74. 'end_time' => strtotime($data1->end_time),
  75. 'winnings' => $arr,
  76. ];
  77. return $this->success($data);
  78. }
  79. /**
  80. * @api {get} /issue 结果,走势
  81. * @apiGroup Issue
  82. * @apiVersion 1.0.0
  83. *
  84. * @apiParam {int} [page=1]
  85. * @apiParam {int} [limit=10]
  86. *
  87. * @apiSuccess {int} code
  88. * @apiSuccess {int} timestamp
  89. * @apiSuccess {String} msg
  90. * @apiSuccess {Object[]} data
  91. * @apiSuccess {int} data.id
  92. * @apiSuccess {String} data.issue_no 期号
  93. * @apiSuccess {String} data.start_time 开始时间
  94. * @apiSuccess {String} data.end_time 结束时间
  95. * @apiSuccess {String[]} data.award 开奖结果
  96. * @apiSuccess {String[]} data.winning_array 开奖结果
  97. * @apiSuccess {int} data.end_timestamp 结束时间 时间戳
  98. *
  99. */
  100. public function index()
  101. {
  102. try {
  103. $page = request()->input('page', 1);
  104. $limit = request()->input('limit', 10);
  105. $params = [
  106. 'page' => $page,
  107. 'limit' => $limit
  108. // 'status'=>3
  109. ];
  110. $res = IssueService::paginate($params);
  111. } catch (ValidationException $e) {
  112. return $this->error($e->validator->errors()->first());
  113. } catch (Exception $e) {
  114. return $this->error($e->getMessage());
  115. }
  116. return $this->success($res);
  117. }
  118. /**
  119. * @api {get} /issue/cao 统计
  120. * @apiGroup Issue
  121. * @apiVersion 1.0.0
  122. *
  123. * @apiSuccess {int} code
  124. * @apiSuccess {int} timestamp
  125. * @apiSuccess {String} msg
  126. * @apiSuccess {Object[]} data
  127. *
  128. */
  129. public function cao()
  130. {
  131. $type = [1, 2, 3, 4];
  132. $list = [];
  133. $list[] = Cao::whereIn('id', $type)->get();
  134. $type = [5, 6, 7, 8];
  135. $list[] = Cao::whereIn('id', $type)->get();
  136. $type = [9, 10];
  137. $list[] = Cao::whereIn('id', $type)->get();
  138. $list[] = [
  139. ['field' => '2.8回本', 'val' => 0],
  140. ['field' => '3.2回本', 'val' => 0],
  141. ];
  142. $type = [11, 12, 13];
  143. $list[] = Cao::whereIn('id', $type)->get();
  144. $list[] = Cao::where('id', '>=', 14)
  145. ->where('id', '<=', 41)
  146. ->get();
  147. $list[] = [
  148. ['field' => '龙', 'val' => 0],
  149. ['field' => '虎', 'val' => 0],
  150. ['field' => '合', 'val' => 0],
  151. ['field' => '鸡', 'val' => 0],
  152. ['field' => '鸭', 'val' => 0],
  153. ['field' => '狗', 'val' => 0],
  154. ];
  155. $list[] = [
  156. ['field' => '中', 'val' => 0],
  157. ['field' => '边', 'val' => 0],
  158. ['field' => '大边', 'val' => 0],
  159. ['field' => '小边', 'val' => 0],
  160. ];
  161. $list[] = Cao::where('id', '>=', 42)
  162. ->where('id', '<=', 49)
  163. ->get();
  164. $list[] = [
  165. ['field' => '三军0点', 'val' => 0],
  166. ['field' => '三军1点', 'val' => 0],
  167. ['field' => '三军2点', 'val' => 0],
  168. ['field' => '三军3点', 'val' => 0],
  169. ['field' => '三军4点', 'val' => 0],
  170. ['field' => '三军5点', 'val' => 0],
  171. ['field' => '三军6点', 'val' => 0],
  172. ['field' => '三军7点', 'val' => 0],
  173. ['field' => '三军8点', 'val' => 0],
  174. ['field' => '三军9点', 'val' => 0],
  175. ];
  176. $list[] = Cao::where('id', '>=', 50)
  177. ->where('id', '<=', 63)
  178. ->get();
  179. $list[] = Cao::where('id', '>=', 64)
  180. ->where('id', '<=', 77)
  181. ->get();
  182. $list[] = Cao::where('id', '>=', 78)
  183. ->where('id', '<=', 91)
  184. ->get();
  185. return $this->success($list);
  186. }
  187. }