Selaa lähdekoodia

update get operator

ayHaru 4 vuotta sitten
vanhempi
commit
d442f8becf

+ 3 - 17
helper/refill/api/lingzh/amingjd/RefillPhone.php

@@ -6,7 +6,6 @@ require_once(BASE_HELPER_RAPI_PATH . '/amingjd/config.php');
 
 use refill;
 use Log;
-use mtopcard;
 
 class RefillPhone extends refill\IRefillPhone
 {
@@ -15,13 +14,13 @@ 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 $amount, int $card_type, string $order_sn)
     {
         $params['mchid'] = config::MCHID;
         $params['tel'] = $phone;
         $params['orderid'] = $order_sn;
         $params['price'] = $amount;
-        $params['teltype'] = $this->phone_type($phone);
+        $params['teltype'] = config::operator[$card_type];
         $params['timeout'] = config::TIMEOUT;
         $params['notify'] = config::NOTIFY_URL;
         $params['time'] = time();
@@ -32,7 +31,7 @@ class RefillPhone extends refill\IRefillPhone
 
     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, $amount, $card_type, $params['order_sn']);
         $sign = $this->sign($params);
         $params['sign'] = $sign;
 
@@ -102,17 +101,4 @@ class RefillPhone extends refill\IRefillPhone
         $content .= $params['time'] . $params['rand'] . config::KEY;
         return md5($content);
     }
-
-    private function phone_type($phone)
-    {
-        $card_type = mtopcard\card_type($phone,$regin_no);
-
-        if ($card_type == mtopcard\ChinaMobileCard) {
-            return 0;
-        } elseif ($card_type == mtopcard\ChinaUnicomCard) {
-            return 1;
-        } elseif ($card_type == mtopcard\ChinaTelecomCard) {
-            return 2;
-        }
-    }
 }

+ 6 - 1
helper/refill/api/lingzh/amingjd/config.php

@@ -3,7 +3,7 @@
 
 namespace refill\amingjd;
 
-
+use mtopcard;
 class config
 {
     const ORDER_URL = 'http://121.43.141.241:8082/api/telpay';
@@ -13,4 +13,9 @@ class config
     const KEY = '14d5ede552830bff5f25d6ae069aad12';
     const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/lingzh/amingjd.php";
     const TIMEOUT = 1800;
+    const operator = [
+        mtopcard\ChinaMobileCard  => 0,
+        mtopcard\ChinaUnicomCard  => 1,
+        mtopcard\ChinaTelecomCard => 2
+    ];
 }

+ 3 - 17
helper/refill/api/lingzh/wailing/RefillPhone.php

@@ -6,7 +6,6 @@ require_once(BASE_HELPER_RAPI_PATH . '/wailing/config.php');
 
 use refill;
 use Log;
-use mtopcard;
 
 class RefillPhone extends refill\IRefillPhone
 {
@@ -15,13 +14,13 @@ 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 $amount, int $card_type, string $order_sn)
     {
         $params['mchid'] = config::MCHID;
         $params['tel'] = $phone;
         $params['orderid'] = $order_sn;
         $params['price'] = $amount;
-        $params['teltype'] = $this->phone_type($phone);
+        $params['teltype'] = config::operator[$card_type];
         $params['timeout'] = config::NotifyTimeout;
         $params['notify'] = config::NOTIFY_URL;
         $params['time'] = time();
@@ -31,7 +30,7 @@ class RefillPhone extends refill\IRefillPhone
 
     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, $amount, $card_type, $params['order_sn']);
         $sign = $this->sign($params);
         $params['sign'] = $sign;
 
@@ -105,17 +104,4 @@ class RefillPhone extends refill\IRefillPhone
         $content .= $params['time'] . $params['rand'] . $key;
         return md5($content);
     }
-
-    private function phone_type($phone)
-    {
-        $card_type = mtopcard\card_type($phone,$regin_no);
-
-        if ($card_type == mtopcard\ChinaMobileCard) {
-            return 0;
-        } elseif ($card_type == mtopcard\ChinaUnicomCard) {
-            return 1;
-        } else { // ($card_type == mtopcard\ChinaTelecomCard)
-            return 2;
-        }
-    }
 }

