stanley-king 3 vuotta sitten
vanhempi
commit
f102f15f3f

+ 24 - 4
helper/refill/api/xyz/zanzan/RefillPhone.php

@@ -6,6 +6,7 @@ require_once(BASE_HELPER_RAPI_PATH . '/zanzan/config.php');
 
 use refill;
 use Log;
+use mtopcard;
 
 class RefillPhone extends refill\IRefillPhone
 {
@@ -14,7 +15,7 @@ class RefillPhone extends refill\IRefillPhone
         parent::__construct($cfgs);
     }
 
-    private function req_params(int $phone, int $amount, string $order_sn)
+    private function req_params(int $phone,int $card_type,int $amount, string $order_sn)
     {
         $params['userid'] = config::USER_ID;
         $params['orderid'] = $order_sn;
@@ -24,18 +25,34 @@ class RefillPhone extends refill\IRefillPhone
         $params['packcode'] = $amount;
         $params['mobile'] = $phone;
         $params['flowtype'] = '1001';
+        $params['channelcode'] = $this->getCode($card_type);
         $params['callback_url'] = config::NOTIFY_URL;
         return $params;
     }
 
+    private function getCode($card_type)
+    {
+        if($card_type == mtopcard\ChinaMobileCard) {
+            return 'cmcc';
+        }
+        elseif($card_type == mtopcard\ChinaUnicomCard) {
+            return 'cucc';
+        }
+        elseif($card_type == mtopcard\ChinaTelecomCard) {
+            return 'ctcc';
+        }
+        else {
+            return '';
+        }
+    }
+
     public function add($card_no, $card_type, $amount, $params)
     {
-        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $params = $this->req_params($card_no, $card_type, $amount, $params['order_sn']);
         $sign = $this->sign($params);
         $params['chargeSign'] = $sign;
 
         $params = json_encode($params);
-
         $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders);
 
         if (empty($resp)) {
@@ -73,6 +90,8 @@ class RefillPhone extends refill\IRefillPhone
         {
             Log::record($resp, Log::DEBUG);
             $resp = json_decode($resp, true);
+            $desc = urldecode($resp['desc']);
+
             if (empty($resp)) {
                 return [false, '系统错误'];
             } elseif ($resp['code'] === '0000') {
@@ -82,8 +101,9 @@ class RefillPhone extends refill\IRefillPhone
             } elseif ($resp['code'] === '0002' || $resp['code'] === '0003') {
                 $order_state = ORDER_STATE_SEND;
             } else {
-                return [false, $resp['desc']];
+                return [false, $desc];
             }
+
             return [true, $order_state];
         }
     }

+ 3 - 4
helper/refill/api/xyz/zanzan/config.php

@@ -6,12 +6,11 @@ namespace refill\zanzan;
 
 class config
 {
-    const ORDER_URL = 'http://47.105.74.255:7066/api/charge.do';
-    const QUERY_URL = 'http://47.105.74.255:7066/api/query_chargestate.do';
+    const ORDER_URL = 'http://118.190.102.209/fee/api/charge.do';
+    const QUERY_URL = 'http://118.190.102.209/fee/api/query_state.do';
 
     const USER_ID = 'd845a4635f7e47668f5e';
     const KEY = '06cfafb0c3804943a582';
-//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_zanzan.php";
-    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_zanzan.php";
     const ExtHeaders = ['Content-Type: application/json'];
 }

+ 8 - 0
mobile/callback/refill_zanzan.php

@@ -0,0 +1,8 @@
+<?php
+
+refill\util::push_notify('zanzan',$_POST);
+
+$reponse = ["code" => "0000", "desc" => ""];
+$body = json_encode($reponse);
+
+echo($body);

+ 10 - 0
test/TestRefillThird.php

@@ -175,6 +175,7 @@ class TestRefillThird extends TestCase
         [$state, $ch_order, $neterr] = $providers->add(1000111100021211884, 2, 50, ['order_sn' => $order_sn]);
         $providers->query(['ch_trade_no' => $ch_order,'order_sn' => $order_sn]);
     }
+
     public function testFNMSCB()
     {
         $params = ['appid' => 'CZ30533982',
@@ -245,4 +246,13 @@ class TestRefillThird extends TestCase
             }
         }
     }
+
+    public function testZanzan()
+    {
+        $providers = $this->getProvider('zanzan','RefillPhone');
+        $order_sn = $this->make_sn();
+        [$state, $ch_order, $neterr] = $providers->add(13911129867, 5, 100, ['order_sn' => $order_sn]);
+//        [$state, $ch_order, $neterr] = $providers->add(18500608333, 5, 100, ['order_sn' => $order_sn]);
+        $providers->query(['ch_trade_no' => '','order_sn' => '76881623077089338712']);
+    }
 }