Browse Source

lechong_high_sec

xiaoyu 2 năm trước cách đây
mục cha
commit
5c644aec76

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

@@ -8071,6 +8071,19 @@ $chuangyu_ylyw_phone = ['name' => 'chuangyu_ylyw', 'store_id' => 294, 'qualitys'
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$lechong_high_sec_phone = ['name' => 'lechong_high_sec', 'store_id' => 295, 'qualitys' => '1',
+    'amount' => [
+//        10 => [['goods_id' => 8438, 'price' => 9.7, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        20 => [['goods_id' => 8439, 'price' => 19.4, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        30 => [['goods_id' => 8440, 'price' => 29.1, 'quality' => 1, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 8441, 'price' => 50.1, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        100 => [['goods_id' => 8442, 'price' => 100.2, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        200 => [['goods_id' => 8443, 'price' => 200.4, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+//        300 => [['goods_id' => 8444, 'price' => 300, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+//        500 => [['goods_id' => 8445, 'price' => 500, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -8320,6 +8333,7 @@ $phone_providers = [
     ['name' => 'xinhengyang_fs', 'cfg' => $xinhengyang_fs_phone],
     ['name' => 'chuangyu_qdw', 'cfg' => $chuangyu_qdw_phone],
     ['name' => 'chuangyu_ylyw', 'cfg' => $chuangyu_ylyw_phone],
+    ['name' => 'lechong_high_sec', 'cfg' => $lechong_high_sec_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 51 - 0
helper/refill/api/xyz/lechong_high_sec/RefillCallBack.php

@@ -0,0 +1,51 @@
+<?php
+namespace refill\lechong_high_sec;
+
+require_once(BASE_HELPER_RAPI_PATH . '/lechong_high_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)
+    {
+        $agentcode = config::AgentCode;
+        $key = config::KEY;
+        $content = "{$params['sellerid']}{$agentcode}{$params['account']}{$params['value']}{$params['payvalue']}{$params['voucher']}{$params['createtime']}{$params['endtime']}";
+        $content .= "{$params['state']}{$params['remark']}{$params['time']}{$key}";
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['state']);
+        $order_sn = $params['sellerid'];
+        $order_info = Model('vr_order')->getOrderInfoForNotify(['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['voucher']) == 'null' ? '' : $params['voucher'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif (in_array($status, [4,-11])) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 141 - 0
helper/refill/api/xyz/lechong_high_sec/RefillPhone.php

@@ -0,0 +1,141 @@
+<?php
+
+namespace refill\lechong_high_sec;
+
+require_once(BASE_HELPER_RAPI_PATH . '/lechong_high_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, int $card_type, string $order_sn)
+    {
+        $params['agentcode'] = config::AgentCode;
+        $params['sellerid'] = $order_sn;
+        $params['account'] = base64_encode($phone);
+        $params['code'] = config::operator[$card_type][$amount];
+        $params['num'] = 1;
+        $params['value'] = $amount;
+        $params['notifyurl'] = config::NOTIFY_URL;
+        $params['remark'] = '';
+        $params['time'] = date("YmdHis");
+
+        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['code'])) {
+            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];
+            }
+            $recode = $resp['recode'];
+            if($recode == 's100') {
+                return [true, '', false];
+            } elseif (in_array($recode, ['s115', 's116'])) {
+                $net_errno = "HTTP-{$recode}";
+                return [false, $resp['msg'], true];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['agentcode'] = config::AgentCode;
+        $params['sellerid'] = $refill_info['order_sn'];
+        $params['time'] = date("YmdHis");
+        $key = config::KEY;
+        $body = "{$params['agentcode']}{$params['sellerid']}{$params['time']}{$key}";
+        $params['sign'] = md5($body);
+
+        $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['recode'] == 'q100') {
+                $state = intval($resp['state']);
+                if ($state === 2) {
+                    $updata['official_sn'] = $resp['voucher'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif (in_array($state,[4,-11])) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } else {
+                    $order_state = ORDER_STATE_SEND;
+                }
+                return [true, $order_state];
+            } elseif ($resp['recode'] == 'q106' && (time() - $refill_info['commit_time'] >= 600)){
+                return [true, ORDER_STATE_NOEXIST];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['agentcode'] = config::AgentCode;
+        $params['time'] = date("YmdHis");
+        $key = config::KEY;
+        $body = "{$params['agentcode']}{$params['time']}{$key}";
+        $params['sign'] = md5($body);
+
+        $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['recode'] == 'b100') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $agentcode = config::AgentCode;
+        $key = config::KEY;
+        $content = "{$agentcode}{$params['sellerid']}{$params['account']}{$params['code']}{$params['num']}{$params['value']}{$params['notifyurl']}{$params['remark']}";
+        $content .= "{$params['time']}{$key}";
+        return md5($content);
+    }
+}

+ 25 - 0
helper/refill/api/xyz/lechong_high_sec/account.txt

@@ -0,0 +1,25 @@
+接口文档:http://121.196.177.34/api/web/#/2
+
+登陆地址:http://121.196.177.34:1012/agent/login
+接口地址:http://121.196.177.34:1012/
+下单地址:http://121.196.177.34:1012/api/md5/submitorder
+余额查询地址:http://121.196.177.34:1012/api/md5/getbalance
+订单查询地址:http://121.196.177.34:1012/api/md5/queryorder
+注册地址:http://121.196.177.34:1012/agent/login
+
+
+商户编号:202302211710
+秘钥:C84F327E1BC81FBD8E4F0821B8FF0926
+
+账号:yezigj
+密码:123456
+http://121.196.177.34:1012/agent/login
+
+移动:
+HUAFEI_YIDONG_QUANGUO_50_ZC
+HUAFEI_YIDONG_QUANGUO_100_ZC
+HUAFEI_YIDONG_QUANGUO_200_ZC
+电信:
+HUAFEI_DIANXIN_QUANGUO_50_ZC
+HUAFEI_DIANXIN_QUANGUO_100_ZC
+HUAFEI_DIANXIN_QUANGUO_200_ZC

+ 30 - 0
helper/refill/api/xyz/lechong_high_sec/config.php

@@ -0,0 +1,30 @@
+<?php
+
+
+namespace refill\lechong_high_sec;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://121.196.177.34:1012/api/md5/submitorder';
+    const QUERY_URL= 'http://121.196.177.34:1012/api/md5/queryorder';
+    const BALANCE_URL= 'http://121.196.177.34:1012/api/md5/getbalance';
+
+    const AgentCode= '202302211710';
+    const KEY = 'C84F327E1BC81FBD8E4F0821B8FF0926';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_lechong_high_sec.php";
+
+    const operator = [
+        mtopcard\ChinaMobileCard  => [
+            50 => 'HUAFEI_YIDONG_QUANGUO_50_ZC',
+            100 => 'HUAFEI_YIDONG_QUANGUO_100_ZC',
+            200 => 'HUAFEI_YIDONG_QUANGUO_200_ZC',
+        ],
+        mtopcard\ChinaTelecomCard  => [
+            50 => 'HUAFEI_DIANXIN_QUANGUO_50_ZC',
+            100 => 'HUAFEI_DIANXIN_QUANGUO_100_ZC',
+            200 => 'HUAFEI_DIANXIN_QUANGUO_200_ZC',
+        ],
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+}

+ 4 - 0
mobile/callback/refill_lechong_high_sec.php

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

+ 6 - 0
test/TestRefill.php

@@ -3098,6 +3098,12 @@ class TestRefill extends TestCase
         $resp = $provider->balance();
     }
 
+    public function testLechong_high_sec()
+    {
+        $provider = $this->getProvider('lechong_high_sec');
+        $resp = $provider->balance();
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);