diff --git a/application/api/controller/User.php b/application/api/controller/User.php index ce5e97242eb491fd239d37b917dadbce0272dd84..260b3272976e804c2e81e232fb86081dc0a54d96 100755 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -93,7 +93,7 @@ class User extends Common } // 授权 - $result = (new \base\AlipayAuth())->GetAuthSessionKey(MyC('common_app_mini_alipay_appid'), $this->data_post['authcode']); + $result = (new \base\Alipay())->GetAuthSessionKey(MyC('common_app_mini_alipay_appid'), $this->data_post['authcode']); if($result['status'] == 0) { // 先从数据库获取用户信息 @@ -243,7 +243,7 @@ class User extends Common */ public function BaiduUserAuth() { - $result = (new \base\BaiduAuth(MyC('common_app_mini_baidu_appid'), MyC('common_app_mini_baidu_appkey'), MyC('common_app_mini_baidu_appsecret')))->GetAuthSessionKey($this->data_post); + $result = (new \base\Baidu(MyC('common_app_mini_baidu_appid'), MyC('common_app_mini_baidu_appkey'), MyC('common_app_mini_baidu_appsecret')))->GetAuthSessionKey($this->data_post); if($result['status'] == 0) { // 先从数据库获取用户信息 @@ -296,7 +296,7 @@ class User extends Common $user = UserService::AppUserInfoHandle(null, 'baidu_openid', $this->data_post['openid']); if(empty($user)) { - $result = (new \base\BaiduAuth(MyC('common_app_mini_baidu_appid'), MyC('common_app_mini_baidu_appkey'), MyC('common_app_mini_baidu_appsecret')))->DecryptData($this->data_post['encrypted_data'], $this->data_post['iv'], $this->data_post['openid']); + $result = (new \base\Baidu(MyC('common_app_mini_baidu_appid'), MyC('common_app_mini_baidu_appkey'), MyC('common_app_mini_baidu_appsecret')))->DecryptData($this->data_post['encrypted_data'], $this->data_post['iv'], $this->data_post['openid']); if($result['status'] == 0 && !empty($result['data'])) { diff --git a/application/tags.php b/application/tags.php index 69e2a107dc99825fcfc20ea82c66e6cae481421e..326660071a743277387930d0da856084a274d4d9 100755 --- a/application/tags.php +++ b/application/tags.php @@ -32,20 +32,6 @@ return array ( 'log_write' => array ( ), - 'plugins_service_users_center_left_menu_handle' => - array ( - 0 => 'app\\plugins\\wallet\\Hook', - 1 => 'app\\plugins\\membershiplevelvip\\Hook', - 2 => 'app\\plugins\\coupon\\Hook', - 3 => 'app\\plugins\\distribution\\Hook', - ), - 'plugins_service_header_navigation_top_right_handle' => - array ( - 0 => 'app\\plugins\\wallet\\Hook', - 1 => 'app\\plugins\\membershiplevelvip\\Hook', - 2 => 'app\\plugins\\coupon\\Hook', - 3 => 'app\\plugins\\distribution\\Hook', - ), 'plugins_css' => array ( 0 => 'app\\plugins\\membershiplevelvip\\Hook', @@ -109,6 +95,18 @@ return array ( array ( 0 => 'app\\plugins\\membershiplevelvip\\Hook', ), + 'plugins_service_users_center_left_menu_handle' => + array ( + 0 => 'app\\plugins\\membershiplevelvip\\Hook', + 1 => 'app\\plugins\\coupon\\Hook', + 2 => 'app\\plugins\\distribution\\Hook', + ), + 'plugins_service_header_navigation_top_right_handle' => + array ( + 0 => 'app\\plugins\\membershiplevelvip\\Hook', + 1 => 'app\\plugins\\coupon\\Hook', + 2 => 'app\\plugins\\distribution\\Hook', + ), 'plugins_js' => array ( 0 => 'app\\plugins\\coupon\\Hook', diff --git a/extend/base/AlipayAuth.php b/extend/base/Alipay.php similarity index 82% rename from extend/base/AlipayAuth.php rename to extend/base/Alipay.php index 4a47c7685c0f274093bdccf8d1ea3c839e5b779c..866dc381768ee45f429c3637bb8a79d7ab6bd390 100755 --- a/extend/base/AlipayAuth.php +++ b/extend/base/Alipay.php @@ -11,11 +11,11 @@ namespace base; /** - * 支付宝授权驱动 + * 支付宝驱动 * @author Devil * @version V_1.0.0 */ -class AlipayAuth +class Alipay { /** * [__construct 构造方法] @@ -234,19 +234,44 @@ class AlipayAuth } /** - * [AlipayQrcodeCreate 小程序二维码创建] + * [MiniQrCodeCreate 小程序二维码创建] * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @datetime 2017-10-28T21:31:41+0800 - * @param [string] $query [生成小程序启动参数(如:type=page&page=shop&value=5)] - * @param [string] $describe [二维码描述(默认:ShopXO)] + * @param [string] $params['page'] [页面地址] + * @param [string] $params['scene'] [参数] */ - public function AlipayQrcodeCreate($query, $describe = 'ShopXO') + public function MiniQrCodeCreate($params) { // 请求参数 - $params = [ - 'app_id' => MyC('common_app_mini_alipay_appid'), + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'appid', + 'error_msg' => '小程序appid不能为空', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'page', + 'error_msg' => 'page地址不能为空', + ], + [ + 'checked_type' => 'length', + 'checked_data' => '1,32', + 'key_name' => 'scene', + 'error_msg' => 'scene参数 1~32 个字符之间', + ], + ]; + $ret = ParamsChecked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 请求参数 + $data = [ + 'app_id' => $params['appid'], 'method' => 'alipay.open.app.qrcode.create', 'charset' => 'utf-8', 'format' => 'JSON', @@ -255,30 +280,33 @@ class AlipayAuth 'version' => '1.0', ]; $biz_content = [ - 'url_param' => C('alipay_mini_default_page'), - 'query_param' => $query, - 'describe' => $describe, + 'url_param' => $params['page'], + 'query_param' => $params['scene'], + 'describe' => empty($params['describe']) ? 'ShopXO' : $params['describe'], ]; - $params['biz_content'] = json_encode($biz_content, JSON_UNESCAPED_UNICODE); + $data['biz_content'] = json_encode($biz_content, JSON_UNESCAPED_UNICODE); // 生成签名参数+签名 - $p = $this->GetParamSign($params); - $params['sign'] = $this->MyRsaSign($p['value']); + $p = $this->GetParamSign($data); + $data['sign'] = $this->MyRsaSign($p['value']); // 执行请求 - $result = $this->HttpRequest('https://openapi.alipay.com/gateway.do', $params); + $result = $this->HttpRequest('https://openapi.alipay.com/gateway.do', $data); // 结果正确则验证签名 并且 存储缓存返回access_token - if(!empty($result['alipay_open_app_qrcode_create_response']['code']) && $result['alipay_open_app_qrcode_create_response']['code'] == 10000) + $key = 'alipay_open_app_qrcode_create_response'; + if(!empty($result[$key]['code']) && $result[$key]['code'] == 10000) { // 验证签名正确则存储缓存返回数据 - if(!$this->SyncRsaVerify($result, 'alipay_open_app_qrcode_create_response')) + if(!$this->SyncRsaVerify($result, $key)) { - return false; + return DataReturn('签名错误', -1); } - return $result['alipay_open_app_qrcode_create_response']; + return DataReturn('获取成功', 0, $result[$key]); } - return false; + + $msg = isset($res['sub_msg']) ? $res['sub_msg'] : '获取二维码失败'; + return DataReturn($msg, -1); } } diff --git a/extend/base/BaiduAuth.php b/extend/base/Baidu.php similarity index 99% rename from extend/base/BaiduAuth.php rename to extend/base/Baidu.php index 28e1019143552e4ee8dfea4da6ebbc3064fc6ffc..5f679e616d810dd1a1181b81e81e0e3ccb256f11 100755 --- a/extend/base/BaiduAuth.php +++ b/extend/base/Baidu.php @@ -11,11 +11,11 @@ namespace base; /** - * 百度用户授权驱动 + * 百度驱动 * @author Devil * @version V_1.0.0 */ -class BaiduAuth +class Baidu { // appid private $_appid; diff --git a/extend/base/Wechat.php b/extend/base/Wechat.php index be07a8780e5523956ee96f6e3f898b86c4691e7e..2a6ec0d8162ebd08399cf124ecf4ff5b1a035c98 100755 --- a/extend/base/Wechat.php +++ b/extend/base/Wechat.php @@ -124,8 +124,9 @@ class Wechat * @blog http://gong.gg/ * @version 1.0.0 * @datetime 2018-01-02T19:53:10+0800 - * @param [array] $params [输入参数] - * @return [string] [成功返回文件流, 失败则空] + * @param [string] $params['page'] [页面地址] + * @param [string] $params['scene'] [参数] + * @return [string] [成功返回文件流, 失败则空] */ public function MiniQrCodeCreate($params) {