浏览代码

xyz yl feimingyu_high

xiaoyu 2 年之前
父节点
当前提交
aa8bb7d2a1

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

@@ -6804,6 +6804,19 @@ $dazhanggui_fs_phone = ['name' => 'dazhanggui_fs', 'store_id' => 248, 'qualitys'
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$feimingyu_high_phone = ['name' => 'feimingyu_high', 'store_id' => 249, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 8063, 'price' => 9.79, 'quality' => 1, 'card_type' => 'chinamobile']],
+        20 => [['goods_id' => 8064, 'price' => 19.58, 'quality' => 1, 'card_type' => 'chinamobile']],
+        30 => [['goods_id' => 8065, 'price' => 29.37, 'quality' => 1, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 8066, 'price' => 48.95, 'quality' => 1, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 8067, 'price' => 97.9, 'quality' => 1, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 8068, 'price' => 195.8, 'quality' => 1, 'card_type' => 'chinamobile']],
+        300 => [['goods_id' => 8069, 'price' => 293.7, 'quality' => 1, 'card_type' => 'chinamobile']],
+        500 => [['goods_id' => 8070, 'price' => 489.5, 'quality' => 1, 'card_type' => 'chinamobile']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -7009,6 +7022,7 @@ $phone_providers = [
     ['name' => 'yingdian_hf', 'cfg' => $yingdian_hf_phone],
     ['name' => 'bodian_yd', 'cfg' => $bodian_yd_phone],
     ['name' => 'dazhanggui_fs', 'cfg' => $dazhanggui_fs_phone],
+    ['name' => 'feimingyu_high', 'cfg' => $feimingyu_high_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

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

@@ -6523,6 +6523,19 @@ $dazhanggui_fs_phone = ['name' => 'dazhanggui_fs', 'store_id' => 238, 'qualitys'
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$feimingyu_high_phone = ['name' => 'feimingyu_high', 'store_id' => 239, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 7995, 'price' => 9.79, 'quality' => 1, 'card_type' => 'chinamobile']],
+        20 => [['goods_id' => 7996, 'price' => 19.58, 'quality' => 1, 'card_type' => 'chinamobile']],
+        30 => [['goods_id' => 7997, 'price' => 29.37, 'quality' => 1, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 7998, 'price' => 48.95, 'quality' => 1, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 7999, 'price' => 97.9, 'quality' => 1, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 8000, 'price' => 195.8, 'quality' => 1, 'card_type' => 'chinamobile']],
+        300 => [['goods_id' => 8001, 'price' => 293.7, 'quality' => 1, 'card_type' => 'chinamobile']],
+        500 => [['goods_id' => 8002, 'price' => 489.5, 'quality' => 1, 'card_type' => 'chinamobile']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -6722,6 +6735,7 @@ $phone_providers = [
     ['name' => 'dazhanggui_high', 'cfg' => $dazhanggui_high_phone],
     ['name' => 'yingdian_hf', 'cfg' => $yingdian_hf_phone],
     ['name' => 'dazhanggui_fs', 'cfg' => $dazhanggui_fs_phone],
+    ['name' => 'feimingyu_high', 'cfg' => $feimingyu_high_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

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

@@ -0,0 +1,48 @@
+<?php
+namespace refill\feimingyu_high;
+
+require_once(BASE_HELPER_RAPI_PATH . '/feimingyu_high/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')->getOrderInfo(['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];
+        }
+    }
+}

+ 155 - 0
helper/refill/api/xyz/feimingyu_high/RefillPhone.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace refill\feimingyu_high;
+
+require_once(BASE_HELPER_RAPI_PATH . '/feimingyu_high/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)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['productid'] = config::ProductIdS[$card_type][$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)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+
+        $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);
+    }
+}

+ 36 - 0
helper/refill/api/xyz/feimingyu_high/config.php

@@ -0,0 +1,36 @@
+<?php
+
+
+namespace refill\feimingyu_high;
+
+use mtopcard;
+class config
+{
+    //https://www.showdoc.com.cn/AQL666666/
+    const ORDER_URL = 'http://121.36.242.90:9086/onlinepay.do';
+    const QUERY_URL= 'http://121.36.242.90:9086/searchpay.do';
+    const BALANCE_URL = 'http://121.36.242.90:9086/searchbalance.do';
+
+    const USER_ID= '10002986';
+    const KEY = 'tbrdiE3MZC6BcN2MmHZMMrXhGkfWA6YH';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_feimingyu_high.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 =>
+        [
+            30  => '101687',
+            50  => '101688',
+            100 => '101689',
+            200 => '101690',
+        ],
+    ];
+}

+ 21 - 0
helper/refill/api/xyz/feimingyu_high/对接文档-yezi.txt

@@ -0,0 +1,21 @@
+账号:005
+88888888
+
+登录名:椰子高价移动
+用户编码:10002986
+密钥:tbrdiE3MZC6BcN2MmHZMMrXhGkfWA6YH
+客户注册和登录地址:http://121.36.242.90:7080/
+api接口文档地址:
+https://www.showdoc.com.cn/AQL666666/
+下单地址:
+http://121.36.242.90:9086/onlinepay.do
+余额查询:
+http://121.36.242.90:9086/searchbalance.do
+订单主动查询地址:
+http://121.36.242.90:9086/searchpay.do
+
+101687  全国移动话费30元直充
+101688  全国移动话费50元直充
+101689  全国移动话费100元直充
+101690  全国移动话费200元直充
+

+ 48 - 0
helper/refill/api/yl/feimingyu_high/RefillCallBack.php

@@ -0,0 +1,48 @@
+<?php
+namespace refill\feimingyu_high;
+
+require_once(BASE_HELPER_RAPI_PATH . '/feimingyu_high/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')->getOrderInfo(['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];
+        }
+    }
+}

+ 155 - 0
helper/refill/api/yl/feimingyu_high/RefillPhone.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace refill\feimingyu_high;
+
+require_once(BASE_HELPER_RAPI_PATH . '/feimingyu_high/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)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['productid'] = config::ProductIdS[$card_type][$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)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+
+        $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);
+    }
+}

