diff --git a/server/app/api/controller/MatchController.php b/server/app/api/controller/MatchController.php index f44e97a..d94aef0 100644 --- a/server/app/api/controller/MatchController.php +++ b/server/app/api/controller/MatchController.php @@ -535,6 +535,7 @@ class MatchController extends BaseApiController $this->request->get('sport_type/d', 0), trim($this->request->get('league_name/s', '')) ), + 'platform_options' => $this->getOddsPlatformOptions(), ]); } @@ -552,6 +553,7 @@ class MatchController extends BaseApiController '', true ), + 'platform_options' => $this->getOddsPlatformOptions(), ]); } @@ -795,11 +797,39 @@ class MatchController extends BaseApiController private function resolveOddsPlatformName(string $sourceSite): string { - $map = [ + $map = $this->getOddsPlatformNameMap(); + return $map[$sourceSite] ?? ($sourceSite !== '' ? strtoupper($sourceSite) : '平台'); + } + + private function getOddsPlatformNameMap(): array + { + return [ 'hg' => '滚球', 'titan007' => '球探', ]; - return $map[$sourceSite] ?? ($sourceSite !== '' ? strtoupper($sourceSite) : '平台'); + } + + private function getOddsPlatformOptions(): array + { + $platformMap = $this->getOddsPlatformNameMap(); + $sourceSites = MatchOdds::where('source_site', '<>', '') + ->group('source_site') + ->column('source_site'); + foreach ($sourceSites as $sourceSite) { + $sourceSite = strtolower(trim((string)$sourceSite)); + if ($sourceSite !== '' && !isset($platformMap[$sourceSite])) { + $platformMap[$sourceSite] = strtoupper($sourceSite); + } + } + + $options = []; + foreach ($platformMap as $key => $label) { + $options[] = [ + 'key' => $key, + 'label' => $label, + ]; + } + return $options; } private function resolveOddsShowTypeText(string $showType): string diff --git a/server/app/common/service/match/MatchLiveService.php b/server/app/common/service/match/MatchLiveService.php index 3e160b7..77bc2bf 100644 --- a/server/app/common/service/match/MatchLiveService.php +++ b/server/app/common/service/match/MatchLiveService.php @@ -97,16 +97,11 @@ class MatchLiveService return ''; } - public static function getLiveCards( - int $sportType = 0, - string $leagueName = '', - bool $worldCupOnly = false - ): array + public static function getLiveCards(int $sportType = 0, string $leagueName = ''): array { $query = MatchLive::alias('live') - ->join('match m', 'm.id = live.match_id') - ->where(['m.is_show' => 1]) - ->where([['m.status', '<>', 2]]); + ->leftJoin('match m', 'm.id = live.match_id') + ->where('live.fetch_status', 1); if ($sportType > 0) { $query->where('m.sport_type', $sportType); @@ -114,13 +109,6 @@ class MatchLiveService if ($leagueName !== '') { $query->where('m.league_name', $leagueName); } - if ($worldCupOnly) { - $query - ->where(function ($query) { - $query->where('m.league_name', '世界杯') - ->whereOr('m.competition_id', 61); - }); - } $rows = $query ->field([ @@ -210,6 +198,6 @@ class MatchLiveService public static function getWorldCupLiveCards(): array { - return self::getLiveCards(0, '', true); + return self::getLiveCards(); } } diff --git a/uniapp/src/packages_match/components/MatchCenterTabsPanel.vue b/uniapp/src/packages_match/components/MatchCenterTabsPanel.vue index 2b4275f..5605ad1 100644 --- a/uniapp/src/packages_match/components/MatchCenterTabsPanel.vue +++ b/uniapp/src/packages_match/components/MatchCenterTabsPanel.vue @@ -123,6 +123,19 @@ + + + + {{ item.label }} + + + + ('schedule') const sportTabs = ref([]) const currentSport = ref(0) @@ -269,6 +289,8 @@ const useLiveCardPosterMode = ref(false) const oddsList = ref([]) const oddsLoading = ref(false) const oddsLoaded = ref(false) +const oddsPlatformOptions = ref([...defaultOddsPlatformOptions]) +const oddsSourceSite = ref('') const oddsShowType = ref('') const oddsKeyword = ref('') const oddsSearchText = ref('') @@ -313,9 +335,12 @@ const matchGroups = computed(() => { }) const oddsFilterSummary = computed(() => { + const platformLabel = oddsPlatformOptions.value.find( + (item) => item.key === oddsSourceSite.value, + )?.label || '全部平台' const showTypeLabel = oddsShowTypeOptions.find((item) => item.key === oddsShowType.value)?.label || '全部盘口' const keyword = oddsKeyword.value.trim() - const parts = [showTypeLabel] + const parts = [platformLabel, showTypeLabel] if (keyword) parts.push(`"${keyword}"`) parts.push(`${oddsList.value.length}场`) return parts.join(' · ') @@ -397,7 +422,10 @@ const fetchLiveCards = async (force = false) => { const buildOddsRequestParams = () => { const params: { + sport_type?: number + league_name?: string show_type?: 'live' | 'today' | 'early' + source_site?: string keyword?: string include_special: number limit: number @@ -405,7 +433,10 @@ const buildOddsRequestParams = () => { include_special: 0, limit: 300, } + if (currentSport.value > 0) params.sport_type = currentSport.value + if (currentLeague.value) params.league_name = currentLeague.value if (oddsShowType.value) params.show_type = oddsShowType.value + if (oddsSourceSite.value) params.source_site = oddsSourceSite.value const keyword = oddsKeyword.value.trim() if (keyword) params.keyword = keyword return params @@ -420,6 +451,21 @@ const fetchOdds = async (force = false) => { const data = await getMatchOdds(buildOddsRequestParams()) if (requestSeq === oddsRequestSeq.value) { oddsList.value = Array.isArray(data?.list) ? data.list : [] + const platformOptions = Array.isArray(data?.platform_options) + ? data.platform_options + : [] + const platformMap = new Map( + defaultOddsPlatformOptions.map((item) => [item.key, item]), + ) + platformOptions.forEach((item: any) => { + if (item?.key) { + platformMap.set(String(item.key), { + key: String(item.key), + label: String(item.label || item.key).trim(), + }) + } + }) + oddsPlatformOptions.value = Array.from(platformMap.values()) oddsLoaded.value = true } } catch (error) { @@ -495,6 +541,13 @@ const switchOddsShowType = (showType: OddsShowType) => { void fetchOdds(true) } +const switchOddsSourceSite = (sourceSite: string) => { + if (oddsSourceSite.value === sourceSite) return + oddsSourceSite.value = sourceSite + oddsLoaded.value = false + void fetchOdds(true) +} + const confirmOddsSearch = () => { const keyword = oddsSearchText.value.trim() if (oddsKeyword.value === keyword && oddsLoaded.value) return @@ -1005,6 +1058,10 @@ onMounted(() => { white-space: nowrap; } +.match-odds-filter__platforms { + margin-bottom: 12rpx; +} + .match-odds-filter__tabs-inner { display: inline-flex; align-items: center;