stanley-king 3 năm trước cách đây
mục cha
commit
d995ac08be

+ 10 - 3
core/framework/function/http.php

@@ -65,13 +65,16 @@ function http_request($url, $params = array(), $method = 'GET', $multi = false,
     $response = curl_exec($ci);
     if($response === false) {
         $err = curl_error($ci);
-        $net_errno  = curl_errno($ci);
+        $errno  = curl_errno($ci);
+        $net_errno = "CURL-{$errno}";
+
         Log::record("netmodule http_request errno={$net_errno} err={$err} url={$url}",Log::ERR);
     }
     else
     {
         $code = curl_getinfo($ci,CURLINFO_HTTP_CODE);
         if($code != 200) {
+            $net_errno = "HTTP-{$code}";
             Log::record("netmodule http_request http errno={$code} url={$url}",Log::ERR);
         }
     }
@@ -107,13 +110,15 @@ function http_post_data($url, $body, $headers = array(),&$net_errno = 0)
     $response = curl_exec($ci);
     if($response === false) {
         $err = curl_error($ci);
-        $net_errno  = curl_errno($ci);
+        $errno  = curl_errno($ci);
+        $net_errno = "CURL-{$errno}";
         Log::record("netmodule http_post_data errno={$net_errno} err={$err}  url={$url}",Log::ERR);
     }
     else
     {
         $code = curl_getinfo($ci,CURLINFO_HTTP_CODE);
         if($code != 200) {
+            $net_errno = "HTTP-{$code}";
             Log::record("netmodule http_request http errno={$code} url={$url}",Log::ERR);
         }
     }
@@ -177,13 +182,15 @@ function https_request($url, $params = array(), $method = 'GET', $multi = false,
     $response = curl_exec($ci);
     if($response === false) {
         $err = curl_error($ci);
-        $net_errno  = curl_errno($ci);
+        $errno  = curl_errno($ci);
+        $net_errno = "CURL-{$errno}";
         Log::record("netmodule https_request errno={$net_errno} err={$err} url={$url}",Log::ERR);
     }
     else
     {
         $code = curl_getinfo($ci,CURLINFO_HTTP_CODE);
         if($code != 200) {
+            $net_errno = "HTTP-{$code}";
             Log::record("netmodule http_request http errno={$code} url={$url}",Log::ERR);
         }
     }

+ 1 - 0
helper/queue/iqueue.php

@@ -225,6 +225,7 @@ abstract class ILooper
                     $res = \Swoole\Coroutine::stats();
                     $num = $res['coroutine_num'];
                     $mem = memory_get_usage();
+                    Log::record("IQueueDB::run coroutin_num={$num} memory={$mem}",Log::DEBUG);
 
                     if($num < ILooper::MAX_COROUTINE)
                     {

+ 2 - 2
helper/refill/RefillBase.php

@@ -446,7 +446,7 @@ class RefillBase
             $start = microtime(true);
             Log::record("start commit order card_no={$card_no}", Log::DEBUG);
 
-            $net_errno = 0;
+            $net_errno = "";
             [$state, $errmsg, $neterr] = $provider->add($card_no, $card_type, $amount, $params,$net_errno);
             Log::record(sprintf(" %s add request time=%.6f", $channel_name,microtime(true) - $start), Log::DEBUG);
 
@@ -473,7 +473,7 @@ class RefillBase
             }
             else
             {
-                if($neterr && util::need_check($net_errno)) {
+                if(!empty($neterr) && util::need_check($net_errno)) {
                     $mod_refill->edit($order_id, ['commit_time' => time(),'neterr' => 1,'err_msg' => "neterr={$net_errno}"]);
                     break;
                 }

+ 3 - 3
helper/refill/policy/lingzh/quality_ploy.php

@@ -9,7 +9,7 @@ class quality_ploy extends Quality
         parent::__construct();
 
         $this->mSpeeds = [
-            self::Normal => ['retry_times' => 2,'retry_timeout' => 180,'per_secs' => 60],
+            self::Normal => ['retry_times' => 2,'retry_timeout' => 180,'per_secs' => 180],
             self::Quick => ['retry_times' => 2,'retry_timeout' => 60,'per_secs' => 30],
             self::CardKey => ['retry_times' => 2,'retry_timeout' => 120,'per_secs' => 60],
             self::ThirdShop => ['retry_times' => 2,'retry_timeout' => 600,'per_secs' => 600],
@@ -18,8 +18,8 @@ class quality_ploy extends Quality
             self::SlowTwo => ['retry_times' => 2,'retry_timeout' => 3600,'per_secs' => 3600],
 
 
-            self::SlowNormal => ['retry_times' => 2,'retry_timeout' => 180,'per_secs' => 120],
-            self::ThirdNormal => ['retry_times' => 2,'retry_timeout' => 180,'per_secs' => 120],
+            self::SlowNormal => ['retry_times' => 2,'retry_timeout' => 180,'per_secs' => 180],
+            self::ThirdNormal => ['retry_times' => 2,'retry_timeout' => 180,'per_secs' => 180],
             self::DefSuccess => ['retry_times' => 2,'retry_timeout' => 60,'per_secs' => 30],
             self::NormalQuick => ['retry_times' => 65, 'retry_timeout' => 900, 'per_secs' => 60],
             self::SlowSixNormal => ['retry_times' => 65, 'retry_timeout' => 21600 , 'per_secs' => 60]

+ 0 - 7
helper/refill/policy/quaility.php

@@ -200,11 +200,7 @@ class Quality
                 }
             }
 
-            if(count($qualities) > 0 && empty($result)) {
-                $result[] = $quality;
-            }
             $result = array_reverse($result);
-
             return $result;
         };
 
@@ -217,7 +213,4 @@ class Quality
 
         return $qualities;
     }
-
-
-
 }

+ 6 - 6
helper/refill/policy/xyz/quality_ploy.php

@@ -10,7 +10,7 @@ class quality_ploy extends Quality
 
         //2-6-24
         $this->mSpeeds = [
-            self::Normal => ['retry_times' => 60, 'retry_timeout' => 900, 'per_secs' => 120],
+            self::Normal => ['retry_times' => 60, 'retry_timeout' => 900, 'per_secs' => 180],
             self::Quick => ['retry_times' => 2, 'retry_timeout' => 60, 'per_secs' => 30],
             self::CardKey => ['retry_times' => 1, 'retry_timeout' => 120, 'per_secs' => 60],
             self::ThirdShop => ['retry_times' => 1, 'retry_timeout' => 900, 'per_secs' => 600],
@@ -19,11 +19,11 @@ class quality_ploy extends Quality
             self::SlowTwo => ['retry_times' => 1, 'retry_timeout' => 7200, 'per_secs' => 7200],
 
 
-            self::SlowNormal => ['retry_times' => 60, 'retry_timeout' => 900, 'per_secs' => 60],
-            self::ThirdNormal => ['retry_times' => 60, 'retry_timeout' => 900, 'per_secs' => 60],
-            self::DefSuccess => ['retry_times' => 65, 'retry_timeout' => 900, 'per_secs' => 60],
-            self::NormalQuick => ['retry_times' => 65, 'retry_timeout' => 900, 'per_secs' => 60],
-            self::SlowSixNormal => ['retry_times' => 65, 'retry_timeout' => 21600 , 'per_secs' => 60]
+            self::SlowNormal => ['retry_times' => 60, 'retry_timeout' => 900, 'per_secs' => 180],
+            self::ThirdNormal => ['retry_times' => 60, 'retry_timeout' => 900, 'per_secs' => 180],
+            self::DefSuccess => ['retry_times' => 65, 'retry_timeout' => 900, 'per_secs' => 180],
+            self::NormalQuick => ['retry_times' => 65, 'retry_timeout' => 900, 'per_secs' => 180],
+            self::SlowSixNormal => ['retry_times' => 65, 'retry_timeout' => 21600 , 'per_secs' => 180]
         ];
 
         //增加组合通道的时候,注意增加时间控制

+ 11 - 2
helper/refill/util.php

@@ -522,7 +522,16 @@ class util
 
     public static function need_check($net_errno)
     {
-        static $errors = [CURLE_GOT_NOTHING,CURLE_RECV_ERROR];
-        return in_array($net_errno,$errors);
+        [$type,$code] = explode('-',$net_errno);
+        $code = intval($code);
+
+        if($type == "CURL") {
+            static $errors = [CURLE_GOT_NOTHING,CURLE_RECV_ERROR];
+            return in_array($code,$errors);
+        } elseif($type == "HTTP") {
+            return true;
+        } else {
+            return false;
+        }
     }
 }

+ 1 - 0
helper/refill_proxy.php

@@ -107,6 +107,7 @@ class refill_proxy
         curl_setopt($ci, CURLOPT_HEADER, false);
         curl_setopt($ci, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
 
+
         $headers = (array) $extheaders;
         switch ($method)
         {

+ 10 - 10
mobile/control/merchant.php

@@ -21,16 +21,16 @@ class merchantControl
             throw new Exception("机构已被关闭。");
         }
 
-//        $ips = unserialize($mchinfo['ip_white_list']);
-//
-//        if(!empty($ips)) {
-//            $addr = $_SERVER['REMOTE_ADDR'];
-//            Log::record("request ip:{$addr}",Log::DEBUG);
-//
-//            if(!in_array($addr,$ips)) {
-//                throw new Exception("请求地址不在白名单中");
-//            }
-//        }
+        $ips = unserialize($mchinfo['ip_white_list']);
+
+        if(!empty($ips)) {
+            $addr = $_SERVER['REMOTE_ADDR'];
+            Log::record("request ip:{$addr}",Log::DEBUG);
+
+            if(!in_array($addr,$ips)) {
+                throw new Exception("请求地址不在白名单中");
+            }
+        }
 
         $this->mUseKey = intval($mchinfo['use_key']);
         if($this->mUseKey && !$this->verify_md5($mchinfo['secure_key'])) {

+ 3 - 1
mobile/control/refill.php

@@ -115,11 +115,13 @@ class refillControl extends merchantControl
             $state = refill\util::push_add($params);
         }
 
+        $mchid = $this->mchid();
         if ($state === true) {
             refill\util::push_queue_order($this->mchid(),$mch_order,ORDER_STATE_QUEUE);
+            Log::record("refill::util::push_add success mchid={$mchid} mch_order={$mch_order}state={$state}",Log::DEBUG);
             return self::outsuccess(['state' => true]);
         } else {
-            Log::record("refill::util::push_add state={$state}",Log::DEBUG);
+            Log::record("refill::util::push_add error mchid={$mchid} mch_order={$mch_order}state={$state}",Log::DEBUG);
             return self::outerr(208, '提交失败');
         }
     }

+ 5 - 1
test/TestRefill.php

@@ -1770,8 +1770,12 @@ class TestRefill extends TestCase
         $ret = preg_match('/[\w\W]+"channelOrderNumber":"(?P<order_sn>[^"]+)"[\w\W]+"message":"(?P<message>[\x{4e00}-\x{9fa5}]+)"[\w\W]+"status":109/u', $line, $matches);
     }
 
+    public function testExpolode()
+    {
+        $x = "HTTP-504";
+        [$type,$code] = explode('-',$x);
 
-
+    }
 
 
     public function testMchctl()