|
|
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\api;
|
|
|
|
|
|
use App\Models\Cao;
|
|
|
use App\Models\CaoHistory;
|
|
|
+use App\Models\Issue as IssueModel;
|
|
|
use App\Models\Prediction;
|
|
|
use App\Services\IssueService;
|
|
|
use Illuminate\Validation\ValidationException;
|
|
|
@@ -24,24 +25,74 @@ class Issue extends BaseController
|
|
|
* @apiSuccess {Object[]} data
|
|
|
*
|
|
|
*/
|
|
|
- function yuanTou()
|
|
|
+ function yuanTou(): JsonResponse
|
|
|
{
|
|
|
-// $data = file_get_contents("https://pc28ya.com/index.php?action=getMyOpensJson");
|
|
|
+ $page = max(1, (int)request()->input('page', 1));
|
|
|
+ $limit = min(max(1, (int)request()->input('limit', 20)), 100);
|
|
|
|
|
|
- $page = request()->input('page', 1);
|
|
|
- $data = file_get_contents("https://pc28ya.com/index.php?Action=MyOpens1&page={$page}");
|
|
|
+ $issues = IssueModel::where('status', IssueModel::STATUS_DRAW)
|
|
|
+ ->whereNotNull('keno')
|
|
|
+ ->where('keno', '!=', '')
|
|
|
+ ->orderByDesc('issue_no')
|
|
|
+ ->forPage($page, $limit)
|
|
|
+ ->get();
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ foreach ($issues as $issue) {
|
|
|
+ $keno = $this->formatYuanTouKeno($issue->keno);
|
|
|
+ if (empty($keno)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $winningNumbers = array_map('intval', explode(',', $issue->winning_numbers));
|
|
|
+ $item = [
|
|
|
+ 'section' => (string)$issue->issue_no,
|
|
|
+ 'openTime' => empty($issue->start_time) ? '' : date('m-d H:i', strtotime($issue->start_time)),
|
|
|
+ 'keno' => $keno,
|
|
|
+ 'keno_html' => '',
|
|
|
+ ];
|
|
|
|
|
|
+ for ($index = 1; $index <= 10; $index++) {
|
|
|
+ $item['openCode' . $index] = (string)($winningNumbers[$index - 1] ?? 0);
|
|
|
+ }
|
|
|
|
|
|
- $data = json_decode($data, true);
|
|
|
-// $data = array_reverse($data['data']);
|
|
|
- $data = $data['data'];
|
|
|
- foreach ($data as &$item) {
|
|
|
- $item['keno'] = explode(',', $item['keno']);
|
|
|
- sort($item['keno']);
|
|
|
+ $data[] = $item;
|
|
|
}
|
|
|
+
|
|
|
return $this->success($data);
|
|
|
}
|
|
|
|
|
|
+ private function formatYuanTouKeno($keno): array
|
|
|
+ {
|
|
|
+ if (is_string($keno)) {
|
|
|
+ $decoded = json_decode($keno, true);
|
|
|
+ $keno = is_array($decoded) ? $decoded : explode(',', $keno);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!is_array($keno)) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+
|
|
|
+ $numbers = [];
|
|
|
+ foreach ($keno as $number) {
|
|
|
+ $value = filter_var($number, FILTER_VALIDATE_INT, [
|
|
|
+ 'options' => [
|
|
|
+ 'min_range' => 1,
|
|
|
+ 'max_range' => 80,
|
|
|
+ ],
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if ($value !== false) {
|
|
|
+ $numbers[] = (int)$value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $numbers = array_values(array_unique($numbers));
|
|
|
+ sort($numbers, SORT_NUMERIC);
|
|
|
+
|
|
|
+ return array_map('strval', $numbers);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @api {get} /issue/history 天机
|