From c8f11c229b87d1652b6da0b15576c166cd51eb8b Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 01 一月 2020 14:25:22 +0800 Subject: [PATCH] 首页悬浮图mapperbug修改,增加商品详情中的比例展示 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java | 144 ++++++++++++++++++++++++++---------------------- 1 files changed, 78 insertions(+), 66 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 3339253..2af722f 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 @@ -27,6 +27,8 @@ import com.yeshi.fanli.dao.mybatis.AccountMessageMapper; import com.yeshi.fanli.dao.mybatis.UserConnectHistoryMapper; import com.yeshi.fanli.dao.mybatis.UserInfoMapper; +import com.yeshi.fanli.dto.user.wx.WXMPLoginData; +import com.yeshi.fanli.dto.user.wx.WXMPLoginResult; import com.yeshi.fanli.dto.wx.WXAccountInfoDTO; import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.bus.user.BindingAccount; @@ -42,6 +44,7 @@ import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum; import com.yeshi.fanli.entity.bus.user.WeiXinUser; import com.yeshi.fanli.exception.user.ForbiddenUserIdentifyCodeException; +import com.yeshi.fanli.exception.user.ThreeSaleException; import com.yeshi.fanli.exception.user.UserAccountException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.money.extract.BindingAccountService; @@ -121,9 +124,8 @@ @Lazy @Resource private UserInfoModifyRecordService userInfoModifyRecordService; - - - @Transactional + + @Transactional(rollbackFor = Exception.class) @Override public LoginResult login(HttpServletRequest request, AcceptData acceptData, Boolean first, String appId, String code, String phone, UserInfo tbUserInfo, boolean wxinstall, int loginType) @@ -159,8 +161,7 @@ userInfo = getUserInfoByTaoBaoOpenId(appId, tbUserInfo.getOpenid()); // 鍒ゆ柇鐢ㄦ埛鏄惁琚垹闄� if (userInfo != null && userInfo.getState() != null - && (userInfo.getState() == UserInfo.STATE_DELETE_OUT_OF_DATE - || userInfo.getState() == UserInfo.STATE_DELETE)) + && (userInfo.getState() != UserInfo.STATE_NORMAL)) userInfo = null; if (userInfo == null) {// 鍘熷厛鐨勮处鍙蜂笉瀛樺湪 userInfo = new UserInfo(); @@ -204,8 +205,8 @@ userInfo = getUserInfoByWXUnionId(appId, weiXinUser.getUnionid()); // 鍒ゆ柇鐢ㄦ埛鏄惁琚垹闄� if (userInfo != null && userInfo.getState() != null - && (userInfo.getState() == UserInfo.STATE_DELETE_OUT_OF_DATE - || userInfo.getState() == UserInfo.STATE_DELETE)) + && (userInfo.getState() != UserInfo.STATE_NORMAL + )) userInfo = null; // 鐩存帴鐢ㄧ殑寰俊鐧诲綍 if (lastUser == null) { @@ -223,7 +224,7 @@ updateUserInfo.setLastLoginTime(System.currentTimeMillis()); updateUserInfo.setLoginType(loginType); updateUserInfo.setLastLoginIp(request.getRemoteHost()); - //鏇存柊openId + // 鏇存柊openId updateUserInfo.setOpenid(weiXinUser.getOpenid()); userInfoMapper.updateByPrimaryKeySelective(updateUserInfo); @@ -343,8 +344,7 @@ userInfo = getUserInfoByPhone(appId, phone); // 鍒ゆ柇鐢ㄦ埛鏄惁琚垹闄� if (userInfo != null && userInfo.getState() != null - && (userInfo.getState() == UserInfo.STATE_DELETE_OUT_OF_DATE - || userInfo.getState() == UserInfo.STATE_DELETE)) + && (userInfo.getState() != UserInfo.STATE_NORMAL)) userInfo = null; if (userInfo == null) {// 鍘熷厛鐨勮处鍙蜂笉瀛樺湪 @@ -381,7 +381,7 @@ } } - @Transactional + @Transactional(rollbackFor = Exception.class) @Override public LoginResult loginNoInstallWX(AcceptData acceptData, String appId, String code, String phone, UserInfo tbUserInfo, int loginType) throws UserAccountException { @@ -433,8 +433,7 @@ } // 鍒ゆ柇鐢ㄦ埛鏄惁琚垹闄� - if (userInfo != null && userInfo.getState() != null && (userInfo.getState() == UserInfo.STATE_DELETE_OUT_OF_DATE - || userInfo.getState() == UserInfo.STATE_DELETE)) + if (userInfo != null && userInfo.getState() != null && (userInfo.getState() != UserInfo.STATE_NORMAL)) userInfo = null; if (userInfo != null) { @@ -504,7 +503,7 @@ connectUsers(mainUser, lessUser); } - @Transactional + @Transactional(rollbackFor = Exception.class) @Override public void connectUsers(UserInfo mainUser, UserInfo lessUser) throws UserAccountException { mainUser = userInfoMapper.selectByPrimaryKeyForUpdate(mainUser.getId()); @@ -595,8 +594,7 @@ List<UserInfo> list = userInfoMapper.listByAppIdAndWXUnionId(appId, unionId); // 鍓旈櫎琚垹闄ゆ帀鐨勭敤鎴� for (int i = 0; i < list.size(); i++) { - if (list.get(i).getState() == UserInfo.STATE_DELETE - || list.get(i).getState() == UserInfo.STATE_DELETE_OUT_OF_DATE) { + if (list.get(i).getState() == UserInfo.STATE_NORMAL) { list.remove(i); i--; } @@ -623,8 +621,7 @@ // 鍓旈櫎琚垹闄ゆ帀鐨勭敤鎴� for (int i = 0; i < list.size(); i++) { - if (list.get(i).getState() == UserInfo.STATE_DELETE - || list.get(i).getState() == UserInfo.STATE_DELETE_OUT_OF_DATE) { + if (list.get(i).getState() != UserInfo.STATE_NORMAL) { list.remove(i); i--; } @@ -652,8 +649,7 @@ // 鍓旈櫎琚垹闄ゆ帀鐨勭敤鎴� for (int i = 0; i < list.size(); i++) { - if (list.get(i).getState() == UserInfo.STATE_DELETE - || list.get(i).getState() == UserInfo.STATE_DELETE_OUT_OF_DATE) { + if (list.get(i).getState() !=UserInfo.STATE_NORMAL) { list.remove(i); i--; } @@ -671,6 +667,7 @@ userInfoMapper.updateByPrimaryKeySelective(userInfo); } + @Transactional(rollbackFor = Exception.class) @Override public void register(UserInfo userInfo) throws UserAccountException { if (!StringUtil.isNullOrEmpty(userInfo.getPhone())) { @@ -694,6 +691,7 @@ addUser(userInfo); } + @Transactional @Override public void addUser(UserInfo user) { @@ -726,12 +724,12 @@ e.printStackTrace(); } + // 娣诲姞璐﹀彿缁戝畾鍘嗗彶 if (!StringUtil.isNullOrEmpty(user.getPhone())) userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindPhone, user.getPhone()); if (!StringUtil.isNullOrEmpty(user.getWxUnionId())) userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, user.getWxUnionId()); - } @Override @@ -974,7 +972,7 @@ return user.getPortrait(); } - @Transactional + @Transactional(rollbackFor = Exception.class) @Override public UserInfo loginPhone(HttpServletRequest request, int loginType, String vcode, String phone, String appId) throws UserAccountException { @@ -1069,12 +1067,12 @@ } finally { jedis.del(watchKey); jedis.unwatch(); - jedisPool.returnResource(jedis); + jedis.close(); } throw new UserAccountException(10, "璇风◢鍚庡啀璇�"); } - @Transactional + @Transactional(rollbackFor = Exception.class) @Override public UserInfo loginWinXin(HttpServletRequest request, AcceptData acceptData, int loginType, String code, String appId) throws UserAccountException { @@ -1087,8 +1085,7 @@ // 閫氳繃Code鎹㈠彇淇℃伅 WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); - WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), - wxAccount.getAppSecret()); + WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret()); if (weiXinUser == null) { throw new UserAccountException(1, "寰俊甯愬彿鎺堟潈澶辫触"); } @@ -1125,23 +1122,24 @@ spreadUserImgService.deleteImgUrl(userInfo.getId()); } else { LogHelper.test("寰俊unionID涓嶅瓨鍦�:" + weiXinUser.getUnionid()); - + String portrait = null; if (!StringUtil.isNullOrEmpty(weiXinUser.getHeadimgurl())) { InputStream asInputStream = HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()); if (asInputStream != null) { FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, - String.format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + "")); + String.format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), + System.currentTimeMillis() + "")); if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) portrait = result.getUrl(); } else { portrait = weiXinUser.getHeadimgurl(); } } - + if (StringUtil.isNullOrEmpty(portrait)) portrait = Constant.systemCommonConfig.getDefaultPortrait(); - + // 鍒涘缓鏂拌处鎴� userInfo = new UserInfo(); userInfo.setPortrait(portrait); @@ -1174,15 +1172,15 @@ } finally { jedis.del(watchKey); jedis.unwatch(); - jedisPool.returnResource(jedis); + jedis.close(); } throw new UserAccountException(10, "璇风◢鍚庡啀璇�"); } - - @Transactional + @Transactional(rollbackFor = Exception.class) @Override - public UserInfo loginWeiXinNew(HttpServletRequest request, AcceptData acceptData, int loginType, String wxCode, String appId) throws UserAccountException { + public UserInfo loginWeiXinNew(HttpServletRequest request, AcceptData acceptData, int loginType, String wxCode, + String appId) throws UserAccountException { // 鏃ュ織淇℃伅 JSONObject logInfo = new JSONObject(); logInfo.put("appId", appId); @@ -1192,8 +1190,7 @@ // 閫氳繃Code鎹㈠彇淇℃伅 WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); - WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(wxCode, wxAccount.getAppId(), - wxAccount.getAppSecret()); + WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(wxCode, wxAccount.getAppId(), wxAccount.getAppSecret()); if (weiXinUser == null) { throw new UserAccountException(1, "寰俊甯愬彿鎺堟潈澶辫触"); } @@ -1206,7 +1203,6 @@ throw new UserAccountException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC); } - UserInfo userInfo = userInfoMapper.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid()); if (userInfo == null) { String longinKey = StringUtil.Md5("WXLogin:" + weiXinUser.getUnionid()); @@ -1225,8 +1221,6 @@ return userInfo; } - - /** * 鏇存柊璐︽埛鐧诲綍淇℃伅 * @@ -1284,15 +1278,33 @@ } + @Transactional(rollbackFor=UserAccountException.class) @Override public void bindWeiXin(AcceptData acceptData, Long uid, String code) throws UserAccountException { + WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); + WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret()); + if (weiXinUser == null) { + throw new UserAccountException(2, "寰俊甯愬彿鎺堟潈澶辫触"); + } + + String wxUnionId = weiXinUser.getUnionid(); + if (StringUtil.isNullOrEmpty(wxUnionId)) { + throw new UserAccountException(2, "寰俊甯愬彿鎺堟潈澶辫触"); + } + bindWeiXin(uid, weiXinUser); + } + + + + + @Transactional(rollbackFor=UserAccountException.class) + @Override + public void bindWeiXin(Long uid,WeiXinUser weiXinUser) throws UserAccountException { UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid); if (user == null) { throw new UserAccountException(1, "鐢ㄦ埛涓嶅瓨鍦�"); } - WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); - WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), - wxAccount.getAppSecret()); + if (weiXinUser == null) { throw new UserAccountException(2, "寰俊甯愬彿鎺堟潈澶辫触"); } @@ -1338,14 +1350,14 @@ String headimgurl = weiXinUser.getHeadimgurl(); InputStream asInputStream = HttpUtil.getAsInputStream(headimgurl); if (asInputStream == null) { - LogHelper.test("寰俊澶村儚涓嬭浇澶辫触: " +weiXinUser.getUnionid()+ " " + headimgurl); + LogHelper.test("寰俊澶村儚涓嬭浇澶辫触: " + weiXinUser.getUnionid() + " " + headimgurl); } else { - FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, - String.format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + "")); + FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String + .format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + "")); if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) { headimgurl = result.getUrl(); } else { - LogHelper.test("寰俊澶村儚涓婁紶澶辫触: " +weiXinUser.getUnionid()+ " " + headimgurl); + LogHelper.test("寰俊澶村儚涓婁紶澶辫触: " + weiXinUser.getUnionid() + " " + headimgurl); } } updateUserInfo.setPortrait(headimgurl); @@ -1369,49 +1381,49 @@ userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, wxUnionId); } - - + @Override - public UserInfo bindPhoneToLogin(String phone, String key, String appId, HttpServletRequest request) throws UserAccountException { + public UserInfo bindPhoneToLogin(String phone, String key, String appId, HttpServletRequest request) + throws UserAccountException { UserInfo phoneUser = userInfoMapper.getEffectiveUserInfoByPhone(phone); - if (phoneUser != null) + if (phoneUser != null) throw new UserAccountException(1, "鍙风爜宸茬粡琚崰鐢�"); - + // 鍒ゆ柇鎵嬫満鍙风爜鏄惁琚皝绂� ForbiddenUserIdentifyCode identifyCode1 = forbiddenUserIdentifyCodeService .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, phone); if (identifyCode1 != null && identifyCode1.getEffective() != null && identifyCode1.getEffective()) throw new UserAccountException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC); - + String value = redisManager.getCommonString(key); if (StringUtil.isNullOrEmpty(value)) throw new UserAccountException(1, "寰俊鎺堟潈澶辨晥锛岃浣跨敤寰俊閲嶆柊鐧诲綍"); - + WeiXinUser weiXinUser = JsonUtil.getSimpleGson().fromJson(value, WeiXinUser.class); if (weiXinUser == null) throw new UserAccountException(1, "寰俊鎺堟潈澶辨晥锛岃浣跨敤寰俊閲嶆柊鐧诲綍"); - + UserInfo userInfo = userInfoMapper.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid()); // 鐩存帴鐢ㄧ殑寰俊鐧诲綍 - if (userInfo != null) + if (userInfo != null) throw new UserAccountException(10, "璇ュ井淇″彿宸茶鍗犵敤"); - + String portrait = null; if (!StringUtil.isNullOrEmpty(weiXinUser.getHeadimgurl())) { InputStream asInputStream = HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()); if (asInputStream != null) { - FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, - String.format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + "")); + FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String + .format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + "")); if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) portrait = result.getUrl(); } else { portrait = weiXinUser.getHeadimgurl(); } } - + if (StringUtil.isNullOrEmpty(portrait)) portrait = Constant.systemCommonConfig.getDefaultPortrait(); - + // 鍒涘缓鏂拌处鎴� userInfo = new UserInfo(); userInfo.setPhone(phone); @@ -1427,7 +1439,7 @@ userInfo.setLastLoginIp(request.getRemoteHost()); userInfo.setState(UserInfo.STATE_NORMAL); addUser(userInfo); - + Long uid = userInfo.getId(); ThreadUtil.run(new Runnable() { public void run() { @@ -1437,7 +1449,7 @@ } catch (Exception e) { e.printStackTrace(); } - + // 鍔犲叆缁戝畾璁板綍 UserAccountBindingHistory history = new UserAccountBindingHistory(); history.setContent(phone); @@ -1447,16 +1459,14 @@ userAccountBindingHistoryService.addUserAccountBindingHistory(history); userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindPhone, phone); - userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, weiXinUser.getUnionid()); + userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, weiXinUser.getUnionid()); } }); // 鍒犻櫎缂撳瓨 redisManager.removeCommonString(key); - + return userInfo; } - - @Override public void forbiddenUserAll(Long uid, String reason) { @@ -1580,4 +1590,6 @@ // 鎻掑叆璁板綍 userInfoDeleteRecordService.addDeleteRecord(uid, UserInfo.STATE_DELETE_OUT_OF_DATE, reason); } + + } -- Gitblit v1.8.0