deploy: auto commit repo-root changes 2026-06-21 17:56:21
This commit is contained in:
@@ -428,10 +428,20 @@ class MatchController extends BaseApiController
|
||||
->order('id asc')
|
||||
->select()
|
||||
->toArray();
|
||||
$liveMap = MatchLiveService::getLiveMapForApi(array_column($rows, 'id'));
|
||||
|
||||
$scheduleMap = [];
|
||||
foreach ($rows as $row) {
|
||||
$roundName = $row['round_name'] ?: '未分轮次';
|
||||
$liveList = $liveMap[(int) $row['id']] ?? [];
|
||||
$defaultLiveUrl = '';
|
||||
foreach ($liveList as $line) {
|
||||
$candidate = trim((string) ($line['default_play_url'] ?? ''));
|
||||
if ($candidate !== '') {
|
||||
$defaultLiveUrl = $candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isset($scheduleMap[$roundName])) {
|
||||
$scheduleMap[$roundName] = [
|
||||
'round_name' => $roundName,
|
||||
@@ -456,6 +466,8 @@ class MatchController extends BaseApiController
|
||||
'match_time' => (int) $row['match_time'],
|
||||
'current_minute' => $row['current_minute'],
|
||||
'half_score' => $row['half_score'],
|
||||
'live_list' => $liveList,
|
||||
'default_live_url' => $defaultLiveUrl,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -23,20 +23,38 @@ class MatchLiveService
|
||||
|
||||
public static function getLiveListForApi(int $matchId): array
|
||||
{
|
||||
$rows = MatchLive::where('match_id', $matchId)
|
||||
$liveMap = self::getLiveMapForApi([$matchId]);
|
||||
|
||||
return $liveMap[$matchId] ?? [];
|
||||
}
|
||||
|
||||
public static function getLiveMapForApi(array $matchIds): array
|
||||
{
|
||||
$matchIds = array_values(array_unique(array_filter(array_map('intval', $matchIds))));
|
||||
if (empty($matchIds)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$rows = MatchLive::whereIn('match_id', $matchIds)
|
||||
->whereNull('delete_time')
|
||||
->order('create_time', 'asc')
|
||||
->order('id', 'asc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$result = [];
|
||||
foreach ($rows as &$row) {
|
||||
$row['stream_options'] = self::buildStreamOptions($row);
|
||||
$row['default_play_url'] = $row['stream_options'][0]['url'] ?? '';
|
||||
$row['default_play_url'] = self::resolveDefaultPlayUrl($row);
|
||||
$matchId = (int) ($row['match_id'] ?? 0);
|
||||
if ($matchId <= 0) {
|
||||
continue;
|
||||
}
|
||||
$result[$matchId][] = $row;
|
||||
}
|
||||
unset($row);
|
||||
|
||||
return $rows;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function buildStreamOptions(array $row): array
|
||||
@@ -62,4 +80,20 @@ class MatchLiveService
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
protected static function resolveDefaultPlayUrl(array $row): string
|
||||
{
|
||||
if (!empty($row['stream_options'][0]['url'])) {
|
||||
return trim((string) $row['stream_options'][0]['url']);
|
||||
}
|
||||
|
||||
foreach (['play_url_m3u8', 'play_url_hd_m3u8', 'play_url_flv', 'play_url_hd_flv'] as $field) {
|
||||
$url = trim((string) ($row[$field] ?? ''));
|
||||
if ($url !== '') {
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user