Issue.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. public function cao()
  75. {
  76. $type = [1, 2, 3, 4];
  77. $list = [];
  78. $list[] = Cao::whereIn('id', $type)->get();
  79. $type = [5, 6, 7, 8];
  80. $list[] = Cao::whereIn('id', $type)->get();
  81. $type = [9, 10];
  82. $list[] = Cao::whereIn('id', $type)->get();
  83. $list[] = [
  84. ['field' => '2.8回本', 'val' => 0],
  85. ['field' => '3.2回本', 'val' => 0],
  86. ];
  87. $type = [11, 12, 13];
  88. $list[] = Cao::whereIn('id', $type)->get();
  89. $list[] = Cao::where('id', '>=', 14)
  90. ->where('id', '<=', 41)
  91. ->get();
  92. $list[] = [
  93. ['field' => '龙', 'val' => 0],
  94. ['field' => '虎', 'val' => 0],
  95. ['field' => '合', 'val' => 0],
  96. ['field' => '鸡', 'val' => 0],
  97. ['field' => '鸭', 'val' => 0],
  98. ['field' => '狗', 'val' => 0],
  99. ];
  100. $list[] = [
  101. ['field' => '中', 'val' => 0],
  102. ['field' => '边', 'val' => 0],
  103. ['field' => '大边', 'val' => 0],
  104. ['field' => '小边', 'val' => 0],
  105. ];
  106. $list[] = Cao::where('id', '>=', 42)
  107. ->where('id', '<=', 49)
  108. ->get();
  109. $list[] = [
  110. ['field' => '三军0点', 'val' => 0],
  111. ['field' => '三军1点', 'val' => 0],
  112. ['field' => '三军2点', 'val' => 0],
  113. ['field' => '三军3点', 'val' => 0],
  114. ['field' => '三军4点', 'val' => 0],
  115. ['field' => '三军5点', 'val' => 0],
  116. ['field' => '三军6点', 'val' => 0],
  117. ['field' => '三军7点', 'val' => 0],
  118. ['field' => '三军8点', 'val' => 0],
  119. ['field' => '三军9点', 'val' => 0],
  120. ];
  121. $list[] = Cao::where('id', '>=', 50)
  122. ->where('id', '<=', 63)
  123. ->get();
  124. $list[] = Cao::where('id', '>=', 64)
  125. ->where('id', '<=', 77)
  126. ->get();
  127. $list[] = Cao::where('id', '>=', 78)
  128. ->where('id', '<=', 91)
  129. ->get();
  130. return $this->success($list);
  131. }
  132. }