vali 6 anni fa
parent
commit
583e8834e6
2 ha cambiato i file con 25 aggiunte e 25 eliminazioni
  1. 13 12
      datainf/logic/HttpServerOnlySet.php
  2. 12 13
      datainf/logic/HttpServerSettelement.php

+ 13 - 12
datainf/logic/HttpServerOnlySet.php

@@ -93,11 +93,11 @@ class HttpServerOnlySet
         $ret = $this->redis->connect($this->redisconfig['host'], $this->redisconfig['port']);
         if (!$ret) {
             $this->redis = false;
-            throw  new \Exception("连接redis失败 " . date("Y-m-d H:i:s"));
+            throw  new \Exception("连接redis失败 " . date("Y-m-d H:i:s"), 108);
             return;
         }
         if (!$this->redis->auth($this->redisconfig['passwd'])) {
-            throw  new \Exception("redis auth 失败 " . date("Y-m-d H:i:s"));
+            throw  new \Exception("redis auth 失败 " . date("Y-m-d H:i:s"), 109);
             return;
         }
         $this->redis->select($this->redisconfig['db']);
@@ -117,7 +117,7 @@ class HttpServerOnlySet
 
             if (!$this->DataPre($order_ids, $bettype, $settype, $game_code, $match_id, $change_status)) {
                 goto LABDOLAST;
-                throw new  \Exception('没找到订单信息');
+                throw new  \Exception('没找到订单信息', 110);
             }
 
             $this->UndoSettlement();
@@ -165,7 +165,8 @@ class HttpServerOnlySet
 
         } catch (\Exception $e) {
             $this->PDatas = [];
-            $data = Response::generate('', 10, '', $e->getMessage() . '--' . $e->getFile() . '--' . $e->getLine());
+            //$data = Response::generate('', $e->getCode(), '', $e->getMessage() . '--' . $e->getFile() . '--' . $e->getLine());
+            $data = Response::generate('', $e->getCode(), '', $e->getMessage() . '--' . $e->getLine());
             echo $data . "\n";
 
         }
@@ -190,20 +191,20 @@ class HttpServerOnlySet
         $change_status = isset($paras['change_status']) ? $paras['change_status'] : 0;
 
         if (intval($match_id) <= 0) {
-            throw  new \Exception('赛事ID不能为空!');
+            throw  new \Exception('赛事ID不能为空!', 100);
             return;
         }
 
         if (empty($game_code)) {
-            throw  new \Exception('赛事类型不能为空!');
+            throw  new \Exception('赛事类型不能为空!', 101);
         }
 
         if (!in_array($bettype, [1, 2])) {
-            throw  new \Exception('订单类型参数错误!');
+            throw  new \Exception('订单类型参数错误!', 102);
         }
 
         if (!in_array($settype, [1, 2])) {
-            throw  new \Exception('结算参数错误');
+            throw  new \Exception('结算参数错误', 103);
         }
 
         $this->PDatas['bettype'] = $bettype;
@@ -333,7 +334,7 @@ class HttpServerOnlySet
 
         foreach ($matchDatas as $val) {
             if (!in_array($val->result, [-1, 1, 2, 3, 4])) {
-                throw  new  \Exception('match比赛结果异常或还没有输赢结果->' . $val->id);
+                throw  new  \Exception('match比赛结果异常或还没有输赢结果->' . $val->id, 104);
             }
         }
 
@@ -425,7 +426,7 @@ class HttpServerOnlySet
 
         foreach ($matchDatas as $val) {
             if (!in_array($val->result, [-1, 1, 2, 3, 4])) {
-                throw  new  \Exception('match比赛结果异常或还没有输赢结果->' . $val->id);
+                throw  new  \Exception('match比赛结果异常或还没有输赢结果->' . $val->id, 105);
             }
         }
 
@@ -433,7 +434,7 @@ class HttpServerOnlySet
         $batch_id = $simplexData->batch_id;
         $matchModels = $matchDatas;
         if (count($matchModels) <= 0) {
-            throw  new  \Exception('match 数据异常-' . $batch_id);
+            throw  new  \Exception('match 数据异常-' . $batch_id, 106);
         }
 
 
@@ -449,7 +450,7 @@ class HttpServerOnlySet
             $in_array = [];
             foreach ($matchModels as $val) {
                 if (!in_array($val->result, [-1, 1, 2, 3, 4])) {
-                    throw  new  \Exception('match 比赛结果异常或还没有输赢结果->' . $val->id);
+                    throw  new  \Exception('match 比赛结果异常或还没有输赢结果->' . $val->id, 107);
                 }
 
                 if ($val->result == -1) {

+ 12 - 13
datainf/logic/HttpServerSettelement.php

@@ -96,7 +96,6 @@ class HttpServerSettelement
         echo "现在任务数:" . $this->httpserver->taskWorkingNum->get() . "\n";
         echo '请求参数是:' . $request_uri . ' - ' . print_r($paras, true) . "\n";
 
-
         if (!in_array($request_uri, $urls)) {
             $data = Response::generate('', 0, '', '无效的url');
             $response->end($data);
@@ -109,6 +108,8 @@ class HttpServerSettelement
             return;
         }
 
+        $this->httpserver->taskWorkingNum->add();
+
         $check_token = true;
         if ($check_token) {
             $token = isset($paras['token']) ? $paras['token'] : '';
@@ -120,14 +121,19 @@ class HttpServerSettelement
         }
 
         if ($request_uri == 'WinFail') {
+            $this->httpserver->taskWorkingNum->sub();
             return $this->doWinFailse($request, $response, $paras);
+
         }
 
         if ($request_uri == 'DoWinFailOneOrder') {
+            $this->httpserver->taskWorkingNum->sub();
             return $this->WinFailOneOrder($request, $response, $paras);
+
         }
 
         if ($request_uri == 'Settelement') {
+            $this->httpserver->taskWorkingNum->sub();
             return $this->doSettelementIntoRedis($request, $response, $paras);
         }
 
@@ -136,8 +142,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 +206,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 +221,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 +252,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,7 +283,6 @@ 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 Swoole\Coroutine\Redis();
                 $redis = new \Redis();
                 $ret = $redis->connect($redisconfig['host'], $redisconfig['port']);
                 if (!$ret) {
@@ -299,13 +298,13 @@ class HttpServerSettelement
 
                 $redis->lpush(self::TASKQNUM, $data);
                 return;
-                //  });
+                // });
                 unset($data);
                 $i++;
             }
 
             LABRETURN:
-            $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');
             $response->end($data);
 
         } catch (\Exception $e) {
@@ -316,7 +315,7 @@ class HttpServerSettelement
 
         }
 
-        $this->httpserver->taskWorkingNum->sub();
+
     }
 
     private function requestpara($request, $response, $paras)