Browse Source

hongxudagy

haru haru 3 years ago
parent
commit
3c2568529d

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

@@ -1398,6 +1398,19 @@ $hongxudayz_phone = ['name' => 'hongxudayz', 'store_id' => 85, 'qualitys' => '2'
         500 => [['goods_id' => 6788, 'price' => 496, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
         500 => [['goods_id' => 6788, 'price' => 496, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
     ],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
     'official_sn' => true, 'refill_type' => 'api'];
+
+$hongxudagy_phone = ['name' => 'hongxudagy', 'store_id' => 86, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 6789, 'price' => 9.92, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6790, 'price' => 19.84, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6791, 'price' => 29.76, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6792, 'price' => 49.6, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6793, 'price' => 99.2, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6794, 'price' => 198.4, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6795, 'price' => 297.6, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6796, 'price' => 496, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
 $phone_providers = [
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1455,7 +1468,8 @@ $phone_providers = [
     ['name' => 'zhenqi', 'cfg' => $zhenqi_phone],
     ['name' => 'zhenqi', 'cfg' => $zhenqi_phone],
     ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone],
     ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone],
     ['name' => 'zhenqi1m', 'cfg' => $zhenqi1m_phone],
     ['name' => 'zhenqi1m', 'cfg' => $zhenqi1m_phone],
-    ['name' => 'hongxudayz', 'cfg' => $hongxudayz_phone]
+    ['name' => 'hongxudayz', 'cfg' => $hongxudayz_phone],
+    ['name' => 'hongxudagy', 'cfg' => $hongxudagy_phone]
 ];
 ];
 $config['phone_providers'] = $phone_providers;
 $config['phone_providers'] = $phone_providers;
 
 

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

@@ -1398,6 +1398,19 @@ $hongxudayz_phone = ['name' => 'hongxudayz', 'store_id' => 85, 'qualitys' => '2'
         500 => [['goods_id' => 6788, 'price' => 496, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
         500 => [['goods_id' => 6788, 'price' => 496, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
     ],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
     'official_sn' => true, 'refill_type' => 'api'];
+
+$hongxudagy_phone = ['name' => 'hongxudagy', 'store_id' => 86, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 6789, 'price' => 9.92, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6790, 'price' => 19.84, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6791, 'price' => 29.76, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6792, 'price' => 49.6, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6793, 'price' => 99.2, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6794, 'price' => 198.4, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6795, 'price' => 297.6, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6796, 'price' => 496, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
 $phone_providers = [
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1455,7 +1468,8 @@ $phone_providers = [
     ['name' => 'zhenqi', 'cfg' => $zhenqi_phone],
     ['name' => 'zhenqi', 'cfg' => $zhenqi_phone],
     ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone],
     ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone],
     ['name' => 'zhenqi1m', 'cfg' => $zhenqi1m_phone],
     ['name' => 'zhenqi1m', 'cfg' => $zhenqi1m_phone],
-    ['name' => 'hongxudayz', 'cfg' => $hongxudayz_phone]
+    ['name' => 'hongxudayz', 'cfg' => $hongxudayz_phone],
+    ['name' => 'hongxudagy', 'cfg' => $hongxudagy_phone]
 ];
 ];
 $config['phone_providers'] = $phone_providers;
 $config['phone_providers'] = $phone_providers;
 
 

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

@@ -1398,6 +1398,19 @@ $hongxudayz_phone = ['name' => 'hongxudayz', 'store_id' => 85, 'qualitys' => '2'
         500 => [['goods_id' => 6788, 'price' => 496, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
         500 => [['goods_id' => 6788, 'price' => 496, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
     ],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
     'official_sn' => true, 'refill_type' => 'api'];
+
+$hongxudagy_phone = ['name' => 'hongxudagy', 'store_id' => 86, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 6789, 'price' => 9.92, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6790, 'price' => 19.84, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6791, 'price' => 29.76, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6792, 'price' => 49.6, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6793, 'price' => 99.2, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6794, 'price' => 198.4, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6795, 'price' => 297.6, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6796, 'price' => 496, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
 $phone_providers = [
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1455,7 +1468,8 @@ $phone_providers = [
     ['name' => 'zhenqi', 'cfg' => $zhenqi_phone],
     ['name' => 'zhenqi', 'cfg' => $zhenqi_phone],
     ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone],
     ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone],
     ['name' => 'zhenqi1m', 'cfg' => $zhenqi1m_phone],
     ['name' => 'zhenqi1m', 'cfg' => $zhenqi1m_phone],
-    ['name' => 'hongxudayz', 'cfg' => $hongxudayz_phone]
+    ['name' => 'hongxudayz', 'cfg' => $hongxudayz_phone],
+    ['name' => 'hongxudagy', 'cfg' => $hongxudagy_phone]
 ];
 ];
 $config['phone_providers'] = $phone_providers;
 $config['phone_providers'] = $phone_providers;
 
 

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

@@ -0,0 +1,51 @@
+<?php
+namespace refill\hongxudagy;
+
+require_once(BASE_HELPER_RAPI_PATH . '/hongxudagy/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)
+    {
+        $userid = config::MER_ID;
+        $key = config::KEY;
+        $content = "{$params['supply_id']}{$params['order_status']}{$userid}{$params['product_no']}{$params['mer_oid']}{$params['phone_no']}{$params['product_face']}";
+        $content .= $key;
+        return strtoupper(md5($content));
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['order_status']);
+        $order_sn = $params['mer_oid'];
+        $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 === 0) {
+            $data['official_sn'] = strtolower($params['cp_id']) == 'null' ? '' : $params['cp_id'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 3) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 123 - 0
helper/refill/api/xyz/hongxudagy/RefillPhone.php

@@ -0,0 +1,123 @@
+<?php
+
+namespace refill\hongxudagy;
+
+require_once(BASE_HELPER_RAPI_PATH . '/hongxudagy/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, string $order_sn)
+    {
+        $params['mer_id'] = config::MER_ID;
+        $params['mer_oid'] = $order_sn;
+        $params['product_face'] = $amount;
+        $params['product_num'] = 1;
+        $params['recharge_amount'] = $amount * config::PRICE;
+        $params['phone_no'] = $phone;
+        $params['notify_url'] = config::NOTIFY_URL;
+        $params['request_time'] = date("YmdHis");
+        $params['recharge_type'] = 0;
+        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, $order_sn);
+
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'GET', false, [], $net_errno);
+
+        if (empty($resp)) {
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            }else {
+                if ($resp['result'] == true && $resp['code'] == 100) {
+                    return [true, $resp['data']['supply_id'], false];
+                } else {
+                    return [false, $resp['msg'], false];
+                }
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['mer_oid'] = $refill_info['order_sn'];
+        $params['mer_id'] = config::MER_ID;
+        $params['tsp'] = date("YmdHis");
+        $content = "{$params['mer_oid']}{$params['mer_id']}{$params['tsp']}".config::KEY;
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::QUERY_URL, $params, 'GET', false, []);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp))
+            {
+                return [false, '网络错误'];
+            }
+            else
+            {
+                $code = $resp['code'];
+                if (in_array($code, [100, 101, 102, 103, 888])) {
+                    $order_status = intval($resp['data']['order_status']);
+                    if ($order_status === 0) {
+                        $updata['official_sn'] = $resp['data']['cp_id'];
+                        Model('refill_order')->edit($refill_info['order_id'], $updata);
+                        $order_state = ORDER_STATE_SUCCESS;
+                    } elseif ($order_status === 3) {
+                        $order_state = ORDER_STATE_CANCEL;
+                    } elseif (in_array($order_status, [1, 2])) {
+                        $order_state = ORDER_STATE_SEND;
+                    } else {
+                        return [false, $resp['msg']];
+                    }
+                    return [true, $order_state];
+                } elseif ($code === 258 && (time() - $refill_info['commit_time'] >= 600)) {
+                    return [true, ORDER_STATE_NOEXIST];
+                } else {
+                    return [false, $resp['msg']];
+                }
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::MER_ID;
+        $key = config::KEY;
+        $content = "{$userid}{$params['mer_oid']}{$params['product_face']}{$params['product_num']}{$params['recharge_amount']}{$params['phone_no']}{$params['notify_url']}";
+        $content .= "{$params['request_time']}{$params['recharge_type']}{$key}";
+        return md5($content);
+    }
+
+    public function xmlToArray($xml)
+    {
+        $replace_str = str_replace(' ','','encoding="gbk"');
+        $xml = mb_convert_encoding($xml,"UTF-8","gbk");
+        $xml = str_replace($replace_str, "encoding='utf-8'", $xml);
+        return json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
+    }
+}

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

@@ -0,0 +1,15 @@
+<?php
+
+
+namespace refill\hongxudagy;
+
+class config
+{
+    const ORDER_URL = 'http://8.134.12.246:8090/recieverOrder';
+    const QUERY_URL= 'http://8.134.12.246:8090/queryOrder';
+
+    const MER_ID= 'bjgyfl';
+    const KEY = '2b0c17cb64106110f53152fc5bf67896';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_hongxudagy.php";
+    const PRICE = 0.992;
+}

+ 11 - 0
helper/refill/api/xyz/hongxudagy/泓旭达对接信息.txt

@@ -0,0 +1,11 @@
+国研
+商户密匙:	2b0c17cb64106110f53152fc5bf67896
+商户编号:	bjgyfl
+http://8.134.12.246:8998/aportal/login.html
+账户:	guoyan  密码:1234qwer&
+
+椰子
+商户密匙:	05375eae5804db4515e1bd0ff0adfe10
+商户编号:	yzhfcz
+http://8.134.12.246:8998/aportal/login.html
+账号:yezihf   密码:1234qwer&

+ 0 - 1
helper/refill/api/xyz/hongxudayz/config.php

@@ -12,5 +12,4 @@ class config
     const KEY = '05375eae5804db4515e1bd0ff0adfe10';
     const KEY = '05375eae5804db4515e1bd0ff0adfe10';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_hongxudayz.php";
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_hongxudayz.php";
     const PRICE = 0.992;
     const PRICE = 0.992;
-    const ExtHeaders = ['charset=utf-8'];
 }
 }

+ 7 - 0
mobile/callback/refill_hongxudagy.php

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

+ 10 - 0
test/TestRefill.php

@@ -676,6 +676,16 @@ class TestRefill extends TestCase
         refill\RefillFactory::instance()->notify('hongxudayz',$input);
         refill\RefillFactory::instance()->notify('hongxudayz',$input);
     }
     }
 
 
+    public function testHongxudagy()
+    {
+        $providers = new refill\hongxudagy\RefillPhone([]);
+//        $resp = $providers->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $providers->query(['order_sn' => '86521626446475240639']);
+        $data = '{"sale_value":"29.76","supply_id":"18790079","order_status":"0","mer_oid":"86521626446475240639","phone_no":"18500608333","mer_id":"bjgyfl","sale_discount":"0.992","sign":"9BDA608364D4E08C653E8C6798151AC2","cp_id":"","product_no":"HFLTBJ_****00003000","product_face":"30","cp_ctype":""}';
+        $input = json_decode($data, true);
+        refill\RefillFactory::instance()->notify('hongxudagy',$input);
+    }
+
     public function testPrice()
     public function testPrice()
     {
     {
         $amounts = [10, 20, 30, 50, 100, 200, 300, 500];
         $amounts = [10, 20, 30, 50, 100, 200, 300, 500];