Browse Source

yl ruixunda_fs

xiaoyu 2 years ago
parent
commit
0377d08b11

+ 14 - 0
data/config/xyz/refill.ini.php

@@ -6945,6 +6945,19 @@ $feimingyu_middle_phone = ['name' => 'feimingyu_middle', 'store_id' => 253, 'qua
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$ruixunda_fs_phone = ['name' => 'ruixunda_fs', 'store_id' => 254, 'qualitys' => '1',
+    'amount' => [
+//        10 => [['goods_id' => 8103, 'price' => 9.99, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+//        20 => [['goods_id' => 8104, 'price' => 19.98, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        30 => [['goods_id' => 8105, 'price' => 29.97, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        50 => [['goods_id' => 8106, 'price' => 49.95, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        100 => [['goods_id' => 8107, 'price' => 99.9, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        200 => [['goods_id' => 8108, 'price' => 199.8, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+//        300 => [['goods_id' => 8109, 'price' => 299.7, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+//        500 => [['goods_id' => 8110, 'price' => 499.5, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -7155,6 +7168,7 @@ $phone_providers = [
     ['name' => 'jinfeng_fs', 'cfg' => $jinfeng_fs_phone],
     ['name' => 'douxun', 'cfg' => $douxun_phone],
     ['name' => 'feimingyu_middle', 'cfg' => $feimingyu_middle_phone],
+    ['name' => 'ruixunda_fs', 'cfg' => $ruixunda_fs_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 14 - 0
data/config/yl/refill.ini.php

@@ -6619,6 +6619,19 @@ $feimingyu_middle_phone = ['name' => 'feimingyu_middle', 'store_id' => 242, 'qua
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$ruixunda_fs_phone = ['name' => 'ruixunda_fs', 'store_id' => 243, 'qualitys' => '1',
+    'amount' => [
+//        10 => [['goods_id' => 8027, 'price' => 9.99, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+//        20 => [['goods_id' => 8028, 'price' => 19.98, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        30 => [['goods_id' => 8029, 'price' => 29.97, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        50 => [['goods_id' => 8030, 'price' => 49.95, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        100 => [['goods_id' => 8031, 'price' => 99.9, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        200 => [['goods_id' => 8032, 'price' => 199.8, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+//        300 => [['goods_id' => 8033, 'price' => 299.7, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+//        500 => [['goods_id' => 8034, 'price' => 499.5, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -6822,6 +6835,7 @@ $phone_providers = [
     ['name' => 'jinfeng_fs', 'cfg' => $jinfeng_fs_phone],
     ['name' => 'douxun', 'cfg' => $douxun_phone],
     ['name' => 'feimingyu_middle', 'cfg' => $feimingyu_middle_phone],
+    ['name' => 'ruixunda_fs', 'cfg' => $ruixunda_fs_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 48 - 0
helper/refill/api/yl/ruixunda_fs/RefillCallBack.php

@@ -0,0 +1,48 @@
+<?php
+namespace refill\ruixunda_fs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/ruixunda_fs/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $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['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 === 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 === 9) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 173 - 0
helper/refill/api/yl/ruixunda_fs/RefillPhone.php

@@ -0,0 +1,173 @@
+<?php
+
+namespace refill\ruixunda_fs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/ruixunda_fs/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    public function goods($quality,int $amount,int $card_type,$regin_no,$other)
+    {
+        [$goods_id, $price] = parent::goods($quality,$amount,$card_type,$regin_no,$other);
+        if($goods_id <= 0) return [0,0];
+        $key = "{$card_type}-{$amount}-{$regin_no}";
+        $price = config::Price[$key];
+        if(empty($price)) {
+            Log::record("channel cannot find price where name={$this->mName}, goods_id = {$goods_id} card_type={$card_type} amount={$amount} regin_no={$regin_no}",Log::ERR);
+            return [0,0];
+        } else {
+            return [$goods_id,ncPriceFormat($price)];
+        }
+    }
+
+    private function req_params(int $phone, int $amount, $card_type, string $order_sn, $regin_no)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['productid'] = config::ProductIdS[$card_type][$regin_no][$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;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $regin_no = $params['regin_no'] ?? -1;
+        if($regin_no <= 0) {
+            return [false, '省份获取错误', false];
+        }
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn, $regin_no);
+
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
+
+        if (empty($resp)) {
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误', 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 {
+                //未知结果码
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resultno, true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $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);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp))
+            {
+                return [false, '网络错误'];
+            }
+            else
+            {
+                $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 ($resultno === '9') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($resultno, ['0','2'], true)) {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] > 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resultno];
+                }
+
+                return [true, $order_state];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $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);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['resultno'] === '1') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['resultno']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $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));
+    }
+
+    public function xmlToArray($xml)
+    {
+        $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);
+    }
+}

