Browse Source

调整赛事所属国家地区分类

彭俊 6 years ago
parent
commit
247092cd7f
1 changed files with 10 additions and 2 deletions
  1. 10 2
      Application/Sports/Controller/MatchList.php

+ 10 - 2
Application/Sports/Controller/MatchList.php

@@ -262,7 +262,7 @@ class  MatchList extends Controller {
         $select=['st_area_country.id as region_id','st_area_country.name as region',$st_league.'.id as lg_id',$st_league.'.name_chinese as league',$st_competition.'.id as match_id'];
         $country = $this->getRegionInfo($where,$search,$select,'st_area_country','id','country_id',$gameType);
         //洲下所有联赛
-        $select=['st_area_country.id as region_id','st_area_country.name as region',$st_league.'.id as lg_id',$st_league.'.name_chinese as league',$st_competition.'.id as match_id'];
+        $select=['st_area_country.id as region_id','st_area_country.name as region',$st_league.'.id as lg_id',$st_league.'.country_id',$st_league.'.name_chinese as league',$st_competition.'.id as match_id'];
         $area = $this->getRegionInfo($where,$search,$select,'st_area_country','id','area_id',$gameType);
         $data['info'] = array_merge($country,$area);
         Render($data, '1', lang('Tips','Sports')->get('success'));
@@ -310,12 +310,20 @@ class  MatchList extends Controller {
             //根据地区分类
             foreach ($info as $key => $vlue) {
                 foreach ($regionInfo as $k => $v) {
-                    if ($vlue['region'] == $v['region']) {
+                    if ($vlue['region'] == $v['region'] and $v['country_id'] == 0) {
                         $info[$key]['league_count'][$k]['league'] = $v['league'];
                         $info[$key]['league_count'][$k]['lg_id'] = $v['lg_id'];
                     }
                 }
             }
+            //去除没有联赛的国家或地区
+            foreach($info as $k =>$v){
+                if(empty($v['league_count'])){
+                    unset($info[$k]);
+                }
+
+            }
+            sort($info);
             //联赛去重
             foreach ($info as $key => $vlue) {
                 $info[$key]['league_count'] = array_unique($vlue['league_count'], SORT_REGULAR);