Jelajahi Sumber

wangliantx update

xiaoyu 3 tahun lalu
induk
melakukan
936453dad1

+ 10 - 10
helper/refill/api/xyz/wangliantx/RefillPhone.php

@@ -57,12 +57,12 @@ class RefillPhone extends refill\IRefillPhone
                 return [false, '网络错误', true];
             }
 
-            $resultno = intval($resp['resultno']);
-            if (in_array($resultno, [0, 1, 2])) {
+            $resultno = $resp['resultno'];
+            if (in_array($resultno, ['0', '1', '2'], true)) {
                 return [true, $resp['orderid'], false];
-            } elseif (in_array($resultno, config::ERR_NOS)) {
+            } elseif (in_array($resultno, config::ERR_NOS, true)) {
                 return [false, $resultno, false];
-            } elseif ($resultno === 9999) {
+            } elseif ($resultno === '9999') {
                 $net_errno = "HTTP-{$resultno}";
                 return [false, $resultno, false];
             } else {
@@ -93,16 +93,16 @@ class RefillPhone extends refill\IRefillPhone
             }
             else
             {
-                $resultno = intval($resp['resultno']);
-                if ($resultno === 1) {
+                $resultno = $resp['resultno'];
+                if ($resultno === '1') {
                     $updata['official_sn'] = $resp['supnumber'];
                     Model('refill_order')->edit($refill_info['order_id'], $updata);
                     $order_state = ORDER_STATE_SUCCESS;
-                } elseif ($resultno === 9) {
+                } elseif ($resultno === '9') {
                     $order_state = ORDER_STATE_CANCEL;
-                } elseif (in_array($resultno, [0,2])) {
+                } elseif (in_array($resultno, ['0','2'], true)) {
                     $order_state = ORDER_STATE_SEND;
-                } elseif ($resultno === 5007 && (time() - $refill_info['commit_time'] >= 600)) {
+                } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] >= 600)) {
                     $order_state = ORDER_STATE_NOEXIST;
                 } else {
                     return [false, $resultno];
@@ -131,7 +131,7 @@ class RefillPhone extends refill\IRefillPhone
             $resp = $this->xmlToArray($resp);
             if (empty($resp)) {
                 return [false, '网络错误'];
-            } elseif ($resp['resultno'] == 1) {
+            } elseif ($resp['resultno'] === '1') {
                 return [true, $resp['balance']];
             } else {
                 return [false, $resp['resultno']];

+ 11 - 11
test/TestRefill.php

@@ -632,8 +632,8 @@ class TestRefill extends TestCase
 
     public function testTianyan()
     {
-        $providers = new refill\tianyan\RefillPhone([]);
-//        $resp = $providers->add(18500608333, 5, 10, ['order_sn' => $this->make_sn()]);
+        $providers = $this->getProvider('tianyan');
+        $resp = $providers->add(18500608333, 5, 1, ['order_sn' => $this->make_sn()]);
 //        $resp = $providers->query(['order_sn' => '71241628067981955316', 'card_no' => 18500608333, 'card_type' => 5]);
 //        $resp = $providers->balance();
         $params['amount'] = '100.00';
@@ -649,7 +649,7 @@ class TestRefill extends TestCase
         $params['ticketNo'] = '110103353022108050819140250945';
         $params['company'] = 'lt';
         $params['status'] = '2';
-        refill\RefillFactory::instance()->notify('tianyan', $params);
+//        refill\RefillFactory::instance()->notify('tianyan', $params);
     }
 
     public function testYunsuoyaoman()
@@ -772,21 +772,21 @@ class TestRefill extends TestCase
 
     public function testWangliantx()
     {
-//        $providers = $this->getProvider('wangliantx');
-//        $resp = $providers->balance();
+        $providers = $this->getProvider('wangliantx');
+        $resp = $providers->balance();
 //        for ($i = 1; $i<=1; $i++){
 //            $resp = $providers->add(18074608795, 6, 50, [
 //                'order_sn' => $this->make_sn(),
 //                'regin_no' => 1
 //            ]);
 //        }
-//        $resp = $providers->query(['order_sn' => '85901629801033376170']);
+//        $resp = $providers->query(['order_sn' => '5064760687879181122498']);
 
-        $body = '{"userid":"10073664","sporderid":"85901629801033376170","orderid":"C5C5D4F49DB61A8773664","resultno":"1","merchantsubmittime":"20210824183109","ordermoney":"47.6","verifystring":"b6a873ecd6dc9cea3a410c6386cdab84","sign":"4a80e2a8c7b07c8aacada4feedd581bd","supnumber":"1000000083421082418345386156"}';
-        $params = json_decode($body, true);
-        $providers = $this->getProvider('wangliantx', 'RefillCallBack');
-        $ret = $providers->verify($params);
-        $resp = $providers->notify($params);
+//        $body = '{"userid":"10073664","sporderid":"85901629801033376170","orderid":"C5C5D4F49DB61A8773664","resultno":"1","merchantsubmittime":"20210824183109","ordermoney":"47.6","verifystring":"b6a873ecd6dc9cea3a410c6386cdab84","sign":"4a80e2a8c7b07c8aacada4feedd581bd","supnumber":"1000000083421082418345386156"}';
+//        $params = json_decode($body, true);
+//        $providers = $this->getProvider('wangliantx', 'RefillCallBack');
+//        $ret = $providers->verify($params);
+//        $resp = $providers->notify($params);
     }
 
     public function testZhuojian()

+ 25 - 0
test/TestRefillNotify.php

@@ -44,6 +44,11 @@ class TestRefillNotify extends TestCase
         }
     }
 
+    private function xmlToArray($xml)
+    {
+        return json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
+    }
+
     public function testCangBu()
     {
         $content = 'customerId=112&tmporder=8099200687720100332338&orderno=s16343761001545489501112&number=15202725166&money=100&amount=96.0000&code=1&cardno=&voucher=527102505060163546&sign=90269787b738e89884d22c5603a3b11f';
@@ -56,4 +61,24 @@ class TestRefillNotify extends TestCase
     }
 
 
+    public function testWangliantx()
+    {
+        $provider = $this->getProvider('wangliantx','RefillCallBack');
+//        $xml = '<order><orderid>7DD563D3C300293073664</orderid><productid>10666</productid><num>1</num><ordercash>28.65</ordercash><price>30.0</price><productname>%E4%BB%A3%E7%90%86%E8%BE%BD%E5%AE%81%E7%A7%BB%E5%8A%A830%E5%85%83</productname><supnumber></supnumber><sporderid>8418840687878184059987</sporderid><mobile>13795190856</mobile><resultno>2</resultno></order>';
+//        $resp = $this->xmlToArray($xml);
+//
+        $params['userid'] = '10073664';
+        $params['sporderid'] = '7017570687879655920102';
+        $params['orderid'] = '02FDE541DBDB482E73664';
+        $params['resultno'] = '1';
+        $params['merchantsubmittime'] = '20211018134203';
+        $params['ordermoney'] = '95.2';
+        $params['verifystring'] = '0187e9b01a1dd25ad3dc0c5fbc7608b1';
+        $params['sign'] = '9b9304a043167905fe88052735c57c2d';
+        $params['supnumber'] = '11010336K132110181341020247862';
+
+        $ret = $provider->verify($params);
+        $this->assertTrue($ret,'Verify is OK');
+        $provider->notify($params);
+    }
 }