+ 88 - 0
helper/refill/api/yl/ruixunda_fs/config.php

@@ -0,0 +1,88 @@
+<?php
+
+
+namespace refill\ruixunda_fs;
+
+use mtopcard;
+class config
+{
+    //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 USER_ID= '10002704';
+    const KEY = 'YHXcbY3XeZ7p6hGa7YkYtYjiwmNARakp';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_ruixunda_fs.php";
+
+    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 => [
+            //贵州
+            24 => [
+                30  => 32384,
+                50  => 32385,
+                100 => 32386,
+                200 => 323627,
+            ],
+            //江苏
+            10 => [
+                30  => 331116,
+                50  => 331117,
+                100 => 331118,
+                200 => 30000000790,
+            ],
+            //山东
+            15 => [
+                30  => 3622,
+                50  => 3623,
+                100 => 3624,
+                200 => 36578,
+            ],
+        ],
+        mtopcard\ChinaTelecomCard => [
+            //湖南
+            18 => [
+                30  => 274329,
+                50  => 274330,
+                100 => 274331,
+                200 => 274591,
+            ],
+            //广东
+            19 => [
+                30  => 267294,
+                50  => 267295,
+                100 => 267296,
+                200 => 267582,
+            ],
+            //上海
+            9 => [
+                30  => 266289,
+                50  => 266290,
+                100 => 266291,
+                200 => 266580,
+            ],
+        ],
+    ];
+
+    //key格式 卡类型-面值-regin_no
+    const Price = [
+        //移动
+        "4-30-24" => 27.9, "4-50-24" => 46.5, "4-100-24" => 93, "4-200-24" => 186,//贵州 24
+        "4-30-10" => 28.5, "4-50-10" => 47.5, "4-100-10" => 95, "4-200-10" => 190,//江苏 10
+        "4-30-15" => 28.5, "4-50-15" => 47.5, "4-100-15" => 95, "4-200-15" => 190,//山东 15
+
+        //电信
+        "6-30-18" => 28.44, "6-50-18" => 47.4, "6-100-18" => 94.8, "6-200-18" => 189.6,//湖南 18
+        "6-30-19" => 28.5, "6-50-19" => 47.5, "6-100-19" => 95, "6-200-19" => 190,//广东 19
+        "6-30-9" => 28.44, "6-50-9" => 47.4, "6-100-9" => 94.8, "6-200-9" => 189.6,//上海 19
+    ];
+}

+ 49 - 0
helper/refill/api/yl/ruixunda_fs/对接文档-yezi.txt

@@ -0,0 +1,49 @@
+登录名:yelinfs7692
+密码:yl123456
+用户编码:10002704
+密钥:YHXcbY3XeZ7p6hGa7YkYtYjiwmNARakp
+
+
+下游客户注册和登录地址:
+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
+
+请记得配置以下的编码!!!:
+32384  贵州移动30元直充
+32385  贵州移动50元直充
+32386  贵州移动100元直充
+323627  贵州移动200元直充
+
+331116  江苏移动30元直充
+331117  江苏移动50元直充
+331118  江苏移动100元直充
+30000000790  江苏移动200元直充
+
+3622  山东移动30元直充
+3623  山东移动50元直充
+3624  山东移动100元直充
+36578  山东移动200元直充
+
+274329  湖南电信30元直充
+274330  湖南电信50元直充
+274331  湖南电信100元直充
+274591  湖南电信200元直充
+
+267294  广东电信30元直充
+267295  广东电信50元直充
+267296  广东电信100元直充
+267582  广东电信200元直充
+
+266289  上海电信30元直充
+266290  上海电信50元直充
+266291  上海电信100元直充
+266580  上海电信200元直充

+ 6 - 0
test/TestRefillYl.php

@@ -860,4 +860,10 @@ class TestRefillYl extends TestCase
         $provider = $this->getProvider('feimingyu_middle');
         $resp = $provider->balance();
     }
+
+    public function testRuixunda_fs()
+    {
+        $provider = $this->getProvider('ruixunda_fs');
+        $resp = $provider->balance();
+    }
 }