+ 36 - 0
helper/refill/api/yl/feimingyu_high/config.php

@@ -0,0 +1,36 @@
+<?php
+
+
+namespace refill\feimingyu_high;
+
+use mtopcard;
+class config
+{
+    //https://www.showdoc.com.cn/AQL666666/
+    const ORDER_URL = 'http://121.36.242.90:9086/onlinepay.do';
+    const QUERY_URL= 'http://121.36.242.90:9086/searchpay.do';
+    const BALANCE_URL = 'http://121.36.242.90:9086/searchbalance.do';
+
+    const USER_ID= '10002987';
+    const KEY = 'FcWrDdZ4EzBZjEmfTjRijNbYKC3Bfwij';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_feimingyu_high.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 =>
+        [
+            30  => '101687',
+            50  => '101688',
+            100 => '101689',
+            200 => '101690',
+        ],
+    ];
+}

+ 21 - 0
helper/refill/api/yl/feimingyu_high/对接文档-yezi.txt

@@ -0,0 +1,21 @@
+账号:006
+88888888
+
+登录名:椰林高价移动
+用户编码:10002987
+密钥:FcWrDdZ4EzBZjEmfTjRijNbYKC3Bfwij
+客户注册和登录地址:http://121.36.242.90:7080/
+api接口文档地址:
+https://www.showdoc.com.cn/AQL666666/
+下单地址:
+http://121.36.242.90:9086/onlinepay.do
+余额查询:
+http://121.36.242.90:9086/searchbalance.do
+订单主动查询地址:
+http://121.36.242.90:9086/searchpay.do
+
+101687  全国移动话费30元直充
+101688  全国移动话费50元直充
+101689  全国移动话费100元直充
+101690  全国移动话费200元直充
+

+ 4 - 0
mobile/callback/refill_feimingyu_high.php

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

+ 14 - 0
test/TestRefill.php

@@ -2572,6 +2572,20 @@ class TestRefill extends TestCase
         $resp = $provider->notify($params);
     }
 
+    public function testFeiminyu_high()
+    {
+//        $provider = $this->getProvider('feimingyu_high');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(15811535608, 4, 30, ['order_sn' => $this->make_sn(), 'regin_no' =>18]);
+//        $resp = $provider->query(['order_sn' => '67901664179951146425']);
+
+        $body = '{"orderid":"EIE22092616129360743","sporderid":"67901664179951146425","userid":"10002986","merchantsubmittime":"20220926161235","resultno":"9","parvalue":"30","remark1":"","payno":"","fundbalance":"-29.37","sign":"1D0D706BBC7944A0D0275382CC6337F5"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('feimingyu_high', 'RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);

+ 6 - 0
test/TestRefillYl.php

@@ -842,4 +842,10 @@ class TestRefillYl extends TestCase
         $provider = $this->getProvider('dazhanggui_fs');
         $resp = $provider->balance();
     }
+
+    public function testFeimingyu_hign()
+    {
+        $provider = $this->getProvider('feimingyu_high');
+        $resp = $provider->balance();
+    }
 }