fanli/src/main/java/com/yeshi/fanli/entity/bus/user/vip/UserVIPPreInfo.java
@@ -15,6 +15,7 @@ public class UserVIPPreInfo { public static int PROCESS_1 = 3;// 超级会员第一阶段 public static int PROCESS_2 = 7;// 超级会员第二阶段 public static int PROCESS_4 = 11;// 超级会员第四阶段 @Column(name = "vpi_id") private Long id; fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderHongBaoMoneyComputeServiceImpl.java
@@ -73,6 +73,10 @@ BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime()) .add(getOfficialSubsidyRate(order.getThirdCreateTime(), getCommonUserLevel(order.getThirdCreateTime(), userLevel), false)); if (userLevel == UserLevelEnum.normalVIP) { rate = new BigDecimal("61"); } if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ) return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100)); else if (order.getEstimate() != null) @@ -86,6 +90,11 @@ BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime()) .add(getOfficialSubsidyRate(order.getThirdCreateTime(), getCommonUserLevel(order.getThirdCreateTime(), userLevel), true)); if (userLevel == UserLevelEnum.normalVIP) { rate = new BigDecimal("61"); } if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ) return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100)); else if (order.getEstimate() != null) @@ -222,6 +231,12 @@ else { rate = null; } } else if (buyerLevel == UserLevelEnum.daRen && firstBoss.getLevel() == UserLevelEnum.normalVIP) { if (boss.getLevel() == UserLevelEnum.normalVIP) rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_7", date.getTime()); else { rate = null; } } // 极差计算法 if (rate == null) { fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/TeamUserLevelStatisticServiceImpl.java
@@ -131,6 +131,23 @@ } @Override public void setUserLevel(Long uid, UserLevelEnum level) { TeamUserLevelStatistic old = selectByUid(uid); if (old == null) { initData(uid); old = selectByUid(uid); } TeamUserLevelStatistic update = new TeamUserLevelStatistic(); update.setId(old.getId()); update.setLevel(level); update.setUpdateTime(new Date()); teamUserLevelStatisticMapper.updateByPrimaryKeySelective(update); } @Override public void add(TeamUserLevelStatistic statistic) { TeamUserLevelStatistic old = selectByUid(statistic.getId()); if (old == null) { fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java
@@ -24,6 +24,7 @@ import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo; import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo; import com.yeshi.fanli.exception.user.vip.UserVIPInfoException; import com.yeshi.fanli.exception.user.vip.UserVIPPreInfoException; 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; @@ -56,10 +57,8 @@ @Resource private HongBaoV2CountService hongBaoV2CountService; @Resource private ThreeSaleSerivce threeSaleSerivce; @Resource private UserVIPPreInfoService userVIPPreInfoService; @@ -79,8 +78,6 @@ @Resource(name = "producer") private Producer producer; @Override @Transactional(rollbackFor = Exception.class) public void addUserVIPInfo(UserVIPInfo info) throws UserVIPInfoException { @@ -96,7 +93,6 @@ info.setCreateTime(new Date()); userVIPInfoMapper.insert(info); } @Override public boolean isVIP(Long uid) { @@ -139,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); @@ -149,7 +144,6 @@ public long countQuery(String key, Integer state) { return userVIPInfoMapper.countQuery(key, state); } @Transactional(rollbackFor = Exception.class) @Override @@ -208,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); @@ -220,27 +225,28 @@ 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()); 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 @@ -285,7 +291,6 @@ } return item; } /** * 验证是否符合VIP @@ -347,4 +352,9 @@ userAccountMsgNotificationService.vipUpgradeFail(uid, reason); } @Override public void deleteByPrimaryKey(Long id) { userVIPInfoMapper.deleteByPrimaryKey(id); } } fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java
@@ -65,7 +65,6 @@ @Resource private UserInfoExtraService userInfoExtraService; @Resource private UserInfoService userInfoService; @@ -302,4 +301,9 @@ return userVIPPreInfoMapper.selectByUidAndProcess(uid, process); } @Override public void deleteByPrimaryKey(Long id) { userVIPPreInfoMapper.deleteByPrimaryKey(id); } } fanli/src/main/java/com/yeshi/fanli/service/inter/user/vip/TeamUserLevelStatisticService.java
@@ -3,6 +3,7 @@ import java.util.List; import com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic; import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; /** * 团队用户 @@ -62,4 +63,15 @@ * @throws */ public void updateUserLevel(Long uid); /** * 设置用户等级 * @Title: setUserLevel * @Description: * @param uid * @param level * void 返回类型 * @throws */ public void setUserLevel(Long uid, UserLevelEnum level); } fanli/src/main/java/com/yeshi/fanli/service/inter/user/vip/UserVIPInfoService.java
@@ -22,7 +22,6 @@ */ public void addUserVIPInfo(UserVIPInfo info) throws UserVIPInfoException; /** * 是否为VIP * @@ -30,7 +29,6 @@ * @return */ public boolean isVIP(Long uid); /** * 在某个时间是否为VIP @@ -60,7 +58,6 @@ */ public Map<Long,Boolean> listByUids(List<Long> uid); /** * 待审核列表 * @param page @@ -71,7 +68,6 @@ public List<UserVIPInfo> listQuery(int page, int count, String key, Integer state); public long countQuery(String key, Integer state); /** * 超级会员申请通过 @@ -95,4 +91,14 @@ */ public void applyVIP(Long uid) throws UserVIPInfoException; /** * 根据主键删除 * @Title: deleteByPrimaryKey * @Description: * @param id * void 返回类型 * @throws */ public void deleteByPrimaryKey(Long id); } fanli/src/main/java/com/yeshi/fanli/service/inter/user/vip/UserVIPPreInfoService.java
@@ -76,5 +76,16 @@ * @param uid 粉丝id */ public void upgradeVipByTeamNum(Long uid); /** * 根据主键删除 * @Title: deleteByPrimaryKey * @Description: * @param id * void 返回类型 * @throws */ public void deleteByPrimaryKey(Long id); } fanli/src/main/java/com/yeshi/fanli/service/manger/order/HongBaoV2AddManager.java
@@ -151,7 +151,6 @@ } } int state = getOrderState(stateSet); /** @@ -258,6 +257,24 @@ return resultList; } private List<UserTeamLevel> getBossList(List<HongBaoV2> children) { List<UserTeamLevel> resultList = new ArrayList<>(); for (HongBaoV2 v2 : children) { UserLevelEnum level = UserLevelUtil.getByOrderRank(v2.getUrank()); if (level == null) level = UserLevelEnum.daRen; UserTeamLevel teamLevel = new UserTeamLevel(v2.getUserInfo().getId(), level); if (v2.getType() == HongBaoV2.TYPE_YIJI || v2.getType() == HongBaoV2.TYPE_SHARE_YIJI) { resultList.add(0, teamLevel); } else { resultList.add(teamLevel); } } return resultList; } private boolean updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap, Date placeOrderTime) throws HongBaoException, UserAccountException { @@ -334,7 +351,7 @@ // 获取子红包 List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId()); if (children != null && children.size() > 0) { List<UserTeamLevel> bossList = getBossList(oldHongBao.getUserInfo().getId(), 2); List<UserTeamLevel> bossList =getBossList(children); for (HongBaoV2 child : children) { if (child.getState() == HongBaoV2.STATE_YILINGQU) @@ -440,7 +457,7 @@ // 获取子红包 List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId()); if (children != null && children.size() > 0) { List<UserTeamLevel> bossList = getBossList(oldHongBao.getUserInfo().getId(), 2); List<UserTeamLevel> bossList =getBossList(children); for (HongBaoV2 child : children) { if (child.getState() == HongBaoV2.STATE_YILINGQU) continue; fanli/src/main/java/com/yeshi/fanli/service/manger/user/UserLevelManager.java
@@ -5,9 +5,14 @@ import javax.annotation.Resource; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo; import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo; import com.yeshi.fanli.exception.user.vip.UserVIPInfoException; import com.yeshi.fanli.exception.user.vip.UserVIPPreInfoException; import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService; import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService; @@ -29,8 +34,6 @@ * @throws */ public UserLevelEnum getUserLevel(Long uid) { if (userVIPInfoService.isVIP(uid)) return UserLevelEnum.superVIP; UserVIPPreInfo info = userVIPPreInfoService.getLatestProcessInfo(uid); if (info != null) for (UserLevelEnum level : UserLevelEnum.values()) @@ -50,8 +53,6 @@ * @throws */ public UserLevelEnum getUserLevel(Long uid, Date date) { if (userVIPInfoService.isVIP(uid, date.getTime())) return UserLevelEnum.superVIP; UserVIPPreInfo info = userVIPPreInfoService.getProcessInfo(uid, date); if (info != null) for (UserLevelEnum level : UserLevelEnum.values()) @@ -60,4 +61,31 @@ return UserLevelEnum.daRen; } @Transactional public void setUserLevel(Long uid, UserLevelEnum level, Date date) { // 删除原有等级 for (UserLevelEnum le : UserLevelEnum.values()) { UserVIPPreInfo info = userVIPPreInfoService.getVipByProcess(uid, le.getLevel()); if (info != null) userVIPPreInfoService.deleteByPrimaryKey(info.getId()); } // 添加新的等级 if (level == UserLevelEnum.daRen) return; UserVIPPreInfo info = new UserVIPPreInfo(); info.setCreateTime(date); info.setProcess(level.getLevel()); info.setUid(uid); try { userVIPPreInfoService.addUserVIPPreInfo(info); } catch (UserVIPPreInfoException e) { e.printStackTrace(); } } } fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/order/OrderDividentsMessageListener.java
@@ -31,6 +31,7 @@ import com.yeshi.fanli.service.inter.user.vip.TeamUserLevelStatisticService; import com.yeshi.fanli.service.manger.order.TeamDividentsManager; import com.yeshi.fanli.service.manger.order.TeamDividentsSourceManager; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.order.CommonOrderUtil; import com.yeshi.fanli.util.rocketmq.MQTopicName; @@ -78,7 +79,11 @@ } } else if (MQTopicName.TOPIC_ORDER.name().equalsIgnoreCase(message.getTopic())) { if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderStatistic.name())) { OrderMQMsg dto = new Gson().fromJson(new String(message.getBody()), OrderMQMsg.class); if (dto == null || dto.getStaticticDate().getTime() < Constant.NEW_ORDER_FANLI_RULE_TIME) return Action.CommitMessage; if (dto.getHandleType() == OrderMQMsg.HANDLE_TYPE_ADD) { List<CommonOrder> commonOrderList = commonOrderService.listBySourceTypeAndOrderId(dto.getType(), dto.getOrderId()); @@ -113,7 +118,6 @@ } } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderConfirm.name())) {// 订单确认收货 // 插入分红 OrderConfirmMQMsg dto = new Gson().fromJson(new String(message.getBody()), OrderConfirmMQMsg.class); teamDividentsSourceManager.orderSettle(dto.getOrderNo(), dto.getSourceType()); } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.taoBaoOrderWeiQuan.name())) {