getLqMatchChange(); if (!$matches) { return; } foreach ($matches as $item) { $matchId = $item['matchId']; $type = Arr::get($item, 'type'); if (!in_array($type, [self::TYPE_DELETE, self::TYPE_MODIFY])) { Log::error('SyncLqMatchChange 未知的modify type类型', $item); continue; } if ($type == self::TYPE_DELETE) { $match = JclqMatch::withTrashed()->where('match_id', $matchId)->first(); if (!$match) { Log::error('SyncLqMatchChange withTrashed比赛id不存在', $item); continue; } if (!$match->trashed()) { $match->delete(); } continue; } $match = JclqMatch::where('match_id', $matchId)->first(); if (!$match) { Log::error('SyncLqMatchChange 比赛id不存在', $item); continue; } $match->status = intval(Arr::get($item, 'matchStatus')); $match->start_time = Arr::get($item, 'matchStartTime', null); $match->home_team_id = intval(Arr::get($item, 'homeTeamId')); $match->away_team_id = intval(Arr::get($item, 'awayTeamId')); $match->home_team_name = strval(Arr::get($item, 'homeTeamName')); $match->away_team_name = strval(Arr::get($item, 'awayTeamName')); $match->save(); } } }