| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <?php
- namespace App\Http\Controllers\api;
- use App\Models\PcCaoHistory;
- use App\Models\PcIssue;
- use App\Models\PcPrediction;
- use Carbon\Carbon;
- use Illuminate\Validation\ValidationException;
- use Exception;
- use Illuminate\Http\JsonResponse;
- class NewPc extends BaseController
- {
- /**
- * @api {get} /newPc/yuanTou 源头
- * @apiGroup newPc
- * @apiVersion 1.0.0
- * @apiSuccess {int} code
- * @apiSuccess {int} timestamp
- * @apiSuccess {String} msg
- * @apiSuccess {Object[]} data
- *
- */
- function yuanTou(): JsonResponse
- {
- $page = request()->input('page', 1);
- $limit = request()->input('limit', 20);
- $data = PcIssue::where('status', PcIssue::STATUS_DRAW)
- ->forPage($page, $limit)
- ->orderByDesc('issue_no')
- ->get();
- foreach ($data as &$item) {
- $item['keno'] = json_decode($item['keno'], true);
- }
- return $this->success($data);
- }
- /**
- * @api {get} /newPc/history 天机
- * @apiGroup newPc
- * @apiVersion 1.0.0
- *
- * @apiParam {int} [date] 日期 默认0
- * - 前1天 则date=1 前2天则date=2
- *
- * @apiSuccess {int} code
- * @apiSuccess {int} timestamp
- * @apiSuccess {String} msg
- * @apiSuccess {Object[]} data
- * @apiSuccess {String} data.date
- * @apiSuccess {int} data.total 总数
- * @apiSuccess {int} data.big 大
- * @apiSuccess {int} data.small 小
- * @apiSuccess {int} data.odd 单
- * @apiSuccess {int} data.even 双
- * @apiSuccess {int} data.big_odd 大单
- * @apiSuccess {int} data.big_even 大双
- * @apiSuccess {int} data.small_odd 小单
- * @apiSuccess {int} data.small_even 小双
- * @apiSuccess {int} data.max 极大
- * @apiSuccess {int} data.min 极小
- * @apiSuccess {int} data.pair 对子
- * @apiSuccess {int} data.sequence 顺子
- * @apiSuccess {int} data.leopard 豹子
- * @apiSuccess {int} data.num_0 00号
- * @apiSuccess {int} data.num_1 01号
- *
- */
- function history(): JsonResponse
- {
- try {
- request()->validate([
- 'date' => ['required', 'integer', 'min:0', 'max:30']
- ]);
- $date = request()->input('date');
- $date = Carbon::now()->subDays($date)->toDateString();
- $list = PcCaoHistory::where('date', $date)->get()->toArray();
- if (count($list) > 0) {
- $list = $list[0];
- } else {
- $list = null;
- }
- } catch (ValidationException $e) {
- return $this->error($e->validator->errors()->first());
- } catch (Exception $e) {
- return $this->error($e->getMessage());
- }
- return $this->success($list);
- }
- /**
- * @api {get} /newPc/prediction 预测
- * @apiGroup newPc
- * @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(): JsonResponse
- {
- try {
- request()->validate([
- 'page' => ['nullable', 'integer', 'min:1'],
- 'limit' => ['nullable', 'integer', 'min:1']
- ]);
- $page = request()->input('page', 1);
- $limit = request()->input('limit', 10);
- $list = PcPrediction::forPage($page, $limit)
- ->orderByDesc('issue_no')
- ->get();
- foreach ($list as &$item) {
- $item['day'] = date("m-d H:i", strtotime($item['updated_at']));
- }
- } catch (ValidationException $e) {
- return $this->error($e->validator->errors()->first());
- } catch (Exception $e) {
- return $this->error($e->getMessage());
- }
- return $this->success($list);
- }
- }
|