ソースを参照

xyz weixue provider huoshengguo_yd add dx 30-200

xiaoyu 2 年 前
コミット
039e135de6

+ 46 - 4
data/config/xyz/refill.ini.php

@@ -6178,19 +6178,23 @@ $huoshenguo_yd_phone = ['name' => 'huoshenguo_yd', 'store_id' => 234, 'qualitys'
 //        20 => [['goods_id' => 7936, 'price' => 19.7, 'quality' => 1, 'card_type' => 'chinamobile']],
         30 => [
             ['goods_id' => 7937, 'price' => 29.55, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7937, 'price' => 28.8, 'quality' => 1, 'card_type' => 'chinaunicom']
+            ['goods_id' => 7937, 'price' => 28.8, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7937, 'price' => 29.34, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         50 => [
             ['goods_id' => 7938, 'price' => 49.25, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7938, 'price' => 48, 'quality' => 1, 'card_type' => 'chinaunicom']
+            ['goods_id' => 7938, 'price' => 48, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7938, 'price' => 48.9, 'quality' => 1, 'card_type' => 'chinatelecom'],
         ],
         100 => [
             ['goods_id' => 7939, 'price' => 98.5, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7939, 'price' => 96, 'quality' => 1, 'card_type' => 'chinaunicom']
+            ['goods_id' => 7939, 'price' => 96, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7939, 'price' => 97.8, 'quality' => 1, 'card_type' => 'chinatelecom'],
         ],
         200 => [
             ['goods_id' => 7940, 'price' => 197, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7940, 'price' => 192, 'quality' => 1, 'card_type' => 'chinaunicom']
+            ['goods_id' => 7940, 'price' => 192, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7940, 'price' => 195.6, 'quality' => 1, 'card_type' => 'chinatelecom'],
         ],
 //        300 => [['goods_id' => 7941, 'price' => 295.5, 'quality' => 1, 'card_type' => 'chinamobile']],
 //        500 => [['goods_id' => 7942, 'price' => 492.5, 'quality' => 1, 'card_type' => 'chinamobile']]
@@ -6541,6 +6545,43 @@ $dazhanggui_phone = ['name' => 'dazhanggui', 'store_id' => 242, 'qualitys' => '1
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$weixue_phone = ['name' => 'weixue', 'store_id' => 243, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 8007, 'price' => 9.67, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8007, 'price' => 9.5, 'quality' => 1, 'card_type' => 'chinaunicom']
+//        ],
+//        20 => [
+//            ['goods_id' => 8008, 'price' => 19.34, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8008, 'price' => 19, 'quality' => 1, 'card_type' => 'chinaunicom']
+//        ],
+        30 => [
+            ['goods_id' => 8009, 'price' => 29.01, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8009, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinaunicom']
+        ],
+        50 => [
+            ['goods_id' => 8010, 'price' => 48.35, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8010, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinaunicom']
+        ],
+        100 => [
+            ['goods_id' => 8011, 'price' => 96.7, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8011, 'price' => 95, 'quality' => 1, 'card_type' => 'chinaunicom']
+        ],
+        200 => [
+            ['goods_id' => 8012, 'price' => 193.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8012, 'price' => 190, 'quality' => 1, 'card_type' => 'chinaunicom']
+        ],
+//        300 => [
+//            ['goods_id' => 8013, 'price' => 290.1, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8013, 'price' => 285, 'quality' => 1, 'card_type' => 'chinaunicom']
+//        ],
+//        500 => [
+//            ['goods_id' => 8014, 'price' => 483.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8014, 'price' => 475, 'quality' => 1, 'card_type' => 'chinaunicom']
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -6740,6 +6781,7 @@ $phone_providers = [
     ['name' => 'ziyugui', 'cfg' => $ziyugui_phone],
     ['name' => 'guitong_yi', 'cfg' => $guitong_yi_phone],
     ['name' => 'dazhanggui', 'cfg' => $dazhanggui_phone],
+    ['name' => 'weixue', 'cfg' => $weixue_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 8 - 4
data/config/yl/refill.ini.php

@@ -6009,19 +6009,23 @@ $huoshenguo_yd_phone = ['name' => 'huoshenguo_yd', 'store_id' => 225, 'qualitys'
 //        20 => [['goods_id' => 7891, 'price' => 19.7, 'quality' => 1, 'card_type' => 'chinamobile']],
         30 => [
             ['goods_id' => 7892, 'price' => 29.55, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7892, 'price' => 28.8, 'quality' => 1, 'card_type' => 'chinaunicom']
+            ['goods_id' => 7892, 'price' => 28.8, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7892, 'price' => 29.34, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         50 => [
             ['goods_id' => 7893, 'price' => 49.25, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7893, 'price' => 48, 'quality' => 1, 'card_type' => 'chinaunicom']
+            ['goods_id' => 7893, 'price' => 48, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7893, 'price' => 48.9, 'quality' => 1, 'card_type' => 'chinatelecom'],
         ],
         100 => [
             ['goods_id' => 7894, 'price' => 98.5, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7894, 'price' => 96, 'quality' => 1, 'card_type' => 'chinaunicom']
+            ['goods_id' => 7894, 'price' => 96, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7894, 'price' => 97.8, 'quality' => 1, 'card_type' => 'chinatelecom'],
         ],
         200 => [
             ['goods_id' => 7895, 'price' => 197, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7895, 'price' => 192, 'quality' => 1, 'card_type' => 'chinaunicom']
+            ['goods_id' => 7895, 'price' => 192, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7895, 'price' => 195.6, 'quality' => 1, 'card_type' => 'chinatelecom'],
         ],
 //        300 => [['goods_id' => 7896, 'price' => 295.5, 'quality' => 1, 'card_type' => 'chinamobile']],
 //        500 => [['goods_id' => 7897, 'price' => 492.5, 'quality' => 1, 'card_type' => 'chinamobile']]

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

@@ -26,6 +26,12 @@ class config
             50  => 100144,
             100 => 100145,
             200 => 100146
+        ],
+        mtopcard\ChinaTelecomCard => [
+            30  => 100166,
+            50  => 100167,
+            100 => 100168,
+            200 => 100169
         ]
     ];
     const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];

+ 7 - 1
helper/refill/api/xyz/huoshenguo_yd/开户信息.txt

@@ -29,4 +29,10 @@ appSecret:hOFjXQWzRXilVAFu
 100143	网厅10分钟联通30
 100144	网厅10分钟联通50
 100145	网厅10分钟联通100
-100146	网厅10分钟联通200
+100146	网厅10分钟联通200
+
+2022.8.22
+100166  网厅10分钟电信30
+100167  网厅10分钟电信50
+100168  网厅10分钟电信100
+100169  网厅10分钟电信200

+ 48 - 0
helper/refill/api/xyz/weixue/RefillCallBack.php

@@ -0,0 +1,48 @@
+<?php
+namespace refill\weixue;
+
+require_once(BASE_HELPER_RAPI_PATH . '/weixue/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];
+        }
+    }
+}

+ 155 - 0
helper/refill/api/xyz/weixue/RefillPhone.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace refill\weixue;
+
+require_once(BASE_HELPER_RAPI_PATH . '/weixue/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $amount, $card_type, string $order_sn)
+    {
+        $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;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+
+        $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);
+    }
+}

+ 44 - 0
helper/refill/api/xyz/weixue/config.php

@@ -0,0 +1,44 @@
+<?php
+
+
+namespace refill\weixue;
+
+use mtopcard;
+class config
+{
+    //https://www.showdoc.com.cn/AQL666666/
+    const ORDER_URL = 'http://121.36.216.15:9086/onlinepay.do';
+    const QUERY_URL= 'http://121.36.216.15:9086/searchpay.do';
+    const BALANCE_URL = 'http://121.36.216.15:9086/searchbalance.do';
+
+    const USER_ID= '10002703';
+    const KEY = '4Y7z54TeXz8PdSWXy8wPGYcTXcfXpctn';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_weixue.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 =>
+            [
+                30  => '101687',
+                50  => '101688',
+                100 => '101689',
+                200 => '101690',
+            ],
+        mtopcard\ChinaUnicomCard =>
+            [
+                30  => '101705',
+                50  => '101706',
+                100 => '101707',
+                200 => '101708',
+            ],
+    ];
+}

+ 29 - 0
helper/refill/api/xyz/weixue/对接文档-yezi.txt

@@ -0,0 +1,29 @@
+下游客户注册和登录地址:
+http://121.36.216.15:7080/
+
+api接口文档地址:
+https://www.showdoc.com.cn/AQL666666/
+
+下单地址:
+http://121.36.216.15:9086/onlinepay.do
+余额查询:
+http://121.36.216.15:9086/searchbalance.do
+订单主动查询地址:
+http://121.36.216.15:9086/searchpay.do
+
+秘钥:4Y7z54TeXz8PdSWXy8wPGYcTXcfXpctn
+ID:10002703
+授信;20w
+账号:椰子
+密码:123456
+
+
+101687 全国移动话费30元直充
+101688 全国移动话费50元直充
+101689 全国移动话费100元直充
+101690 全国移动话费200元直充
+
+101705 全国联通话费30元直充
+101706 全国联通话费50元直充
+101707 全国联通话费100元直充
+101708 全国联通话费200元直充

+ 6 - 0
helper/refill/api/yl/huoshenguo_yd/config.php

@@ -26,6 +26,12 @@ class config
             50  => 100144,
             100 => 100145,
             200 => 100146
+        ],
+        mtopcard\ChinaTelecomCard => [
+            30  => 100166,
+            50  => 100167,
+            100 => 100168,
+            200 => 100169
         ]
     ];
     const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];

+ 4 - 0
mobile/callback/refill_weixue.php

@@ -0,0 +1,4 @@
+<?php
+
+refill\util::push_notify('weixue',$_POST);
+echo ('OK');

+ 14 - 0
test/TestRefill.php

@@ -2502,6 +2502,20 @@ class TestRefill extends TestCase
         $resp = $provider->notify($params);
     }
 
+    public function testWeixue()
+    {
+//        $provider = $this->getProvider('weixue');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(15811535608, 4, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '93321661135376151843']);
+
+        $body = '{"orderid":"GKN22082210298364442","sporderid":"93321661135376151843","userid":"10002703","merchantsubmittime":"20220822103250","resultno":"9","parvalue":"30","remark1":"","payno":"","fundbalance":"-29.01","sign":"550EDFC88E0B08B90EAE3E5DE3CDA62E"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('weixue','RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);