From 98b1a0affd69bbe63223c21fdd2c404e8bedfccb Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 20 五月 2020 17:25:08 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/div' into 2.1.2 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java | 94 +++++++++++++++++++++++++---------------------- 1 files changed, 50 insertions(+), 44 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java index 9b8bdc2..3b02d4f 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java @@ -141,8 +141,7 @@ } userInfo = getUserInfoByTaoBaoOpenId(appId, tbUserInfo.getOpenid()); // 鍒ゆ柇鐢ㄦ埛鏄惁琚垹闄� - if (userInfo != null && userInfo.getState() != null - && (userInfo.getState() != UserInfo.STATE_NORMAL)) + if (userInfo != null && userInfo.getState() != null && (userInfo.getState() != UserInfo.STATE_NORMAL)) userInfo = null; if (userInfo == null) {// 鍘熷厛鐨勮处鍙蜂笉瀛樺湪 userInfo = new UserInfo(); @@ -185,9 +184,7 @@ userInfo = getUserInfoByWXUnionId(appId, weiXinUser.getUnionid()); // 鍒ゆ柇鐢ㄦ埛鏄惁琚垹闄� - if (userInfo != null && userInfo.getState() != null - && (userInfo.getState() != UserInfo.STATE_NORMAL - )) + if (userInfo != null && userInfo.getState() != null && (userInfo.getState() != UserInfo.STATE_NORMAL)) userInfo = null; // 鐩存帴鐢ㄧ殑寰俊鐧诲綍 if (lastUser == null) { @@ -324,8 +321,7 @@ userInfo = getUserInfoByPhone(appId, phone); // 鍒ゆ柇鐢ㄦ埛鏄惁琚垹闄� - if (userInfo != null && userInfo.getState() != null - && (userInfo.getState() != UserInfo.STATE_NORMAL)) + if (userInfo != null && userInfo.getState() != null && (userInfo.getState() != UserInfo.STATE_NORMAL)) userInfo = null; if (userInfo == null) {// 鍘熷厛鐨勮处鍙蜂笉瀛樺湪 @@ -451,7 +447,6 @@ } } - /** * 鏍规嵁绯荤粺涓巙nionid瀵绘壘鐢ㄦ埛 * @@ -524,7 +519,7 @@ // 鍓旈櫎琚垹闄ゆ帀鐨勭敤鎴� for (int i = 0; i < list.size(); i++) { - if (list.get(i).getState() !=UserInfo.STATE_NORMAL) { + if (list.get(i).getState() != UserInfo.STATE_NORMAL) { list.remove(i); i--; } @@ -856,7 +851,6 @@ String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSLoginCount, phone); redisManager.removeCommonString(key); - // 閲囩敤redis浜嬪姟闃叉涓�涓墜鏈哄彿澶氭娉ㄥ唽闂 String watchKey = StringUtil.Md5("REGISTER:" + phone); Jedis jedis = jedisPool.getResource(); @@ -965,8 +959,8 @@ InputStream asInputStream = HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()); if (asInputStream != null) { FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, - String.format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(), - System.currentTimeMillis() + "")); + String.format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", + weiXinUser.getUnionid(), System.currentTimeMillis() + "")); if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) portrait = result.getUrl(); } else { @@ -1042,7 +1036,8 @@ UserInfo userInfo = userInfoMapper.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid()); if (userInfo == null) { - String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5("WXLogin:" + weiXinUser.getUnionid())); + String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, + StringUtil.Md5("WXLogin:" + weiXinUser.getUnionid())); redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(weiXinUser), 60 * 20); throw new UserAccountException(101, key); } @@ -1115,7 +1110,7 @@ } - @Transactional(rollbackFor=UserAccountException.class) + @Transactional(rollbackFor = UserAccountException.class) @Override public void bindWeiXin(AcceptData acceptData, Long uid, String code) throws UserAccountException { WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); @@ -1130,18 +1125,15 @@ } bindWeiXin(uid, weiXinUser); } - - - - - @Transactional(rollbackFor=UserAccountException.class) + + @Transactional(rollbackFor = UserAccountException.class) @Override - public void bindWeiXin(Long uid,WeiXinUser weiXinUser) throws UserAccountException { + public void bindWeiXin(Long uid, WeiXinUser weiXinUser) throws UserAccountException { UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid); if (user == null) { throw new UserAccountException(1, "鐢ㄦ埛涓嶅瓨鍦�"); } - + if (weiXinUser == null) { throw new UserAccountException(2, "寰俊甯愬彿鎺堟潈澶辫触"); } @@ -1189,8 +1181,9 @@ if (asInputStream == null) { LogHelper.test("寰俊澶村儚涓嬭浇澶辫触: " + weiXinUser.getUnionid() + " " + headimgurl); } else { - FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String - .format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + "")); + FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, + String.format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(), + System.currentTimeMillis() + "")); if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) { headimgurl = result.getUrl(); } else { @@ -1222,9 +1215,6 @@ @Override public UserInfo bindPhoneToLogin(String phone, String key, String appId, HttpServletRequest request) throws UserAccountException { - UserInfo phoneUser = userInfoMapper.getEffectiveUserInfoByPhone(phone); - if (phoneUser != null) - throw new UserAccountException(1, "鍙风爜宸茬粡琚崰鐢�"); // 鍒ゆ柇鎵嬫満鍙风爜鏄惁琚皝绂� ForbiddenUserIdentifyCode identifyCode1 = forbiddenUserIdentifyCodeService @@ -1249,8 +1239,9 @@ if (!StringUtil.isNullOrEmpty(weiXinUser.getHeadimgurl())) { InputStream asInputStream = HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()); if (asInputStream != null) { - FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String - .format(FilePathEnum.userWXPortrait.getPath() +"%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + "")); + FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, + String.format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(), + System.currentTimeMillis() + "")); if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) portrait = result.getUrl(); } else { @@ -1261,21 +1252,37 @@ if (StringUtil.isNullOrEmpty(portrait)) portrait = Constant.systemCommonConfig.getDefaultPortrait(); - // 鍒涘缓鏂拌处鎴� - userInfo = new UserInfo(); - userInfo.setPhone(phone); - userInfo.setPortrait(portrait); - userInfo.setAppId(appId); - userInfo.setNickName(weiXinUser.getNickname()); - userInfo.setWxName(weiXinUser.getNickname()); - userInfo.setWxOpenId(weiXinUser.getOpenid()); - userInfo.setWxUnionId(weiXinUser.getUnionid()); - userInfo.setWxPic(weiXinUser.getHeadimgurl()); - userInfo.setLastLoginTime(System.currentTimeMillis()); - userInfo.setLoginType(2); - userInfo.setLastLoginIp(request.getRemoteHost()); - userInfo.setState(UserInfo.STATE_NORMAL); - addUser(userInfo); + // 鏄惁闇�瑕佸垱寤烘柊璐︽埛 + UserInfo phoneUser = userInfoMapper.getEffectiveUserInfoByPhone(phone); + if (phoneUser != null) { + // 缁戝畾寰俊 + if (StringUtil.isNullOrEmpty(phoneUser.getWxUnionId())) { + try { + bindWeiXin(phoneUser.getId(), weiXinUser); + } catch (Exception e) { + throw new UserAccountException(1, "寰俊缁戝畾澶辫触"); + } + } else { + throw new UserAccountException(1, "璇ュ井淇″凡琚粦瀹�"); + } + userInfo = userInfoMapper.selectAvailableByPrimaryKey(phoneUser.getId()); + } else { + // 鍒涘缓鏂拌处鎴� + userInfo = new UserInfo(); + userInfo.setPhone(phone); + userInfo.setPortrait(portrait); + userInfo.setAppId(appId); + userInfo.setNickName(weiXinUser.getNickname()); + userInfo.setWxName(weiXinUser.getNickname()); + userInfo.setWxOpenId(weiXinUser.getOpenid()); + userInfo.setWxUnionId(weiXinUser.getUnionid()); + userInfo.setWxPic(weiXinUser.getHeadimgurl()); + userInfo.setLastLoginTime(System.currentTimeMillis()); + userInfo.setLoginType(2); + userInfo.setLastLoginIp(request.getRemoteHost()); + userInfo.setState(UserInfo.STATE_NORMAL); + addUser(userInfo); + } Long uid = userInfo.getId(); ThreadUtil.run(new Runnable() { @@ -1427,6 +1434,5 @@ // 鎻掑叆璁板綍 userInfoDeleteRecordService.addDeleteRecord(uid, UserInfo.STATE_DELETE_OUT_OF_DATE, reason); } - } -- Gitblit v1.8.0