From eb1adc13eda955e8ef0fc9fe41fb246fa89b722d Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期三, 06 五月 2020 14:03:56 +0800 Subject: [PATCH] 队员相关 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java | 177 ++++++++++++++++++++-------------------------------------- 1 files changed, 62 insertions(+), 115 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 bcf7aae..6018124 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 @@ -16,26 +16,19 @@ import com.yeshi.fanli.dao.mybatis.user.vip.UserVIPInfoMapper; import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum; import com.yeshi.fanli.dto.mq.user.body.UserLevelChangedMQMsg; -import com.yeshi.fanli.entity.bus.user.HongBaoV2; -import com.yeshi.fanli.entity.bus.user.UserInfoExtra; +import com.yeshi.fanli.entity.bus.user.ThreeSale; +import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.UserInviteValidNum; -import com.yeshi.fanli.entity.bus.user.UserSystemCoupon; import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; 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.system.SystemCoupon.CouponTypeEnum; import com.yeshi.fanli.exception.user.vip.UserVIPInfoException; -import com.yeshi.fanli.service.inter.config.ConfigService; +import com.yeshi.fanli.exception.user.vip.UserVIPPreInfoException; import com.yeshi.fanli.service.inter.count.HongBaoV2CountService; -import com.yeshi.fanli.service.inter.msg.UserOtherMsgNotificationService; -import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService; -import com.yeshi.fanli.service.inter.user.UserInfoExtraService; import com.yeshi.fanli.service.inter.user.UserInfoService; -import com.yeshi.fanli.service.inter.user.UserInviteSeparateService; -import com.yeshi.fanli.service.inter.user.UserSystemCouponService; -import com.yeshi.fanli.service.inter.user.integral.IntegralDetailService; import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; +import com.yeshi.fanli.service.inter.user.invite.UserInviteMsgNotificationService; import com.yeshi.fanli.service.inter.user.invite.UserInviteValidNumService; import com.yeshi.fanli.service.inter.user.msg.UserAccountMsgNotificationService; import com.yeshi.fanli.service.inter.user.vip.UserLevelUpgradedNotifyService; @@ -58,9 +51,6 @@ private UserInfoService userInfoService; @Resource - private UserInfoExtraService userInfoExtraService; - - @Resource private UserVipConfigService userVipConfigService; @Lazy @@ -68,44 +58,25 @@ private HongBaoV2CountService hongBaoV2CountService; @Resource - private IntegralDetailService integralDetailService; - - @Resource - private BanLiShopOrderService banLiShopOrderService; - - @Resource - private UserOtherMsgNotificationService userOtherMsgNotificationService; - - @Resource private ThreeSaleSerivce threeSaleSerivce; - - @Resource - private UserInviteSeparateService userInviteSeparateService; - - @Resource - private ConfigService configService; - - @Lazy - @Resource - private UserSystemCouponService userSystemCouponService; @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; - - @Override @Transactional(rollbackFor = Exception.class) @@ -122,7 +93,6 @@ info.setCreateTime(new Date()); userVIPInfoMapper.insert(info); } - @Override public boolean isVIP(Long uid) { @@ -165,7 +135,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); @@ -175,7 +144,6 @@ public long countQuery(String key, Integer state) { return userVIPInfoMapper.countQuery(key, state); } - @Transactional(rollbackFor = Exception.class) @Override @@ -225,11 +193,6 @@ if (!verifyVip(uid)) throw new UserVIPInfoException(1, "绯荤粺楠岃瘉锛氫笉婊¤冻鍗囩骇鏉′欢"); - // 棰濆淇℃伅 - UserInfoExtra userInfoExtra = userInfoExtraService.getByUidForUpdate(uid); - if (userInfoExtra == null) - throw new UserVIPInfoException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); - Date upgradeTime = new Date(); // 閫氳繃瓒呯骇浼氬憳 UserVIPInfo info = new UserVIPInfo(); @@ -239,6 +202,17 @@ info.setUpdateTime(upgradeTime); userVIPInfoMapper.updateByPrimaryKeySelective(info); + UserVIPPreInfo preInfo = new UserVIPPreInfo(); + preInfo.setCreateTime(new Date()); + preInfo.setProcess(UserLevelEnum.superVIP.getLevel()); + preInfo.setUid(uid); + + try { + userVIPPreInfoService.addUserVIPPreInfo(preInfo); + } catch (UserVIPPreInfoException e1) { + throw new UserVIPInfoException(100, "鍗囩骇澶辫触"); + } + // 鍗囩骇寮规鎻愮ず UserLevelUpgradedNotify notify = new UserLevelUpgradedNotify(); notify.setUid(uid); @@ -247,38 +221,32 @@ notify.setValid(true); notify.setCreateTime(new Date()); userLevelUpgradedNotifyService.addUserLevelUpgradedNotify(notify); - - try { - // 璧犻�佸厤鍗曞埜 - String giveCoupon = userVipConfigService.getValueByKey("vip_pre_10_gift_givefree_coupon"); - if (!StringUtil.isNullOrEmpty(giveCoupon)) { - int num = Integer.parseInt(giveCoupon); - userSystemCouponService.freeCouponWin(uid, CouponTypeEnum.freeCouponGive, - UserSystemCoupon.SOURCE_SYSTEM_PUSH, num, true); - } - } catch (Exception e) { - throw new UserVIPInfoException(1, "鍒歌禒閫佸け璐�"); - } - + try { // 鍗囩骇娑堟伅 UserVIPPreInfo pre1 = userVIPPreInfoService.getVipByProcess(uid, UserVIPPreInfo.PROCESS_2); - userAccountMsgNotificationService.vipUpgradeSuccess(uid, TimeUtil.getDayDifferenceCount(pre1.getCreateTime(), new Date())); - - // 鍗囩骇鎻愰啋涓婄骇 - userVIPPreInfoService.remindBoss(uid, "瓒呯骇浼氬憳", getPassItem(uid), upgradeTime, false); + 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); + } } catch (Exception e) { e.printStackTrace(); } - if (!Constant.IS_TEST) { - UserLevelChangedMQMsg msg = new UserLevelChangedMQMsg(uid, UserLevelEnum.highVIP,UserLevelEnum.superVIP, new Date()); + 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 @@ -286,13 +254,8 @@ * @return */ private String getPassItem(Long uid) { - // 鑷喘璁㈠崟 - long doneZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY, - HongBaoV2.TYPE_ZIGOU); - // 鍒嗕韩璁㈠崟 - long doneShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY, - HongBaoV2.TYPE_SHARE_GOODS); - + // 鑷喘 + 鍒嗕韩璁㈠崟 + long doneOrder = hongBaoV2CountService.countMyDirectOrderByCashArrival(uid, Constant.VIP_ORDER_PAY); // 鏈夋晥绮変笣 int doneFirst = 0; int doneSecond = 0; @@ -302,55 +265,41 @@ doneSecond = userInviteValidNum.getNumSecond() == null ? 0 : userInviteValidNum.getNumSecond(); } - long limitZiGou = 0; - String zigou = userVipConfigService.getValueByKey("vip_pre_10_zigou_order_count"); + long limitOrder = 0; + String zigou = userVipConfigService.getValueByKey("vip_pre_10_order_count"); if (!StringUtil.isNullOrEmpty(zigou)) { - limitZiGou = Long.parseLong(zigou); + limitOrder = Long.parseLong(zigou); } - - long limitShare = 0; - String share = userVipConfigService.getValueByKey("vip_pre_10_share_order_count"); - if (!StringUtil.isNullOrEmpty(share)) { - limitShare = Long.parseLong(share); - } - + 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 (doneZiGou >= limitZiGou) { - item = "杩斿埄璁㈠崟"; - } else if (doneShare >= limitShare) { - item = "鍒嗕韩璁㈠崟"; + if (doneOrder >= limitOrder) { + item = "杩斿埄+鍒嗕韩璁㈠崟"; } else if (doneFirst >= limitFirst && doneSecond >= limitSecond) { - item = "閭�璇风矇涓�"; + item = "鐩存帴+闂存帴绮変笣"; } return item; } - - + /** * 楠岃瘉鏄惁绗﹀悎VIP * @param uid * @return */ private boolean verifyVip(Long uid) { - // 鑷喘璁㈠崟 - long doneZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY, - HongBaoV2.TYPE_ZIGOU); - // 鍒嗕韩璁㈠崟 - long doneShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY, - HongBaoV2.TYPE_SHARE_GOODS); - + // 鑷喘 + 鍒嗕韩璁㈠崟 + long doneOrder = hongBaoV2CountService.countMyDirectOrderByCashArrival(uid, Constant.VIP_ORDER_PAY); // 鏈夋晥绮変笣 int doneFirst = 0; int doneSecond = 0; @@ -359,32 +308,25 @@ doneFirst = userInviteValidNum.getNumFirst() == null ? 0 : userInviteValidNum.getNumFirst(); doneSecond = userInviteValidNum.getNumSecond() == null ? 0 : userInviteValidNum.getNumSecond(); } - - long limitZiGou = 0; - String zigou = userVipConfigService.getValueByKey("vip_pre_10_zigou_order_count"); + long limitOrder = 0; + String zigou = userVipConfigService.getValueByKey("vip_pre_10_order_count"); if (!StringUtil.isNullOrEmpty(zigou)) { - limitZiGou = Long.parseLong(zigou); + limitOrder = Long.parseLong(zigou); } - - long limitShare = 0; - String share = userVipConfigService.getValueByKey("vip_pre_10_share_order_count"); - if (!StringUtil.isNullOrEmpty(share)) { - limitShare = Long.parseLong(share); - } - + 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 (doneZiGou >= limitZiGou || doneShare >= limitShare || (doneFirst >= limitFirst && doneSecond >= limitSecond)) { + + if (doneOrder >= limitOrder || (doneFirst >= limitFirst && doneSecond >= limitSecond)) { return true; } return false; @@ -405,10 +347,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