彭俊 6 лет назад
Родитель
Сommit
d7ab3cad41

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

@@ -97,7 +97,7 @@ class MatchListWeb extends Controller{
                     ->select($models['model_match'].'.id as match_id')
                     ->where($where)
                     ->get()
-                    ->toarray();
+                    ->toArray();
                 //===获取当前赛事是否有赔率,如果没有则去除===
                 $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
                 $matchNum = count($matchData_new);
@@ -394,12 +394,12 @@ where a.match_id = b.match_id and a.id = b.id ";
                         $match_odds[$kk]['match_date'] = $vv['match_date'];
                         $match_odds[$kk]['match_time'] = $vv['match_time'];
                         $match_odds[$kk]['tag'] = $vv['tag'];
-                        $match_odds[$kk]['a_time'] = $vv['a_time'];
-                        $match_odds[$kk]['match_process'] = $vv['match_process'];
+                        $match_odds[$kk]['a_time'] = $vv['a_time']?:$this->commonFunction->getMatchTime($vv['match_date'],$vv['match_time']);
+                        $match_odds[$kk]['match_process'] = $vv['match_process']?:$this->commonFunction->getMatchProcess( $match_odds[$kk]['a_time'],$game_code);
                         //如果是网球结果
                         if($game_code == 'wq'){
-                            $match_odds[$kk]['home_player_score'] = $vv['home_player_score'];
-                            $match_odds[$kk]['guest_player_score'] = $vv['guest_player_score'];
+                            $match_odds[$kk]['home_player_score'] = $vv['home_player_score']?:0;
+                            $match_odds[$kk]['guest_player_score'] = $vv['guest_player_score']?:0;
                             //追加赛事实时结果json
                             $match_odds[$kk]['result_mark'] = $vv['result_mark'];
                             //按第一、二、三盘/全场 分组
@@ -420,8 +420,8 @@ where a.match_id = b.match_id and a.id = b.id ";
                                 $match_odds[$kk]['full_oddsData'][] = $v;
                             }
                         }else if($game_code == 'bq'){
-                            $match_odds[$kk]['home_score'] = $vv['home_score'];
-                            $match_odds[$kk]['guest_score'] = $vv['guest_score'];
+                            $match_odds[$kk]['home_score'] = $vv['home_score']?:0;
+                            $match_odds[$kk]['guest_score'] = $vv['guest_score']?:0;
                             //赛事实时结果 json
                             $match_odds[$kk]['result_mark'] = $vv['result_mark'];
                             //按 前五局/全场 分组
@@ -436,8 +436,8 @@ where a.match_id = b.match_id and a.id = b.id ";
                         }
                         else
                         {
-                            $match_odds[$kk]['home_score'] = $vv['home_score'];
-                            $match_odds[$kk]['guest_score'] = $vv['guest_score'];
+                            $match_odds[$kk]['home_score'] = $vv['home_score']?:0;
+                            $match_odds[$kk]['guest_score'] = $vv['guest_score']?:0;
                             $match_odds[$kk]['oddsData'][] = $v;
                         }
                     }

+ 6 - 3
Application/Sports/Model/St_zq_competition.php

@@ -12,6 +12,9 @@ class St_zq_competition extends Model
 {
 
     protected $table = 'st_zq_competition';
+    public function init() {
+        // $this->commonFunction =  C()->get('commonFunction');
+    }
 
     /**
      * @param array $where 条件
@@ -29,7 +32,7 @@ class St_zq_competition extends Model
     /*
      * 获取各球类 滚球赛事关联赛事结果数据
      */
-    public static function getRollMatchDataAll($source,$models,$where,$lg_ids=[]){
+    public static function getRollMatchDataAll($source,$models,$where,$lg_ids=[],$ret){
         $model_match = $models['model_match'];
         $model_result = $models['model_result'];
 
@@ -77,8 +80,8 @@ where a.match_id = b.match_id and a.id = b.id ";
                                 $matchData[$k]['home_score'] = $vv->home_score?:0;
                                 $matchData[$k]['guest_score'] = $vv->guest_score?:0;
                             }
-                            $matchData[$k]['a_time'] = $vv->a_time?:0;
-                            $matchData[$k]['match_process'] = $vv->match_process?:'';
+                            $matchData[$k]['a_time'] = $vv->a_time?:C()->get('commonFunction')->getMatchTime($v['match_date'],$v['match_time']);
+                            $matchData[$k]['match_process'] = $vv->match_process?:C()->get('commonFunction')->getMatchProcess( $matchData[$k]['a_time'],$ret['game_code']);
                         }
                     }
                 }else{

+ 37 - 0
Biz/Common/CommonFunction.php

@@ -1181,6 +1181,43 @@ class CommonFunction {
 
         return $prize_money;
    }
+
+   //计算赛事当前进行时间
+   function getMatchTime($match_date,$match_time){
+    $time = time() - strtotime($match_date.' '.$match_time);
+    //如果需要时刻格式
+    // $time = $this->dataformat($time);
+    return floor($time/60);
+   }
+
+   //将秒 转换为 时 分 秒
+   function dataformat($num=0) {
+        $hour = floor($num/3600);
+        $minute = floor(($num-3600*$hour)/60);
+        $second = floor((($num-3600*$hour)-60*$minute)%60);
+        return $hour.':'.$minute.':'.$second;
+    }
+
+    //根据赛事进行 时间 获取进程
+    function getMatchProcess($time=0,$game_code){
+        if($game_code == 'zq'){
+            if($time < 45) return '上半场';
+            return '下半场';
+        }
+        if($game_code == 'lq'){
+            if($time < 10) return '第一节';
+            if(($time > 10) and ($time < 20)) return '第二节';
+            if(($time > 20) and ($time < 30)) return '第三节';
+            if(($time > 30) and ($time < 40)) return '第四节';
+        }
+        if($game_code == 'wq'){
+            return '';
+        }
+        if($game_code == 'bq'){
+            return '';
+        }
+
+    }
 }
 
 ?>

+ 2 - 2
Biz/Match/GetmatchData.php

@@ -258,7 +258,7 @@ class GetmatchData {
             $lg_ids[] = $v['lg_id'];
         }
         //统计联赛下的赛事及查询赛事
-        $matchData = matchModel::getRollMatchDataAll($source,$models,$where,$lg_ids);
+        $matchData = matchModel::getRollMatchDataAll($source,$models,$where,$lg_ids,$ret);
 
         //如果赛事为空,直接返回
         if(empty($matchData)) return $matchData;
@@ -267,7 +267,7 @@ class GetmatchData {
         $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
         //获取当前match_id
         $match_ids = [];
-        foreach($matchData as $k=>$v){
+        foreach($matchData_new as $k=>$v){
             $match_ids[] = $v['match_id'];
         }
         //组装联赛下赛事