Explorar o código

Merge branch 'raccount' of 39.97.239.116:gyfl/xyzshop into raccount

xiaoyu %!s(int64=3) %!d(string=hai) anos
pai
achega
70d6b3bdc8

+ 15 - 1
data/config/win/refill.ini.php

@@ -2802,6 +2802,19 @@ $pushang_phone = ['name' => 'pushang', 'store_id' => 138, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$huafutong_phone = ['name' => 'huafutong', 'store_id' => 139, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 7195, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 7196, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 7197, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 7198, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 7199, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 7200, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 7201, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 7202, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2906,7 +2919,8 @@ $phone_providers = [
     ['name' => 'jinxin', 'cfg' => $jinxin_phone],
     ['name' => 'kachong', 'cfg' => $kachong_phone],
     ['name' => 'xingzy_normal', 'cfg' => $xingzy_normal_phone],
-    ['name' => 'pushang', 'cfg' => $pushang_phone]
+    ['name' => 'pushang', 'cfg' => $pushang_phone],
+    ['name' => 'huafutong', 'cfg' => $huafutong_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 15 - 1
data/config/xyz/refill.ini.php

@@ -2802,6 +2802,19 @@ $pushang_phone = ['name' => 'pushang', 'store_id' => 138, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$huafutong_phone = ['name' => 'huafutong', 'store_id' => 139, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 7195, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 7196, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 7197, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 7198, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 7199, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 7200, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 7201, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 7202, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2906,7 +2919,8 @@ $phone_providers = [
     ['name' => 'jinxin', 'cfg' => $jinxin_phone],
     ['name' => 'kachong', 'cfg' => $kachong_phone],
     ['name' => 'xingzy_normal', 'cfg' => $xingzy_normal_phone],
-    ['name' => 'pushang', 'cfg' => $pushang_phone]
+    ['name' => 'pushang', 'cfg' => $pushang_phone],
+    ['name' => 'huafutong', 'cfg' => $huafutong_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 15 - 1
data/config/xyzadm/refill.ini.php

@@ -2802,6 +2802,19 @@ $pushang_phone = ['name' => 'pushang', 'store_id' => 138, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$huafutong_phone = ['name' => 'huafutong', 'store_id' => 139, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 7195, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 7196, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 7197, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 7198, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 7199, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 7200, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 7201, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 7202, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2906,7 +2919,8 @@ $phone_providers = [
     ['name' => 'jinxin', 'cfg' => $jinxin_phone],
     ['name' => 'kachong', 'cfg' => $kachong_phone],
     ['name' => 'xingzy_normal', 'cfg' => $xingzy_normal_phone],
-    ['name' => 'pushang', 'cfg' => $pushang_phone]
+    ['name' => 'pushang', 'cfg' => $pushang_phone],
+    ['name' => 'huafutong', 'cfg' => $huafutong_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 60 - 0
helper/refill/api/xyz/dinghui/RefillCallBack.php

@@ -0,0 +1,60 @@
+<?php
+namespace refill\dinghui;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dinghui/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $res = $this->decrypt($params);
+        if ($res == 1) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function decrypt($params)
+    {
+        $sign = $params['sign'];
+        unset($params['sign']);
+        $content = '';
+        ksort($params);
+        foreach ($params as $key => $val){
+            $content .= "{$key}={$val}&";
+        }
+        $content = rtrim($content,'&');
+
+        return openssl_verify($content, hex2bin($sign), config::PUBLIC_KEY);
+    }
+
+    private function message_decrypt($message)
+    {
+        return json_decode(openssl_decrypt($message, 'AES-256-ECB', config::AES_KEY, 0, ''));
+    }
+
+
+    public function notify($params)
+    {
+        $data = $this->message_decrypt($params['message']);
+        $status = $data->charge_result;
+        $order_sn = $data->app_order_no;
+        $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') {
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 'FAILED') {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 137 - 0
helper/refill/api/xyz/dinghui/RefillPhone.php

@@ -0,0 +1,137 @@
+<?php
+
+namespace refill\dinghui;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dinghui/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    //统一请求
+    private function url_request($message, $method)
+    {
+        $params['msgtype'] = 'request_msg';
+        $params['format'] = 'json';
+        $params['version'] = '1.0';
+        $params['app_id'] = config::APP_ID;
+        $params['timestamp'] = $this->getMillisecond();
+        $params['method'] = $method;
+        $params['channel'] = 'wap';
+        $params['request_id'] = "REQ".$params['timestamp'];
+        $params['message'] = $message;
+
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $url = config::API_URL;
+        return http_request($url, $params, 'POST', false, [], $net_errno);
+    }
+
+    private function req_params(int $phone, int $card_type, int $amount, string $order_sn)
+    {
+        $params['goods_sku'] = config::SKU[$card_type][$amount];
+        $params['app_order_no'] = $order_sn;
+        $params['goods_count'] = 1;
+
+        $charge_params = [];
+        $charge_params = (object)$charge_params;
+        $charge_params->charge_account_number = "{$phone}";
+        $charge_params->charge_type = 0;
+        $charge_params->charge_account_type = 'MOBILE';
+        $charge_params->charge_account_os_type = '';
+
+        $params['charge_query_info'] = $charge_params;
+
+        $params['notify_url'] = config::NOTIFY_URL;
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $params = $this->req_params($card_no, $card_type, $amount, $params['order_sn']);
+
+        $message = $this->pub_message($params);
+        $resp = $this->url_request($message,'order.charge.query');
+
+        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'] === '000000') {
+                return [true, $resp['result']['trade_no'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['app_order_no'] = $refill_info['order_sn'];
+        $message = $this->pub_message($params);
+        $resp = $this->url_request($message,'order.charge.query');
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['code'] === '000000') {
+                $status = $resp['result']['charge_result'];
+                if ($status === 'SUCCESS') {
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 'FAILED') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === 'WAITTING') {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $content = '';
+        ksort($params);
+        foreach ($params as $key => $val){
+            $content .= "{$key}={$val}&";
+        }
+        $content = rtrim($content,'&');
+        $res = openssl_pkey_get_private(config::PRIVATE_KEY);
+        openssl_sign($content, $sign, $res);
+        return bin2hex($sign);
+    }
+
+    private function getMillisecond() {
+        list($t1, $t2) = explode(' ', microtime());
+        return (float)sprintf('%.0f',(floatval($t1)+floatval($t2))*1000);
+    }
+
+    private function pub_message($params): string
+    {
+        $encrypt = json_encode($params, JSON_UNESCAPED_SLASHES);
+        return openssl_encrypt($encrypt, 'AES-256-ECB', config::AES_KEY, 0, '');
+    }
+}

+ 71 - 0
helper/refill/api/xyz/dinghui/config.php

@@ -0,0 +1,71 @@
+<?php
+
+
+namespace refill\dinghui;
+
+use mtopcard;
+class config
+{
+    const API_URL = 'https://uat.dearvvip.cn/mini_shop/api2/common';
+
+    const APP_ID = 'yeziapi';
+    const AES_KEY = '4828917c7356f66109d21ee680000003';
+//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_dinghui.php";
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const ExtHeaders = ['Content-Type: application/json'];
+
+    const SKU = [
+        mtopcard\ChinaMobileCard => [
+
+        ],
+        mtopcard\ChinaUnicomCard => [
+            50 => 'YEZI_HF050',
+        ],
+        mtopcard\ChinaTelecomCard => [
+
+        ],
+    ];
+
+    const PUBLIC_KEY = <<<heredoc
+-----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mqZme4QUzYQ==
+-----END PRIVATE KEY-----
+heredoc;
+}

+ 46 - 0
helper/refill/api/xyz/huafutong/RefillCallBack.php

@@ -0,0 +1,46 @@
+<?php
+namespace refill\huafutong;
+
+require_once(BASE_HELPER_RAPI_PATH . '/huafutong/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        return true;
+    }
+
+    public function aes_decrypt($data)
+    {
+        $data = str_replace(' ','+',$data);
+        $data = base64_decode($data);
+        $data = openssl_decrypt($data, 'AES-128-CBC', config::UserKey, OPENSSL_NO_PADDING, config::aesIV);
+        return strstr($data,'}',true) . "}";
+    }
+
+    public function notify($params)
+    {
+        $decrypt = $this->aes_decrypt($params['PostData']);
+        $data = json_decode($decrypt, true);
+
+        $status = intval($data['Status']);
+        $order_sn = $data['OrderNo'];
+        $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 === 3) {
+            Model('refill_order')->edit($order_id, ['official_sn' => $data['OperatorSerialNumber']]);
+            return [$order_id, true, false,true];
+        }
+        elseif (in_array($status, [0, 2])) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 126 - 0
helper/refill/api/xyz/huafutong/RefillPhone.php

@@ -0,0 +1,126 @@
+<?php
+
+namespace refill\huafutong;
+
+require_once(BASE_HELPER_RAPI_PATH . '/huafutong/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, int $amount, string $order_sn)
+    {
+        $data['ChargeAccount'] = $phone;
+        $data['SupBuyNum'] = 1;
+        $data['ChargeValue'] = $amount;
+        $data['OrderType'] = 1;
+        $data['ChargeType'] = config::operator[$card_type];
+        $data['Id'] = $order_sn;
+
+        $params['mchid'] = config::MCH_ID;
+        $params['notifyurl'] = config::NOTIFY_URL;
+        $params['data'] = $this->aes_encrypt($data);
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $params = $this->req_params($card_no, $card_type, $amount, $params['order_sn']);
+
+        $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'] === 'success') {
+                return [true, $resp['data']['trans_sn'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['mchid'] = config::MCH_ID;
+        $params['order_id'] = $refill_info['order_sn'];
+        $params['time'] = time();
+        $content = "{$params['mchid']}{$params['order_id']}{$params['time']}".config::UserKey;
+        $params['sign'] =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 = json_decode($resp, true);
+
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            }
+            elseif (intval($resp['code']) === 3)
+            {
+                $status = intval($resp['data']['status']);
+                if ($status === 3) {
+                    Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $resp['data']['certificate']]);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif (in_array($status, [0, 2])) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === 1) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $status];
+                }
+
+                return [true, $order_state];
+            }
+            elseif (intval($resp['code']) === 2) {
+                return [true, ORDER_STATE_NOEXIST];
+            }
+            else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['mchid'] = config::MCH_ID;
+        $params['time'] = time();
+        $content = "{$params['mchid']}{$params['time']}".config::UserKey;
+        $params['sign'] =md5($content) ;
+
+        $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
+
+        Log::record($resp, Log::DEBUG);
+        $resp = json_decode($resp, true);
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        } elseif (intval($resp['code']) === 3) {
+            return [true, $resp['data']['money']];
+        } else {
+            return [false, $resp['msg']];
+        }
+    }
+
+    private function aes_encrypt($params): string
+    {
+        $encrypt = json_encode($params);
+        return base64_encode(openssl_encrypt($encrypt, 'AES-128-CBC', config::UserKey, OPENSSL_RAW_DATA, config::aesIV));
+    }
+}

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

@@ -0,0 +1,26 @@
+<?php
+
+
+namespace refill\huafutong;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://me.sd.7080.cn:8080/?c=pay&m=create';
+    const QUERY_URL= 'http://api.sd.7080.cn:8080/?m=querys&a=queryorder';
+    const BALANCE_URL = 'http://api.sd.7080.cn:8080/?m=querys&a=querymoney';
+
+    const MCH_ID = '189';
+    const UserKey = '5acedcdd7714bd5f';     #正式key
+//    const UserKey = 'de1b215bac0c1986';   #测试key
+
+    const aesIV = '1111111111111111';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_huafutong.php";
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+
+    const operator = [
+        mtopcard\ChinaMobileCard => 3,
+        mtopcard\ChinaUnicomCard => 1,
+        mtopcard\ChinaTelecomCard => 2
+    ];
+}

+ 6 - 0
helper/refill/api/xyz/huafutong/商户信息.txt

@@ -0,0 +1,6 @@
+后台登入地址:http://me.sd.7080.cn/
+登入账号:yezi
+登入密码:yezi123
+商户号ID: 189
+商户APIKEY秘钥: 5acedcdd7714bd5f
+安全码:yezi123

BIN=BIN
helper/refill/api/xyz/huafutong/对接文档new.docx


+ 47 - 0
helper/refill/api/xyz/shuoruan/RefillCallBack.php

@@ -0,0 +1,47 @@
+<?php
+namespace refill\shuoruan;
+
+require_once(BASE_HELPER_RAPI_PATH . '/shuoruan/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)
+    {
+        $key = config::KEY;
+        $content = "Orderid={$params['Orderid']}&Chargeid={$params['Chargeid']}&Orderstatu_int={$params['Orderstatu_int']}&Errorcode={$params['Errorcode']}&Password={$key}";
+        return md5($content);
+    }
+
+
+    public function notify($params)
+    {
+        $status = intval($params['Orderstatu_int']);
+        $order_sn = $params['Orderid'];
+        $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 (in_array($status, [11, 16])) {
+            return [$order_id, true, false,true];
+        }
+        elseif (in_array($status, [20, 21, 26])) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 129 - 0
helper/refill/api/xyz/shuoruan/RefillPhone.php

@@ -0,0 +1,129 @@
+<?php
+
+namespace refill\shuoruan;
+
+require_once(BASE_HELPER_RAPI_PATH . '/shuoruan/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    //统一请求
+    private function url_request($params, $action)
+    {
+        $params['action'] = $action;
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+        $params['agentAccount'] = config::ACCOUNT;
+        $params = json_encode($params);
+
+        $url = config::API_URL;
+        return http_post_data($url, $params, config::ExtHeaders, $net_errno);
+    }
+
+    private function req_params(int $phone,int $amount, string $order_sn)
+    {
+        $params['orderId'] = $order_sn;
+        $params['chargeAcct'] = $phone;
+        $params['chargeCash'] = $amount;
+        $params['chargeType'] = 0;
+        $params['retUrl'] = urlencode(config::NOTIFY_URL);
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $resp = $this->url_request($params,'CZ');
+
+        if (empty($resp)) {
+            return [false, '系统错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif (intval($resp['errorCode']) === 1) {
+                return [true, $resp['chargeId'], false];
+            } elseif (in_array($resp['errorCode'], [-992, -993, -994, -995, -996, -997, -998])) {
+                $net_errno = $resp['errorCode'];
+                return [false, $resp['errorDesc'], false];
+            } else {
+                return [false, $resp['errorDesc'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $resp = $this->url_request($refill_info['order_sn'],'CX');
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif (intval($resp['errorCode']) === 1) {
+                $status = $resp['orderStatuInt'];
+                if (in_array($status, [11, 16])) {
+                    $updata['official_sn'] = $resp['transo'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif (in_array($status, [20, 21, 26])) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($status, [0, 1, 2, 6])) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $resp['errorDesc']];
+                }
+                return [true, $order_state];
+            } elseif (intval($resp['errorCode']) === -201 && (time() - $refill_info['commit_time'] >= 180)) {
+                return [true, ORDER_STATE_NOEXIST];
+            } else {
+                return [false, $resp['errorDesc']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $resp = $this->url_request([],'YE');
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif (intval($resp['errorCode']) === 1) {
+                return [true, $resp['agentBalance']];
+            } else {
+                return [false, $resp['errorDesc']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $json_str = json_encode($params);
+        $content  = $json_str . config::KEY;
+        return md5($content);
+    }
+}

+ 15 - 0
helper/refill/api/xyz/shuoruan/config.php

@@ -0,0 +1,15 @@
+<?php
+
+
+namespace refill\shuoruan;
+
+
+class config
+{
+    const API_URL = 'http://api.sohan.hk:50080/API';
+
+    const ACCOUNT = '18600608333';
+    const KEY = '471D690CFB902BD8';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_shuoruan.php";
+    const ExtHeaders = ['Content-Type: application/json'];
+}

+ 7 - 0
helper/refill/api/xyz/shuoruan/北京椰子.txt

@@ -0,0 +1,7 @@
+密钥:471D690CFB902BD8
+账号:18600608333
+
+开发接口资料
+接口文档网址:http://apidoc.sy666.com/web/#/3
+接口订单提交地址:
+http://api.sohan.hk:50080/API

+ 6 - 0
mobile/callback/refill_huafutong.php

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

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 26 - 0
test/TestRefill.php


+ 1 - 1
test/TestSecurity.php

@@ -107,7 +107,7 @@ class TestAddData extends TestCase
         $ivlen = openssl_cipher_iv_length($cipher);
         $iv = self::zero_iv($ivlen);
         $key = '55668899';
-        $plaintext = openssl_decrypt($cipher_text, $cipher, $key, 0, $iv);;
+        $plaintext = openssl_decrypt($cipher_text, $cipher, $key, 0, $iv);
     }
 
     public function testSign()