diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java b/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java index 2fdbdef..bbb51f7 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java @@ -210,7 +210,7 @@ public class UserInfoService { userInfo.setSignature(Constants.DEFAULT_USER_SIGNATURE); } else { - userInfo.setAppleId(loginUserInfo.getAppleId()); +// userInfo.setAppleId(loginUserInfo.getAppleId()); userInfo.setLastUseDeviceId(loginUserInfo.getLastUseDeviceId()); userInfo.setLastUseDeviceBrand(loginUserInfo.getLastUseDeviceBrand()); userInfo.setLastLoginIp(loginUserInfo.getLastLoginIp()); diff --git a/luoo_user/src/main/java/com/luoo/user/service/WeChatAouth2Service.java b/luoo_user/src/main/java/com/luoo/user/service/WeChatAouth2Service.java index 6d15328..cf96675 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/WeChatAouth2Service.java +++ b/luoo_user/src/main/java/com/luoo/user/service/WeChatAouth2Service.java @@ -14,6 +14,7 @@ import com.luoo.user.pojo.UserInfo; import constants.Constants; import dto.UserLoginDto; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; import org.apache.http.Consts; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; @@ -106,6 +107,7 @@ public class WeChatAouth2Service { UserInfo userInfo = userInfoDao.findUserInfoByWxId(accessToken.getOpenid()); if(null == userInfo){ // 当前微信用户是新用户,需要先绑定手机号 + redisTemplate.opsForValue().set(loginReq.getCode(),accessToken.getOpenid(),10,TimeUnit.MINUTES); return Result.failed(StatusCode.WECHAT_MOBILE_UNBINDED); } UserInfo loginUserInfo = new UserInfo(); @@ -121,15 +123,16 @@ public class WeChatAouth2Service { public Result register(WeChatLoginReq loginReq,String ipAddress){ - Aouth2WeChatTokenResponse accessToken = getAccessToken(loginReq.getCode()); - if(accessToken == null || accessToken.getAccess_token() == null){ +// Aouth2WeChatTokenResponse accessToken = getAccessToken(loginReq.getCode()); + String openId = (String) redisTemplate.opsForValue().get(loginReq.getCode()); + if(StringUtils.isEmpty(openId)){ return Result.failed(StatusCode.WECHAT_lOGIN_FAILED); } // 如果当前手机号在数据库中存在,更新用户信息wxid,返回token UserInfo userInfo = userInfoDao.findByMobile(loginReq.getMobile()); if(null != userInfo) { - userInfo.setWxId(accessToken.getOpenid()); + userInfo.setWxId(openId); String token = userInfoService.wechatRegister(userInfo); return Result.success(token); } @@ -137,7 +140,7 @@ public class WeChatAouth2Service { // 如果当前手机号不存在,那就是新用户 UserInfo loginUserInfo = new UserInfo(); - loginUserInfo.setWxId(accessToken.getOpenid()); + loginUserInfo.setWxId(openId); loginUserInfo.setMobile(loginReq.getMobile()); loginUserInfo.setLastUseDeviceId(loginReq.getDeviceId()); loginUserInfo.setLastUseDeviceBrand(loginReq.getDeviceBrand());