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

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

@@ -5110,6 +5110,51 @@ $ruizhi_tax_phone = ['name' => 'ruizhi_tax', 'store_id' => 202, 'qualitys' => '2
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$pengxinda_phone = ['name' => 'pengxinda', 'store_id' => 203,'qualitys' => '2',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 7706, 'price' => 10.37, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7706, 'price' => 10.37, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7706, 'price' => 10.37, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 7707, 'price' => 20.74, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7707, 'price' => 20.74, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7707, 'price' => 20.74, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+        30 => [
+//            ['goods_id' => 7708, 'price' => 31.11, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7708, 'price' => 31.11, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7708, 'price' => 31.11, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 7709, 'price' => 51.85, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7709, 'price' => 51.85, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7709, 'price' => 51.85, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7710, 'price' => 103.7, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7710, 'price' => 103.7, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7710, 'price' => 103.7, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7711, 'price' => 207.4, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7711, 'price' => 207.4, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7711, 'price' => 207.4, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 7712, 'price' => 311.1, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7712, 'price' => 311.1, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7712, 'price' => 311.1, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 7713, 'price' => 518.5, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7713, 'price' => 518.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7713, 'price' => 518.5, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -5274,6 +5319,7 @@ $phone_providers = [
     ['name' => 'hangtongyj', 'cfg' => $hangtongyj_phone],
     ['name' => 'ruixundaman', 'cfg' => $ruixundaman_phone],
     ['name' => 'ruizhi_tax', 'cfg' => $ruizhi_tax_phone],
+    ['name' => 'pengxinda', 'cfg' => $pengxinda_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 31 - 0
helper/refill/api/xyz/pengxinda/API信息.txt

@@ -0,0 +1,31 @@
+
+账号:beijingyz
+密码:yz12345
+秘钥:DA01B4249BA58CB8738A8BDA58A253E7
+
+查询地址:http://39.105.7.52:8081/api/products.jsp
+充值地址:http://39.105.7.52:8081/api/recharge.jsp
+余额地址:http://39.105.7.52:8081/api/balance.jsp
+
+后台地址:http://39.105.7.52:8081/member/login.jsp
+
+
+
+
+ 100250		移动话费全国50
+ 1002100	移动话费全国100	
+ 1002200	移动话费全国200	
+ 1002300	移动话费全国300	
+ 1002500	移动话费全国500	
+
+ 1200230	联通沃支付全国30	
+ 1200250	联通沃支付全国50	
+ 12002100	联通沃支付全国100	
+ 12002200	联通沃支付全国200	
+ 12002300	联通沃支付全国300
+
+ 1100250	电信电渠全国50	
+ 11002100 	电信电渠全国100	
+ 11002200 	电信电渠全国200	
+ 11002300 	电信电渠全国300	
+ 11002500 	电信电渠全国500

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

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

+ 133 - 0
helper/refill/api/xyz/pengxinda/RefillPhone.php

@@ -0,0 +1,133 @@
+<?php
+namespace refill\pengxinda;
+
+require_once(BASE_HELPER_RAPI_PATH . '/pengxinda/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)
+    {
+        $product_id = config::Product[$card_type][$amount];
+        if(empty($product_id)) return false;
+
+        $data['api_userid'] = config::API_USER_ID;
+        $data['product_id'] = $product_id;
+        $data['mobile'] = $phone;
+        $data['order_no'] = $order_sn;
+        $json_str = json_encode($data);
+
+        $params['api_userid'] = config::API_USER_ID;
+        $params['api_data'] = $this->encrypt($json_str);
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $input, &$net_errno = 0)
+    {
+        $params = $this->req_params($card_no, $card_type, $amount, $input['order_sn']);
+        if(empty($params)) {
+            return [false, '商品编号错误', false];
+        }
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, [], $net_errno);
+
+        if (empty($resp)) {
+            return [false, '系统错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            $ret_code = $resp['retcode'];
+
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($ret_code === 200) {
+                return [true, '', false];
+            } else {
+                return [false, $resp['retmsg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $data['api_userid'] = config::API_USER_ID;
+        $data['mobile'] = $refill_info['card_no'];
+        $data['order_no'] = $refill_info['order_sn'];
+        $json_str = json_encode($data);
+
+        $params['api_userid'] = config::API_USER_ID;
+        $params['api_data'] = $this->encrypt($json_str);
+
+        $resp = http_request(config::QUERY_URL, $params, 'POST');
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            }
+            else
+            {
+                $ret_code = $resp['retcode'];
+                if ($ret_code === 1) {
+                    $updata['official_sn'] = $resp['errcode'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($ret_code === 0) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($ret_code === 2) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $ret_code];
+                }
+                return [true, $order_state];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $data['api_userid'] = config::API_USER_ID;
+        $json_str = json_encode($data);
+
+        $params['api_userid'] = config::API_USER_ID;
+        $params['api_data'] = $this->encrypt($json_str);
+
+        $resp = http_request(config::BALANCE_URL, $params, 'POST');
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['retcode'] === 200) {
+                return [true, $resp['retmsg']];
+            } else {
+                return [false, $resp['retmsg']];
+            }
+        }
+    }
+
+    //加密
+    private function encrypt($encrypt)
+    {
+        $data = openssl_encrypt($encrypt, 'AES-128-ECB', hex2bin(config::KEY), OPENSSL_RAW_DATA, '');
+        return bin2hex($data);
+    }
+}

+ 39 - 0
helper/refill/api/xyz/pengxinda/config.php

@@ -0,0 +1,39 @@
+<?php
+namespace refill\pengxinda;
+
+use mtopcard;
+class config
+{
+    //回调地址需 上游配置
+    const ORDER_URL = 'http://39.105.7.52:8081/api/recharge.jsp';
+    const QUERY_URL = 'http://39.105.7.52:8081/api/recharge_result.jsp';
+    const BALANCE_URL = 'http://39.105.7.52:8081/api/balance.jsp';
+
+    const API_USER_ID = 'beijingyz';
+    const KEY = 'DA01B4249BA58CB8738A8BDA58A253E7';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_pengxinda.php";
+    const Product = [
+        mtopcard\ChinaMobileCard => [
+            50  => 100250,
+            100 => 1002100,
+            200 => 1002200,
+            300 => 1002300,
+            500 => 1002500
+        ],
+        mtopcard\ChinaUnicomCard => [
+            30  => 1200230,
+            50  => 1200250,
+            100 => 12002100,
+            200 => 12002200,
+            300 => 12002300
+        ],
+        mtopcard\ChinaTelecomCard => [
+            50  => 1100250,
+            100 => 11002100,
+            200 => 11002200,
+            300 => 11002300,
+            500 => 11002500
+        ],
+    ];
+}
+

BIN=BIN
helper/refill/api/xyz/pengxinda/接口说明2.3.docx


+ 4 - 0
mobile/callback/refill_mingxinda.php

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

+ 4 - 0
mobile/callback/refill_ruizhi_tax.php

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

+ 14 - 0
test/TestRefill.php

@@ -1993,6 +1993,20 @@ class TestRefill extends TestCase
         $resp = $provider->notify($params);
     }
 
+    public function testPengxinda()
+    {
+        $provider = $this->getProvider('pengxinda');
+//        $resp = $provider->balance();
+        $resp = $provider->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '29131646900654146357']);
+
+//        $body = '{"api_userid":"beijingyz","order_no":"29131646900654146357","retcode":"1","errcode":"100101101042203101624383157550"}';
+//        $params = json_decode($body, true);
+//        $provider = $this->getProvider('pengxinda','RefillCallBack');
+//        $ret = $provider->verify($params);
+//        $resp = $provider->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);