浏览代码

yunlingdf

haru haru 2 年之前
父节点
当前提交
b294b71c99
共有 3 个文件被更改,包括 31 次插入14 次删除
  1. 15 4
      helper/refill/api/xyz/yunlingdf/RefillPhone.php
  2. 4 2
      helper/refill/api/xyz/yunlingdf/config.php
  3. 12 8
      test/TestRefill.php

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

@@ -15,7 +15,7 @@ class RefillPhone extends refill\IRefillThird
         parent::__construct($cfgs);
     }
 
-    private function req_params(int $phone, int $amount, $company_type, string $order_sn, $province, $card_id, $use_type)
+    private function req_params(int $phone, int $amount, $company_type, string $order_sn, $province, $card_id, $use_type, $city)
     {
         $params['userid'] = config::USER_ID;
         $params['productid'] = config::product_id[$province][$amount];
@@ -27,11 +27,12 @@ class RefillPhone extends refill\IRefillThird
         $params['sporderid'] = $order_sn;
         $params['back_url'] = config::NOTIFY_URL;
 
+        $area = mtopcard\ProvinceList[$province];
         $data = [
             'product_type' => 3, 'userid' => $phone, 'username' => $card_id,
-            'type' => config::USE_TYPE[$use_type], 'area' => mtopcard\ProvinceList[$province]
+            'type' => config::USE_TYPE[$use_type], 'area' => $area, 'city' => $city
         ];
-        $params['account'] = json_encode($data, JSON_UNESCAPED_UNICODE);
+        $params['account'] = mb_convert_encoding(json_encode($data,JSON_UNESCAPED_UNICODE),"gb2312","UTF-8");
         return $params;
     }
 
@@ -48,11 +49,15 @@ class RefillPhone extends refill\IRefillThird
         $card_id = $params['card_id'] ?? '';
         $use_type = $params['use_type'];
         $province = $params['province'] ?? -1;
+        $city = $params['city'] ?? '';
+        if(!empty($city)) {
+            $city = $this->city_filter($city);
+        }
         if($province <= 0) {
             return [false, '省份获取错误', false];
         }
         $product = $this->getProduct($params['product_code']);
-        $params = $this->req_params($card_no, $product['refill_amount'], $company_type, $order_sn, $province, $card_id, $use_type);
+        $params = $this->req_params($card_no, $product['refill_amount'], $company_type, $order_sn, $province, $card_id, $use_type, $city);
 
         if(empty($params['productid'])) {
             return [false, '商品编号获取失败', false];
@@ -162,4 +167,10 @@ class RefillPhone extends refill\IRefillThird
         $content .= "&sporderid={$params['sporderid']}&key={$key}";
         return strtoupper(md5($content));
     }
+
+    private function city_filter($city)
+    {
+        $endtxt = '市';
+        return mb_strcut($city, 0, strrpos($city, $endtxt));
+    }
 }

+ 4 - 2
helper/refill/api/xyz/yunlingdf/config.php

@@ -10,7 +10,9 @@ class config
     const BALANCE_URL= 'http://121.89.243.74:9086/searchbalance.do';
     const USER_ID= '10002623';
     const KEY = 'M4GZNKZCW6kasAMbpGxDn3AcPJiYDFS5';
-    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yunlingdf.php";
+//    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,
@@ -18,7 +20,7 @@ class config
         'pedlar' => 2,
     ];
 
-    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ExtHeaders = ['Content-type : application/x-www-form-urlencoded; charset=gb2312'];
     const ERR_NOS = [
         '5001','5002','5003','5004','5005','5008','5009','5010','5011','5012'
     ];

+ 12 - 8
test/TestRefill.php

@@ -1598,15 +1598,19 @@ class TestRefill extends TestCase
 
     public function testYunlingdf()
     {
-//        $provider = $this->getProvider('yunlingdf');
-//        $resp = $provider->add(1004638637, 4, 50, ['order_sn' => $this->make_sn(), 'province' => 1]);
-//        $resp = $provider->query(['order_sn' => '52311640682774916978']);
+        $provider = $this->getProvider('yunlingdf');
+//        $resp = $provider->balance();
+        $resp = $provider->add(2079727198, 7, 100, [
+            'order_sn' => $this->make_sn(), 'company_type' => 'nation', 'use_type' => 'home',
+            'province' => 18, 'city' => '永州市', 'product_code' => 'DF_nation_home_100'
+        ]);
+//        $resp = $provider->query(['order_sn' => '45331652932902024418']);
 
-        $body = '{"orderid":"RCE21122817138556500","sporderid":"52311640682774916978","userid":"10002623","merchantsubmittime":"20211228182932","resultno":"1","parvalue":"50","remark1":"50.00","payno":"50.00","fundbalance":"-46.5","sign":"B40807706460BAF9CBE150166633F20A"}';
-        $params = json_decode($body, true);
-        $provider = $this->getProvider('yunlingdf', 'RefillCallBack');
-        $ret = $provider->verify($params);
-        $resp = $provider->notify($params);
+//        $body = '{"orderid":"RCE21122817138556500","sporderid":"52311640682774916978","userid":"10002623","merchantsubmittime":"20211228182932","resultno":"1","parvalue":"50","remark1":"50.00","payno":"50.00","fundbalance":"-46.5","sign":"B40807706460BAF9CBE150166633F20A"}';
+//        $params = json_decode($body, true);
+//        $provider = $this->getProvider('yunlingdf', 'RefillCallBack');
+//        $ret = $provider->verify($params);
+//        $resp = $provider->notify($params);
     }
 
     public function testYamiao_high()