Issue.php 4.8 KB

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