|
|
@@ -100,19 +100,31 @@ class Sport extends Command
|
|
|
$this->fixtures();
|
|
|
} elseif ($this->is_live == 2){
|
|
|
// $data = SportClientService::fixtures([
|
|
|
- // 'id' => 1534923,
|
|
|
+ // 'id' => 1506065,
|
|
|
// ]);
|
|
|
- // $data = SportClientService::fixtures(['live' => 'all']);
|
|
|
- // // $data = SportClientService::oddsLive();
|
|
|
- // file_put_contents("1534923.json", json_encode($data));
|
|
|
+ // file_put_contents("1506065.json", json_encode($data));
|
|
|
// print_r($data);
|
|
|
// die;
|
|
|
|
|
|
$this->checkLiveFixtures();
|
|
|
+ //$this->updateOvertimeFixtures();
|
|
|
} elseif ($this->is_live == 3) {
|
|
|
$this->checkOvertimeFixtures();
|
|
|
+ } else {
|
|
|
+ $this->initOdds();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //比赛开始后,超过3个小时,并且更新时间超过10分钟,还是进行中的数据,更新成已完成
|
|
|
+ public function updateOvertimeFixtures()
|
|
|
+ {
|
|
|
+ // 比赛开始后,状态还是未开始的数据检测
|
|
|
+ $end_time = date("Y-m-d H:i:s", time() - 600);
|
|
|
+ SportModel::where('status', 1)->where('state', 1)->where('game_time', '<=', time() - 60*60*3)->where('updated_at', '<=', $end_time)->update(['state' =>2]);
|
|
|
+ // $ids = SportModel::where('status', 1)->where('state', 1)->where('game_time', '<=', time() - 60*60*3)->pluck('data_id')->get();
|
|
|
+ // print_r($ids);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
//到了比赛开始时间,但是状态还是未开始,检查比赛
|
|
|
public function checkOvertimeFixtures()
|
|
|
@@ -137,15 +149,18 @@ class Sport extends Command
|
|
|
$sport_locked = Config::where('field', 'sport_locked')->first()->val ?? 1;
|
|
|
|
|
|
//1. 统一锁盘时间(比赛开始前1分钟)
|
|
|
- SportModel::where(['is_locked' => 0, 'is_roll' => 0])->where('game_time', '<=', time() - 60)->update(['is_locked' => 1]);
|
|
|
+ SportModel::where(['is_locked' => 0, 'is_roll' => 0])->where('game_time', '<=', time() + 90)->update(['is_locked' => 1]);
|
|
|
|
|
|
//2. 比赛进行中,超过3分钟未更新的数据检测
|
|
|
$end_time = date("Y-m-d H:i:s", time() - 180);
|
|
|
$ids = SportModel::where('status', 1)->where('state', 1)->where('updated_at', '<=', $end_time)->pluck('data_id')->toArray();
|
|
|
if ($ids) {
|
|
|
- $ids = implode('-', $ids);
|
|
|
- $data = SportClientService::fixtures(['ids' => $ids]);
|
|
|
- $this->updateOrCreateSport($data, $sport_locked, 1);
|
|
|
+ $chunks = array_chunk($ids, 10);
|
|
|
+ foreach ($chunks as $chunk) {
|
|
|
+ $ids = implode('-', $chunk);
|
|
|
+ $data = SportClientService::fixtures(['ids' => $ids]);
|
|
|
+ $this->updateOrCreateSport($data, $sport_locked, 1);
|
|
|
+ }
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
@@ -311,7 +326,7 @@ class Sport extends Command
|
|
|
SportModel::where('data_id', $item['fixture']['id'])->update($sport_data);
|
|
|
}
|
|
|
//比赛结束,插入比赛事件
|
|
|
- if ($sport_data['state'] == 2 && !empty($item['events'])) {
|
|
|
+ if ($sport_data['state'] >= 2 && !empty($item['events'])) {
|
|
|
foreach($item['events'] as $event) {
|
|
|
SportEvent::create([
|
|
|
'data_id' => $item['fixture']['id'],
|
|
|
@@ -325,7 +340,6 @@ class Sport extends Command
|
|
|
'assist' => $event['assist'] ? json_encode($event['assist']) : $event['assist'],
|
|
|
]);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
if ($tableData) {
|