vali 6 年之前
父节点
当前提交
4592481c74
共有 1 个文件被更改,包括 24 次插入24 次删除
  1. 24 24
      datainf/logic/HttpServerSettelement.php

+ 24 - 24
datainf/logic/HttpServerSettelement.php

@@ -66,12 +66,9 @@ class HttpServerSettelement
         if ($serv->worker_id == 0) {
         if ($serv->worker_id == 0) {
             \Swoole\Timer::tick(60000, function () {
             \Swoole\Timer::tick(60000, function () {
                 $this->logRunStatus();
                 $this->logRunStatus();
-                if ($this->httpserver->taskWorkingNum->get() > 1) {
-                    $this->httpserver->taskWorkingNum->sub();
-                }
+                $this->dosubcount();
             });
             });
         }
         }
-
     }
     }
 
 
 
 
@@ -81,6 +78,12 @@ class HttpServerSettelement
         echo ' work_id:' . $this->httpserver->worker_id . " 内存使用量:" . (memory_get_usage() / 1000) . 'k  峰值:' . (memory_get_peak_usage() / 1000) . "k\n";
         echo ' work_id:' . $this->httpserver->worker_id . " 内存使用量:" . (memory_get_usage() / 1000) . 'k  峰值:' . (memory_get_peak_usage() / 1000) . "k\n";
     }
     }
 
 
+    private function dosubcount()
+    {
+        if ($this->httpserver->taskWorkingNum->get() > 0) {
+            $this->httpserver->taskWorkingNum->sub();
+        }
+    }
 
 
     public function OnRequest($request, $response)
     public function OnRequest($request, $response)
     {
     {
@@ -108,7 +111,6 @@ class HttpServerSettelement
             return;
             return;
         }
         }
 
 
-        $this->httpserver->taskWorkingNum->add();
 
 
         $check_token = true;
         $check_token = true;
         if ($check_token) {
         if ($check_token) {
@@ -120,20 +122,20 @@ class HttpServerSettelement
             }
             }
         }
         }
 
 
+        $this->httpserver->taskWorkingNum->add();
+
         if ($request_uri == 'WinFail') {
         if ($request_uri == 'WinFail') {
-           $this->httpserver->taskWorkingNum->sub();
+            $this->dosubcount();
             return $this->doWinFailse($request, $response, $paras);
             return $this->doWinFailse($request, $response, $paras);
-
         }
         }
 
 
         if ($request_uri == 'DoWinFailOneOrder') {
         if ($request_uri == 'DoWinFailOneOrder') {
-            $this->httpserver->taskWorkingNum->sub();
+            $this->dosubcount();
             return $this->WinFailOneOrder($request, $response, $paras);
             return $this->WinFailOneOrder($request, $response, $paras);
-
         }
         }
 
 
         if ($request_uri == 'Settelement') {
         if ($request_uri == 'Settelement') {
-            $this->httpserver->taskWorkingNum->sub();
+            $this->dosubcount();
             return $this->doSettelementIntoRedis($request, $response, $paras);
             return $this->doSettelementIntoRedis($request, $response, $paras);
         }
         }
 
 
@@ -142,8 +144,7 @@ class HttpServerSettelement
 
 
     public function onTask($serv, $task)
     public function onTask($serv, $task)
     {
     {
-        //$this->httpserver->taskWorkingNum->add();
-        //$this->httpserver->taskWorkingNum->sub();
+
     }
     }
 
 
 
 
@@ -188,7 +189,6 @@ class HttpServerSettelement
             return;
             return;
         }
         }
 
 
