Sfoglia il codice sorgente

yelin ruixunda new api

haru haru 2 anni fa
parent
commit
89970052c7

+ 10 - 10
data/config/yl/refill.ini.php

@@ -3946,16 +3946,16 @@ $ruixunda_phone = ['name' => 'ruixunda', 'store_id' => 169, 'qualitys' => '1',
             ['goods_id' => 7444, 'price' => 187.8, 'quality' => 1, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7444, 'price' => 189, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
-        300 => [
-            ['goods_id' => 7445, 'price' => 288, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7445, 'price' => 281.7, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7445, 'price' => 283.5, 'quality' => 1, 'card_type' => 'chinatelecom']
-        ],
-        500 => [
-            ['goods_id' => 7446, 'price' => 480, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7446, 'price' => 469.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7446, 'price' => 472.5, 'quality' => 1, 'card_type' => 'chinatelecom']
-        ],
+//        300 => [
+//            ['goods_id' => 7445, 'price' => 288, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7445, 'price' => 281.7, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7445, 'price' => 283.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        500 => [
+//            ['goods_id' => 7446, 'price' => 480, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7446, 'price' => 469.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7446, 'price' => 472.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 

+ 11 - 30
helper/refill/api/yl/ruixunda/RefillCallBack.php

@@ -8,9 +8,7 @@ class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
-        $input = $params;
-        unset($input['sign']);
-        $sign = $this->sign($input);
+        $sign = $this->sign($params);
         if ($params['sign'] == $sign) {
             return true;
         } else {
@@ -20,45 +18,28 @@ class RefillCallBack implements refill\IRefillCallBack
 
     private function sign($params)
     {
-        $params['appSecret'] = config::APP_SECRET;
-        ksort($params);
-        $content = '';
-        foreach ($params as $key => $value) {
-            if($this->check_empty($value) === false) {
-                $content .= "{$key}={$value}&";
-            }
-        }
-        $content = rtrim($content, '&');
-        return md5($content);
-    }
-
-    private function check_empty($value)
-    {
-        if (!isset($value))
-            return true;
-        if ($value === null)
-            return true;
-        if (trim($value) === "")
-            return true;
-
-        return false;
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&orderid={$params['orderid']}&sporderid={$params['sporderid']}&merchantsubmittime={$params['merchantsubmittime']}";
+        $content .= "&resultno={$params['resultno']}&key={$key}";
+        return strtoupper(md5($content));
     }
 
     public function notify($params)
     {
-        $status = intval($params['orderStatus']);
-        $order_sn = $params['outOrderId'];
+        $status = intval($params['resultno']);
+        $order_sn = $params['sporderid'];
         $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
         if (empty($order_info)) {
             return [false, false, false,false];
         }
 
         $order_id = $order_info['order_id'];
-        if ($status === 2) {
-            $data['official_sn'] = strtolower($params['ext1']) == 'null' ? '' : $params['ext1'];
+        if ($status === 1) {
+            $data['official_sn'] = strtolower($params['remark1']) == 'null' ? '' : $params['remark1'];
             Model('refill_order')->edit($order_id, $data);
             return [$order_id, true, false, true];
-        } elseif ($status === 3) {
+        } elseif ($status === 9) {
             return [$order_id, false, true, true];
         } else {
             return [$order_id, false, false, false];

+ 62 - 62
helper/refill/api/yl/ruixunda/RefillPhone.php

@@ -14,15 +14,18 @@ class RefillPhone extends refill\IRefillPhone
         parent::__construct($cfgs);
     }
 
-    private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
+    private function req_params(int $phone, int $amount, $card_type, string $order_sn)
     {
-        $params['appId'] = config::APP_ID;
-        $params['outOrderId'] = $order_sn;
-        $params['uuid'] = $phone;
-        $params['itemId'] = config::PRODUCT[$card_type][$amount];
-        $params['itemFace'] = $amount;
-        $params['callbackUrl'] = config::NOTIFY_URL;
-        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['userid'] = config::USER_ID;
+        $params['productid'] = config::ProductIdS[$card_type][$amount];
+        $params['price'] = $amount;
+        $params['num'] = 1;
+        $params['mobile'] = $phone;
+        $params['spordertime'] = date("YmdHis");
+        $params['sporderid'] = $order_sn;
+        $params['back_url'] = config::NOTIFY_URL;
+        $params['paytype'] = config::operator[$card_type];
+
         return $params;
     }
 
@@ -30,9 +33,7 @@ class RefillPhone extends refill\IRefillPhone
     {
         $order_sn = $params['order_sn'];
         $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
-        if(empty($params['itemId'])) {
-            return [false, '商品编号错误', false];
-        }
+
         $sign = $this->sign($params);
         $params['sign'] = $sign;
 
@@ -44,29 +45,35 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = json_decode($resp, true);
+            $resp = $this->xmlToArray($resp);
             if (empty($resp)) {
                 return [false, '网络错误', true];
-            } elseif ($resp['code'] === '00') {
-                return [true, $resp['orderId'], false];
-            } elseif (in_array($resp['code'], config::ERRCODES, true)) {
-                return [false, $resp['msg'], false];
-            } elseif (in_array($resp['code'], ['-22', '-23', '-99'], true)) {
-                $net_errno = "HTTP-{$resp['code']}";
-                return [false, $resp['msg'], true];
+            }
+
+            $resultno = $resp['resultno'];
+            if (in_array($resultno, ['0', '2'], true)) {
+                return [true, $resp['orderid'], false];
+            } elseif (in_array($resultno, config::ERR_NOS, true)) {
+                return [false, $resultno, false];
+            } elseif ($resultno === '9999' || $resultno === '5006') {
+                $net_errno = "HTTP-{$resultno}";
+                return [false, $resultno, true];
             } else {
-                $net_errno = "HTTP-998";
-                return [false, $resp['msg'], true];
+                //未知结果码
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resultno, true];
             }
         }
     }
 
     public function query($refill_info)
     {
-        $params['appId'] = config::APP_ID;
-        $params['outOrderId'] = $refill_info['order_sn'];
-        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
-        $params['sign'] = $this->sign($params);
+        $params['userid'] = config::USER_ID;
+        $params['sporderid'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&sporderid={$params['sporderid']}&key={$key}";
+        $params['sign'] = strtoupper(md5($content));
 
         $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -76,40 +83,39 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = json_decode($resp, true);
-            if (empty($resp)) {
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp))
+            {
                 return [false, '网络错误'];
             }
-            elseif ($resp['code'] === '00')
+            else
             {
-                $status = $resp['orderStatus'];
-                if ($status === '2') {
-                    $updata['official_sn'] = $resp['ext1'];
+                $resultno = $resp['resultno'];
+                if ($resultno === '1') {
+                    $updata['official_sn'] = $resp['remark1'];
                     Model('refill_order')->edit($refill_info['order_id'], $updata);
                     $order_state = ORDER_STATE_SUCCESS;
-                } elseif ($status === '3') {
+                } elseif ($resultno === '9') {
                     $order_state = ORDER_STATE_CANCEL;
-                } elseif ($status === '1') {
+                } elseif (in_array($resultno, ['0','2'], true)) {
                     $order_state = ORDER_STATE_SEND;
-                } elseif ($status === '4' && (time() - $refill_info['commit_time'] >= 600)) {
+                } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] > 600)) {
                     $order_state = ORDER_STATE_NOEXIST;
                 } else {
-                    return [false, $resp['msg']];
+                    return [false, $resultno];
                 }
+
                 return [true, $order_state];
             }
-            else
-            {
-                return [false, $resp['msg']];
-            }
         }
     }
 
     public function balance()
     {
-        $params['appId'] = config::APP_ID;
-        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
-        $params['sign'] = $this->sign($params);
+        $params['userid'] = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&key={$key}";
+        $params['sign'] = strtoupper(md5($content));
 
         $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -119,37 +125,31 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = json_decode($resp, true);
+            $resp = $this->xmlToArray($resp);
             if (empty($resp)) {
                 return [false, '网络错误'];
-            } elseif ($resp['code'] === '00') {
+            } elseif ($resp['resultno'] === '1') {
                 return [true, $resp['balance']];
             } else {
-                return [false, $resp['msg']];
+                return [false, $resp['resultno']];
             }
         }
     }
 
