Issue.php 5.2 KB

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