+ 6 - 0
helper/refill/api/lingzh/wailing/config.php

@@ -3,6 +3,7 @@
 
 namespace refill\wailing;
 
+use mtopcard;
 class config
 {
     const ORDER_URL = 'http://206.119.82.136/api/telpay';
@@ -12,4 +13,9 @@ class config
     const KEY = 'a1b2f886cfda41170547cd6cfc1cf16b';
     const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/lingzh/wailing.php";
     const NotifyTimeout = 7200;
+    const operator = [
+        mtopcard\ChinaMobileCard  => 0,
+        mtopcard\ChinaUnicomCard  => 1,
+        mtopcard\ChinaTelecomCard => 2
+    ];
 }

+ 3 - 18
helper/refill/api/lingzh/wuchen/RefillPhone.php

@@ -6,7 +6,6 @@ require_once(BASE_HELPER_RAPI_PATH . '/wuchen/config.php');
 
 use refill;
 use Log;
-use mtopcard;
 
 class RefillPhone extends refill\IRefillPhone
 {
@@ -15,7 +14,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 $amount, int $card_type, string $order_sn)
     {
         $params['app_id'] = config::APPID;
         $params['request_id'] = $order_sn;
@@ -24,7 +23,7 @@ class RefillPhone extends refill\IRefillPhone
         $data['account'] = "{$phone}";
         $data['order_sn'] = $order_sn;
         $data['amount'] = $amount;
-        $data['operator'] = $this->phone_type($phone);
+        $data['operator'] = config::operator[$card_type];
 
         $params['data'] = [$data];
 
@@ -33,7 +32,7 @@ class RefillPhone extends refill\IRefillPhone
 
     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, $amount, $card_type, $params['order_sn']);
         $params['router'] = 'submit.recharge.order';
 
         $time = time();
@@ -135,18 +134,4 @@ class RefillPhone extends refill\IRefillPhone
         $content  = $params['app_id'] . '&' . $key . '&' . $params['router'] . '&' . $time . '&' . $nonce;
         return md5($content);
     }
-
-    private function phone_type($phone)
-    {
-        $card_type = mtopcard\card_type($phone,$regin_no);
-
-        if ($card_type == mtopcard\ChinaMobileCard) {
-            return 1;
-        } elseif ($card_type == mtopcard\ChinaUnicomCard) {
-            return 2;
-        } elseif ($card_type == mtopcard\ChinaTelecomCard) {
-            return 3;
-        }
-        return 0;
-    }
 }

+ 6 - 1
helper/refill/api/lingzh/wuchen/config.php

@@ -3,7 +3,7 @@
 
 namespace refill\wuchen;
 
-
+use mtopcard;
 class config
 {
     const ORDER_URL = 'http://47.104.140.24:8080/orders';
@@ -12,4 +12,9 @@ class config
     const APPID = '70016';
     const APP_KEY = 'Q4X5OU9U8SSTN5CRWU2U0ANC6VBX3YIJ';
     const NOTIFY_URL = "http://121.89.212.167/racc/callback/lingzh/wuchen.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => 1,
+        mtopcard\ChinaUnicomCard  => 2,
+        mtopcard\ChinaTelecomCard => 3
+    ];
 }

+ 3 - 16
helper/refill/api/test/baidu/RefillPhone.php

@@ -15,14 +15,14 @@ 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 $amount, int $card_type, string $order_sn)
     {
         $params['tel'] = $phone;
         $params['mch_order_id'] = $order_sn;
         $params['mchid'] = config::MCHID;
         $params['price'] = $amount;
         $params['notify'] = config::NOTIFY_URL;
-        $params['teltype'] = $this->phone_type($phone);
+        $params['teltype'] = config::operator[$card_type];
         $params['timeout'] = 50;
         $params['time'] = time();
         $params['rand'] = rand(100000,999999);
@@ -32,7 +32,7 @@ class RefillPhone extends refill\IRefillPhone
 
     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, $amount, $card_type, $params['order_sn']);
         $sign = $this->sign($params);
         $params['sign'] = $sign;
 
@@ -70,17 +70,4 @@ class RefillPhone extends refill\IRefillPhone
         $content .= $params['time'] . $params['rand'] . $key;
         return md5($content);
     }
