彭俊 6 سال پیش
والد
کامیت
ec1ae447b0
1فایلهای تغییر یافته به همراه60 افزوده شده و 6 حذف شده
  1. 60 6
      Biz/Match/GetmatchData.php

+ 60 - 6
Biz/Match/GetmatchData.php

@@ -258,16 +258,42 @@ class GetmatchData {
         //统计联赛下的赛事及查询赛事
         $matchData = matchModel::getRollMatchDataAll($source,$models,$where,$lg_ids);
 
-        //获取赛事id
+        //如果赛事为空,直接返回
+        if(empty($matchData)) return $matchData;
+
+        //===获取当前赛事是否有赔率,如果没有则去除===
+        //获取当前match_id
         $match_ids = [];
-        foreach ($matchData as $k => $v){
+        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){
             $data[$k] = $v;
-            foreach ($matchData as $kk=>$vv){
+            foreach ($matchData_new as $kk=>$vv){
                 if($v['lg_id'] == $vv['lg_id']){
                     $data[$k]['matchData'][] = $vv;
                 }
@@ -298,17 +324,45 @@ class GetmatchData {
         }
         //统计联赛下的赛事及查询赛事
         $matchData = matchModel::getSoonMatchDataAll($source,$models,$where,$lg_ids);
-        //获取赛事id
+
+        //如果赛事为空,直接返回
+        if(empty($matchData)) return $matchData;
+
+        //===获取当前赛事是否有赔率,如果没有则去除===
+        //获取当前match_id
         $match_ids = [];
-        foreach ($matchData as $k => $v){
+        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 = [];
         foreach ($leagueData as $k=>$v){
             $data[$k] = $v;
-            foreach ($matchData as $kk=>$vv){
+            foreach ($matchData_new as $kk=>$vv){
                 if($v['lg_id'] == $vv['lg_id']){
                     $wait_time = ceil(((strtotime( $vv['us_time']))-$s_time)/60);
                     $vv['wait_time'] = $wait_time;//追加距离开赛时间