|
|
@@ -0,0 +1,99 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Console\Commands;
|
|
|
+
|
|
|
+use Illuminate\Console\Command;
|
|
|
+use App\Models\Sport as SportModel;
|
|
|
+
|
|
|
+class Sport extends Command
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * 命令名称和签名
|
|
|
+ *
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $signature = 'sport';
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 命令描述
|
|
|
+ *
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $description = '当天会去更新明天的赛事(23:59:00执行一次)';
|
|
|
+ /**
|
|
|
+ * 执行命令
|
|
|
+ *
|
|
|
+ * @return int
|
|
|
+ */
|
|
|
+ public function handle()
|
|
|
+ {
|
|
|
+ $this->info('开始执行统计比赛数据任务...');
|
|
|
+
|
|
|
+ $this->sportData();
|
|
|
+
|
|
|
+ $this->info('结束执行统计比赛数据任务');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function sportData()
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $today = date('Y-m-d');
|
|
|
+ $host = env('SPORT_HOST');
|
|
|
+ $url = "{$host}/api/sport";
|
|
|
+ $url .= "?date={$today}";
|
|
|
+ $result = file_get_contents($url);
|
|
|
+ $result = $result ? json_decode($result, true) : [];
|
|
|
+ foreach ($result as $item) {
|
|
|
+ $info = SportModel::where('data_id',$item['data_id'])->first();
|
|
|
+ $data = [
|
|
|
+ 'home_team_id' => $item['home_team_id'] ?? '',
|
|
|
+ 'home_team_en' => $item['home_team_en'] ?? '',
|
|
|
+ 'home_team' => $item['home_team'] ?? '',
|
|
|
+ 'home_team_logo' => $item['home_team_logo'] ?? '',
|
|
|
+ 'guest_team_id' => $item['guest_team_id'] ?? '',
|
|
|
+ 'guest_team_en' => $item['guest_team_en'] ?? '',
|
|
|
+ 'guest_team' => $item['guest_team'] ?? '',
|
|
|
+ 'guest_team_logo' => $item['guest_team_logo'] ?? '',
|
|
|
+ 'half_score' => $item['half_score'] ?? '',
|
|
|
+ 'rbt' => $item['rbt'] ?? '',
|
|
|
+ 'is_roll' => $item['is_roll'] ?? 0,
|
|
|
+ 'score' => $item['score'] ?? '',
|
|
|
+ 'league_en' => $item['league_en'] ?? '',
|
|
|
+ 'league' => $item['league'] ?? '',
|
|
|
+ 'odds' => $item['odds'] ?? '',
|
|
|
+ 'state' => $item['state'] ?? 0,
|
|
|
+ 'game_time' => $item['game_time'] ?? 0,
|
|
|
+ 'status' => $item['status'] ?? 0,
|
|
|
+ 'handicap_limit' => $item['handicap_limit'] ?? '',
|
|
|
+ 'over_under_limit' => $item['over_under_limit'] ?? '',
|
|
|
+ 'duying_limit' => $item['duying_limit'] ?? '',
|
|
|
+ 'correct_core_limit' => $item['correct_core_limit'] ?? '',
|
|
|
+ 'odd_even_limit' => $item['odd_even_limit'] ?? '',
|
|
|
+ 'total_goal_limit' => $item['total_goal_limit'] ?? '',
|
|
|
+ 'is_handicap' => $item['is_handicap'] ?? 0,
|
|
|
+ 'is_over_under' => $item['is_over_under'] ?? 0,
|
|
|
+ 'is_duying' => $item['is_duying'] ?? 0,
|
|
|
+ 'is_correct_core' => $item['is_correct_core'] ?? 0,
|
|
|
+ 'is_odd_even' => $item['is_odd_even'] ?? 0,
|
|
|
+ 'is_total_goal' => $item['is_total_goal'] ?? 0,
|
|
|
+ 'is_locked' => $item['is_locked'] ?? 0,
|
|
|
+ ];
|
|
|
+ if ($info) {
|
|
|
+ //更新数据
|
|
|
+ SportModel::where('data_id',$item['data_id'])->update($data);
|
|
|
+ } else {
|
|
|
+ $data['data_id'] = $item['data_id'];
|
|
|
+ SportModel::create($data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|