vali 6 years ago
parent
commit
ce0ee3e165
1 changed files with 211 additions and 281 deletions
  1. 211 281
      app/Lib/Biz/Sport/Common.php

+ 211 - 281
app/Lib/Biz/Sport/Common.php

@@ -1,6 +1,5 @@
 <?php
 namespace App\Lib\Biz\Sport;
-
 use App\Http\Response\Response;
 
 use App\Http\Model\StZqMatch;
@@ -47,15 +46,12 @@ use App\Http\Model\StBqOddsRecord;
 use App\Http\Model\StBqResult;
 use App\Http\Model\StBqBroadcast;
 
-class Common
-{
+class Common {
     function checkDebug()
     {
-        return (isset($_GET['debug']) && intval($_GET['debug']) == -99999) || APP_DEBUG == 1 ? 1 : 0;
+        return (isset($_GET['debug']) && intval($_GET['debug'])==-99999) || APP_DEBUG==1?1:0;
     }
-
-    function View($Path = "")
-    {
+    function View($Path = "") {
         if (!$Path) {
             global $ViewPath;
             $ViewPath = explode("\\", $ViewPath);
@@ -79,13 +75,12 @@ class Common
     }
 
 
-    function M($TABLE_NAME = "")
-    {
+
+    function M($TABLE_NAME = "") {
         return new DB($TABLE_NAME);
     }
 
-    function checkClose()
-    {
+    function checkClose() {
         if (file_exists(ROOT_PATH . '/Cache/system.lock')) {
             if (is_mobile()) {
                 return appExec("Mobile", "Weihu", "index");
@@ -94,7 +89,6 @@ class Common
             }
         }
     }
-
     /**
      * 发布消息
      *
@@ -103,19 +97,16 @@ class Common
      * @param string $data
      * @return void
      */
-    function publishNotify($channel, $status = 1, $data = '')
-    {
+    function publishNotify($channel, $status = 1, $data = '') {
         // toLog('publishNotify-'.$channel.'+++'.$data);
         C()->get('msg')->publish($channel, $data);
     }
-
     /**
      * 数组分类排序
      * @param [array] $columnsArr [需要进行排序的数组]
      * @param [int] $plmid [所属分类ID]
      */
-    function getColumns($columnsArr, $plmid)
-    {
+    function getColumns($columnsArr, $plmid) {
         $menu = array();
 
         foreach ($columnsArr as $v) {
@@ -134,8 +125,7 @@ class Common
     /**
      * 获取客户端真实IP
      */
-    function GETIP()
-    {
+    function GETIP() {
         global $ip;
 
         if (getenv("HTTP_CLIENT_IP")) {
@@ -152,8 +142,7 @@ class Common
 
     }
 
-    function dump($data, $exit = 1)
-    {
+    function dump($data, $exit = 1) {
         echo "<pre>";
         print_r($data);
         echo "</pre>";
@@ -163,19 +152,16 @@ class Common
 
     }
 
-    function OrderID($prefix = '')
-    {
+    function OrderID($prefix = '') {
         $num = mt_rand(100, 999);
         list($s, $m) = explode(' ', microtime());
         $order = date("YmdHis") . ($s * 1000000) . $num;
         return $prefix . $order;
     }
-
     /**
      * 容器
      */
-    function C()
-    {
+    function C() {
         static $c = array();
         if (!isset($c['container'])) {
             $c['container'] = new \System\Di();
@@ -188,8 +174,7 @@ class Common
      * @param [type] $key   [description]
      * @param [type] $value [description]
      */
-    function S($key, $value = null)
-    {
+    function S($key, $value = null) {
         if ($value != null) {
             $GLOBALS[$key] = $value;
         }
@@ -197,37 +182,33 @@ class Common
             return $GLOBALS[$key];
         }
     }
-
     /**
      * 载入模型
      * @param  [type] $name [description]
      * @param  string $proj [description]
      * @return [type]       [description]
      */
-    function lm($name, $proj = '')
-    {
+    function lm($name, $proj = '') {
         $proj = empty($proj) ? S('CUR_PROJECT') : $proj;
         if (empty($proj)) {
             throw new \Exception("项目{$proj}不存在", 1);
         }
         $cls = "\\App\\" . ucfirst($proj) . "\\Model\\" . ucfirst($name);
-        if (!class_exists($cls)) {
+        if(!class_exists($cls)){
             return;
         }
         $key = 'model_' . $name . $proj;
         C()->shared($key, $cls);
         return C()->get($key);
     }
-
     /**
      * 载入语言包
-     * @param  string $key 语言项
+     * @param  string $key  语言项
      * @param  string $file 语言文件名
      * @param  string $proj 项目名称
      * @return [type]       [description]
      */
-    function lang($file = '', $proj = '')
-    {
+    function lang($file = '', $proj = '') {
         $proj = empty($proj) ? S('CUR_PROJECT') : $proj;
         $file = empty($file) ? S('CUR_CONTROLLER') : $file;
         $ckey = "Lang_{$proj}_{$file}";
@@ -268,9 +249,8 @@ class Common
      * @param string $tag
      * @return void
      */
-    function parseTag($message, $data = array(), $tag = '#')
-    {
-        if (is_array($data) && count($data) > 0) {
+    function parseTag($message,$data=array(),$tag='#'){
+        if(is_array($data) && count($data)>0){
             foreach ($data as $k => $v) {
                 $message = str_replace($tag . $k . $tag, $v, $message);
             }
@@ -279,8 +259,7 @@ class Common
         return $message;
     }
 
-    function appExec($proj, $ctrl, $method, $exec = 0)
-    {
+    function appExec($proj, $ctrl, $method, $exec = 0) {
         $proj = ucfirst($proj);
         $ctrl = ucfirst($ctrl);
         $method = ucfirst($method);
@@ -290,7 +269,7 @@ class Common
         checkPlatform();
         toDomain();
         //设置REMOTE_KEY
-        lm('setinfo', 'commons')->setKey();
+        lm('setinfo','commons')->setKey();
 
         $cls = "\\App\\{$proj}\\Controller\\{$ctrl}";
         C()->set($ctrl, $cls);
@@ -318,8 +297,7 @@ class Common
     /**
      * UUID 生成
      */
-    function UUID()
-    {
+    function UUID() {
         $prefix = '';
         $uuid = '';
         $str = md5(uniqid(mt_rand(), true));
@@ -334,9 +312,8 @@ class Common
     /**
      *密码加密码
      */
-    function GenEncryption()
-    {
-        srand((double)microtime() * 1000000); //create a random number feed.
+    function GenEncryption() {
+        srand((double) microtime() * 1000000); //create a random number feed.
         $ychar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
         $list = explode(",", $ychar);
         $authnum = "";
@@ -348,8 +325,7 @@ class Common
     }
 
 //密码加密
-    function GenPassword($password)
-    {
+    function GenPassword($password) {
         $Enc = GenEncryption();
         $Pwd = md5(md5($Enc . $password));
         return array("encryption" => $Enc, "password" => $Pwd);
@@ -357,8 +333,7 @@ class Common
     }
 
 //密码验证
-    function VerPassword($identity, $password)
-    {
+    function VerPassword($identity, $password) {
         $account = M("account_password")->where("account_identity = '$identity' and", "status = ", '1')->select("encryption,account_password")->find();
         $VerPwd = md5(md5($account["encryption"] . $password));
         if ($VerPwd == $account["account_password"]) {
@@ -372,43 +347,39 @@ class Common
         }
 
     }
-
     /**
      * Json return
-     * @param string $data [description]
+     * @param string $data   [description]
      * @param string $status [description]
-     * @param string $msg [description]
+     * @param string $msg    [description]
      * @param string $method [description]
      */
-    function JsonReturn($data = "", $status = "200", $msg = "", $method = "")
-    {
+    function JsonReturn($data = "", $status = "200", $msg = "", $method = "") {
         // header("Content-type:application/json;charset:utf-8");
         // header('content-type:text/html; charset=utf-8');
-        if (isset($_REQUEST['crossdomain']) && !empty($_REQUEST['crossdomain'])) {
+        if(isset($_REQUEST['crossdomain']) && !empty($_REQUEST['crossdomain'])){
             header("Access-Control-Allow-Origin:{$_REQUEST['crossdomain']}");
-        } else {
+        }else{
             header("Access-Control-Allow-Origin:*");
         }
         header('Access-Control-Allow-Methods:POST,GET,PUT,DELETE,OPTIONS');
         header('Access-Control-Allow-Credentials:true');
-        $retdata = array("status" => $status, "msg" => $msg, "data" => $data);
+        $retdata=array("status" => $status, "msg" => $msg, "data" =>$data);
 
-        $devicetype = isset($_REQUEST['devicetype']) ? trim($_REQUEST['devicetype']) : '';
-        if (!empty($devicetype) && in_array($devicetype, array('ios', 'android'))) {
-            $path = S('CUR_PROJECT') . '/' . S('CUR_CONTROLLER') . '/' . S('CUR_METHOD');
-            $retdata = C()->get($devicetype . "Result")->update($path, $retdata);
+        $devicetype=isset($_REQUEST['devicetype'])?trim($_REQUEST['devicetype']):'';
+        if(!empty($devicetype) && in_array($devicetype,array('ios','android'))){
+            $path=S('CUR_PROJECT').'/'.S('CUR_CONTROLLER').'/'.	S('CUR_METHOD');
+            $retdata=C()->get($devicetype."Result")->update($path,$retdata);
         }
 
         if ($method == '') {
             //dump($devicetype);
-            echo(json_encode($retdata, JSON_UNESCAPED_UNICODE));
+            echo (json_encode($retdata,JSON_UNESCAPED_UNICODE));
         } else {
-            echo($method . "(" . json_encode($retdata, JSON_UNESCAPED_UNICODE) . ")");
+            echo ($method . "(" . json_encode($retdata,JSON_UNESCAPED_UNICODE) . ")");
         }
     }
-
-    function XmlReturn($data = "", $status = 200, $msg = '')
-    {
+    function XmlReturn($data = "", $status = 200, $msg = '') {
         // header("Content-type:text/xml;charset:utf-8");
         $xml = '<?xml version="1.0" encoding="utf-8"?>';
         $xml .= "<root>";
@@ -420,9 +391,7 @@ class Common
         $xml .= "</root>";
         echo($xml);
     }
-
-    function toXml($data)
-    {
+    function toXml($data) {
         // print_r($data);
         $xml = '';
         if (is_array($data) && count($data) > 0) {
@@ -443,16 +412,14 @@ class Common
         return $xml;
     }
 
-    function WriteLog($Log)
-    {
+    function WriteLog($Log) {
         $logger = new Logger('LOGGS');
         $logURI = "Cache/log/" . date("Y-m-d-H-i") . ".log";
         $logger->pushHandler(new StreamHandler($logURI, Logger::DEBUG));
         $logger->pushHandler(new FirePHPHandler());
-        $logger->addInfo(var_export($Log, 1));
+        $logger->addInfo(var_export($Log,1));
 
     }
-
     /**
      * 计算当前用时
      *
@@ -460,13 +427,12 @@ class Common
      * @param integer $return
      * @return void
      */
-    function computeTime($runName = '', $return = 0, $start = 1)
-    {
-        $curTime = get_millisecond();
-        $numTime = $curTime - (intval($GLOBALS['startTime']) * 1000);
-        if ($return) {
-            return array('curTime' => $curTime, 'numTime' => $numTime, 'runName' => $runName);
-        } else {
+    function computeTime($runName='',$return=0,$start=1){
+        $curTime= get_millisecond();
+        $numTime=$curTime-(intval($GLOBALS['startTime'])*1000);
+        if($return){
+            return array('curTime'=>$curTime,'numTime'=>$numTime,'runName'=>$runName);
+        }else{
             echo "<pre>执行{$runName} 功能,当前时间为:{$curTime},累积用时: {$numTime}</pre>";
             return;
         }
@@ -481,8 +447,7 @@ class Common
 
     }
 
-    function toLog($text, $rewrite = 0)
-    {
+    function toLog($text, $rewrite = 0) {
         $data = "=============" . date("Y-m-d H:i", time()) . "==========================================" . chr(13);
         $data .= var_export($text, 1) . chr(13);
         $data .= "======================================================================================" . chr(13);
@@ -498,10 +463,9 @@ class Common
      * 发送数据到前台,根据请求的数据格式返回相应的数据
      * @param [type] $data   [description]
      * @param string $status [description]
-     * @param string $msg [description]
+     * @param string $msg    [description]
      */
-    function Render($data, $status = "1", $msg = "", $method = '')
-    {
+    function Render($data, $status = "1", $msg = "", $method = '') {
         $format = S('CUR_RETURN_FORMAT');
         $msg = empty($msg) ? lang('errors', 'api')->get('error' . $status) : $msg;
 
@@ -515,21 +479,16 @@ class Common
     }
 
 
-    function _beginTransaction()
-    {
+
+    function _beginTransaction() {
         S('DB')->beginTransaction();
     }
-
-    function _rollBack()
-    {
+    function _rollBack() {
         S('DB')->rollBack();
     }
-
-    function _commit()
-    {
+    function _commit() {
         S('DB')->commit();
     }
-
     /**
      * 服务
      *
@@ -537,18 +496,15 @@ class Common
      * @param array $params
      * @return void
      */
-    function SRV($name, $params = array())
-    {
+    function SRV($name, $params = array()) {
         return C()->get($name)->update($params);
     }
-
     /**
      * 是否验证token过期
      *
      * @return bool
      */
-    function isCheckToken()
-    {
+    function isCheckToken() {
         $result = true;
         $allowMethod = include ROOT_PATH . "/Config/AllowMethod.php";
         $key = S('CUR_PROJECT') . '/' . S('CUR_CONTROLLER') . '/' . S('CUR_METHOD');
@@ -557,23 +513,19 @@ class Common
         }
         return $result;
     }
+    function checkPlatform(){
 
-    function checkPlatform()
-    {
-
-        if (isset($_GET['platform'])) {
-            $_SESSION['platform'] = $_GET['platform'] == 'wap' ? 1 : 0;
+        if(isset($_GET['platform'])){
+            $_SESSION['platform']=$_GET['platform']=='wap'?1:0;
         }
-        if (isset($_GET['clearPlatform']) && intval($_GET['clearPlatform']) == 1) {
-            $_SESSION['platform'] = null;
+        if(isset($_GET['clearPlatform']) && intval($_GET['clearPlatform'])==1){
+            $_SESSION['platform']=null;
         }
 
     }
-
-    function is_mobile()
-    {
-        if (isset($_SESSION['platform']) && $mobile = intval($_SESSION['platform']) > 0) {
-            return $mobile == 1 ? true : false;
+    function is_mobile() {
+        if(isset($_SESSION['platform']) && $mobile=intval($_SESSION['platform'])>0 ){
+            return $mobile==1?true:false;
         }
         $user_agent = $_SERVER['HTTP_USER_AGENT'];
         $mobile_agents = Array("240x320", "acer", "acoon", "acs-", "abacho", "ahong", "airness", "alcatel", "amoi", "android", "anywhereyougo.com", "applewebkit/525", "applewebkit/532", "asus", "audio", "au-mic", "avantogo", "becker", "benq", "bilbo", "bird", "blackberry", "blazer", "bleu", "cdm-", "compal", "coolpad", "danger", "dbtel", "dopod", "elaine", "eric", "etouch", "fly ", "fly_", "fly-", "go.web", "goodaccess", "gradiente", "grundig", "haier", "hedy", "hitachi", "htc", "huawei", "hutchison", "inno", "ipad", "ipaq", "ipod", "jbrowser", "kddi", "kgt", "kwc", "lenovo", "lg ", "lg2", "lg3", "lg4", "lg5", "lg7", "lg8", "lg9", "lg-", "lge-", "lge9", "longcos", "maemo", "mercator", "meridian", "micromax", "midp", "mini", "mitsu", "mmm", "mmp", "mobi", "mot-", "moto", "nec-", "netfront", "newgen", "nexian", "nf-browser", "nintendo", "nitro", "nokia", "nook", "novarra", "obigo", "palm", "panasonic", "pantech", "philips", "phone", "pg-", "playstation", "pocket", "pt-", "qc-", "qtek", "rover", "sagem", "sama", "samu", "sanyo", "samsung", "sch-", "scooter", "sec-", "sendo", "sgh-", "sharp", "siemens", "sie-", "softbank", "sony", "spice", "sprint", "spv", "symbian", "tablet", "talkabout", "tcl-", "teleca", "telit", "tianyu", "tim-", "toshiba", "tsm", "up.browser", "utec", "utstar", "verykool", "virgin", "vk-", "voda", "voxtel", "vx", "wap", "wellco", "wig browser", "wii", "windows ce", "wireless", "xda", "xde", "zte");
@@ -587,8 +539,7 @@ class Common
         return $is_mobile;
     }
 
-    function toDomain()
-    {
+    function toDomain() {
 
         $domain = $_SERVER['HTTP_HOST'];
         $config = include ROOT_PATH . '/Config/Domain.php';
@@ -638,44 +589,40 @@ class Common
         }
         /**
          * 数据签名认证
-         * @param  array $data 被认证的数据
+         * @param  array  $data 被认证的数据
          * @return string       签名
          */
-        function data_auth_sign($data)
-        {
+        function data_auth_sign($data) {
             //数据类型检测
             if (!is_array($data)) {
-                $data = (array)$data;
+                $data = (array) $data;
             }
             ksort($data); //排序
             $code = http_build_query($data); //url编码并生成query字符串
             $sign = sha1($code); //生成签名
             return $sign;
         }
-
         /*
          * 判断用户是否登录
          * */
-        function isLogin($str = '', $type = 'agent')
-        {
-            $session = $_SESSION[$type . 'Info'];
-            if (empty($session)) {
+        function isLogin($str = '',$type='agent') {
+            $session = $_SESSION[$type.'Info'];
+            if(empty($session)){
                 return null;
             }
-            if ($type == 'agent') {
-                if ($str == 'name') {
+            if($type=='agent'){
+                if($str=='name'){
                     return $session['agent_user'];
                 }
-                if ($str == 'uid') {
+                if($str=='uid'){
                     return $session['user_identity'];
                 }
             }
         }
     }
 
-    function jump($url)
-    {
-        header('Location:' . $url);
+    function jump($url){
+        header('Location:'.$url);
     }
 
 //手机中间星号
@@ -694,11 +641,10 @@ class Common
      * @throws Exception
      * 根据球类代码 定义相关model
      */
-    static function getModels($game_code, $isJoin = 1)
-    {
+    static function getModels($game_code,$isJoin=1){
         // 获取不同球类model
-        if ($isJoin == 1) {
-            switch ($game_code) {
+        if($isJoin == 1){
+            switch ($game_code){
                 case 'zq':
                     $model_league = new StZqLeague;
                     $model_match = new StZqMatch;
@@ -752,16 +698,16 @@ class Common
             }
         }
         $data = [
-            'model_league' => $model_league,//联赛
-            'model_match' => $model_match,//赛事
-            'model_odds' => $model_odds,//赔率
-            'model_result' => $model_result,//赛事结果
+            'model_league'=>$model_league,//联赛
+            'model_match'=>$model_match,//赛事
+            'model_odds'=>$model_odds,//赔率
+            'model_result' =>$model_result,//赛事结果
             'model_odds_record' => $model_odds_record,//赔率记录
-            'model_result_record' => $model_result_record,//赛事结果记录
-            'model_league_result' => $model_league_result,//联赛结果
-            'model_local_league' => $model_local_league,//本地关联联赛
-            'model_local_match' => $model_local_match,//本地关联赛事
-            'model_broadcast' => $model_broadcast,
+            'model_result_record' =>$model_result_record,//赛事结果记录
+            'model_league_result'=>$model_league_result,//联赛结果
+            'model_local_league'=>$model_local_league,//本地关联联赛
+            'model_local_match'=>$model_local_match,//本地关联赛事
+            'model_broadcast'=>$model_broadcast,
         ];
         return $data;
     }
@@ -772,94 +718,93 @@ class Common
      * @throws \Exception
      * 获取不同状态下的 查询条件
      */
-    function getState($type_code, $model_match = '')
-    {
-        if ($model_match == '') {
-            switch ($type_code) {
+    function getState($type_code,$model_match = ''){
+        if($model_match == ''){
+            switch ($type_code){
                 case 'StRollBall'://滚球 正在进行
                     $where = [
-                        ['status', '=', '1'],
+                        ['status','=','1'],
                     ];
                     break;
                 case 'StSoon'://即将 今日两小时内开始
                     $where = [
-                        ['status', '=', '0'],
-                        ['match_date', '=', date("Y-m-d")],
-                        ['match_time', '<', date("H:i:s", strtotime("+2 hour"))],
-                        ['match_time', '>', date("H:i:s", time())]
+                        ['status','=','0'],
+                        ['match_date','=',date("Y-m-d")],
+                        ['match_time','<',date("H:i:s", strtotime("+2 hour"))],
+                        ['match_time','>',date("H:i:s", time())]
                     ];
                     break;
                 case 'StToday'://今日 今日未开始未结束
                     $where = [
-                        ['match_date', '=', date("Y-m-d")],
-                        ['match_time', '>', date("H:i:s", time())],
+                        ['match_date','=',date("Y-m-d")],
+                        ['match_time','>',date("H:i:s", time())],
                     ];
                     break;
                 case 'StMorningPlate'://早盘
                     $where = [
                         ['is_morningplate', '=', 1],
-                        ['us_time', '>', $this->qgmdate('Y-m-d H:i:s', '', -4)],
+                        ['us_time','>',$this->qgmdate('Y-m-d H:i:s', '', -4)],
                     ];
                     break;
                 case 'StStringScene'://串场
                     $where = [
                         ['is_stringscene', '=', 1],
-                        ['us_time', '>', $this->qgmdate('Y-m-d H:i:s', '', -4)],
+                        ['us_time','>',$this->qgmdate('Y-m-d H:i:s', '', -4)],
                     ];
                     break;
                 case 'StChampion'://冠军
                     $where = [
-                        'type' => 1
+                        'type'=>1
                     ];
                     break;
                 default:
-                    throw new \Exception(Render([], '10002', lang('Tips', 'Sports')->get('PARAM_ERROR')));
+                    throw new \Exception(Render([], '10002', lang('Tips','Sports')->get('PARAM_ERROR')));
             }
-        } else {
-            switch ($type_code) {
+        }else{
+            switch ($type_code){
                 case 'StRollBall'://滚球 正在进行
                     $where = [
-                        [$model_match . '.status', '=', '1'],
+                        [$model_match.'.status','=','1'],
                     ];
                     break;
                 case 'StSoon'://即将 今日两小时内开始
                     $where = [
-                        [$model_match . '.status', '=', '0'],
-                        [$model_match . '.match_date', '=', date("Y-m-d")],
-                        [$model_match . '.match_time', '<', date("H:i:s", strtotime("+2 hour"))],
-                        [$model_match . '.match_time', '>', date("H:i:s", time())]
+                        [$model_match.'.status','=','0'],
+                        [$model_match.'.match_date','=',date("Y-m-d")],
+                        [$model_match.'.match_time','<',date("H:i:s", strtotime("+2 hour"))],
+                        [$model_match.'.match_time','>',date("H:i:s", time())]
                     ];
                     break;
                 case 'StToday'://今日 今日未开始未结束
                     $where = [
-                        [$model_match . '.match_date', '=', date("Y-m-d")],
-                        [$model_match . '.match_time', '>', date("H:i:s", time())],
+                        [$model_match.'.match_date','=',date("Y-m-d")],
+                        [$model_match.'.match_time','>',date("H:i:s", time())],
                     ];
                     break;
                 case 'all'://所有赛事
                     $where = [
-                        [$model_match . '.status', '<', '2'],
+                        [$model_match.'.status', '<', '2'],
                     ];
                     break;
                 case 'StMorningPlate'://早盘
                     $where = [
-                        [$model_match . '.is_morningplate', '=', 1],
-                        [$model_match . '.us_time', '>', self::qgmdate('Y-m-d H:i:s', '', -4)],
+                        [$model_match.'.is_morningplate','=',1],
+                        [$model_match.'.us_time','>',self::qgmdate('Y-m-d H:i:s', '', -4)],
                     ];
                     break;
                 case 'StStringScene'://串场 查询串场状态为1 开赛时间大于当前时间
                     $where = [
-                        [$model_match . '.is_stringscene', '=', 1],
-                        [$model_match . '.us_time', '>', self::qgmdate('Y-m-d H:i:s', '', -4)],
+                        [$model_match.'.is_stringscene','=',1],
+                        [$model_match.'.us_time','>',self::qgmdate('Y-m-d H:i:s', '', -4)],
                     ];
                     break;
                 case 'StChampion'://冠军
                     $where = [
-                        'type' => 1
+                        'type'=>1
                     ];
                     break;
                 default:
-                    throw new \Exception(Render([], '10002', lang('Tips', 'Sports')->get('PARAM_ERROR')));
+                    throw new \Exception(Render([], '10002', lang('Tips','Sports')->get('PARAM_ERROR')));
             }
         }
 
@@ -871,23 +816,22 @@ class Common
      * @return array
      * 处理当国家下无联赛数据 删除该数组
      */
-    function handleArr($data)
-    {
+    function handleArr($data){
         $hData = [];
-        foreach ($data as $key => $v) {
-            if (empty($v['league_count'])) {
+        foreach ($data as $key =>$v){
+            if(empty($v['league_count'])){
                 $v = [];
             }
-            $hData[] = $v;
+            $hData[]=$v;
         }
-        foreach ($hData as $k => $v) {
-            if (empty($v)) {
+        foreach($hData as $k=>$v){
+            if(empty($v)){
                 unset($hData[$k]);
             }
         }
-        foreach ($hData as $k => $v) {
+        foreach ($hData as $k=>$v){
             $v['league_count'] = array_values($v['league_count']);
-            $hData[$k] = $v;
+            $hData[$k]=$v;
         }
 
         return array_values($hData);
@@ -900,15 +844,14 @@ class Common
      * @return array
      * 去除二维数组重复项
      */
-    function array_unset_tt($arr, $key)
-    {
+    function array_unset_tt($arr,$key){
         //建立一个目标数组
         $res = array();
         foreach ($arr as $value) {
             //查看有没有重复项
-            if (isset($res[$value[$key]])) {
+            if(isset($res[$value[$key]])){
                 unset($value[$key]);  //有:销毁
-            } else {
+            }else{
                 $res[$value[$key]] = $value;
             }
         }
@@ -918,28 +861,27 @@ class Common
     /**
      * 处理冠军盘口 数组结构
      */
-    function array_gj_tt($data, $oddsData)
-    {
-        foreach ($data as $k => &$v) {
-            foreach ($v['league_count'] as $kk => &$vv) {
-                foreach ($oddsData as $kkk => $vvv) {
-                    if ($vv['lg_id'] == $vvv['lg_id']) {
-                        $vv['oddsData'][] = $vvv;
+    function array_gj_tt($data,$oddsData){
+        foreach ($data as $k=>&$v){
+            foreach ($v['league_count'] as $kk=>&$vv){
+                foreach ($oddsData as $kkk=>$vvv){
+                    if($vv['lg_id'] == $vvv['lg_id']){
+                        $vv['oddsData'][]=$vvv;
                     }
                 }
 
-                if ($vv['oddsData']) {
-                    $vv['oddsData'] = $this->array_unset_tt($vv['oddsData'], 'p_code');
+                if($vv['oddsData']){
+                    $vv['oddsData'] = $this->array_unset_tt($vv['oddsData'],'p_code');
                     $vv['count'] = count($vv['oddsData']);
                     unset($vv['oddsData']);
                 }
 
-                if (count($vv) == 5) {
+                if(count($vv) == 5){
                     unset($v['league_count'][$kk]);
                 }
             }
-            $v['league_count'] = array_values($v['league_count']);
-            if (empty($v['league_count'])) {
+            $v['league_count'] =  array_values($v['league_count']);
+            if(empty($v['league_count'])){
                 unset($data[$k]);
             }
         }
@@ -950,28 +892,27 @@ class Common
     /**
      * 处理冠军以外 数组结构
      */
-    function array_other_tt($data, $matchData)
-    {
-        foreach ($data as $k => &$v) {
-            foreach ($v['league_count'] as $kk => &$vv) {
-                foreach ($matchData as $kkk => $vvv) {
-                    if ($vv['lg_id'] == $vvv['lg_id']) {
-                        $vv['matchData'][] = $vvv;
+    function array_other_tt($data,$matchData){
+        foreach ($data as $k=>&$v){
+            foreach ($v['league_count'] as $kk=>&$vv){
+                foreach ($matchData as $kkk=>$vvv){
+                    if($vv['lg_id'] == $vvv['lg_id']){
+                        $vv['matchData'][]=$vvv;
                     }
                 }
 
-                if ($vv['matchData']) {
-                    $vv['matchData'] = $this->array_unset_tt($vv['matchData'], 'match_id');
+                if($vv['matchData']){
+                    $vv['matchData'] = $this->array_unset_tt($vv['matchData'],'match_id');
                     $vv['count'] = count($vv['matchData']);
                     unset($vv['matchData']);
                 }
 
-                if (count($vv) == 5) {
+                if(count($vv) == 5){
                     unset($v['league_count'][$kk]);
                 }
             }
-            $v['league_count'] = array_values($v['league_count']);
-            if (empty($v['league_count'])) {
+            $v['league_count'] =  array_values($v['league_count']);
+            if(empty($v['league_count'])){
                 unset($data[$k]);
             }
         }
@@ -986,9 +927,8 @@ class Common
      * @param int $timeoffset 时区偏差 默认8 北京时间 -4美东时间
      * @return string
      */
-    public static function qgmdate($dateformat = 'Y-m-d H:i:s', $timestamp = '', $timeoffset = 8, $type = '')
-    {
-        if (empty($timestamp)) {
+    public static function qgmdate($dateformat = 'Y-m-d H:i:s', $timestamp = '', $timeoffset = 8,$type = '') {
+        if(empty($timestamp)) {
             $timestamp = time();
         }
         $result = gmdate($dateformat, $timestamp + $timeoffset * 3600);
@@ -1001,8 +941,7 @@ class Common
      * @param mixed $arrs 运动类型
      * @return string
      */
-    function judgeEqual($arr, $arrs)
-    {
+    function judgeEqual($arr, $arrs){
         foreach ($arrs as $value) {
             if (count($value) === count($arr)) {
                 $a = 0;
@@ -1021,8 +960,7 @@ class Common
     }
 
 // 排列
-    function arrangement($a, $m)
-    {
+    function arrangement($a, $m) {
         $r = array();
 
         $n = count($a);
@@ -1030,13 +968,13 @@ class Common
             return $r;
         }
 
-        for ($i = 0; $i < $n; $i++) {
+        for ($i=0; $i<$n; $i++) {
             $b = $a;
             $t = array_splice($b, $i, 1);
             if ($m == 1) {
                 $r[] = $t;
             } else {
-                $c = $this->arrangement($b, $m - 1);
+                $c = $this->arrangement($b, $m-1);
                 foreach ($c as $v) {
                     $r[] = array_merge($t, $v);
                 }
@@ -1047,8 +985,7 @@ class Common
     }
 
 // 组合
-    function combination($a, $m)
-    {
+    function combination($a, $m) {
         $r = array();
 
         $n = count($a);
@@ -1056,13 +993,13 @@ class Common
             return $r;
         }
 
-        for ($i = 0; $i < $n; $i++) {
+        for ($i=0; $i<$n; $i++) {
             $t = array($a[$i]);
             if ($m == 1) {
                 $r[] = $t;
             } else {
-                $b = array_slice($a, $i + 1);
-                $c = $this->combination($b, $m - 1);
+                $b = array_slice($a, $i+1);
+                $c = $this->combination($b, $m-1);
                 foreach ($c as $v) {
                     $r[] = array_merge($t, $v);
                 }
@@ -1073,21 +1010,18 @@ class Common
     }
 
 // 阶乘
-    function factorial($n)
-    {
+    function factorial($n) {
         return array_product(range(1, $n));
     }
 
 // 排列数
-    function A1($n, $m)
-    {
-        return factorial($n) / factorial($n - $m);
+    function A1($n, $m) {
+        return factorial($n)/factorial($n-$m);
     }
 
 // 组合数
-    function C1($n, $m)
-    {
-        return A1($n, $m) / factorial($m);
+    function C1($n, $m) {
+        return A1($n, $m)/factorial($m);
     }
 
     /**
@@ -1098,11 +1032,10 @@ class Common
      *
      * 验证本地联赛中是否存在 用于写入联赛/赛事数据验证
      */
-    static function ver_league($lg_id, $source, $lg_data)
-    {
-        foreach ($lg_data as $item) {
-            if (!is_array($item)) return false;
-            if ($item['others_lg_id'] == $lg_id and $item['source'] == $source) return $item['lg_id'];
+    static function ver_league($lg_id,$source,$lg_data) {
+        foreach($lg_data as $item) {
+            if(!is_array($item)) return false;
+            if($item['others_lg_id'] == $lg_id and $item['source'] == $source ) return $item['lg_id'];
         }
         return false;
     }
@@ -1114,11 +1047,10 @@ class Common
      * @return bool|mixed 成功返回本地赛事id
      * 验证本地赛事记录是否存在
      */
-    static function ver_match($match_id, $source, $match_data)
-    {
-        foreach ($match_data as $item) {
-            if (!is_array($item)) return false;
-            if ($item['others_match_id'] == $match_id and $item['source'] == $source) return $item['match_id'];
+    static function ver_match($match_id,$source,$match_data) {
+        foreach($match_data as $item) {
+            if(!is_array($item)) return false;
+            if($item['others_match_id'] == $match_id and $item['source'] == $source ) return $item['match_id'];
         }
         return false;
     }
@@ -1131,11 +1063,10 @@ class Common
      * @return bool|mixed 成功返回 赔率id
      * 验证赔率
      */
-    static function ver_odds($sole, $source, $odds_data)
-    {
-        foreach ($odds_data as $item) {
-            if (!is_array($item)) return false;
-            if ($item['sole'] == $sole and $item['source'] == $source) return $item['id'];
+    static function ver_odds($sole,$source,$odds_data) {
+        foreach($odds_data as $item) {
+            if(!is_array($item)) return false;
+            if($item['sole'] == $sole and $item['source'] == $source ) return $item['id'];
         }
         return false;
     }
@@ -1147,63 +1078,62 @@ class Common
      * @return bool|mixed 成功返回 赔率记录id
      * 验证赔率记录
      */
-    static function ver_odds_record($odds_only, $source, $odds_record_data)
-    {
-        foreach ($odds_record_data as $item) {
-            if (!is_array($item)) return false;
-            if ($item['odds_only'] == $odds_only and $item['source'] == $source) return $item['id'];
+    static function ver_odds_record($odds_only,$source,$odds_record_data) {
+        foreach($odds_record_data as $item) {
+            if(!is_array($item)) return false;
+            if($item['odds_only'] == $odds_only and $item['source'] == $source ) return $item['id'];
         }
         return false;
     }
 
     /**
      * 二维数组根据某个字段去重
-     * @param array $array 二维数组
+     * @param array $array  二维数组
      * @para array  去重后的数组
      */
-    static function uniquArr($array, $key)
-    {
-        if (empty($array)) {
-            return [];
-        }
-        $result = [];
-        foreach ($array as $val) {
-            $keyval = $val[$key];
-            if (!isset($result[$keyval])) {
-                $result[$keyval] = $val;
+    static function uniquArr($array,$key){
+        $result = array();
+        foreach($array as $k=>$val){
+            $code = false;
+            foreach($result as $_val){
+                if($_val[$key] == $val[$key]){
+                    $code = true;
+                    break;
+                }
+            }
+            if(!$code){
+                $result[]=$val;
             }
         }
-        return array_values($result);
+        return $result;
     }
 
     /**
-     * 把数据转为带键的数组,注意要唯一性
+     * 二维数组 按指定键去重 
      */
-    static function arrayKeyArr($array, $ukey)
-    {
-        if (empty($array)) {
-            return [];
-        }
-        $ret = [];
-        foreach ($array as $val) {
-            $ret[$val[$ukey]] = $val;
-        }
-        return $ret;
-    }
-
+    static function  uniquArrV2($array,$key){
+        $result = [];
+        foreach ($array as $val){
+           $keyval = $val[$key];
+           if  (!isset($result[$keyval])){
+             $result[$keyval] = $val;
+           }
+       }
+         return  array_values($result);
+     }
+     
 
     /**
      * 按字段 搜索 二维数组
      */
-    static function searcharray($value, $key, $array, $r_key = '')
-    {
+    static function searcharray($value, $key, $array,$r_key = '') {
         foreach ($array as $k => $val) {
             if ($val[$key] == $value) {
                 return $val[$r_key];
             }
         }
         return null;
-    }
+     }
 }
 
 ?>