Explorar o código

追加推送 限制数据 5/24

彭俊 %!s(int64=6) %!d(string=hai) anos
pai
achega
f75f597e55

+ 308 - 473
Application/Sports/Controller/MatchList.php

@@ -28,91 +28,57 @@ class  MatchList extends Controller {
      private function zq_participate (){
          $data['type'] = '足球';
          $data['game_code'] = 'zq';
+         $where_search = [];
         //查询今日赛事
+         $where = $this->commonFunction->getState('StToday');
+         $Orwhere = [];
          $data['info'][0]['name'] = '今日赛事';
          $data['info'][0]['code'] = 'today';
-         $data['info'][0]['count'] = lm('st_zq_competition','Sports')
-             ->join('st_zq_league','st_zq_league.lg_id','st_zq_competition.lg_id')
-             ->where($this->commonFunction->getState('StToday'))
-             ->where('st_zq_competition.source',$this->source['source'])
-             ->where('st_zq_competition.home_team','<>',null)
-             ->where('st_zq_competition.guest_team','<>',null)
-             ->distinct('st_zq_competition.match_id')
-             ->count('*');
+         $data['info'][0]['count'] = $this->getMatchCount($where,$Orwhere,$where_search,$data['game_code']);
+
         //查询明日赛事
+         $where=[['st_zq_competition.match_date','tomorrow']];
+         $Orwhere=[];
          $data['info'][1]['name'] = '明日赛事';
          $data['info'][1]['code'] = 'tomorrow';
-         $data['info'][1]['count'] = lm('st_zq_competition','Sports')
-             ->join('st_zq_league','st_zq_league.lg_id','st_zq_competition.lg_id')
-             ->where('st_zq_competition.source',$this->source['source'])
-             ->where('st_zq_competition.match_date','tomorrow')
-             ->where('st_zq_competition.home_team','<>',null)
-             ->where('st_zq_competition.guest_team','<>',null)
-             ->count('*');
+         $data['info'][1]['count'] = $this->getMatchCount($where,$Orwhere,$where_search,$data['game_code']);
+
         //受欢迎的欧洲赛事
+         $where =[['area.name_en','Europe'],['st_zq_league.hot',0]];
+         $Orwhere=[];
          $data['info'][2]['name'] = '受欢迎的欧洲赛事';
          $data['info'][2]['code'] = 'popular';
-         $data['info'][2]['count'] = lm('st_zq_competition','Sports')
-             ->join('st_zq_league','st_zq_league.lg_id','st_zq_competition.lg_id')
-             ->join('st_area','st_area.id','st_zq_league.area_id')
-             ->where('st_area.code',"Europe")
-             ->where('st_zq_league.hot',0)
-             ->where('st_zq_competition.status','<',2)
-             ->where('st_zq_competition.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
-             ->where('st_zq_competition.source',$this->source['source'])
-             ->where('st_zq_competition.home_team','<>',null)
-             ->where('st_zq_competition.guest_team','<>',null)
-             ->count('*');
+         $data['info'][2]['count'] = $this->getMatchCount($where,$Orwhere,$where_search,$data['game_code']);
 
         //查询亚洲,澳洲赛事
+         $where =[];
+         $Orwhere  = function ($query) {
+             $query->Orwhere('area.name_en','=','Asia')
+                 ->Orwhere('country.name_en','=','Australia');
+         };
          $data['info'][3]['name'] = '亚洲/澳洲赛事';
          $data['info'][3]['code'] = 'asia_aus';
-         $data['info'][3]['count'] = lm('st_zq_competition','Sports')
-             ->join('st_zq_league','st_zq_league.lg_id','st_zq_competition.lg_id')
-             ->leftjoin('st_country','st_country.country_id','st_zq_league.country_id')
-             ->leftjoin('st_area','st_area.id','st_zq_league.area_id')
-             ->select('match_id')
-             ->where(function ($query) {
-                 $query->Orwhere('st_area.code','=','Asian')
-                     ->Orwhere('st_country.name_english','=','Australia');
-             })
-             ->where('st_zq_competition.status','<',2)
-             ->where('st_zq_competition.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
-             ->where('st_zq_competition.source',$this->source['source'])
-             ->where('st_zq_competition.home_team','<>',null)
-             ->where('st_zq_competition.guest_team','<>',null)
-             ->count('*');
+         $data['info'][3]['count'] = $this->getMatchCount($where,$Orwhere,$where_search,$data['game_code']);
+
          //查询北美,南美赛事
+         $where = [];
+         $Orwhere = function ($query) {
+             $query->Orwhere('area.name_en','=', "South America")
+                 ->Orwhere('area.name_en','=', "North America");
+         };
          $data['info'][4]['name'] = '北美/南美赛事';
          $data['info'][4]['code'] = 'south_north';
-         $data['info'][4]['count'] = lm('st_zq_competition','Sports')
-            ->join('st_zq_league','st_zq_league.lg_id','st_zq_competition.lg_id')
-            ->join('st_area','st_area.id','st_zq_league.area_id')
-            ->where(function ($query) {
-                $query->Orwhere('st_area.code','=', "South_America")
-                    ->Orwhere('st_area.code','=', "North_America");
-            })
-            ->where('st_zq_competition.status', '<', '2')
-             ->where('st_zq_competition.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
-            ->where('st_area.source',$this->source['source'])
-             ->where('st_zq_competition.home_team','<>',null)
-             ->where('st_zq_competition.guest_team','<>',null)
-            ->count('*');
+         $data['info'][4]['count'] = $this->getMatchCount($where,$Orwhere,$where_search,$data['game_code']);
+
          //国际赛事
+         $where = [['area.name_en',"world"]];
+         $Orwhere = [];
          $data['info'][5]['name'] = '国际赛事';
          $data['info'][5]['code'] = 'intl';
-         $data['info'][5]['count'] = lm('st_area','Sports')
-            ->join('st_zq_league','st_zq_league.area_id','st_area.id')
-             ->join('st_zq_competition','st_zq_competition.lg_id','st_zq_league.id')
-            ->where('st_area.code',"world")
-             ->where('st_zq_competition.status', '<', '2')
-             ->where('st_zq_competition.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
-            ->where('st_area.source',$this->source['source'])
-             ->where('st_zq_competition.home_team','<>',null)
-             ->where('st_zq_competition.guest_team','<>',null)
-            ->count('*');
+         $data['info'][5]['count'] = $this->getMatchCount($where,$Orwhere,$where_search,$data['game_code']);
          return $data;
     }
+
     /*
      *首页条件筛选(其他球参赛表)
      */
@@ -122,25 +88,25 @@ class  MatchList extends Controller {
          $data['game_code'] = $typeGame;
          $data['type'] = lm('GameType','Sports')->where('game_code',$typeGame)->value('game_name');
          $st_competition = $getModels['model_match'];
+//       所有赛事
+         $where_search = [];
+         $where = [];
+         $Orwhere = [];
          $data['info'][0]['name'] = '所有赛事';
          $data['info'][0]['code'] = 'all';
-         $data['info'][0]['count'] =lm($st_competition,'Sports')
-             ->where([[$st_competition.'.status', '<', '2'],
-             [$st_competition.'.source',$this->source['source']]])
-             ->where($st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
-             ->where($st_competition.'.home_team','<>',null)
-             ->where($st_competition.'.guest_team','<>',null)
-             ->count('*');
+         $data['info'][0]['count'] = $this->getMatchCount($where,$Orwhere,$where_search,$data['game_code']);
+         //今日赛事
+         $where = $this->commonFunction->getState('StToday',$st_competition);
+         $Orwhere = [];
          $data['info'][1]['name'] = '今日赛事';
          $data['info'][1]['code'] = 'today';
-         $data['info'][1]['count']=lm($st_competition,'Sports')
-             ->where($st_competition.'.source',$this->source['source'])
-             ->where($this->commonFunction->getState('StToday',$st_competition))
-             ->where($st_competition.'.home_team','<>',null)
-             ->where($st_competition.'.guest_team','<>',null)
-             ->count('*');
-        return $data;
+         $data['info'][1]['count']=$this->getMatchCount($where,$Orwhere,$where_search,$data['game_code']);
+         return $data;
     }
+
+    /*
+     * 参赛表数据接口
+     */
      public function participate(){
          $type = $_REQUEST['typeGame'];
          if($type != 'zq'|| empty($type)){
@@ -164,343 +130,80 @@ class  MatchList extends Controller {
         $getModels = $this->commonFunction->getModels($game_code);
         $st_league = $getModels['model_league'];
         $st_competition = $getModels['model_match'];
+        $st_odds = $getModels['model_odds'];
         $where_search = function($query)use ($st_competition,$search){
             $query->where($st_competition.'.home_team','like','%'.$search.'%')
                 ->orWhere(function($query)use ($st_competition,$search) {
                     $query->where($st_competition . '.guest_team', 'like', '%' . $search . '%');
                 });
         };
-        $Orwhere = "";
+        $Orwhere = [];
         switch ($code)
         {
-            case $code == 'today':
-                $where =  $this->commonFunction->getState('StToday',$st_competition);
-                //查询今日赛事
-                $data = lm($st_competition,'Sports')
-                    ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
-                    ->select($st_league.'.name_chinese',$st_league.'.lg_id')
-                    ->where($where)
-                    ->where($where_search)
-                    ->where($st_competition.'.home_team','<>',null)
-                    ->where($st_competition.'.guest_team','<>',null)
-                    ->where($st_competition.'.source',$this->source['source'])
-                    ->distinct($st_competition.'.match_id')
-                    ->get()
-                    ->toarray();
-  break;
-            case $code == 'popular':
-                $where =[
-                    ['st_area.code','Europe'],[$st_league.'.hot',0],
-                    [$st_competition.'.status', '<', '2'],
-                    [$st_competition.'.source',$this->source['source']],
-                    [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
-                    [$st_competition.'.home_team','<>',null],
-                    [$st_competition.'.guest_team','<>',null],
-
-                ];
-                //欧洲最受欢迎的赛事
-                $data = lm($st_competition,'Sports')
-                    ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
-                    ->join('st_area','st_area.id','st_zq_league.area_id')
-                    ->select($st_league.'.name_chinese',$st_league.'.lg_id')
-                    ->where($where)
-                    ->where($where_search)
-                    ->distinct($st_competition.'.match_id')
-                    ->get()
-                    ->toarray();
-  break;
-            case $code == 'asia_aus':
-                $where = [
-                    [$st_competition.'.status', '<', '2'],
-                    [$st_competition.'.source',$this->source['source']],
-                    [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
-                    [$st_competition.'.home_team','<>',null],
-                    [$st_competition.'.guest_team','<>',null],
-                ];
+        case $code == 'today':
+            $where =$this->commonFunction->getState('StToday');
+            //查询今日赛事
+            $data  = $this->getMatchInfo($where,$Orwhere,$where_search,$game_code);
+        break;
+
+        case $code == 'popular':
+            $where =[['area.name_en','Europe'],[$st_league.'.hot',0]];
+            //欧洲最受欢迎的赛事
+            $data  = $this->getMatchInfo($where,$Orwhere,$where_search,$game_code);
+        break;
+
+        case $code == 'asia_aus':
+                $where = [];
                 $Orwhere  = function ($query) {
-                    $query->Orwhere('st_area.code','=','Asian')
-                    ->Orwhere('st_country.name_english','=','Australia');
+                $query->Orwhere('area.name_en','=','Asia')
+                ->Orwhere('country.name_en','=','Australia');
                 };
+        //亚洲/澳洲赛事
+        $data  = $this->getMatchInfo($where,$Orwhere,$where_search,$game_code);
+        break;
 
-                //亚洲/澳洲赛事
-                $data = lm($st_competition,'Sports')
-                    ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
-                    ->leftjoin('st_country','st_country.country_id',$st_league.'.country_id')
-                    ->leftjoin('st_area','st_area.id',$st_league.'.area_id')
-                    ->select($st_league.'.name_chinese',$st_league.'.lg_id')
-                    ->where($where)
-                    ->where($Orwhere)
-                    ->where($where_search)
-                    ->distinct($st_competition.'.match_id')
-                    ->get()
-                    ->toarray();
-  break;
-            case $code == 'south_north':
-                $where = [
-                    [$st_competition.'.status', '<', '2'],
-                    [$st_competition.'.source',$this->source['source']],
-                    [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
-                    [$st_competition.'.home_team','<>',null],
-                    [$st_competition.'.guest_team','<>',null],
-                ];
+        case $code == 'south_north':
+                $where = [];
                 $Orwhere = function ($query) {
-                    $query->Orwhere('st_area.code','=', "South_America")
-                        ->Orwhere('st_area.code','=', "North_America");
+                $query->Orwhere('area.name_en','=', "South America")
+                ->Orwhere('area.name_en','=', "North America");
                 };
                 //南美洲/北美洲赛事
-                $data = lm($st_competition,'Sports')
-                    ->join($st_league,$st_league.'.lg_id',$st_league.'.lg_id')
-                    ->join('st_area','st_area.id','st_zq_league.area_id')
-                    ->select($st_league.'.name_chinese',$st_league.'.lg_id')
-                    ->where($where)
-                    ->where($Orwhere)
-                    ->where($where_search)
-                    ->distinct($st_competition.'.match_id')
-                    ->get()
-                    ->toarray();
-  break;
-            case $code == 'tomorrow':
-                $where = [
-                    [$st_competition.'.match_date','tomorrow'],
-                    [$st_competition.'.status',0],
-                    [$st_competition.'.source',$this->source['source']],
-                    [$st_competition.'.home_team','<>',null],
-                    [$st_competition.'.guest_team','<>',null],
-                ];
+                $data  = $this->getMatchInfo($where,$Orwhere,$where_search,$game_code);
+        break;
+
+        case $code == 'tomorrow':
+                $where = [[$st_competition.'.match_date','tomorrow']];
                 //明日赛事
-                $data = lm($st_competition,'Sports')
-                    ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
-                    ->select($st_league.'.name_chinese',$st_league.'.lg_id')
-                    ->where($where)
-                    ->where($where_search)
-                    ->distinct($st_league.'.lg_id')
-                    ->get()
-                    ->toarray();
-  break;
-            case $code == 'intl':
-                 $where = [
-                     ['st_area.code', "world"],
-                     [$st_competition.'.status','<','2'],
-                     [$st_competition.'.source',$this->source['source']],
-                     [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
-                     [$st_competition.'.home_team','<>',null],
-                     [$st_competition.'.guest_team','<>',null],
-                 ];
-            //国际赛事
-            $data = lm($st_competition,'Sports')
-                ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
-                ->join('st_area','st_area.id',$st_league.'.area_id')
-                ->select($st_league.'.name_chinese',$st_league.'.lg_id')
-                ->where($where)
-                ->where($where_search)
-                ->distinct($st_competition.'.match_id')
-                ->get()
-                ->toarray();
-            break;
-            case $code == 'all':
-                $where = [
-                    [$st_competition.'.status','<', '2'],
-                    [$st_competition.'.source',$this->source['source']],
-                    [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
-                    [$st_competition.'.home_team','<>',null],
-                    [$st_competition.'.guest_team','<>',null],
-                    ];
-                //所有赛事
-                $data = lm($st_competition,'Sports')
-                    ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
-                    ->select($st_league.'.name_chinese',$st_league.'.lg_id')
-                    ->where($where)
-                    ->where($where_search)
-                    ->distinct($st_competition.'.match_id')
-                    ->get()
-                    ->toarray();
-  break;
-            case $code == 'qt':
-                $where = [
-                    [$st_competition.'.status','<', '2'],
-                    [$st_competition.'.source',$this->source['source']],
-                    [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
-                    [$st_league.'.lg_id',$lg_id],
-                    [$st_competition.'.home_team','<>',null],
-                    [$st_competition.'.guest_team','<>',null],
-                ];
-                //指定联赛下的赛事
-                $data = lm($st_competition,'Sports')
-                    ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
-                    ->select($st_league.'.name_chinese',$st_league.'.lg_id')
-                    ->where($where)
-                    ->where($where_search)
-                    ->distinct($st_competition.'.match_id')
-                    ->get()
-                    ->toarray();
-  break;
-        }
-        //根据联赛ID赛事信息
-        $data = $this->Competition_info($data,$getModels,$where,$where_search,$Orwhere);
-        Render($data, '1', lang('Tips','Sports')->get('success'));
-    }
-    /*
-     * 获取联赛信息
-     */
-    private function Competition_info(array $data,$getModels,$where,$where_search,$Orwhere){
-            $st_competition = $getModels['model_match'];
-            $st_odds = $getModels['model_odds'];
-            $st_league = $getModels['model_league'];
-            if(!$Orwhere){
-                $Orwhere = [];
-            }
-            foreach($data as $k => $v){
-                //统计赛事
-                $data[$k]['count'] = lm($st_competition,'Sports')
-                    ->join($st_odds,$st_odds.'.match_id',$st_competition.'.match_id')
-                    ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
-                    ->leftjoin('st_country','st_country.country_id',$st_league.'.country_id')
-                    ->leftjoin('st_area','st_area.id',$st_league.'.area_id')
-                    ->where($st_competition.'.lg_id',$v['lg_id'])
-                    ->where($where)
-                    ->where($Orwhere)
-                    ->where($where_search)
-                    ->distinct($st_competition.'.match_id')
-                    ->count($st_competition.'.match_id');
-
-                //获取赛事信息
-                $data[$k]['match_info'] = lm($st_competition,'Sports')
-                    ->join($st_odds,$st_odds.'.match_id',$st_competition.'.match_id')
-                    ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
-                    ->leftjoin('st_country','st_country.country_id',$st_league.'.country_id')
-                    ->leftjoin('st_area','st_area.id',$st_league.'.area_id')
-                    ->select($st_competition.'.match_id',$st_competition.'.home_team',$st_competition.'.guest_team',$st_competition.'.match_date',$st_competition.'.status',$st_competition.'.match_time',$st_competition.'.tag')
-                    ->distinct($st_competition.'.match_id')
-                    ->where($where)
-                    ->where($Orwhere)
-                    ->where($where_search)
-                    ->where($st_competition.'.lg_id',$v['lg_id'])
-                    ->get()
-                    ->toarray();
-                if(!$data[$k]['match_info']){
-                    unset($data[$k]);
-                }
-                //循环获取赛事赔率
-                foreach ($data[$k]['match_info'] as $key=>$item){
-                    $data[$k]['match_info'][$key]['oddsData'] = lm($st_odds, 'Sports')
-                        ->select('id','p_code','odds_code','status','odds','condition','sort')
-                        ->where($this->source)
-                        ->where(['match_id'=>$item['match_id'],'type'=>0])
-                        ->where(function($query)use ($st_odds){
-                            $query->where($st_odds.'.odds_code','concede_home')
-                                ->orWhere(function($query)use ($st_odds){
-                                    $query->where($st_odds.'.odds_code','concede_guest');
-                                })
-                                ->orWhere(function($query)use ($st_odds){
-                                    $query->where($st_odds.'.odds_code','size_home');
-                                })
-                                ->orWhere(function($query)use ($st_odds){
-                                    $query->where($st_odds.'.odds_code','size_guest');
-                                });
-                        })
-                        ->get()->toArray();
+                $data  = $this->getMatchInfo($where,$Orwhere,$where_search,$game_code);
+        break;
 
-                    if(!empty($data[$k]['match_info'][$key]['oddsData'])){
-                        //根据 排序 获取 最新让球/大小玩法赔率
-                        $sortData = array_column($data[$k]['match_info'][$key]['oddsData'],'sort');
-                        array_multisort($sortData,SORT_DESC,$data[$k]['match_info'][$key]['oddsData']);
-                        $data[$k]['match_info'][$key]['oddsData'] = array_slice($data[$k]['match_info'][$key]['oddsData'],0,4);//前四条 放入
+        case $code == 'intl':
+                $where = [['area.name_en', "world"]];
+                //国际赛事
+                $data  = $this->getMatchInfo($where,$Orwhere,$where_search,$game_code);
+        break;
 
-                    }else{
-                        $data[$k]['match_info'][$key]['oddsData'] = [];
-                    }
-            }
-        }
-        return $data;
-    }
-     /*
-     *首页条件筛选(冠军赛事)
-     */
-    public function first (){
-        $gameType = $_REQUEST['typeGame'];
-        $search = $_REQUEST['search'];
-        //===查询该球类是否存在或启用===
-        $gameType = empty($gameType)? 'zq':$gameType;
-        $getModels = $this->commonFunction->getModels($gameType);
-        $st_league = $getModels['model_league'];
-        $st_competition = $getModels['model_match'];
-        $data['type']  = lm('GameType', 'Sports')->where('game_code',$gameType)->value('game_name');
-        //国家下所有联赛
-        $country = lm($st_league,"Sports")
-            ->join($st_competition,$st_competition.'.lg_id',$st_league.'.id')
-            ->join('st_country','st_country.country_id',$st_league.'.country_id')
-            ->select('st_country.id as region_id','st_country.name_chinese as region')
-            ->distinct('st_country.name_chinese')
-            ->where($st_league.'.name_chinese','like','%'.$search.'%')
-            ->where($st_league.'.source',$this->source)
-            ->where([])
-            ->where($st_competition.'.home_team','<>',null)
-            ->where($st_competition.'.guest_team','<>',null)
-            ->get()
-            ->toArray();
-        //洲下所有联赛
-        $area = lm($st_league,"Sports")
-            ->join($st_competition,$st_competition.'.lg_id',$st_league.'.id')
-            ->join('st_area','st_area.id',$st_league.'.area_id')
-            ->select('st_area.id as region_id','st_area.title as region')
-            ->distinct('st_area.title')
-            ->where($st_league.'.name_chinese','like','%'.$search.'%')
-            ->where($st_league.'.source',$this->source)
-            ->where()
-            ->where([])
-            ->where($st_competition.'.home_team','<>',null)
-            ->where($st_competition.'.guest_team','<>',null)
-            ->get()
-            ->toArray();
-        //统计国家联赛下的赛事.
-        if(!empty($country)){
-            foreach($country as $k => $v) {
-                $country[$k]['league_count'] = lm($st_league, 'Sports')
-                    ->select('lg_id', 'name_chinese as league')
-                    ->where($this->source)
-                    ->where('country_id', $v['region_id'])
-                    ->get()->toarray();
-            }
-            foreach ($country as $k => $v) {
-                foreach($v['league_count'] as $kk => $vv ){
-                    $country[$k]['league_count'][$kk]['count'] = lm($st_competition, 'Sports')
-                        ->where($this->source)
-                        ->where('lg_id',$vv['lg_id'])
-                        ->where($st_competition.'.home_team','<>',null)
-                        ->where($st_competition.'.guest_team','<>',null)
-                        ->count('*');
-                    if($country[$k]['league_count'][$kk]['count'] == 0){
-                        unset($country[$k]['league_count'][$kk]);
-                    }
-                }
-            }
+        case $code == 'all':
+                $where = [];
+                //所有赛事
+                $data  = $this->getMatchInfo($where,$Orwhere,$where_search,$game_code);
+        break;
+
+        case $code == 'qt':
+                $where = [[$st_league.'.lg_id',$lg_id]];
+                //指定联赛下的赛事
+                $data  = $this->getMatchInfo($where,$Orwhere,$where_search,$game_code);
+        break;
         }
-        //统计洲联赛下的赛事
-        if(!empty($area)){
-            foreach($area as $k => $v) {
-                $area[$k]['league_count'] = lm($st_league, 'Sports')
-                    ->select('lg_id ', 'name_chinese as league')
-                    ->where($this->source)
-                    ->where('area_id', $v['region_id'])
-                    ->get()->toarray();
-            }
-            foreach ($area as $k => $v) {
-                foreach($v['league_count'] as $kk => $vv ){
-                    $area[$k]['league_count'][$kk]['count'] = lm($st_competition, 'Sports')
-                        ->where($this->source)
-                        ->where('lg_id',$vv['lg_id'])
-                        ->where($st_competition.'.home_team','<>',null)
-                        ->where($st_competition.'.guest_team','<>',null)
-                        ->count('*');
-                    if($area[$k]['league_count'][$kk]['count'] == 0){
-                        unset($area[$k]['league_count'][$kk]);
-                    }
-                }
-            }
+        //根据赛事ID获取赔率数据
+        foreach($data as $k => $v){
+            $data[$k]['match_info'] = $this->getOdds($v['match_info'],$st_odds);
         }
-        $data['info'] = array_merge($country,$area);
+
         Render($data, '1', lang('Tips','Sports')->get('success'));
     }
+
     /*
      *首页条件筛选(所有赛事)
      */
@@ -508,7 +211,7 @@ class  MatchList extends Controller {
         $gameType = $_REQUEST['gameType'];
         $search = $_REQUEST['search'];
         $date = $_REQUEST['datetime'];
-        //===查询该球类是否存在或启用===
+        //=获取球了MODEL
         $gameType = empty($gameType) ? 'zq':$gameType;
         $getModels = $this->commonFunction->getModels($gameType);
         $st_league = $getModels['model_league'];
@@ -525,100 +228,88 @@ class  MatchList extends Controller {
                 $where[$st_competition.'.match_date'] = $date;
             }
         }
-
+        //查询球类名称
         $data['type']  = lm('GameType', 'Sports')
             ->where('game_code',$gameType)
             ->value('game_name');
         //国家联赛数据
-        $country = lm($st_league,"Sports")
-            ->join($st_competition,$st_competition.'.lg_id',$st_league.'.lg_id')
-            ->join('st_country','st_country.country_id',$st_league.'.country_id')
-            ->select('st_country.country_id as region_id','st_country.name_chinese as region')
-            ->distinct($st_league.'.lg_id')
-            ->where($st_league.'.source',$this->source)
-            ->where($st_league.'.name_chinese','like','%'.$search.'%')
-            ->where($where)
-            ->where($st_competition.'.status', '<', '2')
-            ->where($st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
-            ->get()
-            ->toArray();
-
+        $select=['st_country.country_id as region_id','st_country.name_chinese as region',$st_league.'.lg_id',$st_league.'.name_chinese as league'];
+        $country = $this->getRegionInfo($where,$search,$select,'st_country','country_id',$gameType);
         //洲下所有联赛
-        $area = lm($st_league,"Sports")
-            ->join($st_competition,$st_competition.'.lg_id',$st_league.'.lg_id')
-            ->join('st_area','st_area.id',$st_league.'.area_id')
-            ->select('st_area.id as region_id','st_area.title as region')
-            ->distinct($st_league.'.lg_id')
-            ->where($st_league.'.source',$this->source)
-            ->where($st_league.'.name_chinese','like','%'.$search.'%')
-            ->where($where)
-            ->where($st_competition.'.status', '<', '2')
-            ->where($st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
-            ->get()
-            ->toArray();
-        //统计国家联赛下的赛事
-        if(!empty($country)){
-            foreach($country as $k => $v) {
-                $country[$k]['league_count'] = lm($st_league, 'Sports')
-                    ->select('lg_id', 'name_chinese as league')
-                    ->where($st_league.'.source',$this->source)
-                    ->where($st_league.'.name_chinese','like','%'.$search.'%')
-                    ->where('country_id', $v['region_id'])
-                    ->get()
-                    ->toarray();
+        $select=['st_area.id as region_id','st_area.title as region',$st_league.'.lg_id',$st_league.'.name_chinese as league'];
+        $area = $this->getRegionInfo($where,$search,$select,'st_area','id',$gameType);
+        $data['info'] = array_merge($country,$area);
+        Render($data, '1', lang('Tips','Sports')->get('success'));
+    }
+    /**
+     * 根据地区获取信息
+     * @param  [array]  $where 条件
+     * @param  [array] $search 搜索条件
+     * @param  [string] $regionModel 地区model
+     * @param  [int]  $regionID 地区model
+     * @param  [type] $game_code 球类代码
+     * @return [array] $data
+     */
+    public function getRegionInfo($where=[],$search,$select,$regionModel,$regionID,$game_code ='zq'){
+        $getModels = $this->commonFunction->getModels($game_code);
+        $st_league = $getModels['model_league'];
+        $st_competition = $getModels['model_match'];
+        try{
+            //地区联赛赛事数据
+            $regionInfo = lm($st_league,"Sports")
+                ->join($st_competition,$st_competition.'.lg_id',$st_league.'.lg_id')
+                ->join($regionModel,$regionModel.'.'.$regionID,$st_league.'.country_id')
+                ->select($select)
+                ->where($st_league.'.name_chinese','like','%'.$search.'%')
+                ->where($where)
+                ->where([
+                    [$st_competition.'.home_team','<>',null],
+                    [$st_competition.'.guest_team','<>',null],
+                    [$st_league.'.name_chinese','<>',null],
+                    [$st_competition.'.status','<',2],
+                    [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)]
+                ])
+                ->get()
+                ->toArray();
+            //地区分割
+            $info = [];
+            foreach($regionInfo as $k => $v){
+                $info[$k]['region']  = $v['region'];
+                $info[$k]['region_id']  = $v['region_id'];
             }
-            foreach ($country as $k => $v) {
-                foreach($v['league_count'] as $kk => $vv ){
-                    $country[$k]['league_count'][$kk]['count'] = lm($st_competition, 'Sports')
-                        ->where($this->source)
-                        ->where($where)
-                        ->where('lg_id',$vv['lg_id'])
-                        ->where('status', '<', '2')
-                        ->where('us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
-                        ->where($st_competition.'.home_team','<>',null)
-                        ->where($st_competition.'.guest_team','<>',null)
-                        ->count('*');
-                    if($country[$k]['league_count'][$kk]['count'] == 0){
-                        unset($country[$k]['league_count'][$kk]);
+            //地区去重
+            $info = array_unique($info, SORT_REGULAR);
+            //根据地区分类
+            foreach ($info as $key => $vlue) {
+                foreach ($regionInfo as $k => $v) {
+                    if ($vlue['region'] == $v['region']) {
+                        $info[$key]['league_count'][$k]['league'] = $v['league'];
+                        $info[$key]['league_count'][$k]['lg_id'] = $v['lg_id'];
                     }
                 }
             }
-        }
-
-        //统计洲联赛下的赛事
-        if (!empty($area)){
-            foreach($area as $k => $v) {
-                $area[$k]['league_count'] = lm($st_league,'Sports')
-                    ->select('lg_id', 'name_chinese as league')
-                    ->where($this->source)
-                    ->where($st_league.'.name_chinese','like','%'.$search.'%')
-                    ->where('area_id', $v['region_id'])
-                    ->get()
-                    ->toarray();
-            }
-            foreach ($area as $k => $v) {
-                foreach($v['league_count'] as $kk => $vv ){
-                    $area[$k]['league_count'][$kk]['count'] = lm($st_competition, 'Sports')
-                        ->where($this->source)
-                        ->where($where)
-                        ->where($st_competition.'.home_team','<>',null)
-                        ->where($st_competition.'.guest_team','<>',null)
-                        ->where('status', '<', '2')
-                        ->where('us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
-                        ->where('lg_id',$vv['lg_id'])
-                        ->count('*');
-                    if($area[$k]['league_count'][$kk]['count'] == 0){
-                        unset($area[$k]['league_count'][$kk]);
+            //联赛去重
+            foreach ($info as $key => $vlue) {
+                $info[$key]['league_count'] = array_unique($vlue['league_count'], SORT_REGULAR);
+                //统计联赛下赛事
+                foreach ($vlue['league_count'] as $k => $v) {
+                    foreach ($regionInfo as $kk => $vv) {
+                        if ($v['league'] == $vv['league']) {
+                            if(!empty($info[$key]['league_count'][$kk]['league'])){
+                                $info[$key]['league_count'][$kk]['count'] += 1;
+                            }
+                        }
                     }
                 }
             }
+            return $info;
+        } catch (\Exception $e) {
+            echo $e->getMessage();
         }
-        $data['info'] = array_merge($country,$area);
-        Render($data, '1', lang('Tips','Sports')->get('success'));
+
     }
     /**
      * 联赛下 赛事及默认赔率数据
-     *
      */
     public function matchDetails(){
 
@@ -826,6 +517,7 @@ class  MatchList extends Controller {
                     ['home_team','<>',null],
                     ['guest_team','<>',null],
                     ['status','<',2],
+                    ['us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
                     ['lg_id',$matchData->lg_id],
                 ];
 
@@ -1022,4 +714,147 @@ class  MatchList extends Controller {
         Render($data, '1', lang('Tips','Sports')->get('success'));
     }
 
+    /**
+     * 获取赛事所有数据
+     * @param  [array] $where 条件
+     *@param  [array] $Orwhere 或者条件
+     * @param  [type] $game_code 球类代码
+     * @return [array]  $data
+     */
+    public function getMatchInfo($where=[],$Orwhere=[],$where_search=[],$game_code ='zq'){
+        $getModels = $this->commonFunction->getModels($game_code);
+        $st_league = $getModels['model_league'];
+        $st_competition = $getModels['model_match'];
+        try{
+            //查询今日赛事
+            $data = lm($st_competition,'Sports')
+                ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
+                ->leftjoin('st_area_country as country','country.id',$st_league.'.country_id')
+                ->leftjoin('st_area_country as area','area.id',$st_league.'.area_id')
+                ->select($st_league.'.name_chinese',$st_league.'.lg_id',$st_competition.'.match_id',$st_competition.'.home_team',$st_competition.'.guest_team',$st_competition.'.match_date',$st_competition.'.status',$st_competition.'.match_time',$st_competition.'.tag','country.name as country_name','area.name as area_name')
+                ->where($where)
+                ->where($Orwhere)
+                ->where($where_search)
+                ->where([
+                    [$st_competition.'.home_team','<>',null],
+                    [$st_competition.'.guest_team','<>',null],
+                    [$st_league.'.name_chinese','<>',null],
+                    [$st_competition.'.status','<',2],
+                    [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)]
+                ])
+                ->distinct($st_competition.'.match_id')
+                ->get()
+                ->toarray();
+            $data = $this->division($data);
+            return $data;
+        } catch (\Exception $e) {
+            echo $e->getMessage();
+        }
+    }
+
+    /**
+     * 数据分割器
+     * @param  [array] $matchData 赛事数据
+     * @param  [type] $type 分割类型 1:以联赛分
+     * @return [array]  $league
+     */
+    public function division(array $matchData)
+    {
+        //联赛分割
+        $league = [];
+        foreach ($matchData as $k => $v) {
+            $league[$k]['name_chinese']  = $v['name_chinese'];
+            $league[$k]['lg_id']  = $v['lg_id'];
+        }
+        //联赛去重
+        $league = array_unique($league, SORT_REGULAR);
+        //根据联赛分类
+        foreach ($league as $key => $vlue) {
+            foreach ($matchData as $k => $v) {
+                if ($vlue['name_chinese'] == $v['name_chinese']) {
+                    $league[$key]['match_info'][$k] = $v;
+                }
+            }
+        }
+        //统计联赛下赛事
+        foreach ($league as $key => $vlue) {
+            $league[$key]['match_info'] = array_sort($league[$key]['match_info']);
+            $league[$key]['count'] = count($vlue['match_info']);
+        }
+        return $league;
+    }
+
+    /**
+     * 获取赛事赔率数据
+     * @param  [array] $where 条件
+     *@param  [array] $Orwhere 或者条件
+     * @param  [type] $game_code 球类代码
+     * @return [array]  $data
+     */
+    private function getOdds(array $data,$st_odds){
+        //循环获取赛事赔率
+        foreach ($data as $key=>$item){
+            $data[$key]['oddsData'] = lm($st_odds, 'Sports')
+                ->select('id','p_code','odds_code','status','odds','condition','sort')
+                ->where($this->source)
+                ->where(['match_id'=>$item['match_id'],'type'=>0])
+                ->where(function($query)use ($st_odds){
+                    $query->where($st_odds.'.odds_code','concede_home')
+                        ->orWhere(function($query)use ($st_odds){
+                            $query->where($st_odds.'.odds_code','concede_guest');
+                        })
+                        ->orWhere(function($query)use ($st_odds){
+                            $query->where($st_odds.'.odds_code','size_home');
+                        })
+                        ->orWhere(function($query)use ($st_odds){
+                            $query->where($st_odds.'.odds_code','size_guest');
+                        });
+                })
+                ->get()->toArray();
+
+            if(!empty($data[$key]['oddsData'])){
+                //根据 排序 获取 最新让球/大小玩法赔率
+                $sortData = array_column($data[$key]['oddsData'],'sort');
+                array_multisort($sortData,SORT_DESC,$data[$key]['oddsData']);
+                $data[$key]['oddsData'] = array_slice($data[$key]['oddsData'],0,4);//前四条 放入
+            }else{
+                $data[$key]['oddsData'] = [];
+            }
+        }
+        return $data;
+    }
+
+    /**
+     * 获取赛事总数
+     * @param  [array] $where 条件
+     *@param  [array] $Orwhere 或者条件
+     * @param  [type] $game_code 球类代码
+     * @return [int]  $dataCount
+     */
+    public function getMatchCount($where=[],$Orwhere=[],$where_search=[],$game_code ='zq'){
+        $getModels = $this->commonFunction->getModels($game_code);
+        $st_league = $getModels['model_league'];
+        $st_competition = $getModels['model_match'];
+
+        //查询今日赛事
+        $dataCount = lm($st_competition,'Sports')
+            ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
+            ->leftjoin('st_area_country as country','country.id',$st_league.'.country_id')
+            ->leftjoin('st_area_country as area','area.id',$st_league.'.area_id')
+            ->where($where)
+            ->where($Orwhere)
+            ->where($where_search)
+            ->where([
+                [$st_competition.'.home_team','<>',null],
+                [$st_competition.'.guest_team','<>',null],
+                [$st_league.'.name_chinese','<>',null],
+                [$st_competition.'.status','<',2],
+                [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)]
+            ])
+            ->distinct($st_competition.'.match_id')
+            ->count('*');
+
+        return $dataCount;
+    }
+
 }

+ 2 - 1
Application/Sports/Model/St_bq_odds.php

@@ -27,9 +27,10 @@ class St_bq_odds extends Model
     }
 
     //获取棒球赛事下 默认赔率数据
-    public static function getMatchOdds($source){
+    public static function getMatchOdds($source,$match_ids=[]){
         $oddsData = self::select('match_id','id','p_code','odds_code','status','odds','condition','sort','odds_only')
             ->where($source)
+            ->whereIn('match_id',$match_ids)
             ->where(
                 function($query){
                     $query->where('odds_code','capot_home')

+ 2 - 1
Application/Sports/Model/St_lq_odds.php

@@ -27,9 +27,10 @@ class St_lq_odds extends Model
     }
 
     //获取篮球赛事下 默认赔率数据
-    public static function getMatchOdds($source){
+    public static function getMatchOdds($source,$match_ids=[]){
         $oddsData = self::select('match_id','id','p_code','odds_code','status','odds','condition','sort','odds_only')
             ->where($source)
+            ->whereIn('match_id',$match_ids)
             ->where(function($query){
                 $query->where('odds_code','concede_home')
                     ->orWhere(function($query){

+ 2 - 1
Application/Sports/Model/St_wq_odds.php

@@ -27,9 +27,10 @@ class St_wq_odds extends Model
     }
 
     //获取网球赛事下 默认赔率数据
-    public static function getMatchOdds($source){
+    public static function getMatchOdds($source,$match_ids=[]){
         $oddsData = self::select('match_id','id','p_code','odds_code','status','odds','condition','sort','odds_only')
             ->where($source)
+            ->whereIn('match_id',$match_ids)
             ->where(
                 function($query){
                     $query->where('odds_code','dishes_home')

+ 4 - 2
Application/Sports/Model/St_zq_competition.php

@@ -27,7 +27,7 @@ class St_zq_competition extends Model
     }
 
     //获取各球类 滚球赛事关联赛事结果数据
-    public static function getRollMatchDataAll($source,$models,$where){
+    public static function getRollMatchDataAll($source,$models,$where,$lg_ids=[]){
         $model_match = $models['model_match'];
         $model_result = $models['model_result'];
 
@@ -35,6 +35,7 @@ class St_zq_competition extends Model
             ->leftjoin($model_result,$model_result.'.match_id',$model_match.'.match_id')
             ->select($model_match.'.lg_id',$model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team','home_score','guest_score',$model_result.'.match_time as a_time','match_process')
             ->where($model_match.'.source',$source['source'])
+            ->whereIn($model_match.'.lg_id',$lg_ids)
             ->where($where)
             ->get()
             ->toarray();
@@ -43,13 +44,14 @@ class St_zq_competition extends Model
     }
 
     //获取各球类 非滚球赛事关联赛事结果数据
-    public static function getSoonMatchDataAll($source,$models,$where){
+    public static function getSoonMatchDataAll($source,$models,$where,$lg_ids=[]){
         $model_match = $models['model_match'];
 
         $data = lm($model_match,"Sports")
             ->select($model_match.'.lg_id',$model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team',$model_match.'.us_time')
             ->where($source)
             ->where($where)
+            ->whereIn($model_match.'.lg_id',$lg_ids)
             ->orderBy('match_time','asc')
             ->get()
             ->toarray();

+ 2 - 1
Application/Sports/Model/St_zq_odds.php

@@ -26,11 +26,12 @@ class St_zq_odds extends Model
     }
 
     //获取足球赛事下 滚球盘默认赔率
-    public static function getMatchOdds($source,$models){
+    public static function getMatchOdds($source,$models,$match_ids=[]){
         $model_odds = $models['model_odds'];
         $oddsData= lm($model_odds,"Sports")
             ->select($model_odds.'.match_id',$model_odds.'.id','p_code','odds_code',$model_odds.'.status','odds','condition','odds_only','sort')
             ->where($model_odds.'.source',$source['source'])
+            ->whereIn($model_odds.'.match_id',$match_ids)
             ->where([$model_odds.'.type'=>0])//查询滚球赔率
             //->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
             ->where(function($query)use ($model_odds){

+ 116 - 10
Biz/Match/GetmatchData.php

@@ -207,11 +207,20 @@ class GetmatchData {
         if(empty($leagueData)){
             return $leagueData=[];
         }
+        //获取联赛id
+        $lg_ids = [];
+        foreach ($leagueData as $k => $v){
+            $lg_ids[] = $v['lg_id'];
+        }
         //统计联赛下的赛事及查询赛事
-        $matchData = matchModel::getRollMatchDataAll($source,$models,$where);
+        $matchData = matchModel::getRollMatchDataAll($source,$models,$where,$lg_ids);
+        //获取赛事id
+        $match_ids = [];
+        foreach ($matchData as $k => $v){
+            $match_ids[] = $v['match_id'];
+        }
         //获取赛事下滚球默认赔率
-        $oddsData = ZQoddsModel::getMatchOdds($source,$models);
-
+        $oddsData = ZQoddsModel::getMatchOdds($source,$models,$match_ids);
         $data = [];
         foreach ($leagueData as $k=>$v){
             $data[$k] = $v;
@@ -422,8 +431,18 @@ class GetmatchData {
         if(empty($leagueData)){
             return $leagueData=[];
         }
+        //获取联赛id
+        $lg_ids = [];
+        foreach ($leagueData as $k => $v){
+            $lg_ids[] = $v['lg_id'];
+        }
         //统计联赛下的赛事及查询赛事
-        $matchData = matchModel::getSoonMatchDataAll($source,$models,$where);
+        $matchData = matchModel::getSoonMatchDataAll($source,$models,$where,$lg_ids);
+        //获取赛事id
+        $match_ids = [];
+        foreach ($matchData as $k => $v){
+            $match_ids[] = $v['match_id'];
+        }
         //获取当前美东时间
         $s_time = strtotime($this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4));
         $data = [];
@@ -440,7 +459,7 @@ class GetmatchData {
         }
         if($ret['game_code'] == 'zq') {
             //获取赛事下默认赔率
-            $oddsData = ZQoddsModel::getMatchOdds($source, $models);
+            $oddsData = ZQoddsModel::getMatchOdds($source, $models,$match_ids);
             foreach ($data as $k=>$v){
                 foreach ($v['matchData'] as $kk=>$vv){
                     //获取赛事下赔率并且分组
@@ -461,7 +480,7 @@ class GetmatchData {
             }
         }
         if($ret['game_code'] == 'lq') {
-            $oddsData = LQoddsModel::getMatchOdds($source);
+            $oddsData = LQoddsModel::getMatchOdds($source,$match_ids);
             foreach ($data as $k=>$v){
                 foreach ($v['matchData'] as $kk=>$vv){
                     //获取赛事下赔率并且分组
@@ -476,7 +495,7 @@ class GetmatchData {
             }
         }
         if($ret['game_code'] == 'wq') {
-            $oddsData = WQoddsModel::getMatchOdds($source);
+            $oddsData = WQoddsModel::getMatchOdds($source,$match_ids);
             foreach ($data as $k=>$v){
                 foreach ($v['matchData'] as $kk=>$vv){
                     //获取赛事下赔率并且分组
@@ -491,7 +510,7 @@ class GetmatchData {
             }
         }
         if($ret['game_code'] == 'bq') {
-            $oddsData = BQoddsModel::getMatchOdds($source);
+            $oddsData = BQoddsModel::getMatchOdds($source,$match_ids);
             foreach ($data as $k=>$v){
                 foreach ($v['matchData'] as $kk=>$vv){
                     //获取赛事下赔率并且分组
@@ -1118,7 +1137,7 @@ class GetmatchData {
     /**
      * 获取欧冠 滚球数据
      */
-    public function getUEFAStRollBall($model,$type_code,$source,$lg_id,$search=''){
+    public function __getUEFAStRollBall($model,$type_code,$source,$lg_id,$search=''){
         $model_match = $model['model_match'];
         $model_odds = $model['model_odds'];
         $model_result = $model['model_result'];
@@ -1187,11 +1206,57 @@ class GetmatchData {
 
         return $matchData;
     }
+    public function getUEFAStRollBall($model,$type_code,$source,$lg_id,$search=''){
+        $model_match = $model['model_match'];
+        $model_odds = $model['model_odds'];
+        $model_result = $model['model_result'];
+
+        $where = $this->commonFunction->getState($type_code,$model_match);
+        $matchData = lm($model_match,"Sports")
+            ->leftjoin($model_result,$model_result.'.match_id',$model_match.'.match_id')
+            ->select($model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team','home_score','guest_score',$model_result.'.match_time as a_time','match_process')
+            ->where($model_match.'.source',$source['source'])
+            ->where($model_match.'.lg_id',$lg_id)
+            ->where($where)
+            ->where(function($query)use ($model_match,$search){
+                $query->where($model_match.'.home_team','like','%'.$search.'%')
+                    ->orWhere(function($query)use ($model_match,$search) {
+                        $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
+                    });
+            })
+            ->get()
+            ->toarray();
+
+        //获取赛事id
+        $match_ids = [];
+        foreach ($matchData as $k => $v){
+            $match_ids[] = $v['match_id'];
+        }
+        //获取赛事下滚球默认赔率
+        $oddsData = ZQoddsModel::getMatchOdds($source,$model,$match_ids);
+        foreach ($matchData as $k=>$v){
+            //获取赛事下赔率并且分组
+            $capot = [];
+            $concede_size = [];
+            foreach ($oddsData as $kk=>$vv){
+                if ($vv['match_id'] == $v['match_id'] and $vv['sort']==0) {
+                    if($vv['p_code'] == 'concede_size'){
+                        $concede_size[] = $vv;
+                    }
+                    if($vv['p_code'] == 'capot'){
+                        $capot[] = $vv;
+                    }
+                }
+            }
+            $matchData[$k]['oddsData'] = [$concede_size,$capot];
+        }
+        return $matchData;
+    }
 
     /**
      * 获取欧冠 今日数据
      */
-    public function getUEFAStToday($model,$type_code,$source,$lg_id,$search=''){
+    public function __getUEFAStToday($model,$type_code,$source,$lg_id,$search=''){
         $model_match = $model['model_match'];
         $model_odds = $model['model_odds'];
 
@@ -1225,6 +1290,47 @@ class GetmatchData {
 
         return $matchData;
     }
+    public function getUEFAStToday($model,$type_code,$source,$lg_id,$search=''){
+        $model_match = $model['model_match'];
+        $model_odds = $model['model_odds'];
+
+        $where = $this->commonFunction->getState($type_code);
+        $matchData = lm($model_match,'Sports')
+            ->select('match_id','match_date','match_time','tag','home_team','guest_team')
+            ->where($model_match.'.source',$source['source'])
+            ->where($where)
+            ->where('lg_id',$lg_id)
+            ->where(function($query)use ($model_match,$search){
+                $query->where($model_match.'.home_team','like','%'.$search.'%')
+                    ->orWhere(function($query)use ($model_match,$search) {
+                        $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
+                    });
+            })
+            ->get()->toArray();
+
+        //获取赛事id
+        $match_ids = [];
+        foreach ($matchData as $k => $v){
+            $match_ids[] = $v['match_id'];
+        }
+        //获取赔率数据
+        $oddsData = lm($model_odds, "Sports")
+            ->select( 'id','p_code', 'odds_code','odds_only','status', 'odds', 'condition', 'sort','match_id')
+            ->where('source',$source['source'])
+            ->whereIn('match_id', $match_ids)
+            ->groupBy($model_odds . '.id','p_code', 'odds_code','odds_only', $model_odds . '.status', 'odds', 'condition', 'sort','match_id')
+            ->orderBy($model_odds . '.id','desc')
+            ->get()
+            ->toarray();
+        foreach ($matchData as $k=>$v){
+            foreach ($oddsData as $kk=>$vv){
+                if($v['match_id'] == $vv['match_id']){
+                    $matchData[$k]['oddsData'][] = $vv;
+                }
+            }
+        }
+        return $matchData;
+    }
 
     /**
      * 获取欧冠 早盘数据