Browse Source

youhedf yunchonggongdf yunlingdf

xiaoyu 3 years ago
parent
commit
5109cfddb8

+ 11 - 7
helper/refill/api/xyz/youhedf/RefillPhone.php

@@ -15,13 +15,13 @@ class RefillPhone extends refill\IRefillPhone
         parent::__construct($cfgs);
     }
 
-    private function req_params(int $phone, int $amount, int $card_type, string $order_sn, $regin_no)
+    private function req_params(int $phone, int $amount, $company_type, string $order_sn, $province, $card_id)
     {
         $params['szAgentId'] = config::USER_ID;
         $params['szOrderId'] = $order_sn;
         $params['szPhoneNum'] = $phone;
         $params['nMoney'] = $amount;
-        $params['nSortType'] = $card_type;
+        $params['nSortType'] = config::operator[$company_type];
         $params['nProductClass'] = 1;
         $params['nProductType'] = 1;
         $params['szProductId'] = config::Product[$amount];
@@ -29,9 +29,11 @@ class RefillPhone extends refill\IRefillPhone
         $params['szNotifyUrl'] = config::NOTIFY_URL;
 
         $data = [
-            'province' => mtopcard\ProvinceList[$regin_no],
-            'area' => mtopcard\ProvinceList[$regin_no],
+            'province' => mtopcard\ProvinceList[$province]
         ];
+        if($company_type === 'south') {
+            $data['cardId'] = $card_id;
+        }
         $params['params'] = json_encode($data, JSON_UNESCAPED_UNICODE);
         return $params;
     }
@@ -39,11 +41,13 @@ class RefillPhone extends refill\IRefillPhone
     public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
     {
         $order_sn = $params['order_sn'];
-        $regin_no = $params['regin_no'] ?? -1;
-        if($regin_no <= 0) {
+        $company_type = $params['$company_type'];
+        $card_id = $params['card_id'] ?? '';
+        $province = $params['province'] ?? -1;
+        if($province <= 0) {
             return [false, '省份获取错误', false];
         }
-        $params = $this->req_params($card_no, $amount, $card_type, $order_sn, $regin_no);
+        $params = $this->req_params($card_no, $amount, $company_type, $order_sn, $province, $card_id);
 
         $sign = $this->sign($params);
         $params['szVerifyString'] = $sign;

+ 5 - 6
helper/refill/api/xyz/youhedf/config.php

@@ -3,7 +3,6 @@
 
 namespace refill\youhedf;
 
-use mtopcard;
 class config
 {
     const ORDER_URL = 'http://118.31.168.250:10186/plat/api/df/submitorder';
@@ -12,12 +11,13 @@ class config
 
     const USER_ID= '200044';
     const KEY = '940500a70ce346e6838fa314adf104cc';
-    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_youhedf.php";
+//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_youhedf.php";
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+
 
     const operator = [
-        mtopcard\ChinaMobileCard  => 1,
-        mtopcard\ChinaUnicomCard  => 2,
-        mtopcard\ChinaTelecomCard => 3
+        'nation'  => 101,
+        'south'  => 102,
     ];
     const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
 
@@ -32,6 +32,5 @@ class config
         300     => 101030300,
         500     => 101030500,
         1000    => 1010301000,
-
     ];
 }

+ 14 - 7
helper/refill/api/xyz/yunchonggongdf/RefillPhone.php

@@ -15,7 +15,7 @@ class RefillPhone extends refill\IRefillPhone
         parent::__construct($cfgs);
     }
 