-
-    private function phone_type($phone)
-    {
-        $card_type = mtopcard\card_type($phone,$regin_no);
-
-        if ($card_type == mtopcard\ChinaMobileCard) {
-            return 2;
-        } elseif ($card_type == mtopcard\ChinaUnicomCard) {
-            return 1;
-        } elseif ($card_type == mtopcard\ChinaTelecomCard) {
-            return 3;
-        }
-    }
 }

+ 6 - 1
helper/refill/api/test/baidu/config.php

@@ -3,7 +3,7 @@
 
 namespace refill\baidu;
 
-
+use mtopcard;
 class config
 {
     const ORDER_URL = 'https://www.baidu.com/';
@@ -12,4 +12,9 @@ class config
     const MCHID = 10019;
     const KEY = '953b8e10a70ef4e85b77f09448c0e316';
     const NOTIFY_URL = "https://www.xyzshops.cn/mobile/refill_baidu.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => 2,
+        mtopcard\ChinaUnicomCard  => 1,
+        mtopcard\ChinaTelecomCard => 3
+    ];
 }

+ 3 - 17
helper/refill/api/xyz/afand/RefillPhone.php

@@ -6,7 +6,6 @@ require_once(BASE_HELPER_RAPI_PATH . '/afand/config.php');
 
 use refill;
 use Log;
-use mtopcard;
 
 class RefillPhone extends refill\IRefillPhone
 {
@@ -15,14 +14,14 @@ 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 $amount, int $card_type, string $order_sn)
     {
         $params['tel'] = $phone;
         $params['mch_order_id'] = $order_sn;
         $params['mchid'] = config::MCHID;
         $params['price'] = $amount;
         $params['notify'] = config::NOTIFY_URL;
-        $params['teltype'] = $this->phone_type($phone);
+        $params['teltype'] = config::operator[$card_type];
         $params['timeout'] = 50;
         $params['time'] = time();
         $params['rand'] = rand(100000,999999);
@@ -33,7 +32,7 @@ class RefillPhone extends refill\IRefillPhone
     //[$state, $errmsg,$neterr]
     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, $amount, $card_type, $params['order_sn']);
         $sign = $this->sign($params);
         $params['sign'] = $sign;
 
@@ -106,17 +105,4 @@ class RefillPhone extends refill\IRefillPhone
         $content .= $params['time'] . $params['rand'] . $key;
         return md5($content);
     }
-
-    private function phone_type($phone)
-    {
-        $card_type = mtopcard\card_type($phone,$regin_no);
-
-        if ($card_type == mtopcard\ChinaMobileCard) {
-            return 2;
-        } elseif ($card_type == mtopcard\ChinaUnicomCard) {
-            return 1;
-        } elseif ($card_type == mtopcard\ChinaTelecomCard) {
-            return 3;
-        }
-    }
 }

+ 6 - 1
helper/refill/api/xyz/afand/config.php

@@ -3,7 +3,7 @@
 
 namespace refill\afand;
 
-
+use mtopcard;
 class config
 {
     const ORDER_URL = 'http://47.98.208.197/api/telpay';
@@ -12,4 +12,9 @@ class config
     const MCHID = 10019;
     const KEY = '953b8e10a70ef4e85b77f09448c0e316';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/refill_afand.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => 2,
+        mtopcard\ChinaUnicomCard  => 1,
+        mtopcard\ChinaTelecomCard => 3
+    ];
 }

+ 3 - 17
helper/refill/api/xyz/jiec/RefillPhone.php

@@ -6,7 +6,6 @@ require_once(BASE_HELPER_RAPI_PATH . '/jiec/config.php');
 
 use refill;
 use Log;
-use mtopcard;
 
 class RefillPhone extends refill\IRefillPhone
 {
@@ -15,20 +14,20 @@ 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 $amount, int $card_type, string $order_sn)
     {
         $params['phone'] = $phone;
         $params['partner_order_no'] = $order_sn;
         $params['partner_id'] = config::PARTNER_ID;
         $params['amount'] = $amount;
         $params['notify_url'] = config::NOTIFY_URL;
-        $params['charge_type'] = $this->phone_type($phone);
+        $params['charge_type'] = config::operator[$card_type];
         return $params;
     }
 
     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, $amount, $card_type, $params['order_sn']);
         $sign = $this->sign($params);
         $params['sign'] = $sign;
 
