Commit c33d7377 authored by jianghaiming's avatar jianghaiming

update:Set

parent 24847322
...@@ -30,7 +30,7 @@ class UserService ...@@ -30,7 +30,7 @@ class UserService
//需要授权微信 //需要授权微信
if (empty($openid)) { //if (empty($openid)) {
$appid = \Yaf\Registry::get('config')->wechat->appid; $appid = \Yaf\Registry::get('config')->wechat->appid;
$secret = \Yaf\Registry::get('config')->wechat->secret; $secret = \Yaf\Registry::get('config')->wechat->secret;
$grant_type = 'authorization_code'; $grant_type = 'authorization_code';
...@@ -52,10 +52,9 @@ class UserService ...@@ -52,10 +52,9 @@ class UserService
//throw new \Exception('获取openid失败:' . $response['errcode']); //throw new \Exception('获取openid失败:' . $response['errcode']);
throw new UserException(['cus' => 1]); throw new UserException(['cus' => 1]);
} }
//检查系统是已注册 //检查系统是已注册
$openid = !empty($response['openid']) ? $response['openid'] : ''; $openid = !empty($response['openid']) ? $response['openid'] : '';
} //}
$user = UserWechatBind::getRecord(['openid' => $openid]); $user = UserWechatBind::getRecord(['openid' => $openid]);
//如果系统不存在,用户信息,则注册新用户 //如果系统不存在,用户信息,则注册新用户
...@@ -79,6 +78,12 @@ class UserService ...@@ -79,6 +78,12 @@ class UserService
if (empty($user)) { if (empty($user)) {
throw new UserException(['cus' => 2]); throw new UserException(['cus' => 2]);
} }
$insert = [
'session_key' => !empty($response['session_key']) ? $response['session_key'] : '',
];
$newWechatId = UserWechatBind::save($insert,['openid' => $openid]);
} }
$user['third_session'] = self::generate3rdSession($openid); $user['third_session'] = self::generate3rdSession($openid);
...@@ -91,8 +96,7 @@ class UserService ...@@ -91,8 +96,7 @@ class UserService
$openid = !empty($params['openid']) ? $params['openid'] : ''; $openid = !empty($params['openid']) ? $params['openid'] : '';
$encryptedData = !empty($params['encryptedData']) ? urldecode($params['encryptedData']) : ''; $encryptedData = !empty($params['encryptedData']) ? urldecode($params['encryptedData']) : '';
$iv = !empty($params['iv']) ? urldecode($params['iv']) : ''; $iv = !empty($params['iv']) ? urldecode($params['iv']) : '';
$appid = \Yaf\Registry::get('config')->wechat->appid; $appid = \Yaf\Registry::get('config')->wechat->appid;
if (!$encryptedData) { if (!$encryptedData) {
...@@ -104,11 +108,8 @@ class UserService ...@@ -104,11 +108,8 @@ class UserService
} }
$userInfo = UserWechatBind::getRecord(['openid' => $openid]); $userInfo = UserWechatBind::getRecord(['openid' => $openid]);
$sessionKey = !empty($userInfo['session_key']) ? $userInfo['session_key'] : ''; $sessionKey = !empty($userInfo['session_key']) ? $userInfo['session_key'] : '';
$openid = isset($userInfo['openid']) && $userInfo['openid'] ? $userInfo['openid'] : ''; $openid = isset($userInfo['openid']) && $userInfo['openid'] ? $userInfo['openid'] : '';
if (empty($userInfo) || !$sessionKey || !$openid) { if (empty($userInfo) || !$sessionKey || !$openid) {
throw new UserException(['cus' => 5]); throw new UserException(['cus' => 5]);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment