ayHaru 4 år sedan
förälder
incheckning
d3b8edb357

+ 19 - 4
helper/refill/api/lingzh/legou/RefillPhone.php

@@ -48,7 +48,10 @@ class RefillPhone extends refill\IRefillPhone
         $params['rechargePwd'] = $this->encryptWithOpenssl($rcard_key);
 
         $resp = http_request(config::ORDER_URL, $params , 'POST' , false , config::ExtHeaders);
+
+        $card_id = $card->card_id();
         if ($resp === false) {
+            cards_helper::reuse($card_id);
             return [false, '网络错误', true];
         }
         else
@@ -57,6 +60,7 @@ class RefillPhone extends refill\IRefillPhone
             $resp = json_decode($resp ,true);
 
             if($resp == false) {
+                cards_helper::reuse($card_id);
                 return [false, '网络错误', true];
             }
 
@@ -64,8 +68,10 @@ class RefillPhone extends refill\IRefillPhone
 
             if($status == 100000) {
                 return [true, $resp['obj'], false];
+            }else{
+                cards_helper::reuse($card_id);
+                return [false , $resp['code']['desc'], false];
             }
-            return [false , $resp['code']['desc'], false];
         }
     }
 
@@ -78,17 +84,26 @@ class RefillPhone extends refill\IRefillPhone
 
         $resp = http_request(config::QUERY_URL, $params , 'POST' , false , config::ExtHeaders);
         if ($resp === false) {
-            return [false, '系统错误'];
+            return [false, '网络错误'];
         } else {
             Log::record($resp, Log::DEBUG);
             $resp = json_decode($resp, true);
-            if ($resp['code']['status'] == 100000) {
-                $order_state = ORDER_STATE_SEND;
+            if($resp == false) {
+                return [false, '网络错误'];
+            }
+            $status = intval($resp['code']['status']);
+            if ($status == 100000) {
+                $order_state = -1;
                 $obj = $resp['obj'];
                 if ($obj['resultCode'] == 2) {
                     $order_state = ORDER_STATE_SUCCESS;
                 } elseif ($obj['resultCode'] == 3) {
                     $order_state = ORDER_STATE_CANCEL;
+                } else {
+                    $order_state = ORDER_STATE_SEND;
+                }
+                if ($order_state == -1) {
+                    return [false, $resp['code']['desc']];
                 }
                 return [true, $order_state];
             } else {

+ 4 - 4
helper/refill/api/lingzh/legou/config.php

@@ -9,11 +9,11 @@ class config
     const ORDER_URL = 'https://recv.shujubuy.com/api/recv/submitOrder';
     const QUERY_URL = 'https://recv.shujubuy.com/api/recv/queryOrder';
 
-    const USERNAME = 10019;
-    const KEY = '953b8e10a70ef4e85b77f09448c0e316';
-    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/refill_legou.php";
+    const USERNAME = 'lzdc';
+    const KEY = '20cb7911903744e58786956eaffe1d3b';
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
     const ExtHeaders = ['ContentType: application/x-www-form-urlencoded;charset=utf-8'];
 
     const ProductIDS = [mtopcard\ChinaMobileCard => 400002,mtopcard\ChinaUnicomCard => 400003,mtopcard\ChinaTelecomCard => 400004];
-    const StoreIDS = [];
+    const StoreIDS = [34];
 }

+ 7 - 1
test/TestRefill.php

@@ -253,10 +253,16 @@ class TestRefill extends TestCase
 
     }
 
+    public function testLegouPhone()
+    {
+        $providers = new refill\legou\RefillPhone([]);
+        $resp = $providers->add('18500608333', 5, 30, ['order_sn' => '690653407667699667' , 'order_id' => 248 , 'buyer_id' => 52667]);
+    }
+
     public function testTongyPhone()
     {
         $providers = new refill\tongy\RefillPhone([]);
-        $resp = $providers->add('18500608333', 5, 30, ['order_sn' => $this->make_sn()]);
+        $resp = $providers->add('18500608333', 5, 30, ['order_sn' => '690653407667699667' , 'order_id' => 248 , 'buyer_id' => 52667]);
     }
 
     public function testWeiyiPhone()