-
         try {
         try {
             $logic_obj->WinFailOneOrder($orderInfo, $match_datas, $result['0']);
             $logic_obj->WinFailOneOrder($orderInfo, $match_datas, $result['0']);
             $data = Response::generate('', 1, ['cost' => (microtime(true) - $request->server['request_time_float'])], 'succes ');
             $data = Response::generate('', 1, ['cost' => (microtime(true) - $request->server['request_time_float'])], 'succes ');
@@ -220,17 +220,17 @@ class HttpServerSettelement
 
 
             $match_firstModel = isset($matchs_1['0']) ? $matchs_1['0'] : (isset($matchs_2['0']) ? $matchs_2['0'] : false);
             $match_firstModel = isset($matchs_1['0']) ? $matchs_1['0'] : (isset($matchs_2['0']) ? $matchs_2['0'] : false);
             if (!$match_firstModel) {
             if (!$match_firstModel) {
-                throw  new  \Exception('无数据异常-1!');
+                throw  new  \Exception('无数据异常-1!', 1100);
             }
             }
             $gjModel = $logic_obj->getGjDatas($match_firstModel);
             $gjModel = $logic_obj->getGjDatas($match_firstModel);
 
 
             if (count($matchs_1) > 0 && count($moneySimples) <= 0) {
             if (count($matchs_1) > 0 && count($moneySimples) <= 0) {
-                throw  new  \Exception('数据异常-2!');
+                throw  new  \Exception('数据异常-2!', 1101);
             }
             }
 
 
             if (strtolower($match_firstModel->p_code) == 'gj') {
             if (strtolower($match_firstModel->p_code) == 'gj') {
                 if (empty($gjModel)) {
                 if (empty($gjModel)) {
-                    throw new  \Exception("没有冠军数据数据--match_id" . $noticeModel->match_id);
+                    throw new  \Exception("没有冠军数据数据--match_id" . $noticeModel->match_id, 1102);
                 }
                 }
                 $result = [$gjModel];
                 $result = [$gjModel];
             }
             }
@@ -268,7 +268,7 @@ class HttpServerSettelement
             if ($bettype == 1) {
             if ($bettype == 1) {
                 $chekArr = $this->Match_check($order_ids, $bettype);
                 $chekArr = $this->Match_check($order_ids, $bettype);
                 if (empty($chekArr) || count($chekArr) != 1) {
                 if (empty($chekArr) || count($chekArr) != 1) {
-                    throw  new \Exception('不同场比赛不能同时结算!');
+                    throw  new \Exception('不同场比赛不能同时结算!', 1105);
                 }
                 }
                 unset($chekArr);
                 unset($chekArr);
             }
             }
@@ -286,12 +286,12 @@ class HttpServerSettelement
                 $redis = new \Redis();
                 $redis = new \Redis();
                 $ret = $redis->connect($redisconfig['host'], $redisconfig['port']);
                 $ret = $redis->connect($redisconfig['host'], $redisconfig['port']);
                 if (!$ret) {
                 if (!$ret) {
-                    throw  new \Exception('redis 连接失败');
+                    throw  new \Exception('redis 连接失败', 1106);
                 }
                 }
                 if (!empty($redisconfig['passwd'])) {
                 if (!empty($redisconfig['passwd'])) {
                     $ret = $redis->auth($redisconfig['passwd']);
                     $ret = $redis->auth($redisconfig['passwd']);
                     if (!$ret) {
                     if (!$ret) {
-                        throw  new \Exception('redis auth 失败');
+                        throw  new \Exception('redis auth 失败', 1107);
                     }
                     }
                 }
                 }
                 $redis->select($redisconfig['db']);
                 $redis->select($redisconfig['db']);
@@ -309,7 +309,7 @@ class HttpServerSettelement
 
 
         } catch (\Exception $e) {
         } catch (\Exception $e) {
 
 
-            $data = Response::generate('', 10, '', $e->getMessage() . '--' . $e->getFile() . '--' . $e->getLine());
+            $data = Response::generate('', $e->getCode(), '', $e->getMessage() . '--' . '--' . $e->getLine());
             $response->end($data);
             $response->end($data);
             unset($data);
             unset($data);
 
 
@@ -337,20 +337,20 @@ class HttpServerSettelement
         }, $idoarr);
         }, $idoarr);
 
 
         if (intval($match_id) <= 0) {
         if (intval($match_id) <= 0) {
-            throw  new \Exception('赛事ID不能为空!');
+            throw  new \Exception('赛事ID不能为空!', 1108);
             return;
             return;
         }
         }
 
 
         if (empty($game_code)) {
         if (empty($game_code)) {
-            throw  new \Exception('赛事类型不能为空!');
+            throw  new \Exception('赛事类型不能为空!', 1109);
         }
         }
 
 
         if (!in_array($bettype, [1, 2])) {
         if (!in_array($bettype, [1, 2])) {
-            throw  new \Exception('订单类型参数错误!');
+            throw  new \Exception('订单类型参数错误!', 1110);
         }
         }
 
 
         if (!in_array($settype, [1, 2])) {
         if (!in_array($settype, [1, 2])) {
-            throw  new \Exception('结算参数错误');
+            throw  new \Exception('结算参数错误', 1111);
         }
         }
 
 
         $ret = [$order_ids, $bettype, $settype, $game_code, $match_id, $change_status];
         $ret = [$order_ids, $bettype, $settype, $game_code, $match_id, $change_status];