-    /**
-     * 获取毫秒级别的时间戳
-     */
-    private function get_millisecond()
+    private function sign($params)
     {
-        list($usec, $sec) = explode(" ", microtime());
-        return round($usec*1000);
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&productid={$params['productid']}&price={$params['price']}&num={$params['num']}&mobile={$params['mobile']}&spordertime={$params['spordertime']}";
+        $content .= "&sporderid={$params['sporderid']}&key={$key}";
+        return strtoupper(md5($content));
     }
 
-    private function sign($params)
+    public function xmlToArray($xml)
     {
-        $params['appSecret'] = config::APP_SECRET;
-        ksort($params);
-        $content = '';
-        foreach ($params as $key => $value) {
-            if($this->check_empty($value) === false) {
-                $content .= "{$key}={$value}&";
-            }
-        }
-        $content = rtrim($content, '&');
-        return md5($content);
+        $replace_str = str_replace(' ','','encoding="gb2312"');
+        $xml = mb_convert_encoding($xml,"UTF-8","gb2312");
+        $xml = str_replace($replace_str, "encoding='utf-8'", $xml);
+        return refill\util::xmlToArray($xml);
     }
 }

+ 38 - 32
helper/refill/api/yl/ruixunda/config.php

@@ -6,39 +6,45 @@ namespace refill\ruixunda;
 use mtopcard;
 class config
 {
-    const ORDER_URL = 'http://47.98.117.207:8911/api/hf/order/submit';
-    const QUERY_URL = 'http://47.98.117.207:8911/api/order/query';
-    const BALANCE_URL = 'http://47.98.117.207:8911/api/account/balance';
+    //https://www.showdoc.com.cn/AQL666666/
+    const ORDER_URL = 'http://47.96.69.138:9086/onlinepay.do';
+    const QUERY_URL= 'http://47.96.69.138:9086/searchpay.do';
+    const BALANCE_URL = 'http://47.96.69.138:9086/searchbalance.do';
 
-    const APP_ID = 'G0sEOnF3jm';
-    const APP_SECRET = 'bbpZLlMcJChpNFgn';
+    const USER_ID= '10002505';
+    const KEY = 'k2xkSaFr4BH5ZD5iDWf5Ha4QTE3fKtN5';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_ruixunda.php";
-    const PRODUCT = [
-        mtopcard\ChinaMobileCard => [
-            30  => 7,
-            50  => 8,
-            100 => 9,
-            200 => 10,
-            300 => 11,
-            500 => 12,
-        ],
-        mtopcard\ChinaUnicomCard => [
-            30  => 13,
-            50  => 14,
-            100 => 15,
-            200 => 16,
-            300 => 17,
-            500 => 18,
-        ],
-        mtopcard\ChinaTelecomCard => [
-            30  => 19,
-            50  => 20,
-            100 => 21,
-            200 => 22,
-            300 => 23,
-            500 => 24,
-        ],
+
+    const operator = [
+        mtopcard\ChinaMobileCard  => 'yd',
+        mtopcard\ChinaUnicomCard  => 'lt',
+        mtopcard\ChinaTelecomCard => 'dx'
+    ];
+    const ERR_NOS = [
+        '5001','5002','5003','5004','5005','5008','5009','5010','5011','5012'
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;'];
+    const ProductIdS = [
+        mtopcard\ChinaMobileCard =>
+            [
+                30  => '101687',
+                50  => '101688',
+                100 => '101689',
+                200 => '101690',
+            ],
+        mtopcard\ChinaUnicomCard =>
+            [
+                30  => '101705',
+                50  => '101706',
+                100 => '101707',
+                200 => '101708',
+            ],
+        mtopcard\ChinaTelecomCard =>
+            [
+                30  => '101723',
+                50  => '101724',
+                100 => '101725',
+                200 => '101726',
+            ]
     ];
-    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
-    const ERRCODES = ['-10', '-12', '-13', '-14', '-15', '-16', '-18', '-21'];
 }

BIN
helper/refill/api/yl/ruixunda/云九一商品编码.docx


+ 35 - 0
helper/refill/api/yl/ruixunda/对接文档-yezi.txt

@@ -0,0 +1,35 @@
+登录名:椰林全国
+密码:yelin8765
+用户编码:10002505
+密钥:k2xkSaFr4BH5ZD5iDWf5Ha4QTE3fKtN5
+
+
+下游客户注册和登录地址:
+http://47.96.69.138:7080/
+
+api接口文档地址:
+https://www.showdoc.com.cn/AQL666666/
+
+话费下单地址:
+http://47.96.69.138:9086/onlinepay.do
+订单主动查询地址:
+http://47.96.69.138:9086/searchpay.do
+余额查询:
+http://47.96.69.138:9086/searchbalance.do
+
+
+101687	全国移动话费30元直充
+101688	全国移动话费50元直充
+101689	全国移动话费100元直充
+101690	全国移动话费200元直充
+
+101723	全国电信话费30元直充
+101724	全国电信话费50元直充
+101725	全国电信话费100元直充
+101726	全国电信话费200元直充
+
+101705	全国联通话费30元直充
+101706	全国联通话费50元直充
+101707	全国联通话费100元直充
+101708	全国联通话费200元直充
+

+ 0 - 37
helper/refill/api/yl/ruixunda/开户信息.txt

@@ -1,37 +0,0 @@
-后台地址:http://47.98.117.207:8888
-帐号:yelin7639
-密码:386751
-appId:G0sEOnF3jm
-appSecret:bbpZLlMcJChpNFgn
-后台-商品列表,可查看已配置商品信息
-后台-安全中心,可配置IP白名单
-接口文档:https://www.showdoc.com.cn/1686453783298366/7925312871840290
-话费直充接口:http://47.98.117.207:8911/api/hf/order/submit
-通用直充接口:http://47.98.117.207:8911/api/order/submit
-卡密提取接口:http://47.98.117.207:8911/api/card/get
-查询接口接口:http://47.98.117.207:8911/api/order/query
-余额查询接口:http://47.98.117.207:8911/api/account/balance
-
-全国移动编码
-全国移动30   7
-全国移动50   8
-全国移动100   9
-全国移动200   10
-全国移动300   11
-全国移动500   12
-
-全国联通编码
-全国联通30  13
-全国联通50  14
-全国联通100  15
-全国联通200  16
-全国联通300  17
-全国联通500  18
-
-全国电信编码
-全国电信30  19
-全国电信50  20
-全国电信100  21
-全国电信200  22
-全国电信300  23
-全国电信500  24