Quellcode durchsuchen

追加推送 6/6

彭俊 vor 6 Jahren
Ursprung
Commit
69a443124f

+ 79 - 9
Application/Sports/Controller/MatchListWeb.php

@@ -10,6 +10,8 @@ namespace App\Sports\Controller;
 use BaseController\Controller;
 use Biz\Match\GetmatchData;
 use Biz\Match\GetOddsData;
+use App\Sports\Model\St_area as areaModel;
+use App\Sports\Model\St_country as countryModel;
 
 /**
  * Class MatchListWeb
@@ -147,10 +149,6 @@ class MatchListWeb extends Controller{
                 $select = [$models['model_league'].'.lg_id',$models['model_league'].'.name_chinese as leagueName',$models['model_match'].'.match_id','home_team','guest_team','match_date','match_time','tag','country_id','area_id'];
             }
         }
-        //国家数据
-        $country = lm('st_country',"Sports")
-            ->select('country_id','name_chinese')
-            ->get()->toArray();
 
         //赛事数据
         $matchNum = lm($models['model_league'],"Sports")
@@ -160,22 +158,30 @@ class MatchListWeb extends Controller{
             ->where($where)
             ->where($timeWhere)
             ->get()->toArray();
+        //
 
         //赔率数据
         $oddsCodeNum = $this->getOddsData($game_code,$models['model_odds'],$matchNum,$p_code);
         if($p_code){
             $match_odds = [];
             if($p_code == 'kemp'){
+                $matchNum = $this->uniquArr($matchNum,'lg_id');
+
                 foreach ($oddsCodeNum as $k=>$v){
                     foreach ($matchNum as $kk => $vv){
                         if($v['lg_id'] == $vv['lg_id']){
+                            $match_odds[$kk]['area_id'] = $vv['area_id'];
+                            $match_odds[$kk]['country_id'] = $vv['country_id'];
                             $match_odds[$kk]['lg_id'] = $vv['lg_id'];
                             $match_odds[$kk]['leagueName'] = $vv['leagueName'];
                             $match_odds[$kk]['last_time'] = $vv['last_time'];
                             $match_odds[$kk]['oddsData'][] = $v;
                         }
                     }
+
                 }
+                sort($match_odds);
+
                 $gjData = [];
                 foreach ($match_odds as $k=>$v){
                     //按p_code分组
@@ -193,7 +199,51 @@ class MatchListWeb extends Controller{
                     }
                     $gjData[] = $sd;
                 }
-                return $gjData;
+                //国家数据
+                $country = countryModel::getName();
+                //获取国家联赛列表
+                $countryList = [];
+                foreach ($country as $k=>$v){
+                    foreach ($match_odds as $kk=>$vv){
+                        if($v['country_id'] == $vv['country_id']){
+                            unset($vv['last_time']);
+                            //联赛下父级玩法 盘口数量
+                            $oddsCode = array_column($vv['oddsData'], 'odds_code');
+                            //获取冠军盘口下 父级玩法 数量
+                            $oddsCodeN = array_count_values($oddsCode);
+                            $vv['matchNum'] = count($oddsCodeN);
+                            unset($vv['oddsData']);
+                            $v['lg_list'][] = $vv;
+                            $countryList[$k] = $v;
+                        }
+                    }
+                }
+                sort($countryList);
+
+                //地区数据
+                $area = areaModel::getName();
+                //获取地区联赛列表
+                $areaList = [];
+                foreach ($area as $k=>$v){
+                    foreach ($match_odds as $kk=>$vv){
+                        if($v['id'] == $vv['area_id']){
+                            unset($vv['last_time']);
+                            //联赛下父级玩法 盘口数量
+                            $oddsCode = array_column($vv['oddsData'], 'odds_code');
+                            //获取冠军盘口下 父级玩法 数量
+                            $oddsCodeN = array_count_values($oddsCode);
+                            $vv['matchNum'] = count($oddsCodeN);
+                            unset($vv['oddsData']);
+                            $v['lg_list'][] = $vv;
+                            $areaList[$k] = $v;
+                        }
+                    }
+                }
+                sort($areaList);
+                //国家/地区 联赛列表
+                $leagueList = array_merge($countryList,$areaList);
+                $data = [$gjData,$leagueList];
+                return $data;
             }
             foreach ($oddsCodeNum as $k=>$v){
                 foreach ($matchNum as $kk=>$vv){
@@ -227,8 +277,10 @@ class MatchListWeb extends Controller{
             //赛事详细数据 去重
             $matchData = $this->uniquArr($data,'lg_id');
 
+            //国家数据
+            $country = countryModel::getName();
             //获取国家联赛列表
-            $leagueList = [];
+            $countryList = [];
             foreach ($country as $k=>$v){
                 foreach ($matchData as $kk=>$vv){
                     if($v['country_id'] == $vv['country_id']){
@@ -236,13 +288,31 @@ class MatchListWeb extends Controller{
                         $vv['matchNum'] = count($vv['matchData']);
                         unset($vv['matchData']);
                         $v['lg_list'][] = $vv;
-                        $leagueList[$k] = $v;
+                        $countryList[$k] = $v;
+                    }
+                }
+            }
+            sort($countryList);
+
+            //地区数据
+            $area = areaModel::getName();
+            //获取地区联赛列表
+            $areaList = [];
+            foreach ($area as $k=>$v){
+                foreach ($matchData as $kk=>$vv){
+                    if($v['id'] == $vv['area_id']){
+                        //联赛下赛事数量
+                        $vv['matchNum'] = count($vv['matchData']);
+                        unset($vv['matchData']);
+                        $v['lg_list'][] = $vv;
+                        $areaList[$k] = $v;
                     }
                 }
             }
-            sort($leagueList);
+            sort($areaList);
 
-            //国家-联赛列表
+            //国家/地区 联赛列表
+            $leagueList = array_merge($countryList,$areaList);
             $data = [$matchData,$leagueList];
             return $data;
         }

+ 16 - 0
Application/Sports/Model/St_area.php

@@ -12,4 +12,20 @@ class St_area extends Model
 {
 
     protected $table = 'st_area';
+
+    //根据地区id获取地区名称
+    public static function getName($areaId = ''){
+        $where = [];
+        //拼装查询条件
+        if(!empty($areaId)){
+            $where = [
+                ['id','=',$areaId]
+            ];
+        }
+        $name = self::select('id','title')
+            ->where($where)
+            ->get()
+            ->toArray();
+        return $name;
+    }
 }

+ 17 - 0
Application/Sports/Model/St_country.php

@@ -12,4 +12,21 @@ class St_country extends Model
 {
 
     protected $table = 'st_country';
+
+    //根据国家id 获取国家名称
+    public static function getName($countryId = ''){
+        $where = [];
+        //拼装查询条件
+        if(!empty($countryId)){
+            $where = [
+                ['country_id','=',$countryId]
+            ];
+        }
+        $name = self::select('country_id','name_chinese')
+            ->where($where)
+            ->get()
+            ->toArray();
+
+        return $name;
+    }
 }

+ 4 - 3
Biz/Match/GetmatchData.php

@@ -232,6 +232,7 @@ class GetmatchData {
             }
             $data[$k]['matchNum'] = count($data[$k]['matchData']);
         }
+
         if($ret['game_code'] == 'wq') {
             $oddsData = WQoddsModel::getMatchOdds($source,$match_ids);
             foreach ($data as $k=>$v){
@@ -254,7 +255,7 @@ class GetmatchData {
                     $concede_size = [];
                     foreach ($oddsData as $kkk=>$vvv) {
                         if ($vv['match_id'] == $vvv['match_id'] and $vvv['sort']==0) {
-                            if($vvv['odds_code'] == 'concede_guest' || $vvv['odds_code'] == 'concede_home' || $vvv['odds_code'] == 'goal_size_home' || $vvv['odds_code'] == 'goal_size_guest'){
+                            if($vvv['odds_code'] == 'concede_guest' || $vvv['odds_code'] == 'concede_home' || $vvv['odds_code'] == 'total_size_small' || $vvv['odds_code'] == 'total_size_big'){
                                 $concede_size[] = $vvv;
                             }
                             if($vvv['p_code'] == 'capot'){
@@ -337,10 +338,10 @@ class GetmatchData {
                                     $query->where($model_odds.'.odds_code','concede_guest');
                                 })
                                 ->orWhere(function($query)use ($model_odds){
-                                    $query->where($model_odds.'.odds_code','size_home');
+                                    $query->where($model_odds.'.odds_code','total_size_small');
                                 })
                                 ->orWhere(function($query)use ($model_odds){
-                                    $query->where($model_odds.'.odds_code','size_guest');
+                                    $query->where($model_odds.'.odds_code','total_size_big');
                                 })
                                 ->orWhere(function($query)use ($model_odds){
                                     $query->where($model_odds.'.odds_code','capot_home');