From eec7e789a87863c25d92c10ad5dfc22ad80c448d Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 14 七月 2020 12:36:48 +0800 Subject: [PATCH] 系统区分BUG修复 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java | 98 +++++++++++++++++++++++++++++++++---------------- 1 files changed, 66 insertions(+), 32 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 2f030c6..424488d 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 @@ -8,13 +8,14 @@ import javax.servlet.http.HttpSession; import com.yeshi.fanli.entity.SystemEnum; +import com.yeshi.fanli.entity.system.BusinessSystem; import com.yeshi.fanli.util.*; +import com.yeshi.fanli.vo.taobao.TaoBaoUser; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.yeshi.utils.HttpUtil; import org.yeshi.utils.JsonUtil; -import org.yeshi.utils.SystemUtil; import org.yeshi.utils.entity.FileUploadResult; import org.yeshi.utils.entity.ProxyIP; import org.yeshi.utils.tencentcloud.COSManager; @@ -22,7 +23,6 @@ import com.google.gson.Gson; import com.qcloud.cos.model.COSObjectSummary; import com.qcloud.cos.model.ObjectListing; -import com.yeshi.fanli.dao.mybatis.UserInfoMapper; import com.yeshi.fanli.dto.wx.WXAccountInfoDTO; import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.bus.user.BindingAccount; @@ -452,6 +452,7 @@ /** * 鏍规嵁绯荤粺涓巙nionid瀵绘壘鐢ㄦ埛 + * * @param system * @param unionId * @return @@ -480,7 +481,8 @@ /** - *鏍规嵁绯荤粺鍜屾窐瀹濈殑Openid瀵绘壘鐢ㄦ埛 + * 鏍规嵁绯荤粺鍜屾窐瀹濈殑Openid瀵绘壘鐢ㄦ埛 + * * @param system * @param openId * @return @@ -509,6 +511,7 @@ /** * 鏍规嵁绯荤粺鍜岀數璇濆彿鐮佸鎵剧敤鎴� + * * @param system * @param phone * @return @@ -572,7 +575,7 @@ user.setRank(0); if (StringUtil.isNullOrEmpty(user.getPortrait())) user.setPortrait(Constant.systemCommonConfig.getDefaultPortrait()); - userInfoService.createUser(user,user.getSystem()); + userInfoService.createUser(user, user.getSystem()); // 鏄电О涓虹┖鏃� 榛樿鏄电О if (StringUtil.isNullOrEmpty(user.getNickName())) { UserInfo updateUserInfo = new UserInfo(user.getId()); @@ -797,7 +800,7 @@ @Transactional(rollbackFor = Exception.class) @Override - public UserInfo loginPhone(ProxyIP ipInfo, AcceptData acceptData, int loginType, String vcode, String phone, String appId) + public UserInfo loginPhone(ProxyIP ipInfo, int loginType, String vcode, String phone, BusinessSystem businessSystem) throws UserAccountException { // 绌洪娓呯悊 @@ -826,7 +829,7 @@ } JSONObject logInfo = new JSONObject(); - logInfo.put("appId", appId); + logInfo.put("appId", businessSystem.getAppid()); logInfo.put("phone", phone); logInfo.put("loginType", loginType); LogHelper.lgoinInfo(logInfo.toString()); @@ -846,7 +849,7 @@ // 閲囩敤redis浜嬪姟闃叉涓�涓墜鏈哄彿澶氭娉ㄥ唽闂 String watchKey = StringUtil.Md5("REGISTER:" + phone); - Jedis jedis = jedisPool.getResource(); + Jedis jedis = redisManager.getJedis(); try { jedis.watch(watchKey); if (jedis.get(watchKey) != null && Integer.parseInt(jedis.get(watchKey)) > 1) @@ -859,19 +862,18 @@ } else { // 鏌ヨ鏄惁瀛樺湪璇ョ數璇濆巻鍙茬敤鎴� - UserInfo userInfo = userInfoService.getEffectiveUserInfoByPhone(phone, SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages())); + UserInfo userInfo = userInfoService.getEffectiveUserInfoByPhone(phone, businessSystem.getSystem()); if (userInfo != null) { // 鏇存柊璐︽埛鐧诲綍淇℃伅 updateLonginInfo(userInfo, loginType, ipInfo); } else { userInfo = new UserInfo(); - userInfo.setAppId(appId); - // userInfo.setNickName(Constant.systemCommonConfig.getDefaultNickName()); + userInfo.setAppId(businessSystem.getAppid()); userInfo.setPortrait(Constant.systemCommonConfig.getDefaultPortrait()); userInfo.setPhone(phone); userInfo.setLoginType(loginType); userInfo.setState(UserInfo.STATE_NORMAL); - userInfo.setSystem(SystemInfoUtil.getSystem(acceptData)); + userInfo.setSystem(businessSystem.getSystem()); // 鍒涘缓鐢ㄦ埛 addUser(userInfo); @@ -895,10 +897,43 @@ throw new UserAccountException(10, "璇风◢鍚庡啀璇�"); } + @Override + public UserInfo loginTB(ProxyIP ipInfo, TaoBaoUser taoBaoUser, BusinessSystem businessSystem) throws UserAccountException { + + if (StringUtil.isNullOrEmpty(taoBaoUser.getUserid())) + throw new UserAccountException(1, "娣樺疂鎺堟潈淇℃伅涓嶅畬鏁�"); + + UserInfo userInfo = userInfoService.getEffectiveUserInfoByOpenId(taoBaoUser.getOpenId(), businessSystem.getSystem()); + if (userInfo != null) { + // 鏇存柊璐︽埛鐧诲綍淇℃伅 + updateLonginInfo(userInfo, 1, ipInfo); + } else { + userInfo = new UserInfo(); + userInfo.setNickName(taoBaoUser.getNick()); + userInfo.setPortrait(taoBaoUser.getAvatarUrl()); + userInfo.setAppId(businessSystem.getAppid()); + userInfo.setTaoBaoUid(taoBaoUser.getUserid()); + userInfo.setOpenid(taoBaoUser.getOpenId()); + userInfo.setLoginType(1); + userInfo.setState(UserInfo.STATE_NORMAL); + userInfo.setSystem(businessSystem.getSystem()); + // 鍒涘缓鐢ㄦ埛 + addUser(userInfo); + try { + // 绗竴娆$櫥褰曟椂鍒涘缓鐢ㄦ埛棰濆淇℃伅 + userInfoExtraService.createUserInfoExtra(userInfo.getId()); + } catch (Exception e) { + e.printStackTrace(); + } + } + return userInfo; + } + @Transactional(rollbackFor = Exception.class) @Override - public UserInfo loginPhoneNew(ProxyIP ipInfo, AcceptData acceptData, int loginType, String vcode, String phone, String appId) + public UserInfo loginPhoneNew(ProxyIP ipInfo, AcceptData acceptData, int loginType, String vcode, String + phone, String appId) throws UserAccountException { // 绌洪娓呯悊 if (phone == null || phone.trim().length() == 0) { @@ -944,7 +979,7 @@ // 閲囩敤redis浜嬪姟闃叉涓�涓墜鏈哄彿澶氭娉ㄥ唽闂 String watchKey = StringUtil.Md5("REGISTER:" + phone); - Jedis jedis = jedisPool.getResource(); + Jedis jedis = redisManager.getJedis(); try { jedis.watch(watchKey); if (jedis.get(watchKey) != null && Integer.parseInt(jedis.get(watchKey)) > 1) @@ -981,18 +1016,17 @@ @Transactional(rollbackFor = Exception.class) @Override - public UserInfo loginWinXin(ProxyIP ipInfo, AcceptData acceptData, int loginType, String code, - String appId) throws UserAccountException { + public UserInfo loginWeiXin(ProxyIP ipInfo, int loginType, String code, + BusinessSystem businessSystem) throws UserAccountException { // 鏃ュ織淇℃伅 JSONObject logInfo = new JSONObject(); - logInfo.put("appId", appId); + logInfo.put("appId", businessSystem.getAppid()); logInfo.put("code", code); logInfo.put("loginType", loginType); LogHelper.lgoinInfo(logInfo.toString()); // 閫氳繃Code鎹㈠彇淇℃伅 - WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); - WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret()); + WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, businessSystem.getWxAppId(), businessSystem.getWxAppSecret()); if (weiXinUser == null) { throw new UserAccountException(1, "寰俊甯愬彿鎺堟潈澶辫触"); } @@ -1007,7 +1041,7 @@ // 閲囩敤redis浜嬪姟闃叉涓�涓井淇″彿澶氭娉ㄥ唽闂 String watchKey = StringUtil.Md5("REGISTER:" + weiXinUser.getUnionid()); - Jedis jedis = jedisPool.getResource(); + Jedis jedis = redisManager.getJedis(); try { jedis.watch(watchKey); if (jedis.get(watchKey) != null && Integer.parseInt(jedis.get(watchKey)) > 1) @@ -1018,12 +1052,12 @@ if (exec == null || exec.size() == 0) { throw new UserAccountException(10, "璇风◢鍚庡啀璇�"); } else { - UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages())); + UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), businessSystem.getSystem()); // 鐩存帴鐢ㄧ殑寰俊鐧诲綍 if (userInfo != null) { LogHelper.test("寰俊unionID瀛樺湪:" + weiXinUser.getUnionid()); // 鏇存柊璐︽埛鐧诲綍淇℃伅 - updateLonginInfo(userInfo, loginType,ipInfo ); + updateLonginInfo(userInfo, loginType, ipInfo); // 鍒犻櫎閭�璇峰垎浜浘 spreadUserImgService.deleteImgUrl(userInfo.getId()); } else { @@ -1049,7 +1083,7 @@ // 鍒涘缓鏂拌处鎴� userInfo = new UserInfo(); userInfo.setPortrait(portrait); - userInfo.setAppId(appId); + userInfo.setAppId(businessSystem.getAppid()); userInfo.setNickName(weiXinUser.getNickname()); userInfo.setWxName(weiXinUser.getNickname()); userInfo.setWxOpenId(weiXinUser.getOpenid()); @@ -1059,7 +1093,7 @@ userInfo.setLoginType(loginType); userInfo.setLastLoginIp(ipInfo.getIp()); userInfo.setState(UserInfo.STATE_NORMAL); - userInfo.setSystem(SystemInfoUtil.getSystem(acceptData)); + userInfo.setSystem(businessSystem.getSystem()); addUser(userInfo); try { @@ -1086,18 +1120,17 @@ @Transactional(rollbackFor = Exception.class) @Override - public UserInfo loginWeiXinNew(ProxyIP ipInfo, AcceptData acceptData, int loginType, String wxCode, - String appId) throws UserAccountException { + public UserInfo loginWeiXinNew(ProxyIP ipInfo, int loginType, String wxCode, + BusinessSystem businessSystem) throws UserAccountException { // 鏃ュ織淇℃伅 JSONObject logInfo = new JSONObject(); - logInfo.put("appId", appId); + logInfo.put("appId", businessSystem.getAppid()); logInfo.put("wxCode", wxCode); logInfo.put("loginType", loginType); LogHelper.lgoinInfo(logInfo.toString()); // 閫氳繃Code鎹㈠彇淇℃伅 - WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); - WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(wxCode, wxAccount.getAppId(), wxAccount.getAppSecret()); + WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(wxCode, businessSystem.getWxAppId(), businessSystem.getWxAppSecret()); if (weiXinUser == null) { throw new UserAccountException(1, "寰俊甯愬彿鎺堟潈澶辫触"); } @@ -1110,7 +1143,7 @@ throw new UserAccountException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC); } - UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), SystemInfoUtil.getSystem(acceptData)); + UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), businessSystem.getSystem()); if (userInfo == null) { String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5("WXLogin:" + weiXinUser.getUnionid())); @@ -1157,7 +1190,7 @@ throw new UserAccountException(2, "鎮ㄥ凡缁忕粦瀹氫簡璇ョ數璇濆彿鐮�"); } - UserInfo phoneUser = userInfoService.getEffectiveUserInfoByPhone(phone,user.getSystem()); + UserInfo phoneUser = userInfoService.getEffectiveUserInfoByPhone(phone, user.getSystem()); if (phoneUser != null) { throw new UserAccountException(2, "鍙风爜宸茬粡琚崰鐢�"); } @@ -1393,7 +1426,8 @@ @Override - public UserInfo bindWXToLogin(ProxyIP ipInfo, AcceptData acceptData, String code, String appId, String key) throws UserAccountException { + public UserInfo bindWXToLogin(ProxyIP ipInfo, AcceptData acceptData, String code, String appId, String key) throws + UserAccountException { // 鏃ュ織淇℃伅 JSONObject logInfo = new JSONObject(); logInfo.put("appId", appId); @@ -1424,7 +1458,7 @@ // 閲囩敤redis浜嬪姟闃叉涓�涓井淇″彿澶氭娉ㄥ唽闂 String watchKey = StringUtil.Md5("REGISTER:" + weiXinUser.getUnionid()); - Jedis jedis = jedisPool.getResource(); + Jedis jedis = redisManager.getJedis(); try { jedis.watch(watchKey); if (jedis.get(watchKey) != null && Integer.parseInt(jedis.get(watchKey)) > 1) -- Gitblit v1.8.0