xiaoyu 3 rokov pred
rodič
commit
64fa9ec8a1

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

@@ -2867,6 +2867,19 @@ $linzhu_phone = ['name' => 'linzhu', 'store_id' => 144,'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$fangxing_phone = ['name' => 'fangxing', 'store_id' => 145, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 7243, 'price' => 9.68, 'quality' => 2, 'card_type' => 'chinamobile']],
+        20 => [['goods_id' => 7244, 'price' => 19.36, 'quality' => 2, 'card_type' => 'chinamobile']],
+        30 => [['goods_id' => 7245, 'price' => 29.04, 'quality' => 2, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 7246, 'price' => 48.4, 'quality' => 2, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 7247, 'price' => 96.8, 'quality' => 2, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 7248, 'price' => 193.6, 'quality' => 2, 'card_type' => 'chinamobile']],
+        300 => [['goods_id' => 7249, 'price' => 290.4, 'quality' => 2, 'card_type' => 'chinamobile']],
+        500 => [['goods_id' => 7250, 'price' => 484, 'quality' => 2, 'card_type' => 'chinamobile']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],

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

@@ -2867,6 +2867,19 @@ $linzhu_phone = ['name' => 'linzhu', 'store_id' => 144,'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$fangxing_phone = ['name' => 'fangxing', 'store_id' => 145, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 7243, 'price' => 9.68, 'quality' => 2, 'card_type' => 'chinamobile']],
+        20 => [['goods_id' => 7244, 'price' => 19.36, 'quality' => 2, 'card_type' => 'chinamobile']],
+        30 => [['goods_id' => 7245, 'price' => 29.04, 'quality' => 2, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 7246, 'price' => 48.4, 'quality' => 2, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 7247, 'price' => 96.8, 'quality' => 2, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 7248, 'price' => 193.6, 'quality' => 2, 'card_type' => 'chinamobile']],
+        300 => [['goods_id' => 7249, 'price' => 290.4, 'quality' => 2, 'card_type' => 'chinamobile']],
+        500 => [['goods_id' => 7250, 'price' => 484, 'quality' => 2, 'card_type' => 'chinamobile']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],

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

@@ -2867,6 +2867,19 @@ $linzhu_phone = ['name' => 'linzhu', 'store_id' => 144,'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$fangxing_phone = ['name' => 'fangxing', 'store_id' => 145, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 7243, 'price' => 9.68, 'quality' => 2, 'card_type' => 'chinamobile']],
+        20 => [['goods_id' => 7244, 'price' => 19.36, 'quality' => 2, 'card_type' => 'chinamobile']],
+        30 => [['goods_id' => 7245, 'price' => 29.04, 'quality' => 2, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 7246, 'price' => 48.4, 'quality' => 2, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 7247, 'price' => 96.8, 'quality' => 2, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 7248, 'price' => 193.6, 'quality' => 2, 'card_type' => 'chinamobile']],
+        300 => [['goods_id' => 7249, 'price' => 290.4, 'quality' => 2, 'card_type' => 'chinamobile']],
+        500 => [['goods_id' => 7250, 'price' => 484, 'quality' => 2, 'card_type' => 'chinamobile']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],

+ 47 - 0
helper/refill/api/xyz/fangxing/RefillCallBack.php

@@ -0,0 +1,47 @@
+<?php
+
+
+namespace refill\fangxing;
+
+require_once(BASE_HELPER_RAPI_PATH . '/fangxing/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)
+    {
+        $content = $params['orderId'] . $params['transNo'] . $params['respCode'] . config::APP_SECRET;
+        return strtoupper(md5($content));
+    }
+
+
+    public function notify($params)
+    {
+        $status = $params['respCode'];
+        $order_sn = $params['transNo'];
+        $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 === '10003') {
+            return [$order_id, true, false, true];
+        } elseif ($status === '10002') {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 132 - 0
helper/refill/api/xyz/fangxing/RefillPhone.php

@@ -0,0 +1,132 @@
+<?php
+
+namespace refill\fangxing;
+
+require_once(BASE_HELPER_RAPI_PATH . '/fangxing/config.php');
+
+use refill;
+use Log;
+use QueueClient;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $amount, string $order_sn)
+    {
+        $params['appKey'] = config::APP_KEY;
+        $params['ts'] = date("YmdHis").$this->get_millisecond();
+        $params['phoneNo'] = $phone;
+        $params['prodCode'] = $amount;
+        $params['prodId'] = '1';
+        $params['range'] = '0';
+        $params['backUrl'] = config::NOTIFY_URL;
+        $params['transNo'] = $order_sn;
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $order_id = $params['order_id'];
+        $params = $this->req_params($card_no, $amount, $params['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 = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($resp['respCode'] === '10001' || $resp['respCode'] === '10005') {
+                return [true, $resp['orderId'], false];
+            } elseif ($resp['respCode'] === '10003') {
+                QueueClient::async_push("QueryRefillState",['order_id' => $order_id],5);
+                return [true, $resp['orderId'], false];
+            } else {
+                return [false, $resp['respMsg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['appKey'] = config::APP_KEY;
+        $params['ts'] = date("YmdHis").$this->get_millisecond();
+        $params['orderId'] = $refill_info['order_sn'];
+        $appSecret = config::APP_SECRET;
+        $content = "appSecret={$appSecret}&orderId={$params['orderId']}&ts={$params['ts']}";
+        $params['sign'] = strtoupper(md5($content));
+
+        $resp = http_request(config::QUERY_URL, $params);
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['respCode'] === '10003') {
+                $order_state = ORDER_STATE_SUCCESS;
+            } elseif ($resp['respCode'] === '10002') {
+                $order_state = ORDER_STATE_CANCEL;
+            } elseif ($resp['respCode'] === '10001') {
+                $order_state = ORDER_STATE_SEND;
+            } else {
+                return [false, $resp['respMsg']];
+            }
+            return [true, $order_state];
+        }
+    }
+
+    public function balance()
+    {
+        $params['appKey'] = config::APP_KEY;
+        $params['ts'] = date("YmdHis").$this->get_millisecond();
+        $appSecret = config::APP_SECRET;
+        $content = "appSecret={$appSecret}&ts={$params['ts']}";
+        $params['sign'] = strtoupper(md5($content));
+
+        $resp = http_request(config::BALANCE_URL, $params);
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['respCode'] === '0000') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['respMsg']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $appSecret = config::APP_SECRET;
+        $content = "appSecret={$appSecret}&backUrl={$params['backUrl']}&phoneNo={$params['phoneNo']}&prodCode={$params['prodCode']}&prodId={$params['prodId']}&transNo={$params['transNo']}&ts={$params['ts']}";
+        return strtoupper(md5($content));
+    }
+
+    private function get_millisecond()
+    {
+        list($usec, $sec) = explode(" ", microtime());
+        return round($usec*1000);
+    }
+}

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

@@ -0,0 +1,15 @@
+<?php
+
+
+namespace refill\fangxing;
+
+class config
+{
+    const ORDER_URL = 'http://47.92.109.196/ht/order';
+    const QUERY_URL = 'http://47.92.109.196/ht/query';
+    const BALANCE_URL = 'http://47.92.109.196/ht/queryBalance';
+
+    const APP_KEY = 'bf708c9ff35f8b6eae12f2b088dcadc89c5755ff';
+    const APP_SECRET = '00ec6742c26efce3792dbc305cb870cdb1ad38b4';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_fangxing.php";
+}

BIN
helper/refill/api/xyz/fangxing/开发接口文档V1.2.4.pdf


+ 12 - 0
helper/refill/api/xyz/fangxing/账号.txt

@@ -0,0 +1,12 @@
+接口地址 http://47.92.109.196/ht/
+管理后台地址 
+http://47.92.161.74:8091/login_toLogin
+账号 guoyanflfs
+密码 123456
+备注:开发者密钥请至后台“用户中心-账户设置”输入支付密码后查看,支付密码默认为登录密码
+
+appKey:
+bf708c9ff35f8b6eae12f2b088dcadc89c5755ff
+
+secretKey:
+00ec6742c26efce3792dbc305cb870cdb1ad38b4

+ 4 - 0
mobile/callback/refill_fangxing.php

@@ -0,0 +1,4 @@
+<?php
+
+refill\util::push_notify('fangxing',$_POST);
+echo json_encode(['respCode' => '0000']);

+ 16 - 2
test/TestRefill.php

@@ -1233,6 +1233,20 @@ class TestRefill extends TestCase
         $data = $providers->notify($params);
     }
 
+    public function testFangxing()
+    {
+        $providers = $this->getProvider('fangxing');
+//        $resp = $providers->balance();
+//        $resp = $providers->add(13898167806, 4, 10, ['order_sn' => $this->make_sn(), 'order_id' => 111111]);
+        $resp = $providers->query(['order_sn' => '82581635239506988570']);
+
+        $body = '{"orderId":"O21102617115969210570","respCode":"10003","respMsg":"\u6210\u529f \u5bf9\u7aef\u6d41\u6c34\u53f7: 21102617611981771","sign":"013F54D5E415668D3E012BBDE9E4BF16","transNo":"82581635239506988570"}';
+        $params = json_decode($body, true);
+        $providers = $this->getProvider('fangxing','RefillCallBack');
+        $ret = $providers->verify($params);
+        $data = $providers->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $providers = new refill\amingjd\RefillPhone([]);
@@ -1440,10 +1454,10 @@ class TestRefill extends TestCase
     }
     public function testYunchonggong()
     {
-//        $providers = $this->getProvider('yunchonggong');
+        $providers = $this->getProvider('yunchonggong');
 //        $resp = $providers->balance();
 //        $resp = $providers->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
-//        $resp = $providers->query(['order_sn' => '59901635220132734124']);
+        $resp = $providers->query(['order_sn' => '59901635220132734124']);
 
         $body = '{"orderId":"211026114901000481","appId":"c4vuuOV43q","outOrderId":"59901635220132734124","sign":"4749539f129242a13f1f083dbc114f23","orderStatus":"3","completeTime":"20211026115027","orderDesc":"\u8ba2\u5355\u5931\u8d25"}';
         $params = json_decode($body, true);