彭俊 6 年 前
コミット
d499fe22f6

+ 26 - 9
Application/Sports/Controller/Head.php

@@ -42,10 +42,22 @@ class Head extends Controller{
         $where = [
             ['status','<','2']
         ];
-        $ZQmatchData = leagueModel::getLeagueMatchData($this->commonFunction->getModels('zq'),$where);
-        $LQmatchData = leagueModel::getLeagueMatchData($this->commonFunction->getModels('lq'),$where);
-        $WQmatchData = leagueModel::getLeagueMatchData($this->commonFunction->getModels('wq'),$where);
-        $BQmatchData = leagueModel::getLeagueMatchData($this->commonFunction->getModels('bq'),$where);
+        $zqModel = $this->commonFunction->getModels('zq');
+        $lqModel = $this->commonFunction->getModels('lq');
+        $wqModel = $this->commonFunction->getModels('wq');
+        $bqModel = $this->commonFunction->getModels('bq');
+
+        $ZQmatchData = leagueModel::getLeagueMatchData($zqModel,$where,'zq');
+        $LQmatchData = leagueModel::getLeagueMatchData($lqModel,$where,'lq');
+        $WQmatchData = leagueModel::getLeagueMatchData($wqModel,$where,'wq');
+        $BQmatchData = leagueModel::getLeagueMatchData($bqModel,$where,'bq');
+
+        //处理空赔率赛事
+        $ZQmatchData = $this->commonFunction->Handle_Odds_Null($ZQmatchData,$zqModel);
+        $LQmatchData = $this->commonFunction->Handle_Odds_Null($LQmatchData,$lqModel);
+        $WQmatchData = $this->commonFunction->Handle_Odds_Null($WQmatchData,$wqModel);
+        $BQmatchData = $this->commonFunction->Handle_Odds_Null($BQmatchData,$bqModel);
+
         //合并所有球类赛事
         $matchAll = array_merge_recursive($ZQmatchData,$LQmatchData,$WQmatchData,$BQmatchData);
 
@@ -56,7 +68,7 @@ class Head extends Controller{
         ];
         $select = ['match_id','type'];
         $ZQoddsData = ZQoddsModel::getOddsData($where,$select)->toArray();
-        $LQoddsData = LQoddsModel::getOddsData($where,$select)->toArray();
+        $LQoddsData = LQoddsModel::getOddsData($where,$select)->toArray(); 
         $WQoddsData = WQoddsModel::getOddsData($where,$select)->toArray();
         $BQoddsData = BQoddsModel::getOddsData($where,$select)->toArray();
         //合并所有球类冠军盘口
@@ -69,19 +81,24 @@ class Head extends Controller{
         $StStringScene = [];
         //按状态条件分装数组
         foreach ($matchAll as $kk=>$vv){
-            if($vv['status'] == '1'){
+            //滚球
+            if($vv['is_rollball'] == '1' and $vv['status'] < 2){
                 $StRollBall[] = $vv;
             }
+            //即将
             if($vv['status'] == '0' and $vv['match_date'] == date("Y-m-d") and $vv['match_time'] < date("H:i:s", strtotime("+2 hour")) and $vv['match_time'] > date("H:i:s", time())){
                 $StSoon[] = $vv;
             }
-            if($vv['match_date'] == date("Y-m-d") and $vv['match_time'] > date("H:i:s", time())){
+            //今日
+            if($vv['match_date'] == date("Y-m-d") and $vv['match_time'] > date("H:i:s", time()) and $vv['status'] < 2){
                 $StToday[] = $vv;
             }
-            if($vv['is_morningplate'] == 1 and $vv['us_time'] > $this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4)){
+            //早盘
+            if($vv['is_morningplate'] == 1 and $vv['us_time'] > $this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4) and $vv['status'] < 2 and $vv['match_date'] > date("Y-m-d")){
                 $StMorningPlate[] = $vv;
             }
-            if($vv['is_stringscene'] == 1 and $vv['us_time'] > $this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4)){
+            //串场
+            if($vv['is_stringscene'] == 1 and $vv['us_time'] > $this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4) and $vv['status'] < 2){
                 $StStringScene[] = $vv;
             }
         }

+ 7 - 7
Application/Sports/Model/St_zq_league.php

@@ -73,14 +73,14 @@ class St_zq_league extends Model
         $model_league = $models['model_league'];
         $model_result = $models['model_result'];
         //当前状态下所有联赛
+       
         $data = lm($model_league,"Sports")
-            ->join($model_match,$model_match.'.lg_id',$model_league.'.id')
-            ->select($model_league.'.id as lg_id',$model_league.'.name_chinese as leagueName',$model_match.'.id as match_id',$model_match.'.status',$model_match.'.match_date',$model_match.'.match_time',$model_match.'.us_time',$model_match.'.is_morningplate',$model_match.'.is_stringscene')
-            ->where([[$model_league.'.name_chinese','!=','']])
-            ->where([[$model_match.'.status','<',2]])
-            ->get()
-            ->toarray();
-
+        ->join($model_match,$model_match.'.lg_id',$model_league.'.id')
+        ->select($model_league.'.id as lg_id',$model_league.'.name_chinese as leagueName',$model_match.'.id as match_id',$model_match.'.status',$model_match.'.match_date',$model_match.'.match_time',$model_match.'.us_time',$model_match.'.is_morningplate',$model_match.'.is_stringscene',$model_match.'.is_rollball',$model_match.'.is_today')
+        ->where([[$model_league.'.name_chinese','!=','']])
+        ->where([[$model_match.'.status','<',2]])
+        ->get();
+      
         return $data;
     }
 }