@@ -97,17 +96,4 @@ class RefillPhone extends refill\IRefillPhone
         $content = $params['partner_id'] . $params['partner_order_no'] . $params['phone'] . $params['amount'] . $params['notify_url'] . $key;
         return md5($content);
     }
-
-    private function phone_type($phone)
-    {
-        $card_type = mtopcard\card_type($phone,$regin_no);
-
-        if ($card_type == mtopcard\ChinaMobileCard) {
-            return 2;
-        } elseif ($card_type == mtopcard\ChinaUnicomCard) {
-            return 0;
-        } elseif ($card_type == mtopcard\ChinaTelecomCard) {
-            return 1;
-        }
-    }
 }

+ 6 - 1
helper/refill/api/xyz/jiec/config.php

@@ -3,7 +3,7 @@
 
 namespace refill\jiec;
 
-
+use mtopcard;
 class config
 {
     const ORDER_URL = 'http://14.192.8.43/api/receiveOrder';
@@ -13,4 +13,9 @@ class config
     const KEY = '6699182237209e03e1eb4f92e75434c0';
     const NOTIFY_URL =  BASE_SITE_URL."/mobile/refill_jiec.php";
     const ExtHeaders = ['Content-Type: application/x-www-form-urlencoded'];
+    const operator = [
+        mtopcard\ChinaMobileCard  => 2,
+        mtopcard\ChinaUnicomCard  => 0,
+        mtopcard\ChinaTelecomCard => 1
+    ];
 }

+ 3 - 17
helper/refill/api/xyz/weit/RefillPhone.php

@@ -6,7 +6,6 @@ require_once(BASE_HELPER_RAPI_PATH . '/weit/config.php');
 
 use refill;
 use Log;
-use mtopcard;
 
 class RefillPhone extends refill\IRefillPhone
 {
@@ -15,13 +14,13 @@ 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 $amount, int $card_type, string $order_sn)
     {
         $params['mchid'] = config::MCH_ID;
         $params['tel'] = $phone;
         $params['mch_order_id'] = $order_sn;
         $params['price'] = $amount;
-        $params['teltype'] = $this->phone_type($phone);
+        $params['teltype'] = config::operator[$card_type];
         $params['timeout'] = 50;
         $params['notify'] = config::NOTIFY_URL;
         $params['time'] = time();
@@ -31,7 +30,7 @@ class RefillPhone extends refill\IRefillPhone
 
     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, $amount, $card_type, $params['order_sn']);
         $sign = $this->sign($params);
         $params['sign'] = $sign;
 
@@ -104,17 +103,4 @@ class RefillPhone extends refill\IRefillPhone
         $content .= $params['rand'] . $key;
         return md5($content);
     }
-
-    private function phone_type($phone)
-    {
-        $card_type = mtopcard\card_type($phone,$regin_no);
-
-        if ($card_type == mtopcard\ChinaMobileCard) {
-            return 2;
-        } elseif ($card_type == mtopcard\ChinaUnicomCard) {
-            return 1;
-        } elseif ($card_type == mtopcard\ChinaTelecomCard) {
-            return 3;
-        }
-    }
 }

+ 6 - 1
helper/refill/api/xyz/weit/config.php

@@ -3,7 +3,7 @@
 
 namespace refill\weit;
 
-
+use mtopcard;
 class config
 {
     const ORDER_URL = 'http://47.98.208.197/api/telpay';
@@ -13,4 +13,9 @@ class config
     const KEY = 'f2962db97df033cac91e3f082dc342bf';
     const NOTIFY_URL =  BASE_SITE_URL."/mobile/refill_weit.php";
     const ExtHeaders = ['Content-Type: application/x-www-form-urlencoded'];
+    const operator = [
+        mtopcard\ChinaMobileCard  => 2,
+        mtopcard\ChinaUnicomCard  => 1,
+        mtopcard\ChinaTelecomCard => 3
+    ];
 }