|
|
@@ -245,30 +245,29 @@ class Sport extends Command
|
|
|
SportModel::where('data_id', $item['fixture']['id'])->update($sport_data);
|
|
|
}
|
|
|
|
|
|
- if ($sport_data['state'] == 2 ) {
|
|
|
+ if ($sport_data['state'] == 2) {
|
|
|
$data_id = $item['fixture']['id'];
|
|
|
//比赛结束,插入比赛事件
|
|
|
if (!empty($item['events'])) {
|
|
|
$this->insertSportEvents($data_id, $item['events']);
|
|
|
}
|
|
|
- //比赛结束,插入比赛事件
|
|
|
+ //比赛结束,插入比赛统计数据
|
|
|
$data = SportClientService::statistics(['fixture' => $data_id,'half' => 'true']);
|
|
|
- // file_put_contents("fixturesStatistics.json", json_encode($data));
|
|
|
+ file_put_contents("fixturesStatistics.json", json_encode($data));
|
|
|
$statistics_data = empty($data['response']) ? [] : $data['response'];
|
|
|
foreach($statistics_data as $item) {
|
|
|
- $team_id = $item['team']['id'];
|
|
|
- //上半场的数据
|
|
|
- if(!empty($item['statistics_1h'])) {
|
|
|
- $statistics_1h = $item['statistics_1h'];
|
|
|
- $this->insertSportStatistics($data_id, $team_id, $statistics_1h, 1);
|
|
|
- }
|
|
|
- //下半场的数据
|
|
|
- if(!empty($item['statistics_2h'])) {
|
|
|
- $statistics_2h = $item['statistics_2h'];
|
|
|
- $this->insertSportStatistics($data_id, $team_id, $statistics_2h, 2);
|
|
|
+ $team_id = $item['team']['id'];
|
|
|
+ //上半场的数据
|
|
|
+ if(!empty($item['statistics_1h'])) {
|
|
|
+ $statistics_1h = $item['statistics_1h'];
|
|
|
+ $this->insertSportStatistics($data_id, $team_id, $statistics_1h, 1);
|
|
|
+ }
|
|
|
+ //下半场的数据
|
|
|
+ if(!empty($item['statistics_2h'])) {
|
|
|
+ $statistics_2h = $item['statistics_2h'];
|
|
|
+ $this->insertSportStatistics($data_id, $team_id, $statistics_2h, 2);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
}
|
|
|
}
|
|
|
@@ -345,21 +344,30 @@ class Sport extends Command
|
|
|
SportModel::addSportLeague($item['league']);
|
|
|
|
|
|
//比赛结束,插入比赛事件
|
|
|
- if (isset($sport_data['state']) && $sport_data['state'] == 2 && !empty($item['events'])) {
|
|
|
- foreach($item['events'] as $event) {
|
|
|
- SportEvent::create([
|
|
|
- 'data_id' => $item['fixture']['id'],
|
|
|
- 'type' => $event['type'],
|
|
|
- 'time_elapsed' => $event['time']['elapsed'],
|
|
|
- 'time' => json_encode($event['time']),
|
|
|
- 'detail' => $event['detail'],
|
|
|
- 'player' => $event['player'] ? json_encode($event['player']) : $event['player'],
|
|
|
- 'team_id' => $event['team']['id'],
|
|
|
- 'comments' => $event['comments'],
|
|
|
- 'assist' => $event['assist'] ? json_encode($event['assist']) : $event['assist'],
|
|
|
- ]);
|
|
|
+ if (isset($sport_data['state']) && $sport_data['state'] == 2 ) {
|
|
|
+
|
|
|
+ $data_id = $item['fixture']['id'];
|
|
|
+ if (!empty($item['events'])) {
|
|
|
+ $this->insertSportEvents($data_id, $item['events']);
|
|
|
+ }
|
|
|
+
|
|
|
+ //比赛结束,插入比赛事件
|
|
|
+ $data = SportClientService::statistics(['fixture' => $data_id,'half' => 'true']);
|
|
|
+ file_put_contents("fixturesStatistics.json", json_encode($data));
|
|
|
+ $statistics_data = empty($data['response']) ? [] : $data['response'];
|
|
|
+ foreach($statistics_data as $item) {
|
|
|
+ $team_id = $item['team']['id'];
|
|
|
+ //上半场的数据
|
|
|
+ if(!empty($item['statistics_1h'])) {
|
|
|
+ $statistics_1h = $item['statistics_1h'];
|
|
|
+ $this->insertSportStatistics($data_id, $team_id, $statistics_1h, 1);
|
|
|
+ }
|
|
|
+ //下半场的数据
|
|
|
+ if(!empty($item['statistics_2h'])) {
|
|
|
+ $statistics_2h = $item['statistics_2h'];
|
|
|
+ $this->insertSportStatistics($data_id, $team_id, $statistics_2h, 2);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
if ($tableData) {
|