xiaoyu vor 3 Jahren
Ursprung
Commit
e9cec63b89

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

@@ -1743,6 +1743,19 @@ $kangkai_phone = ['name' => 'kangkai', 'store_id' => 98,'qualitys' => '5',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$lechong_phone = ['name' => 'lechong', 'store_id' => 99, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 6885, 'price' => 9.57, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6886, 'price' => 19.14, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6887, 'price' => 28.71, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6888, 'price' => 47.85, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6889, 'price' => 95.7, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6890, 'price' => 191.4, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6891, 'price' => 287.1, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6892, 'price' => 478.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],
@@ -1811,7 +1824,8 @@ $phone_providers = [
     ['name' => 'cangbukami', 'cfg' => $cangbukami_phone],
     ['name' => 'sialan', 'cfg' => $sialan_phone],
     ['name' => 'moxj_new', 'cfg' => $moxj_new_phone],
-    ['name' => 'kangkai', 'cfg' => $kangkai_phone]
+    ['name' => 'kangkai', 'cfg' => $kangkai_phone],
+    ['name' => 'lechong', 'cfg' => $lechong_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -1743,6 +1743,19 @@ $kangkai_phone = ['name' => 'kangkai', 'store_id' => 98,'qualitys' => '5',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$lechong_phone = ['name' => 'lechong', 'store_id' => 99, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 6885, 'price' => 9.57, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6886, 'price' => 19.14, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6887, 'price' => 28.71, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6888, 'price' => 47.85, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6889, 'price' => 95.7, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6890, 'price' => 191.4, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6891, 'price' => 287.1, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6892, 'price' => 478.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],
@@ -1811,7 +1824,8 @@ $phone_providers = [
     ['name' => 'cangbukami', 'cfg' => $cangbukami_phone],
     ['name' => 'sialan', 'cfg' => $sialan_phone],
     ['name' => 'moxj_new', 'cfg' => $moxj_new_phone],
-    ['name' => 'kangkai', 'cfg' => $kangkai_phone]
+    ['name' => 'kangkai', 'cfg' => $kangkai_phone],
+    ['name' => 'lechong', 'cfg' => $lechong_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -1743,6 +1743,19 @@ $kangkai_phone = ['name' => 'kangkai', 'store_id' => 98,'qualitys' => '5',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$lechong_phone = ['name' => 'lechong', 'store_id' => 99, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 6885, 'price' => 9.57, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6886, 'price' => 19.14, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6887, 'price' => 28.71, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6888, 'price' => 47.85, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6889, 'price' => 95.7, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6890, 'price' => 191.4, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6891, 'price' => 287.1, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6892, 'price' => 478.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],
@@ -1811,7 +1824,8 @@ $phone_providers = [
     ['name' => 'cangbukami', 'cfg' => $cangbukami_phone],
     ['name' => 'sialan', 'cfg' => $sialan_phone],
     ['name' => 'moxj_new', 'cfg' => $moxj_new_phone],
-    ['name' => 'kangkai', 'cfg' => $kangkai_phone]
+    ['name' => 'kangkai', 'cfg' => $kangkai_phone],
+    ['name' => 'lechong', 'cfg' => $lechong_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

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

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

+ 112 - 0
helper/refill/api/xyz/lechong/RefillPhone.php

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

+ 12 - 0
helper/refill/api/xyz/lechong/account.txt

@@ -0,0 +1,12 @@
+接口文档: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
+
+
+商户编号:202108021753
+秘钥:5BCE4762BC53B3EECB113A0285BF64DC

+ 37 - 0
helper/refill/api/xyz/lechong/config.php

@@ -0,0 +1,37 @@
+<?php
+
+
+namespace refill\lechong;
+
+use mtopcard;
+class config
+{
+    //957
+    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 AgentCode= '202108021753';
+    const KEY = '5BCE4762BC53B3EECB113A0285BF64DC';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_lechong.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => [
+            30 => 'HUAFEI_YIDONG_QUANGUO_30_DJ',
+            50 => 'HUAFEI_YIDONG_QUANGUO_50_DJ',
+            100 => 'HUAFEI_YIDONG_QUANGUO_100_DJ',
+            200 => 'HUAFEI_YIDONG_QUANGUO_200_DJ'
+        ],
+        mtopcard\ChinaUnicomCard  => [
+            30 => 'HUAFEI_LIANTONG_QUANGUO_30_DJ',
+            50 => 'HUAFEI_LIANTONG_QUANGUO_50_DJ',
+            100 => 'HUAFEI_LIANTONG_QUANGUO_100_DJ',
+            200 => 'HUAFEI_LIANTONG_QUANGUO_200_DJ'
+        ],
+        mtopcard\ChinaTelecomCard => [
+            30 => 'HUAFEI_DIANXIN_QUANGUO_30_DJ',
+            50 => 'HUAFEI_DIANXIN_QUANGUO_50_DJ',
+            100 => 'HUAFEI_DIANXIN_QUANGUO_100_DJ',
+            200 => 'HUAFEI_DIANXIN_QUANGUO_200_DJ'
+        ]
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+}

+ 4 - 0
mobile/callback/refill_lechong.php

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

+ 10 - 0
test/TestRefill.php

@@ -559,6 +559,16 @@ class TestRefill extends TestCase
         refill\RefillFactory::instance()->notify('kangkai', $params);
     }
 
+    public function testLechong()
+    {
+        $providers = new refill\lechong\RefillPhone([]);
+//        $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
+//        $resp = $providers->query(['order_sn' => '55641627902450221838']);
+        $body = '{"sellerid":"55641627902450221838","agentcode":"202108021753","account":"MTg1MDA2MDgzMzM=","value":"50","payvalue":"47.8500","voucher":"","createtime":"20210802190739","endtime":"20210802191008","state":"4","remark":"","time":"20210802191008","sign":"0e2d69318d03871d887debd498cc50f2"}';
+        $params = json_decode($body, true);
+        refill\RefillFactory::instance()->notify('lechong', $params);
+    }
+
     public function testAmingjd()
     {
 //        $providers = new refill\amingjd\RefillPhone([]);