From 972d3bc71115ec977dccf835fbcd148da3bcc86c Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期二, 03 九月 2019 16:41:49 +0800 Subject: [PATCH] 统计可用的免单券数量-countUsableFreeCouponForBuy --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java | 83 ++++++++++++++++++++++++++--------------- 1 files changed, 53 insertions(+), 30 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java index 9d92fbd..04916dd 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java @@ -20,6 +20,7 @@ import org.hibernate.Query; import org.hibernate.SQLQuery; import org.hibernate.Session; +import org.springframework.context.annotation.Lazy; import org.springframework.core.task.TaskExecutor; import org.springframework.orm.hibernate4.HibernateCallback; import org.springframework.stereotype.Service; @@ -43,18 +44,22 @@ import com.yeshi.fanli.entity.bus.user.InviteUser; import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; import com.yeshi.fanli.entity.bus.user.UserInfo; +import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum; import com.yeshi.fanli.entity.bus.user.WeiXinUser; import com.yeshi.fanli.entity.system.BusinessSystem; -import com.yeshi.fanli.exception.ThreeSaleException; +import com.yeshi.fanli.exception.user.ThreeSaleException; import com.yeshi.fanli.exception.user.UserInfoException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.count.HongBaoV2CountService; import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce; import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionAuthRecordService; +import com.yeshi.fanli.service.inter.user.BindingAccountService; +import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService; import com.yeshi.fanli.service.inter.user.SpreadUserImgService; import com.yeshi.fanli.service.inter.user.UserActiveLogService; import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService; +import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService; import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.UserRankService; import com.yeshi.fanli.util.Constant; @@ -73,7 +78,7 @@ @Resource(name = "taskExecutor") private TaskExecutor executor; - + @Resource private UserInfoDao userInfoDao; @@ -118,10 +123,19 @@ @Resource private TaoBaoUnionAuthRecordService taoBaoUnionAuthRecordService; - + @Resource private SpreadUserImgService spreadUserImgService; + + @Resource + private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService; + + @Resource + private BindingAccountService bindingAccountService; + @Lazy + @Resource + private UserInfoModifyRecordService userInfoModifyRecordService; public UserInfo getUserByLoginTypeAndOpenId(int loginType, String openid, String appid) { @@ -717,17 +731,23 @@ userInfoVO.setLastLoginTime(null); } - /* - * 鏄剧ず鐢ㄦ埛寰俊 娣樺疂 鑰佺増鏈瓨鍦� String wxUnionId = userInfoVO.getWxUnionId(); if - * (wxUnionId == null || wxUnionId.trim().length() == 0) { - * userInfoVO.setWxName(null); } - * - * String taoBaoUid = userInfoVO.getTaoBaoUid(); if (taoBaoUid == null - * || taoBaoUid.trim().length() == 0) { userInfoVO.setTbName(null); } - */ + + //鏄剧ず鐢ㄦ埛寰俊 娣樺疂 鑰佺増鏈瓨鍦� + String wxUnionId = userInfoVO.getWxUnionId(); + if (wxUnionId == null || wxUnionId.trim().length() == 0) { + userInfoVO.setWxName(null); + } + + // 鏄惁缁戝畾鏀粯瀹濓紙璐拱 + 鍒嗕韩鏉冮檺锛� + String taoBaoUid = userInfoVO.getTaoBaoUid(); + String tbSpecialId = userInfoVO.getTbSpecialId(); + String tbRelationId = userInfoVO.getTbRelationId(); + if (StringUtil.isNullOrEmpty(taoBaoUid) || StringUtil.isNullOrEmpty(tbSpecialId) || StringUtil.isNullOrEmpty(tbRelationId)) { + userInfoVO.setTbName(null); + userInfoVO.setTaoBaoUid(null); + } Long uid = userInfoVO.getId(); - /* 缁戝畾鏀舵璐﹀彿淇℃伅 */ List<BindingAccount> account = bindingAccountMapper.selectByUid(uid); if (account != null && account.size() > 0) { @@ -881,8 +901,8 @@ throw new UserInfoException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC); } - if (userInfo.getState() != UserInfo.STATE_NORMAL) { - throw new UserInfoException(1, "鐢ㄦ埛涓嶅瓨鍦�"); + if (userInfo.getState() == UserInfo.STATE_DELETE || userInfo.getState() == UserInfo.STATE_DELETE_OUT_OF_DATE) { + throw new UserInfoException(Constant.CODE_FORBIDDEN_USER, "甯愭埛宸茶鍒犻櫎锛岃閲嶆柊鐧诲綍"); } // 娣樺疂鏄电О 缁勭粐 @@ -925,43 +945,46 @@ @Override public void uploadPortrait(MultipartFile file, Long uid) throws UserInfoException, IOException { - + UserInfo userInfo = userInfoMapper.selectByPKey(uid); - if(userInfo == null) { + if (userInfo == null) { throw new UserInfoException(1, "鐢ㄦ埛涓嶅瓨鍦�"); } - + // 璋锋瓕鍘嬬缉鍥剧墖 - String targetPath = FileUtil.getCacheDir() + "/uploadPortrait_" + uid + "_" + System.currentTimeMillis() + ".jpg"; + String targetPath = FileUtil.getCacheDir() + "/uploadPortrait_" + uid + "_" + System.currentTimeMillis() + + ".jpg"; Thumbnails.of(file.getInputStream()).size(200, 200).toFile(targetPath); - + // 鎵ц涓婁紶 - String filePath="/img/user/" + UUID.randomUUID().toString().replace("-", "") + ".jpg"; - String fileLink= COSManager.getInstance().uploadFile(new File(targetPath), filePath).getUrl(); - + String filePath = "/img/user/" + UUID.randomUUID().toString().replace("-", "") + ".jpg"; + String fileLink = COSManager.getInstance().uploadFile(new File(targetPath), filePath).getUrl(); + // 鍒犻櫎鏈湴鍥剧墖 if (new File(targetPath).exists()) { new File(targetPath).delete(); } - + // 鍘熷ご鍍� String portrait = userInfo.getPortrait(); - + // 鏇存柊淇℃伅 userInfo.setPortrait(fileLink); userInfoMapper.updateByPrimaryKeySelective(userInfo); - + // 鍒犻櫎鍘熷ご鍍� if (!StringUtil.isNullOrEmpty(portrait) && portrait.contains("/img/user/")) { COSManager.getInstance().deleteFile(portrait); } + + userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.portrait, fileLink); executor.execute(new Runnable() { @Override public void run() { try { // 鍒犻櫎鍒嗕韩澶村儚淇℃伅 - spreadUserImgService.deleteImgUrl(uid); + spreadUserImgService.deleteImgUrl(uid); } catch (Exception e) { try { LogHelper.errorDetailInfo(e); @@ -972,16 +995,16 @@ } }); } - - + @Override public void saveUserInfo(String nickName, Long uid) throws UserInfoException { UserInfo userInfo = userInfoMapper.selectByPKey(uid); - if(userInfo == null) { + if (userInfo == null) { throw new UserInfoException(1, "鐢ㄦ埛涓嶅瓨鍦�"); } - + userInfo.setNickName(nickName); userInfoMapper.updateByPrimaryKeySelective(userInfo); } + } -- Gitblit v1.8.0