From 744594ef1a2f530fc3e86ea9dc48b62247f79420 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 19 五月 2020 17:13:23 +0800 Subject: [PATCH] 饿了么绘图,添加口碑 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java | 120 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 80 insertions(+), 40 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java index 3c14853..24e850e 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java @@ -23,7 +23,12 @@ import com.yeshi.fanli.entity.bus.user.vip.UserLevelUpgradedNotify; import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo; import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo; +import com.yeshi.fanli.entity.common.Config; +import com.yeshi.fanli.entity.system.ConfigKeyEnum; import com.yeshi.fanli.exception.user.vip.UserVIPInfoException; +import com.yeshi.fanli.exception.user.vip.UserVIPPreInfoException; +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.user.UserInfoService; import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; @@ -37,6 +42,7 @@ import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TimeUtil; +import com.yeshi.fanli.util.email.MailSenderUtil; import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory; import com.yeshi.fanli.util.rocketmq.MQTopicName; @@ -56,30 +62,29 @@ @Resource private HongBaoV2CountService hongBaoV2CountService; - @Resource private ThreeSaleSerivce threeSaleSerivce; - @Resource private UserVIPPreInfoService userVIPPreInfoService; @Resource private UserAccountMsgNotificationService userAccountMsgNotificationService; - + @Resource private UserInviteValidNumService userInviteValidNumService; - + @Resource private UserLevelUpgradedNotifyService userLevelUpgradedNotifyService; - + @Resource private UserInviteMsgNotificationService userInviteMsgNotificationService; - + @Resource(name = "producer") private Producer producer; - - + + @Resource + private ConfigService configService; @Override @Transactional(rollbackFor = Exception.class) @@ -96,7 +101,6 @@ info.setCreateTime(new Date()); userVIPInfoMapper.insert(info); } - @Override public boolean isVIP(Long uid) { @@ -139,7 +143,6 @@ return map; } - @Override public List<UserVIPInfo> listQuery(int page, int count, String key, Integer state) { return userVIPInfoMapper.listQuery((page - 1) * count, count, key, state); @@ -150,7 +153,6 @@ return userVIPInfoMapper.countQuery(key, state); } - @Transactional(rollbackFor = Exception.class) @Override public void applyVIP(Long uid) throws UserVIPInfoException { @@ -159,7 +161,8 @@ throw new UserVIPInfoException(1, "璇峰厛鍗囩骇涓洪珮绾т細鍛�"); } - if (!verifyVip(uid)) + int verifyResult = verifyVip(uid); + if (verifyResult <= 0) throw new UserVIPInfoException(1, "涓嶆弧瓒冲崌绾ф潯浠�"); UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid); @@ -178,6 +181,22 @@ info.setState(UserVIPInfo.STATE_VERIFING); info.setUpdateTime(new Date()); userVIPInfoMapper.updateByPrimaryKeySelective(info); + // 鍙戦�侀偖浠堕�氱煡 + try { + Config config = configService.getConfig(ConfigKeyEnum.extractCodeEmailFrom.getKey()); + String[] sts = config.getValue().split(","); + String account = sts[0]; + String pwd = sts[1]; + + String msg = String.format("鐢ㄦ埛ID:%s 鐢宠瓒呯骇浼氬憳", uid + ""); + String email = userVipConfigService.getValueByKey("apply_vip_email"); + String[] emails = email.split(","); + for (String e : emails) { + MailSenderUtil.sendEmail(e, account, pwd, msg, msg); + } + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } } @Transactional(rollbackFor = Exception.class) @@ -196,9 +215,11 @@ throw new UserVIPInfoException(1, "璇ョ敤鎴疯繕涓嶆槸楂樼骇浼氬憳"); } - if (!verifyVip(uid)) + int verifyVipResult = verifyVip(uid); + + if (verifyVipResult <= 0) throw new UserVIPInfoException(1, "绯荤粺楠岃瘉锛氫笉婊¤冻鍗囩骇鏉′欢"); - + Date upgradeTime = new Date(); // 閫氳繃瓒呯骇浼氬憳 UserVIPInfo info = new UserVIPInfo(); @@ -208,6 +229,18 @@ info.setUpdateTime(upgradeTime); userVIPInfoMapper.updateByPrimaryKeySelective(info); + UserVIPPreInfo preInfo = new UserVIPPreInfo(); + preInfo.setCreateTime(new Date()); + preInfo.setProcess(UserLevelEnum.superVIP.getLevel()); + preInfo.setSourceType(verifyVipResult); + preInfo.setUid(uid); + + try { + userVIPPreInfoService.addUserVIPPreInfo(preInfo); + } catch (UserVIPPreInfoException e1) { + throw new UserVIPInfoException(100, "鍗囩骇澶辫触"); + } + // 鍗囩骇寮规鎻愮ず UserLevelUpgradedNotify notify = new UserLevelUpgradedNotify(); notify.setUid(uid); @@ -216,31 +249,25 @@ notify.setValid(true); notify.setCreateTime(new Date()); userLevelUpgradedNotifyService.addUserLevelUpgradedNotify(notify); - + try { // 鍗囩骇娑堟伅 UserVIPPreInfo pre1 = userVIPPreInfoService.getVipByProcess(uid, UserVIPPreInfo.PROCESS_2); - userAccountMsgNotificationService.vipUpgradeSuccess(uid, TimeUtil.getDayDifferenceCount(pre1.getCreateTime(), new Date())); - + userAccountMsgNotificationService.vipUpgradeSuccess(uid, + TimeUtil.getDayDifferenceCount(pre1.getCreateTime(), new Date())); + // 鐩存帴绮変笣鍗囩骇鎻愰啋 ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid); if (threeSale != null) { Long bossId = threeSale.getBoss().getId(); UserInfo userInfo = userInfoService.selectByPKey(uid); - userInviteMsgNotificationService.fansUpgrade(bossId, "瓒呯骇浼氬憳", userInfo.getNickName(), getPassItem(uid), upgradeTime); + userInviteMsgNotificationService.fansUpgrade(bossId, "瓒呯骇浼氬憳", userInfo.getNickName(), getPassItem(uid), + upgradeTime); } } catch (Exception e) { e.printStackTrace(); } - - - if (!Constant.IS_TEST) { - UserLevelChangedMQMsg msg = new UserLevelChangedMQMsg(uid, UserLevelEnum.highVIP,UserLevelEnum.superVIP, new Date()); - Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userLevelChanged, msg); - producer.send(message); - } } - /** * 楠岃瘉鏄惁绗﹀悎VIP @@ -264,19 +291,19 @@ if (!StringUtil.isNullOrEmpty(zigou)) { limitOrder = Long.parseLong(zigou); } - + long limitFirst = 0; String first = userVipConfigService.getValueByKey("vip_pre_10_first_level_team_count"); if (!StringUtil.isNullOrEmpty(first)) { limitFirst = Long.parseLong(first); } - + long limitSecond = 0; String second = userVipConfigService.getValueByKey("vip_pre_10_second_level_team_count"); if (!StringUtil.isNullOrEmpty(second)) { limitSecond = Long.parseLong(second); } - + String item = ""; if (doneOrder >= limitOrder) { item = "杩斿埄+鍒嗕韩璁㈠崟"; @@ -285,14 +312,17 @@ } return item; } - - + /** - * 楠岃瘉鏄惁绗﹀悎VIP + * 楠岃瘉鏄惁绗﹀悎VIP + * @Title: verifyVip + * @Description: * @param uid - * @return + * @return 0-涓嶇鍚� 1-璁㈠崟 2-鍥㈤槦 + * int 杩斿洖绫诲瀷 + * @throws */ - private boolean verifyVip(Long uid) { + private int verifyVip(Long uid) { // 鑷喘 + 鍒嗕韩璁㈠崟 long doneOrder = hongBaoV2CountService.countMyDirectOrderByCashArrival(uid, Constant.VIP_ORDER_PAY); // 鏈夋晥绮変笣 @@ -308,23 +338,27 @@ if (!StringUtil.isNullOrEmpty(zigou)) { limitOrder = Long.parseLong(zigou); } - + long limitFirst = 0; String first = userVipConfigService.getValueByKey("vip_pre_10_first_level_team_count"); if (!StringUtil.isNullOrEmpty(first)) { limitFirst = Long.parseLong(first); } - + long limitSecond = 0; String second = userVipConfigService.getValueByKey("vip_pre_10_second_level_team_count"); if (!StringUtil.isNullOrEmpty(second)) { limitSecond = Long.parseLong(second); } - - if (doneOrder >= limitOrder || (doneFirst >= limitFirst && doneSecond >= limitSecond)) { - return true; + + if (doneOrder >= limitOrder) { + return UserVIPPreInfo.SOURCE_TYPE_ORDER; } - return false; + + if ((doneFirst >= limitFirst && doneSecond >= limitSecond)) + + return UserVIPPreInfo.SOURCE_TYPE_TEAM; + return 0; } @Transactional(rollbackFor = Exception.class) @@ -342,9 +376,15 @@ info.setId(userInfo.getId()); info.setState(UserVIPInfo.STATE_INVALID); info.setUpdateTime(new Date()); + info.setBeiZhu(reason); userVIPInfoMapper.updateByPrimaryKeySelective(info); // 娑堟伅 userAccountMsgNotificationService.vipUpgradeFail(uid, reason); } + @Override + public void deleteByPrimaryKey(Long id) { + userVIPInfoMapper.deleteByPrimaryKey(id); + } + } -- Gitblit v1.8.0