+ 34 - 0
Biz/Common/CommonFunction.php

@@ -1081,6 +1081,40 @@ class CommonFunction {
     function C1($n, $m) {
         return A1($n, $m)/factorial($m);
     }
+
+    //处理空赔率赛事
+    function Handle_Odds_Null($matchData=[],$models=[]){
+         //===获取当前赛事是否有赔率,如果没有则去除===
+        //获取当前match_id
+        $match_ids = [];
+        foreach($matchData as $k=>$v){
+            $match_ids[] = $v['match_id'];
+        }
+        //获取下赛事赔率
+        $oddsData = lm($models['model_odds'],'Sports')
+        ->select('id','match_id')
+        ->whereIn('match_id',$match_ids)
+        ->get()
+        ->toArray();
+
+        //根据match_id 去重
+        $oddsData = $this->array_unset_tt($oddsData,'match_id');
+        sort($oddsData);
+
+        //如果赔率为空,则返回空
+        if(empty($oddsData)) return $oddsData;
+        $matchData_new = [];
+        foreach($matchData as $k=>$v){
+            foreach($oddsData as $kk=>$vv){
+                if($v['match_id'] == $vv['match_id']){
+                    $matchData_new[] = $matchData[$k];
+                }
+            }
+        }
+
+        return $matchData_new;
+        //===赛事空赔率 处理end ===
+    }
 }
 
 ?>

+ 6 - 99
Biz/Match/GetmatchData.php

