From 486e22c57ca8a1e2dc6877b539e2f3add67250f1 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 23 十一月 2019 18:28:00 +0800 Subject: [PATCH] 冲突解决 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java | 73 +++++++++++++++++++++++++++--------- 1 files changed, 54 insertions(+), 19 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java index dcb943b..d80e726 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java @@ -13,6 +13,7 @@ import javax.annotation.Resource; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.yeshi.utils.DateUtil; import org.yeshi.utils.HttpUtil; import org.yeshi.utils.entity.FileUploadResult; @@ -404,8 +405,7 @@ } // 鑾峰彇寰俊淇℃伅 - WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), - wxAccount.getAppSecret()); + WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret()); if (weiXinUser == null) { throw new UserInfoExtraException(1, "寰俊鎺堟潈澶辫触"); } @@ -446,14 +446,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); @@ -518,7 +518,6 @@ } } - @Override public void activeInviteWX(Long uid, WeiXinUser weiXinUser) throws UserInfoExtraException { if (uid == null || weiXinUser == null) { @@ -577,14 +576,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); @@ -648,8 +647,7 @@ userInfoExtraMapper.insertSelective(userInfoExtra); } } - - + @Override public void updateActiveTime(Long uid, Date date) { UserInfoExtra userInfoExtra = new UserInfoExtra(); @@ -657,29 +655,27 @@ userInfoExtra.setActiveTime(date); userInfoExtraMapper.updateInfoExtraByUid(userInfoExtra); } - - + @Override public UserInfoExtra getUserInfoExtra(Long uid) { return userInfoExtraMapper.getInfoExtraByUid(uid); } - + @Override public UserInfoExtra getUserALLInfo(Long uid) { return userInfoExtraMapper.gerUserRank(uid); } - @Override public UserInfoExtra getByUidForUpdate(Long uid) { return userInfoExtraMapper.getByUidForUpdate(uid); } - + @Override public void updateGoldCoin(Long id, Integer goldCoin) { userInfoExtraMapper.updateGoldCoin(id, goldCoin); } - + @Override public UserInfoExtraVO getInfoExtraVOByUid(Long uid) { return userInfoExtraMapper.getInfoExtraVOByUid(uid); @@ -819,4 +815,43 @@ public void updateAutoExtract(Integer days) { userInfoExtraMapper.updateAutoExtract(days); } + + @Transactional + @Override + public void updateInviteCode(String inviteCode, Long uid) throws UserInfoExtraException { + if (inviteCode.length() >= 6 && inviteCode.length() <= 12) { + UserInfoExtra extra = getUserInfoExtra(uid); + if (extra == null) { + throw new UserInfoExtraException(2, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); + } + + if (StringUtil.isNullOrEmpty(extra.getInviteCode())) { + throw new UserInfoExtraException(3, "閭�璇风爜灏氭湭婵�娲�"); + } + + if (extra.getInviteCodeState() == null + || extra.getInviteCodeState() != UserInfoExtra.INVITE_CODE_SATTE_VALID_NO_UPDATE) { + throw new UserInfoExtraException(4, "鍙兘淇敼涓�娆�"); + } + + if (inviteCode.equalsIgnoreCase(extra.getInviteCode())) { + throw new UserInfoExtraException(5, "涓嶈兘涓哄師閭�璇风爜"); + } + UserInfoExtra update = new UserInfoExtra(); + update.setId(extra.getId()); + + extra = userInfoExtraMapper.selectByInviteCode(inviteCode); + if (extra != null) { + throw new UserInfoExtraException(6, "閭�璇风爜宸插瓨鍦�"); + } + + update.setInviteCode(inviteCode); + update.setInviteCodeState(UserInfoExtra.INVITE_CODE_SATTE_VALID_UPDATED); + update.setUpdateTime(new Date()); + userInfoExtraMapper.updateByPrimaryKeySelective(update); + } else { + throw new UserInfoExtraException(1, "閭�璇风爜蹇呴』涓�6鍒�12浣�"); + } + + } } -- Gitblit v1.8.0