| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?php
- namespace App\Http\Controllers\api;
- use App\Models\Cao;
- use App\Models\Prediction;
- use App\Services\IssueService;
- use Illuminate\Validation\ValidationException;
- use Exception;
- class Issue extends BaseController
- {
- /**
- * @api {get} /issue/prediction 预测
- * @apiGroup Issue
- * @apiVersion 1.0.0
- *
- * @apiSuccess {int} code
- * @apiSuccess {int} timestamp
- * @apiSuccess {String} msg
- * @apiSuccess {Object} data
- *
- * @apiParam {int} [page=1]
- * @apiParam {int} [limit=10]
- *
- * @apiSuccess {int} code
- * @apiSuccess {int} timestamp
- * @apiSuccess {String} msg
- * @apiSuccess {Object[]} data
- * @apiSuccess {int} data.id
- * @apiSuccess {String} data.issue_no 期号
- * @apiSuccess {int} data.size 预测大小:0小,1大
- * @apiSuccess {int} data.odd_or_even 预测单双:0单,1双
- * @apiSuccess {int} data.is_valid 结果:0错误,1正确
- * @apiSuccess {int[]} data.winning_numbers 开奖结果
- */
- function prediction()
- {
- try {
- request()->validate([
- 'page' => ['nullable', 'integer', 'min:1'],
- 'limit' => ['nullable', 'integer', 'min:1']
- ]);
- $page = request()->input('page', 1);
- $limit = request()->input('limit', 10);
- $list = Prediction::forPage($page, $limit)
- ->orderByDesc('issue_no')
- ->get();
- } catch (ValidationException $e) {
- return $this->error($e->validator->errors()->first());
- } catch (Exception $e) {
- return $this->error($e->getMessage());
- }
- return $this->success($list);
- }
- /**
- * @api {get} /issue/countdown 倒计时
- * @apiGroup Issue
- * @apiVersion 1.0.0
- *
- * @apiSuccess {int} code
- * @apiSuccess {int} timestamp
- * @apiSuccess {String} msg
- * @apiSuccess {Object} data
- * @apiSuccess {String} data.issue_no 期号
- * @apiSuccess {int} data.current_time 当前时间
- * @apiSuccess {int} data.end_time 结束时间
- * @apiSuccess {Object} data.winnings 开奖结果
- *
- */
- public function countdown()
- {
- $data1 = \App\Models\Issue::where('status', 1)->orderByDesc('issue_no')->first();
- $data2 = \App\Models\Issue::where('status', 3)->orderByDesc('issue_no')->first();
- $winnings = explode(',', $data2->winning_numbers);
- $winnings = array_map('intval', $winnings);
- $award = IssueService::award($winnings);
- $arr['sum'] = array_sum($winnings);
- $arr['a'] = $winnings[0];
- $arr['b'] = $winnings[1];
- $arr['c'] = $winnings[2];
- $arr['size'] = in_array('大', $award) ? '大' : "小";
- $arr['odd_or_even'] = in_array('单', $award) ? '单' : "双";
- $arr['issue_no'] = $data2->issue_no;
- $data = [
- 'issue_no' => $data1->issue_no,
- 'current_time' => time(),
- 'end_time' => strtotime($data1->end_time),
- 'winnings' => $arr,
- ];
- return $this->success($data);
- }
- /**
- * @api {get} /issue 结果,走势
- * @apiGroup Issue
- * @apiVersion 1.0.0
- *
- * @apiParam {int} [page=1]
- * @apiParam {int} [limit=10]
- *
- * @apiSuccess {int} code
- * @apiSuccess {int} timestamp
- * @apiSuccess {String} msg
- * @apiSuccess {Object[]} data
- * @apiSuccess {int} data.id
- * @apiSuccess {String} data.issue_no 期号
- * @apiSuccess {String} data.start_time 开始时间
- * @apiSuccess {String} data.end_time 结束时间
- * @apiSuccess {String[]} data.award 开奖结果
- * @apiSuccess {String[]} data.winning_array 开奖结果
- * @apiSuccess {int} data.end_timestamp 结束时间 时间戳
- *
- */
- public function index()
- {
- try {
- $page = request()->input('page', 1);
- $limit = request()->input('limit', 10);
- $params = [
- 'page' => $page,
- 'limit' => $limit
- // 'status'=>3
- ];
- $res = IssueService::paginate($params);
- } catch (ValidationException $e) {
- return $this->error($e->validator->errors()->first());
- } catch (Exception $e) {
- return $this->error($e->getMessage());
- }
- return $this->success($res);
- }
- /**
- * @api {get} /issue/cao 统计
- * @apiGroup Issue
- * @apiVersion 1.0.0
- *
- * @apiSuccess {int} code
- * @apiSuccess {int} timestamp
- * @apiSuccess {String} msg
- * @apiSuccess {Object[]} data
- *
- */
- public function cao()
- {
- $type = [1, 2, 3, 4];
- $list = [];
- $list[] = Cao::whereIn('id', $type)->get();
- $type = [5, 6, 7, 8];
- $list[] = Cao::whereIn('id', $type)->get();
- $type = [9, 10];
- $list[] = Cao::whereIn('id', $type)->get();
- $list[] = [
- ['field' => '2.8回本', 'val' => 0],
- ['field' => '3.2回本', 'val' => 0],
- ];
- $type = [11, 12, 13];
- $list[] = Cao::whereIn('id', $type)->get();
- $list[] = Cao::where('id', '>=', 14)
- ->where('id', '<=', 41)
- ->get();
- $list[] = [
- ['field' => '龙', 'val' => 0],
- ['field' => '虎', 'val' => 0],
- ['field' => '合', 'val' => 0],
- ['field' => '鸡', 'val' => 0],
- ['field' => '鸭', 'val' => 0],
- ['field' => '狗', 'val' => 0],
- ];
- $list[] = [
- ['field' => '中', 'val' => 0],
- ['field' => '边', 'val' => 0],
- ['field' => '大边', 'val' => 0],
- ['field' => '小边', 'val' => 0],
- ];
- $list[] = Cao::where('id', '>=', 42)
- ->where('id', '<=', 49)
- ->get();
- $list[] = [
- ['field' => '三军0点', 'val' => 0],
- ['field' => '三军1点', 'val' => 0],
- ['field' => '三军2点', 'val' => 0],
- ['field' => '三军3点', 'val' => 0],
- ['field' => '三军4点', 'val' => 0],
- ['field' => '三军5点', 'val' => 0],
- ['field' => '三军6点', 'val' => 0],
- ['field' => '三军7点', 'val' => 0],
- ['field' => '三军8点', 'val' => 0],
- ['field' => '三军9点', 'val' => 0],
- ];
- $list[] = Cao::where('id', '>=', 50)
- ->where('id', '<=', 63)
- ->get();
- $list[] = Cao::where('id', '>=', 64)
- ->where('id', '<=', 77)
- ->get();
- $list[] = Cao::where('id', '>=', 78)
- ->where('id', '<=', 91)
- ->get();
- return $this->success($list);
- }
- }
|