浏览代码

hongxudayz

haru haru 3 年之前
父节点
当前提交
a1c0a0dd12

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

@@ -1385,6 +1385,19 @@ $zhenqi1m_phone = ['name' => 'zhenqi1m', 'store_id' => 84, 'qualitys' => '2',
         200 => [['goods_id' => 6780, 'price' => 199.2, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
+
+$hongxudayz_phone = ['name' => 'hongxudayz', 'store_id' => 85, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 6781, 'price' => 9.92, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6782, 'price' => 19.84, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6783, 'price' => 29.76, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6784, 'price' => 49.6, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6785, 'price' => 99.2, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6786, 'price' => 198.4, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6787, 'price' => 297.6, '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'];
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1442,6 +1455,7 @@ $phone_providers = [
     ['name' => 'zhenqi', 'cfg' => $zhenqi_phone],
     ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone],
     ['name' => 'zhenqi1m', 'cfg' => $zhenqi1m_phone],
+    ['name' => 'hongxudayz', 'cfg' => $hongxudayz_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -1385,6 +1385,19 @@ $zhenqi1m_phone = ['name' => 'zhenqi1m', 'store_id' => 84, 'qualitys' => '2',
         200 => [['goods_id' => 6780, 'price' => 199.2, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
+
+$hongxudayz_phone = ['name' => 'hongxudayz', 'store_id' => 85, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 6781, 'price' => 9.92, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6782, 'price' => 19.84, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6783, 'price' => 29.76, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6784, 'price' => 49.6, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6785, 'price' => 99.2, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6786, 'price' => 198.4, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6787, 'price' => 297.6, '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'];
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1442,6 +1455,7 @@ $phone_providers = [
     ['name' => 'zhenqi', 'cfg' => $zhenqi_phone],
     ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone],
     ['name' => 'zhenqi1m', 'cfg' => $zhenqi1m_phone],
+    ['name' => 'hongxudayz', 'cfg' => $hongxudayz_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -1385,6 +1385,19 @@ $zhenqi1m_phone = ['name' => 'zhenqi1m', 'store_id' => 84, 'qualitys' => '2',
         200 => [['goods_id' => 6780, 'price' => 199.2, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
+
+$hongxudayz_phone = ['name' => 'hongxudayz', 'store_id' => 85, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 6781, 'price' => 9.92, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6782, 'price' => 19.84, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6783, 'price' => 29.76, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6784, 'price' => 49.6, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6785, 'price' => 99.2, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6786, 'price' => 198.4, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6787, 'price' => 297.6, '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'];
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1442,6 +1455,7 @@ $phone_providers = [
     ['name' => 'zhenqi', 'cfg' => $zhenqi_phone],
     ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone],
     ['name' => 'zhenqi1m', 'cfg' => $zhenqi1m_phone],
+    ['name' => 'hongxudayz', 'cfg' => $hongxudayz_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -0,0 +1,51 @@
+<?php
+namespace refill\hongxudayz;
+
+require_once(BASE_HELPER_RAPI_PATH . '/hongxudayz/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/hongxudayz/RefillPhone.php

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

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

@@ -0,0 +1,16 @@
+<?php
+
+
+namespace refill\hongxudayz;
+
+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= 'yzhfcz';
+    const KEY = '05375eae5804db4515e1bd0ff0adfe10';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_hongxudayz.php";
+    const PRICE = 0.992;
+    const ExtHeaders = ['charset=utf-8'];
+}

+ 11 - 0
helper/refill/api/xyz/hongxudayz/泓旭达对接信息.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&

+ 7 - 0
mobile/callback/refill_hongxudayz.php

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

+ 10 - 0
test/TestRefill.php

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