-    private function req_params(int $phone, int $amount, int $card_type, string $order_sn, $regin_no)
+    private function req_params(int $phone, int $amount, $company_type, string $order_sn, $province, $card_id, $use_type)
     {
         $params['appId'] = config::APP_ID;
         $params['outOrderId'] = $order_sn;
@@ -27,20 +27,27 @@ class RefillPhone extends refill\IRefillPhone
         $params['timestamp'] = date("YmdHis").$this->get_millisecond();
 
         // ext1 为省份汉字, ext2 电卡为南网时传身份证号后6位, ext3 为电费户别类型 1-住宅,2-店铺,3-企业
-        $params['ext1'] = mtopcard\ProvinceList[$regin_no];
-        $params['ext2'] = '';
-        $params['ext3'] = $card_type;
+        $params['ext1'] = mtopcard\ProvinceList[$province];
+        if($company_type === 'south') {
+            $params['ext2'] = $card_id;
+        }else{
+            $params['ext2'] = '';
+        }
+        $params['ext3'] = config::USE_TYPE[$use_type];
         return $params;
     }
 
     public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
     {
         $order_sn = $params['order_sn'];
-        $regin_no = $params['regin_no'] ?? -1;
-        if($regin_no <= 0) {
+        $company_type = $params['$company_type'];
+        $card_id = $params['card_id'] ?? '';
+        $use_type = $params['use_type'];
+        $province = $params['province'] ?? -1;
+        if($province <= 0) {
             return [false, '省份获取错误', false];
         }
-        $params = $this->req_params($card_no, $amount, $card_type, $order_sn, $regin_no);
+        $params = $this->req_params($card_no, $amount, $company_type, $order_sn, $province, $card_id, $use_type);
         if(empty($params['itemId'])) {
             return [false, '商品编号错误', false];
         }

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

@@ -3,7 +3,6 @@
 
 namespace refill\yunchonggongdf;
 
-use mtopcard;
 class config
 {
     const ORDER_URL = 'http://119.23.54.206:8911/api/order/submit';
@@ -13,6 +12,12 @@ class config
     const APP_ID = 'FckhPc9kAK';
     const APP_SECRET = 'zOGQRiMKyfoxBtJy';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yunchonggongdf.php";
+
+    const USE_TYPE = [
+        'home'  => 1,
+        'commerce'  => 3,
+        'pedlar' => 2,
+    ];
     const PRODUCT = [
         50  => 100113,
         100 => 100114,

+ 15 - 6
helper/refill/api/xyz/yunlingdf/RefillPhone.php

@@ -15,29 +15,38 @@ class RefillPhone extends refill\IRefillPhone
         parent::__construct($cfgs);
     }
 
-    private function req_params(int $phone, int $amount, string $order_sn, $province)
+    private function req_params(int $phone, int $amount, $company_type, string $order_sn, $province, $card_id, $use_type)
     {
         $params['userid'] = config::USER_ID;
         $params['productid'] = config::product_id[$province][$amount];
         $params['num'] = 1;
-        $params['areaid'] = '';
-        $params['serverid'] = '';
-        $params['account'] = $phone;
+        if($company_type === 'south') {
+            $params['userip'] = $card_id;
+        }
         $params['spordertime'] = date("YmdHis");
         $params['sporderid'] = $order_sn;
         $params['back_url'] = config::NOTIFY_URL;
 
+        $data = [
+            'product_type' => 3, 'userid' => $phone, 'username' => $card_id,
+            'type' => config::USE_TYPE[$use_type], 'area' => mtopcard\ProvinceList[$province]
+        ];
+        $params['account'] = json_encode($data, JSON_UNESCAPED_UNICODE);
         return $params;
     }
 
     public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
     {
         $order_sn = $params['order_sn'];
+        $company_type = $params['$company_type'];
+        $card_id = $params['card_id'] ?? '';
+        $use_type = $params['use_type'];
         $province = $params['province'] ?? -1;
-        if($province < 0) {
+        if($province <= 0) {
             return [false, '省份获取错误', false];
         }
-        $params = $this->req_params($card_no, $amount, $order_sn, $province);
+        $params = $this->req_params($card_no, $amount, $company_type, $order_sn, $province, $card_id, $use_type);
+
         if(empty($params['productid'])) {
             return [false, '商品编号获取失败', false];
         }

+ 6 - 0
helper/refill/api/xyz/yunlingdf/config.php

@@ -13,6 +13,12 @@ class config
 //    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yunlingdf.php";
     const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
 
+    const USE_TYPE = [
+        'home'  => 1,
+        'commerce'  => 3,
+        'pedlar' => 2,
+    ];
+
     const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
     const ERR_NOS = [
         '5001','5002','5003','5004','5005','5008','5009','5010','5011','5012'