فهرست منبع

kuaikuai jianjiao update

xiaoyu 3 سال پیش
والد
کامیت
208c53e489

+ 1 - 26
helper/refill/api/xyz/jianjiao/RefillCallBack.php

@@ -10,7 +10,7 @@ class RefillCallBack implements refill\IRefillCallBack
     {
         $input = $params;
         unset($input['sign']);
-        $sign = $this->sign($input);
+        $sign = config::sign($input);
         if ($params['sign'] == $sign) {
             return true;
         } else {
@@ -18,31 +18,6 @@ class RefillCallBack implements refill\IRefillCallBack
         }
     }
 
-    private function sign($params)
-    {
-        ksort($params);
-        $content = '';
-        foreach ($params as $key => $value) {
-            if($this->check_empty($value) === false) {
-                $content .= "{$key}={$value}&";
-            }
-        }
-        $content .= 'app_secret='.config::APP_SECRET;
-        return md5($content);
-    }
-
-    private function check_empty($value)
-    {
-        if (!isset($value))
-            return true;
-        if ($value === null)
-            return true;
-        if (trim($value) === "")
-            return true;
-
-        return false;
-    }
-
     public function notify($params)
     {
         $order_sn = $params['out_order_id'];

+ 9 - 22
helper/refill/api/xyz/jianjiao/RefillPhone.php

@@ -27,8 +27,7 @@ class RefillPhone extends refill\IRefillPhone
     public function add($card_no, $card_type, $amount, $input, &$net_errno = 0)
     {
         $params = $this->req_params($card_no, $amount, $input['order_sn']);
-        $sign = $this->sign($params);
-        $params['sign'] = $sign;
+        $params['sign'] = config::sign($params);
 
         $params = json_encode($params);
         $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders, $net_errno);
@@ -40,13 +39,15 @@ class RefillPhone extends refill\IRefillPhone
         {
             Log::record($resp, Log::DEBUG);
             $resp = json_decode($resp, true);
+            $code = $resp['code'];
+
             if (empty($resp)) {
                 return [false, '系统错误', true];
-            } elseif ($resp['code'] === 200) {
+            } elseif ($code === 200) {
                 return [true, $resp['data']['order_id'], false];
-            } elseif ($resp['code'] === 1011) {
-                $net_errno = "HTTP-{$resp['code']}";
-                return [false, $resp['message'], true];
+            } elseif ($code === 1011) {
+                $net_errno = "HTTP-{$code}";
+                return [false, '查-' . $resp['message'], true];
             } else {
                 return [false, $resp['message'], false];
             }
@@ -58,8 +59,7 @@ class RefillPhone extends refill\IRefillPhone
         $params['out_order_id'] = $refill_info['order_sn'];
         $params['app_key'] = config::APP_KEY;
         $params['timestamp'] = time();
-        $sign = $this->sign($params);
-        $params['sign'] = $sign;
+        $params['sign'] = config::sign($params);
 
         $params = json_encode($params);
         $resp = http_post_data(config::QUERY_URL, $params , config::ExtHeaders);
@@ -103,7 +103,7 @@ class RefillPhone extends refill\IRefillPhone
     {
         $params['app_key'] = config::APP_KEY;
         $params['timestamp'] = time();
-        $params['sign'] = $this->sign($params);
+        $params['sign'] = config::sign($params);
 
         $params = json_encode($params);
         $resp = http_post_data(config::BALANCE_URL, $params , config::ExtHeaders);
@@ -124,17 +124,4 @@ class RefillPhone extends refill\IRefillPhone
             }
         }
     }
-
-    private function sign($params)
-    {
-        ksort($params);
-        $content = '';
-        foreach ($params as $key => $value) {
-            if($this->check_empty($value) === false) {
-                $content .= "{$key}={$value}&";
-            }
-        }
-        $content .= 'app_secret='.config::APP_SECRET;
-        return md5($content);
-    }
 }

+ 25 - 0
helper/refill/api/xyz/jianjiao/config.php

@@ -12,4 +12,29 @@ class config
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_jianjiao.php";
 
     const ExtHeaders = ['Content-Type: application/json;charset=UTF-8'];
+
+    public static function sign($params)
+    {
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if(self::check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content .= 'app_secret='.config::APP_SECRET;
+        return md5($content);
+    }
+
+    public static function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
 }

+ 1 - 26
helper/refill/api/xyz/kuaikuai/RefillCallBack.php

@@ -11,7 +11,7 @@ class RefillCallBack implements refill\IRefillCallBack
         $input = $params;
         unset($input['sign']);
         unset($input['msg']);
