Ver código fonte

椰子:恒耶是2号

lowkeyman 11 meses atrás
pai
commit
33426565ca

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

@@ -11150,6 +11150,35 @@ $huifen_fast_sec_phone = ['name' => 'huifen_fast_sec', 'store_id' => 410, 'quali
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$hengyeshi_sec_phone = ['name' => 'hengyeshi_sec', 'store_id' => 411, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 9248, 'price' => 10, 'quality' => 1, 'card_type' => 'chinamobile'],
+//        ],
+//        20 => [
+//            ['goods_id' => 9249, 'price' => 20, 'quality' => 1, 'card_type' => 'chinamobile'],
+//        ],
+//        30 => [
+//            ['goods_id' => 9250, 'price' => 30, 'quality' => 1, 'card_type' => 'chinamobile'],
+//        ],
+        50 => [
+            ['goods_id' => 9251, 'price' => 48.75, 'quality' => 1, 'card_type' => 'chinamobile'],
+        ],
+        100 => [
+            ['goods_id' => 9252, 'price' => 97.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+        ],
+        200 => [
+            ['goods_id' => 9253, 'price' => 195, 'quality' => 1, 'card_type' => 'chinamobile'],
+        ],
+//        300 => [
+//            ['goods_id' => 9254, 'price' => 300, 'quality' => 1, 'card_type' => 'chinamobile'],
+//        ],
+//        500 => [
+//            ['goods_id' => 9255, 'price' => 500, 'quality' => 1, 'card_type' => 'chinamobile'],
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_p hone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -11478,6 +11507,7 @@ $phone_providers = [
     ['name' => 'ruizhi_tax_yj', 'cfg' => $ruizhi_tax_yj_phone],
     ['name' => 'kachong_sec', 'cfg' => $kachong_sec_phone],
     ['name' => 'huifen_fast_sec', 'cfg' => $huifen_fast_sec_phone],
+    ['name' => 'hengyeshi_sec', 'cfg' => $hengyeshi_sec_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 28 - 0
helper/refill/api/xyz/hengyeshi_sec/API.MD

@@ -0,0 +1,28 @@
+
+## 恒耶是2号
+
+### 账号信息
+- 后台登录地址:http://1.94.31.238:10060
+- 登录名:福庆顺全国2号
+- 初始密码:123456
+
+### 接口信息
+- 用户id:10002746
+- 密钥:Zz5SQ2Gw4bAhJ46fChSne3GwxS36Ccnk
+
+## 接口地址
+话费充值接口:http://1.94.31.238:9086/onlinepay.do
+订单查询接口:http://1.94.31.238:9086/searchpay.do
+账户余额查询接口:http://1.94.31.238:9086/searchbalance.do
+
+## 店铺账号
+- 账号:hengyeshi_sec
+- 密码:hengyeshi_sec67890
+
+## 编码
+30000000909 全国移动50元直充
+30000000910 全国移动100元直充
+30000000911 全国移动200元直充
+
+## 折扣
+97.5

BIN
helper/refill/api/xyz/hengyeshi_sec/API.doc


+ 52 - 0
helper/refill/api/xyz/hengyeshi_sec/RefillCallBack.php

@@ -0,0 +1,52 @@
+<?php
+namespace refill\hengyeshi_sec;
+
+require_once(BASE_HELPER_RAPI_PATH . '/hengyeshi_sec/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): string
+    {
+        $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): array
+    {
+        $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) {
+            $official_sn = $params['remark1'] ?? '';
+            $ch_trade_no = $params['orderid'] ?? '';
+            Model('refill_order')->edit($order_id, ['official_sn' => $official_sn, 'ch_trade_no' => $ch_trade_no]);
+            return [$order_id, true, false, true, $official_sn];
+        } elseif ($status === 9) {
+            $ch_trade_no = $params['orderid'] ?? '';
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no]);
+            return [$order_id, false, true, true, ''];
+        } else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

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

@@ -0,0 +1,155 @@
+<?php
+
+namespace refill\hengyeshi_sec;
+
+require_once(BASE_HELPER_RAPI_PATH . '/hengyeshi_sec/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): array
+    {
+        $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): array
+    {
+        $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): array
+    {
+        $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'] = 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
+            {
+                $official_sn = $resp['remark1'] ?? '';
+                $ch_trade_no = $resp['orderid'] ?? '';
+
+                $resultno = $resp['resultno'];
+                if ($resultno === '1') {
+                    Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $official_sn,'ch_trade_no' => $ch_trade_no]);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($resultno === '9') {
+                    Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $ch_trade_no]);
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] > 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    $order_state = ORDER_STATE_SEND;
+                }
+
+                return [true, $order_state, $official_sn];
+            }
+        }
+    }
+
+    public function balance(): array
+    {
+        $params['userid'] = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&key={$key}";
+        $params['sign'] = 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): string
+    {
+        $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 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);
+    }
+}

+ 38 - 0
helper/refill/api/xyz/hengyeshi_sec/config.php

@@ -0,0 +1,38 @@
+<?php
+
+
+namespace refill\hengyeshi_sec;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://1.94.31.238:9086/onlinepay.do';
+    const QUERY_URL= 'http://1.94.31.238:9086/searchpay.do';
+    const BALANCE_URL= 'http://1.94.31.238:9086/searchbalance.do';
+    const USER_ID= '10002746';
+    const KEY = 'Zz5SQ2Gw4bAhJ46fChSne3GwxS36Ccnk';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_hengyeshi_sec.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', '7001'
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;'];
+
+    const ProductIdS = [
+        mtopcard\ChinaMobileCard => [
+            50 => '30000000909',
+            100 => '30000000910',
+            200 => '30000000911'
+        ],
+        mtopcard\ChinaUnicomCard => [
+
+        ],
+        mtopcard\ChinaTelecomCard => [
+
+        ],
+    ];
+}

+ 4 - 0
mobile/callback/refill_hengyeshi_sec.php

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

+ 6 - 0
test/TestRefill.php

@@ -6130,6 +6130,12 @@ class TestRefill extends TestCase
         $provider = $this->getProvider('gudelake');
         $resp = $provider->balance();
     }
+
+    public function testhengyeshi_sec()
+    {
+        $provider = $this->getProvider('hengyeshi_sec');
+        $resp = $provider->balance();
+    }
 }