瀏覽代碼

xyz yuewen_fs_gd

xiaoyu 2 年之前
父節點
當前提交
da9bfe9873

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

@@ -7522,6 +7522,19 @@ $feimingyu_fs_phone = ['name' => 'feimingyu_fs', 'store_id' => 280, 'qualitys' =
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$yuewen_fs_gd_phone = ['name' => 'yuewen_fs_gd', 'store_id' => 281, 'qualitys' => '1',
+    'amount' => [
+//        10 => [['goods_id' => 8333, 'price' => 9.4, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        20 => [['goods_id' => 8334, 'price' => 18.8, 'quality' => 1, 'card_type' => 'chinamobile']],
+        30 => [['goods_id' => 8335, 'price' => 28.2, 'quality' => 1, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 8336, 'price' => 47, 'quality' => 1, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 8337, 'price' => 94, 'quality' => 1, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 8338, 'price' => 188, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        300 => [['goods_id' => 8339, 'price' => 282, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        500 => [['goods_id' => 8340, 'price' => 470, 'quality' => 1, 'card_type' => 'chinamobile']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -7758,6 +7771,7 @@ $phone_providers = [
     ['name' => 'hanwei', 'cfg' => $hanwei_phone],
     ['name' => 'hanwei_fs', 'cfg' => $hanwei_fs_phone],
     ['name' => 'feimingyu_fs', 'cfg' => $feimingyu_fs_phone],
+    ['name' => 'yuewen_fs_gd', 'cfg' => $yuewen_fs_gd_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 48 - 0
helper/refill/api/xyz/yuewen_fs_gd/RefillCallBack.php

@@ -0,0 +1,48 @@
+<?php
+namespace refill\yuewen_fs_gd;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yuewen_fs_gd/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::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&orderid={$params['orderid']}&sporderid={$params['sporderid']}&merchantsubmittime={$params['merchantsubmittime']}";
+        $content .= "&resultno={$params['resultno']}&key={$key}";
+        return strtoupper(md5($content));
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['resultno']);
+        $order_sn = $params['sporderid'];
+        $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false,false];
+        }
+
+        $order_id = $order_info['order_id'];
+        if ($status === 1) {
+            $data['official_sn'] = strtolower($params['remark1']) == 'null' ? '' : $params['remark1'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true];
+        } elseif ($status === 9) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 162 - 0
helper/refill/api/xyz/yuewen_fs_gd/RefillPhone.php

@@ -0,0 +1,162 @@
+<?php
+
+namespace refill\yuewen_fs_gd;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yuewen_fs_gd/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, $card_type, string $order_sn, $regin_no)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['productid'] = config::ProductIdS[$card_type][$regin_no][$amount];
+        $params['price'] = $amount;
+        $params['num'] = 1;
+        $params['mobile'] = $phone;
+        $params['spordertime'] = date("YmdHis");
+        $params['sporderid'] = $order_sn;
+        $params['back_url'] = config::NOTIFY_URL;
+        $params['paytype'] = config::operator[$card_type];
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $regin_no = $params['regin_no'] ?? -1;
+        if($regin_no <= 0) {
+            return [false, '省份获取错误', false];
+        }
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn, $regin_no);
+        if(empty($params['productid'])) {
+            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 = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            }
+
+            $resultno = $resp['resultno'];
+            if (in_array($resultno, ['0', '2'], true)) {
+                return [true, $resp['orderid'], false];
+            } elseif (in_array($resultno, config::ERR_NOS, true)) {
+                return [false, $resultno, false];
+            } elseif ($resultno === '9999' || $resultno === '5006') {
+                $net_errno = "HTTP-{$resultno}";
+                return [false, $resultno, true];
+            } else {
+                //未知结果码
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resultno, true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['sporderid'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&sporderid={$params['sporderid']}&key={$key}";
+        $params['sign'] = strtoupper(md5($content));
+
+        $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp))
+            {
+                return [false, '网络错误'];
+            }
+            else
+            {
+                $resultno = $resp['resultno'];
+                if ($resultno === '1') {
+                    $updata['official_sn'] = $resp['remark1'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($resultno === '9') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($resultno, ['0','2'], true)) {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] > 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resultno];
+                }
+
+                return [true, $order_state];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['userid'] = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&key={$key}";
+        $params['sign'] = strtoupper(md5($content));
+
+        $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['resultno'] === '1') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['resultno']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&productid={$params['productid']}&price={$params['price']}&num={$params['num']}&mobile={$params['mobile']}&spordertime={$params['spordertime']}";
+        $content .= "&sporderid={$params['sporderid']}&key={$key}";
+        return strtoupper(md5($content));
+    }
+
+    public function xmlToArray($xml)
+    {
+        $replace_str = str_replace(' ','','encoding="gb2312"');
+        $xml = mb_convert_encoding($xml,"UTF-8","gb2312");
+        $xml = str_replace($replace_str, "encoding='utf-8'", $xml);
+        return refill\util::xmlToArray($xml);
+    }
+}

+ 46 - 0
helper/refill/api/xyz/yuewen_fs_gd/config.php

@@ -0,0 +1,46 @@
+<?php
+
+
+namespace refill\yuewen_fs_gd;
+
+use mtopcard;
+class config
+{
+    //https://www.showdoc.com.cn/AQL666666/
+    const ORDER_URL = 'http://123.60.5.158:9086/onlinepay.do';
+    const QUERY_URL= 'http://123.60.5.158:9086/searchpay.do';
+    const BALANCE_URL = 'http://123.60.5.158:9086/searchbalance.do';
+
+    const USER_ID= '10002723';
+    const KEY = 'y5izjYhZzbtZNAQEtaE2DfbhydtrwtKx';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yuewen_fs_gd.php";
+
+    const operator = [
+        mtopcard\ChinaMobileCard  => 'yd',
+        mtopcard\ChinaUnicomCard  => 'lt',
+        mtopcard\ChinaTelecomCard => 'dx'
+    ];
+    const ERR_NOS = [
+        '5001','5002','5003','5004','5005','5008','5009','5010','5011','5012'
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;'];
+    const ProductIdS = [
+        mtopcard\ChinaMobileCard =>
+        [
+            //广东
+            19 => [
+                50  => '3311',
+                100 => '3312',
+                200 => '10000000131',
+            ],
+        ],
+        mtopcard\ChinaUnicomCard =>
+        [
+
+        ],
+        mtopcard\ChinaTelecomCard =>
+        [
+
+        ]
+    ];
+}

+ 20 - 0
helper/refill/api/xyz/yuewen_fs_gd/对接文档-yezi.txt

@@ -0,0 +1,20 @@
+下游客户注册和登录地址:
+http://123.60.5.158:7080/
+账号:yeziguangdong
+密码:123456
+商户号:10002723
+秘钥:y5izjYhZzbtZNAQEtaE2DfbhydtrwtKx
+
+ api接口文档地址:
+https://www.showdoc.com.cn/AQL666666/
+
+话费下单地址:
+http://123.60.5.158:9086/onlinepay.do
+订单主动查询地址:
+http://123.60.5.158:9086/searchpay.do
+余额查询:
+http://123.60.5.158:9086/searchbalance.do
+
+3311	广东移动50元直充
+3312	广东移动100元直充
+10000000131	广东移动200元直充

+ 4 - 0
mobile/callback/refill_yuewen_fs_gd.php

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

+ 6 - 0
test/TestRefill.php

@@ -3000,6 +3000,12 @@ class TestRefill extends TestCase
         $resp = $provider->notify($params);
     }
 
+    public function testYuewen_fs_gd()
+    {
+        $provider = $this->getProvider('yuewen_fs_gd');
+        $resp = $provider->balance();
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);