@@ -262,33 +262,12 @@ class GetmatchData {
         if(empty($matchData)) return $matchData;
 
         //===获取当前赛事是否有赔率,如果没有则去除===
+        $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
         //获取当前match_id
         $match_ids = [];
         foreach($matchData as $k=>$v){
             $match_ids[] = $v['match_id'];
         }
-        //获取下赛事赔率
-        $oddsData = lm($models['model_odds'],'Sports')
-        ->select('id','match_id')
-        ->whereIn('match_id',$match_ids)
-        ->get()
-        ->toArray();
-
-        //根据match_id 去重
-        $oddsData = $this->commonFunction->array_unset_tt($oddsData,'match_id');
-        sort($oddsData);
-
-        //如果赔率为空,则返回空
-        if(empty($oddsData)) return $oddsData;
-        $matchData_new = [];
-        foreach($matchData as $k=>$v){
-            foreach($oddsData as $kk=>$vv){
-                if($v['match_id'] == $vv['match_id']){
-                    $matchData_new[] = $matchData[$k];
-                }
-            }
-        }
-        //===赛事空赔率 处理end ===
         //组装联赛下赛事
         $data = [];
         foreach ($leagueData as $k=>$v){
@@ -329,34 +308,13 @@ class GetmatchData {
         if(empty($matchData)) return $matchData;
 
         //===获取当前赛事是否有赔率,如果没有则去除===
+        $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
+
         //获取当前match_id
         $match_ids = [];
         foreach($matchData as $k=>$v){
             $match_ids[] = $v['match_id'];
         }
-        //获取下赛事赔率
-        $oddsData = lm($models['model_odds'],'Sports')
-        ->select('id','match_id')
-        ->whereIn('match_id',$match_ids)
-        ->get()
-        ->toArray();
-
-        //根据match_id 去重
-        $oddsData = $this->commonFunction->array_unset_tt($oddsData,'match_id');
-        sort($oddsData);
-
-        //如果赔率为空,则返回空
-        if(empty($oddsData)) return $oddsData;
-        $matchData_new = [];
-        foreach($matchData as $k=>$v){
-            foreach($oddsData as $kk=>$vv){
-                if($v['match_id'] == $vv['match_id']){
-                    $matchData_new[] = $matchData[$k];
-                }
-            }
-        }
-        //===赛事空赔率 处理end ===
-
         //获取当前美东时间
         $s_time = strtotime($this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4));
         $data = [];
@@ -548,33 +506,7 @@ class GetmatchData {
         if(empty($matchData)) return $matchData;
 
         //===获取当前赛事是否有赔率,如果没有则去除===
-        //获取当前match_id
-        $match_ids = [];
-        foreach($matchData as $k=>$v){
-            $match_ids[] = $v['match_id'];
-        }
-        //获取下赛事赔率
-        $oddsData = lm($models['model_odds'],'Sports')
-        ->select('id','match_id')
-        ->whereIn('match_id',$match_ids)
-        ->get()
-        ->toArray();
-
-        //根据match_id 去重
-        $oddsData = $this->commonFunction->array_unset_tt($oddsData,'match_id');
-        sort($oddsData);
-
-        //如果赔率为空,则返回空
-        if(empty($oddsData)) return $oddsData;
-        $matchData_new = [];
-        foreach($matchData as $k=>$v){
-            foreach($oddsData as $kk=>$vv){
-                if($v['match_id'] == $vv['match_id']){
-                    $matchData_new[] = $matchData[$k];
-                }
-            }
-        }
-        //===赛事空赔率 处理end ===
+        $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
 
         //按国家
         $countryData = [];
@@ -746,33 +678,8 @@ class GetmatchData {
         if(empty($matchData)) return $matchData;
 
         //===获取当前赛事是否有赔率,如果没有则去除===
-        //获取当前match_id
-        $match_ids = [];
-        foreach($matchData as $k=>$v){
-            $match_ids[] = $v['match_id'];
-        }
-        //获取下赛事赔率
-        $oddsData = lm($model_odds,'Sports')
-        ->select('id','match_id')
-        ->whereIn('match_id',$match_ids)
-        ->get()
-        ->toArray();
-
-        //根据match_id 去重
-        $oddsData = $this->commonFunction->array_unset_tt($oddsData,'match_id');
-        sort($oddsData);
-
-        //如果赔率为空,则返回空
-        if(empty($oddsData)) return $oddsData;
-        $matchData_new = [];
-        foreach($matchData as $k=>$v){
-            foreach($oddsData as $kk=>$vv){
-                if($v['match_id'] == $vv['match_id']){
-                    $matchData_new[] = $matchData[$k];
-                }
-            }
-        }
-        //===赛事空赔率 处理end ===
+        $models = ['model_odds'=>$model_odds];
+        $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
 
         //获取各球类默认赔率
         $game_code = $_REQUEST['game_code'];