vali 6 rokov pred
rodič
commit
7064a5ab13
1 zmenil súbory, kde vykonal 28 pridanie a 26 odobranie
  1. 28 26
      datainf/logic/HttpServerSettelement.php

+ 28 - 26
datainf/logic/HttpServerSettelement.php

@@ -89,7 +89,7 @@ class HttpServerSettelement
         $paras = array_merge(['request_time' => date("H:i:s")], !empty($request->get) ? $request->get : [], !empty($request->post) ? $request->post : []);
 
         $request_uri = substr($request->server['request_uri'], 1);
-        $urls = ['WinFail', 'Settelement','DoWinFailOneOrder'];
+        $urls = ['WinFail', 'Settelement', 'DoWinFailOneOrder'];
 
         $this->httpserver->account->add();
 
@@ -108,6 +108,8 @@ class HttpServerSettelement
             $response->end($data);
             return;
         }
+        $this->httpserver->taskWorkingNum->add();
+
 
         $check_token = true;
         if ($check_token) {
@@ -120,15 +122,21 @@ class HttpServerSettelement
         }
 
         if ($request_uri == 'WinFail') {
-            return $this->doWinFailse($request, $response, $paras);
+            $ret = $this->doWinFailse($request, $response, $paras);
+            $this->httpserver->taskWorkingNum->sub();
+            return $ret;
         }
 
         if ($request_uri == 'DoWinFailOneOrder') {
-            return $this->WinFailOneOrder($request, $response, $paras);
+            $ret = $this->WinFailOneOrder($request, $response, $paras);
+            $this->httpserver->taskWorkingNum->sub();
+            return $ret;
         }
 
         if ($request_uri == 'Settelement') {
-            return $this->doSettelementIntoRedis($request, $response, $paras);
+            $ret = $this->doSettelementIntoRedis($request, $response, $paras);
+            $this->httpserver->taskWorkingNum->sub();
+            return $ret;
         }
 
         return;
@@ -136,8 +144,8 @@ class HttpServerSettelement
 
     public function onTask($serv, $task)
     {
-        $this->httpserver->taskWorkingNum->add();
-        $this->httpserver->taskWorkingNum->sub();
+        //$this->httpserver->taskWorkingNum->add();
+        //$this->httpserver->taskWorkingNum->sub();
     }
 
 
@@ -200,7 +208,6 @@ class HttpServerSettelement
     //胜负计算
     private function doWinFailse($request, $response, $paras)
     {
-        $this->httpserver->taskWorkingNum->add();
 
         $logic_obj = new WinfailLogic();
         $notice = isset($paras['noticeid']) ? $paras['noticeid'] : 0;
@@ -216,7 +223,6 @@ class HttpServerSettelement
             $match_firstModel = isset($matchs_1['0']) ? $matchs_1['0'] : (isset($matchs_2['0']) ? $matchs_2['0'] : false);
             if (!$match_firstModel) {
                 throw  new  \Exception('无数据异常-1!');
-                return true;
             }
             $gjModel = $logic_obj->getGjDatas($match_firstModel);
 
@@ -248,16 +254,12 @@ class HttpServerSettelement
             $response->end($data);
         }
 
-        $this->httpserver->taskWorkingNum->sub();
-
         return;
     }
 
 
     private function doSettelementIntoRedis($request, $response, $paras)
     {
-        $this->httpserver->taskWorkingNum->add();
-
         try {
             list($order_ids, $bettype, $settype, $game_code, $match_id, $change_status) = $tmp = $this->requestpara($request, $response, $paras);
 
@@ -283,22 +285,22 @@ class HttpServerSettelement
                 $nowchange_status = ($i == 1) ? $change_status : 0;
                 $data = json_encode(['ids' => $p_order_ids, 'bettype' => $bettype, 'settype' => $settype, 'game_code' => $game_code, 'match_id' => $match_id, 'change_status' => $nowchange_status], 256);
                 //go(function () use ($data, $redisconfig) {
-                    $redis = new \Redis();
-                    $ret = $redis->connect($redisconfig['host'], $redisconfig['port']);
+                $redis = new \Redis();
+                $ret = $redis->connect($redisconfig['host'], $redisconfig['port']);
+                if (!$ret) {
+                    throw  new \Exception('redis 连接失败');
+                }
+                if (!empty($redisconfig['passwd'])) {
+                    $ret = $redis->auth($redisconfig['passwd']);
                     if (!$ret) {
-                        throw  new \Exception('redis 连接失败');
-                    }
-                    if (!empty($redisconfig['passwd'])) {
-                        $ret = $redis->auth($redisconfig['passwd']);
-                        if (!$ret) {
-                            throw  new \Exception('redis auth 失败');
-                        }
+                        throw  new \Exception('redis auth 失败');
                     }
-                    $redis->select($redisconfig['db']);
+                }
+                $redis->select($redisconfig['db']);
 
-                    $redis->lpush(self::TASKQNUM, $data);
-                    return;
-               // });
+                $redis->lpush(self::TASKQNUM, $data);
+                return;
+                // });
                 unset($data);
                 $i++;
             }
@@ -315,7 +317,7 @@ class HttpServerSettelement
 
         }
 
-        $this->httpserver->taskWorkingNum->sub();
+
     }
 
     private function requestpara($request, $response, $paras)