浏览代码

hangtongyj ruixundaman

xiaoyu 3 年之前
父节点
当前提交
5b3a1d499b

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

@@ -5021,6 +5021,32 @@ $feimingyunew_phone = ['name' => 'feimingyunew', 'store_id' => 199, 'qualitys' =
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$hangtongyj_phone = ['name' => 'hangtongyj', 'store_id' => 200, 'qualitys' => '1',
+    'amount' => [
+//        10 => [['goods_id' => 7681, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        20 => [['goods_id' => 7682, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinamobile']],
+        30 => [['goods_id' => 7683, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 7684, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 7685, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 7686, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        300 => [['goods_id' => 7687, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        500 => [['goods_id' => 7688, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinamobile']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+$ruixundaman_phone = ['name' => 'ruixundaman', 'store_id' => 201, 'qualitys' => '5',
+    'amount' => [
+//        10 => [['goods_id' => 7689, 'price' => 8.95, 'quality' => 5, 'card_type' => 'chinaunicom']],
+//        20 => [['goods_id' => 7690, 'price' => 17.9, 'quality' => 5, 'card_type' => 'chinaunicom']],
+        30 => [['goods_id' => 7691, 'price' => 26.85, 'quality' => 5, 'card_type' => 'chinaunicom']],
+        50 => [['goods_id' => 7692, 'price' => 44.75, 'quality' => 5, 'card_type' => 'chinaunicom']],
+        100 => [['goods_id' => 7693, 'price' => 89.5, 'quality' => 5, 'card_type' => 'chinaunicom']],
+        200 => [['goods_id' => 7694, 'price' => 179, 'quality' => 5, 'card_type' => 'chinaunicom']],
+//        300 => [['goods_id' => 7695, 'price' => 268.5, 'quality' => 5, 'card_type' => 'chinaunicom']],
+//        500 => [['goods_id' => 7696, 'price' => 447.5, 'quality' => 5, 'card_type' => 'chinaunicom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -5182,6 +5208,9 @@ $phone_providers = [
     ['name' => 'ningying_normal', 'cfg' => $ningying_normal_phone],
     ['name' => 'yuanrun', 'cfg' => $yuanrun_phone],
     ['name' => 'feimingyunew', 'cfg' => $feimingyunew_phone],
+    ['name' => 'hangtongyj', 'cfg' => $hangtongyj_phone],
+    ['name' => 'ruixundaman', 'cfg' => $ruixundaman_phone],
+
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 15 - 1
helper/refill/api/xyz/bailian/config.php

@@ -26,9 +26,23 @@ class config
         ksort($params);
         $content = '';
         foreach ($params as $key => $value) {
-            $content .= "{$key}{$value}";
+            if(self::check_empty($value) === false) {
+                $content .= "{$key}{$value}";
+            }
         }
         $content .= config::KEY;
         return md5($content);
     }
+
+    public static function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
 }

+ 34 - 0
helper/refill/api/xyz/hangtongyj/RefillCallBack.php

@@ -0,0 +1,34 @@
+<?php
+namespace refill\hangtongyj;
+require_once(BASE_HELPER_RAPI_PATH . '/hangtongyj/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+       return true;
+    }
+
+    public function notify($params)
+    {
+        $status = $params['status'];
+        $order_sn = $params['otherNo'];
+
+        $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 === 'success') {
+            $data['official_sn'] = strtolower($params['ext']) == 'null' ? '' : $params['ext'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true];
+        } elseif ($status === 'fail') {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 136 - 0
helper/refill/api/xyz/hangtongyj/RefillPhone.php

@@ -0,0 +1,136 @@
+<?php
+
+namespace refill\hangtongyj;
+
+require_once(BASE_HELPER_RAPI_PATH . '/hangtongyj/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 $card_type, string $order_sn)
+    {
+        $params['account'] = config::ACCOUNT;
+        $params['otherNo'] = $order_sn;
+        $params['phone'] = $phone;
+        $params['ispCode'] = config::operator[$card_type];
+        $params['cbkUrl'] = config::NOTIFY_URL;
+        $params['timestamp'] = date("YmdHis");
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $params = $this->req_params($card_no, $card_type, $params['order_sn']);
+        $params['productCode'] = config::ProductIDS[$card_type][$amount];
+        if (empty($params['productCode'])) {
+            return [false, '产品编号错误', false];
+        }
+
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'GET', false, [], $net_errno);
+
+        if (empty($resp)) {
+            return [false, '系统错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp ,true);
+
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($resp['status'] === 'success') {
+                return [true, $resp['orderNo'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['account'] = config::ACCOUNT;
+        $params['otherNo'] = $refill_info['order_sn'];
+        $params['timestamp'] = date("YmdHis");
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::QUERY_URL, $params);
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            }
+            elseif ($resp['qstatus'] === 'success')
+            {
+                $result = $resp['result'];
+                $status = $result['status'];
+                if ($status === 'success') {
+                    $order_state = ORDER_STATE_SUCCESS;
+                    $save['official_sn'] = strtolower($result['ext']) == 'null' ? '' : $result['ext'];
+                    Model('refill_order')->edit($refill_info['order_id'], $save);
+                } elseif ($status === 'fail') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === 'ing') {
+                    $order_state = ORDER_STATE_SEND;
+                }
+                elseif ($status === 'non') {
+                    if( (time() - $refill_info['commit_time'] >=30) && (time() - $refill_info['commit_time'] < 10800) ) {
+                        $order_state = ORDER_STATE_NOEXIST;
+                    }else{
+                        $order_state = ORDER_STATE_SEND;
+                    }
+                }
+                else {
+                    return [false, $resp['msg']];
+                }
+
+                return [true, $order_state];
+            }
+            else
+            {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['account'] = config::ACCOUNT;
+        $params['timestamp'] = date("YmdHis");
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::BALANCE_URL, $params);
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            return [true, $resp['balance']];
+        }
+    }
+
+    private function sign($params)
+    {
+        $signature = [config::KEY, $params['timestamp'], config::ACCOUNT];
+        sort($signature, SORT_STRING);
+        $signature = implode($signature);
+        return sha1($signature);
+    }
+}

+ 29 - 0
helper/refill/api/xyz/hangtongyj/config.php

@@ -0,0 +1,29 @@
+<?php
+
+
+namespace refill\hangtongyj;
+use mtopcard;
+
+class config
+{
+    const ORDER_URL = 'http://47.108.161.207/flow-receiver/api/v2/recharge';
+    const QUERY_URL = 'http://47.108.161.207/flow-receiver/api/v2/query/single';
+    const BALANCE_URL = 'http://47.108.161.207/flow-receiver/api/v2/balance/query';
+    const NOTIFY_URL = BASE_SITE_URL . '/mobile/callback/refill_hangtongyj.php';
+
+    const ACCOUNT = 'yeziyj';
+    const KEY = 'b79ba40ae2924c779851178471958850';
+    const operator = [
+        mtopcard\ChinaMobileCard  => 'CMCC',
+        mtopcard\ChinaUnicomCard  => 'CUCC',
+        mtopcard\ChinaTelecomCard => 'CTCC'
+    ];
+    const ProductIDS = [
+        mtopcard\ChinaMobileCard => [
+            30 => 'CMCCALLr30sP00008',
+            50 => 'CMCCALLr50sP00009',
+            100 => 'CMCCALLr100sP00010',
+            200 => 'CMCCALLr200sP00011'
+        ]
+    ];
+}

+ 18 - 0
helper/refill/api/xyz/hangtongyj/椰子.txt

@@ -0,0 +1,18 @@
+账号	yeziyj
+
+密钥	b79ba40ae2924c779851178471958850
+
+
+下单地址
+http://47.108.161.207/flow-receiver/api/v2/recharge
+查询地址
+http://47.108.161.207/flow-receiver/api/v2/query/single
+余额查询地址
+http://47.108.161.207/flow-receiver/api/v2/balance/query
+
+
+移动溢价产品编码		面值
+CMCCALLr30sP00008		30
+CMCCALLr50sP00009		50
+CMCCALLr100sP00010		100
+CMCCALLr200sP00011		200

文件差异内容过多而无法显示
+ 159 - 0
helper/refill/api/xyz/hangtongyj/话费充值接口v2.doc


+ 67 - 0
helper/refill/api/xyz/ruixundaman/RefillCallBack.php

@@ -0,0 +1,67 @@
+<?php
+namespace refill\ruixundaman;
+
+require_once(BASE_HELPER_RAPI_PATH . '/ruixundaman/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    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;
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['orderStatus']);
+        $order_sn = $params['outOrderId'];
+        $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'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true];
+        } elseif ($status === 3) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

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

@@ -0,0 +1,155 @@
+<?php
+
+namespace refill\ruixundaman;
+
+require_once(BASE_HELPER_RAPI_PATH . '/ruixundaman/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, int $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();
+        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);
+        if(empty($params['itemId'])) {
+            return [false, '商品编号错误', false];
+        }
+        $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 = json_decode($resp, true);
+            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];
+            } else {
+                $net_errno = "HTTP-998";
+                return [false, $resp['msg'], 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);
+
+        $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            }
+            elseif ($resp['code'] === '00')
+            {
+                $status = $resp['orderStatus'];
+                if ($status === '2') {
+                    $updata['official_sn'] = $resp['ext1'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === '3') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === '1') {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($status === '4' && (time() - $refill_info['commit_time'] >= 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resp['msg']];
+                }
+                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);
+
+        $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function get_millisecond()
+    {
+        list($usec, $sec) = explode(" ", microtime());
+        return round($usec*1000);
+    }
+
+    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);
+    }
+}

+ 26 - 0
helper/refill/api/xyz/ruixundaman/config.php

@@ -0,0 +1,26 @@
+<?php
+
+
+namespace refill\ruixundaman;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://120.76.172.131:8911/api/hf/order/submit';
+    const QUERY_URL = 'http://120.76.172.131:8911/api/order/query';
+    const BALANCE_URL = 'http://120.76.172.131:8911/api/account/balance';
+
+    const APP_ID = '8tYeow0MYZ';
+    const APP_SECRET = 'BJpyvAXRxrJRMlnq';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_ruixundaman.php";
+
+    const PRODUCT = [
+        mtopcard\ChinaUnicomCard => [
+            50  => 100105,
+            100 => 100106,
+            200 => 100107,
+        ]
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERRCODES = ['-10', '-12', '-13', '-14', '-15', '-16', '-18', '-21'];
+}

+ 19 - 0
helper/refill/api/xyz/ruixundaman/开户信息.txt

@@ -0,0 +1,19 @@
+后台地址:http://120.76.172.131:8888
+帐号:yezimc123
+密码:457633
+二级密码:yTFW5577
+appId:8tYeow0MYZ
+appSecret:BJpyvAXRxrJRMlnq
+后台-商品列表,可查看已配置商品信息
+后台-安全中心,可配置IP白名单
+接口文档:https://www.showdoc.com.cn/1686453783298366/7925312871840290
+话费直充接口:http://120.76.172.131:8911/api/hf/order/submit
+通用直充接口:http://120.76.172.131:8911/api/order/submit
+卡密提取接口:http://120.76.172.131:8911/api/card/get
+查单接口接口:http://120.76.172.131:8911/api/order/query
+余额接口接口:http://120.76.172.131:8911/api/account/balance
+
+慢充编码:
+100105 慢充联通50
+100106 慢充联通100
+100107 慢充联通200

+ 8 - 0
mobile/callback/refill_hangtongyj.php

@@ -0,0 +1,8 @@
+<?php
+
+$content = $_SERVER['post_content'];
+
+$input = json_decode($content,true);
+refill\util::push_notify('hangtongyj',$input);
+
+echo ('SUCCESS');

+ 4 - 0
mobile/callback/refill_ruixundaman.php

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

+ 22 - 0
test/TestRefill.php

@@ -1951,6 +1951,28 @@ class TestRefill extends TestCase
         $resp = $provider->balance();
     }
 
+    public function testHangtongyj()
+    {
+        $provider = $this->getProvider('hangtongyj');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
+        $resp = $provider->query(['order_sn' => '13791646729519910878']);
+
+//        $body = '{"phone":"13699279618","orderNo":"F2203081623054678137","status":"fail","otherNo":"23351646727780199005","msg":"产品不存在","ext":null}';
+//        $params = json_decode($body, true);
+//        $provider = $this->getProvider('hangtongyj','RefillCallBack');
+//        $ret = $provider->verify($params);
+//        $resp = $provider->notify($params);
+    }
+
+    public function testRuixundaman()
+    {
+        $provider = $this->getProvider('ruixundaman');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
+        $resp = $provider->query(['order_sn' => '98441646796808890306']);
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);