Commit c33d7377 authored by jianghaiming's avatar jianghaiming

update:Set

parent 24847322
......@@ -30,7 +30,7 @@ class UserService
//需要授权微信
if (empty($openid)) {
//if (empty($openid)) {
$appid = \Yaf\Registry::get('config')->wechat->appid;
$secret = \Yaf\Registry::get('config')->wechat->secret;
$grant_type = 'authorization_code';
......@@ -52,10 +52,9 @@ class UserService
//throw new \Exception('获取openid失败:' . $response['errcode']);
throw new UserException(['cus' => 1]);
}
//检查系统是已注册
$openid = !empty($response['openid']) ? $response['openid'] : '';
}
//}
$user = UserWechatBind::getRecord(['openid' => $openid]);
//如果系统不存在,用户信息,则注册新用户
......@@ -79,6 +78,12 @@ class UserService
if (empty($user)) {
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);
......@@ -92,7 +97,6 @@ class UserService
$openid = !empty($params['openid']) ? $params['openid'] : '';
$encryptedData = !empty($params['encryptedData']) ? urldecode($params['encryptedData']) : '';
$iv = !empty($params['iv']) ? urldecode($params['iv']) : '';
$appid = \Yaf\Registry::get('config')->wechat->appid;
if (!$encryptedData) {
......@@ -104,11 +108,8 @@ class UserService
}
$userInfo = UserWechatBind::getRecord(['openid' => $openid]);
$sessionKey = !empty($userInfo['session_key']) ? $userInfo['session_key'] : '';
$openid = isset($userInfo['openid']) && $userInfo['openid'] ? $userInfo['openid'] : '';
if (empty($userInfo) || !$sessionKey || !$openid) {
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