-        $sign = $this->sign($input);
+        $sign = config::sign($input);
         if ($params['sign'] == $sign) {
             return true;
         } else {
@@ -19,31 +19,6 @@ class RefillCallBack implements refill\IRefillCallBack
         }
     }
 
-    private function sign($params)
-    {
-        ksort($params);
-        $content = '';
-        foreach ($params as $key => $value) {
-            if($this->check_empty($value) === false) {
-                $content .= "{$key}={$value}&";
-            }
-        }
-        $content .= 'key='.config::KEY;
-        return md5($content);
-    }
-
-    private function check_empty($value)
-    {
-        if (!isset($value))
-            return true;
-        if ($value === null)
-            return true;
-        if (trim($value) === "")
-            return true;
-
-        return false;
-    }
-
     public function notify($params)
     {
         $order_sn = $params['orderId'];

+ 2 - 15
helper/refill/api/xyz/kuaikuai/RefillPhone.php

@@ -31,7 +31,7 @@ class RefillPhone extends refill\IRefillPhone
         if(empty($params['pid'])) {
             return [false, '商品编号错误', false];
         }
-        $sign = $this->sign($params);
+        $sign = config::sign($params);
         $params['sign'] = $sign;
 
         $params = json_encode($params);
@@ -64,7 +64,7 @@ class RefillPhone extends refill\IRefillPhone
         $params['oid'] = $refill_info['order_sn'];
         $params['ts'] = date("YmdHis");
         $params['uid'] = config::UID;
-        $sign = $this->sign($params);
+        $sign = config::sign($params);
         $params['sign'] = $sign;
 
         $params = json_encode($params);
@@ -134,17 +134,4 @@ class RefillPhone extends refill\IRefillPhone
             }
         }
     }
-
-    private function sign($params)
-    {
-        ksort($params);
-        $content = '';
-        foreach ($params as $key => $value) {
-            if($this->check_empty($value) === false) {
-                $content .= "{$key}={$value}&";
-            }
-        }
-        $content .= 'key='.config::KEY;
-        return md5($content);
-    }
 }

+ 25 - 0
helper/refill/api/xyz/kuaikuai/config.php

@@ -32,4 +32,29 @@ class config
             20  => '2c922ab97f2683b5017f3ef2f5da59dd',
         ],
     ];
+
+    public static function sign($params)
+    {
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if(self::check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content .= 'key='.config::KEY;
+        return md5($content);
+    }
+
+    public static function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
 }

+ 9 - 9
test/TestRefill.php

@@ -1866,8 +1866,8 @@ class TestRefill extends TestCase
     {
 //        $provider = $this->getProvider('kuaikuai');
 //        $resp = $provider->balance();
-//        $resp = $provider->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
-//        $resp = $provider->query(['order_sn' => '37691646038424123424']);
+//        $resp = $provider->add(185006083, 5, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '48821646219340197679']);
 
         $body = '{"msg":"100101101012202281653493036477","orderId":"37691646038424123424","createTime":1646038427,"sign":"35df4f13ee4dcaed2d582d709ff66073","orderNum":"2c922ab97f2683b5017f3f89246d1e4a","status":2}';
         $params = json_decode($body, true);
@@ -1878,16 +1878,16 @@ class TestRefill extends TestCase
 
     public function testJianjiao()
     {
-//        $provider = $this->getProvider('jianjiao');
+        $provider = $this->getProvider('jianjiao');
 //        $resp = $provider->balance();
-//        $resp = $provider->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
+        $resp = $provider->add(136992796, 4, 50, ['order_sn' => $this->make_sn()]);
 //        $resp = $provider->query(['order_sn' => '14481646204704630736']);
 
-        $body = '{"order_id":"22030215052639807","out_order_id":"14481646204704630736","status":3,"mobile":"13699279618","amount":50,"app_key":"3l6kd2yqsvcwftij","official_sn":"","timestamp":1646205722,"sign":"db77f48b8964b74e9c5e44fa9b3dcf49"}';
-        $params = json_decode($body, true);
-        $provider = $this->getProvider('jianjiao','RefillCallBack');
-        $ret = $provider->verify($params);
-        $resp = $provider->notify($params);
+//        $body = '{"order_id":"22030215052639807","out_order_id":"14481646204704630736","status":3,"mobile":"13699279618","amount":50,"app_key":"3l6kd2yqsvcwftij","official_sn":"","timestamp":1646205722,"sign":"db77f48b8964b74e9c5e44fa9b3dcf49"}';
+//        $params = json_decode($body, true);
+//        $provider = $this->getProvider('jianjiao','RefillCallBack');
+//        $ret = $provider->verify($params);
+//        $resp = $provider->notify($params);
     }
 
     public function testAmingjd()