Browse Source

异常处理

彭俊 6 years ago
parent
commit
e32110bcef
1 changed files with 29 additions and 17 deletions
  1. 29 17
      app/Lib/Biz/Sport/Common.php

+ 29 - 17
app/Lib/Biz/Sport/Common.php

@@ -1142,44 +1142,56 @@ class Common {
      * $bet_match 投注赛事数据
      * $result_match_r 投注赛事结果记录
      */
-    static function WARN_CHECK($bet_match='',$result_match=[]){
+    static function WARN_CHECK($bet_match = '', $result_match = [])
+    {
         /*
         危险球定义:
-            1.角球  
-            2. 12码罚球  
-            3.自由球(攻方在守方禁区附近的自由球)  
-            4.掷入球(攻方靠近守方禁区的掷入球)   
+            1.角球
+            2. 12码罚球
+            3.自由球(攻方在守方禁区附近的自由球)
+            4.掷入球(攻方靠近守方禁区的掷入球)
             5.一队向另一队禁区附近进攻
             ...
         危险球审核时间:
             下注成功后60~90秒
         */
-        if(!empty($bet_match) and !empty($result_match)) {
+
+        $defdata = [
+            'code' => 1,
+            'warn_more' => '',
+        ];
+
+        if (!empty($bet_match) and !empty($result_match)) {
             //获取投注时间  时间戳
             $bet_time = strtotime($bet_match->ctime);
             //取出所有有危险球的数据
             $warn_more = $result_match[0]->warn_more;
+
+            //当值为默认值时,表示没有危险球,不用再作判断了
+            if (trim($warn_more) == '[{"timei":"1970-1-1 0:0:1","rtype":0}]') {
+                return $defdata;
+            }
+
             //json转数组
-            $warn_more = json_decode($warn_more,true);
-            foreach($warn_more as $k=>$v){
+            $warn_more = json_decode($warn_more, true);
+            foreach ($warn_more as $k => $v) {
                 //获取危险球出现时间 转时间戳
                 $warn_time = strtotime($v['timei']);
-                if(($warn_time - $bet_time) < 90){
-                    $data=[
-                        'code'=>-1,
-                        'warn_more'=>$v
+                if (($warn_time - $bet_time) < 90) {
+                    $data = [
+                        'code' => -1,
+                        'warn_more' => $v
                     ];
                     return $data;
                 }
             }
-            $data = [
-                'code' => 1,
-                'warn_more'=>'',
-            ];
-            return $data;
+
+            return $defdata;
         }
     }
 
+
+
     //写入赛事数据日志文件
     static function SET_SPORTS_RECORD($game_code,$getData=[],$title,$msg){
         //中文不转义