| | |
| | | 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;
|
| | |
| | | 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)
|
| | |
| | | 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)
|
| | |
| | | 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) {
|
| | |
| | | }
|
| | |
|
| | | @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) {
|
| | |
| | | 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;
|
| | |
| | | @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;
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | |
| | | info.setCreateTime(new Date());
|
| | | userVIPInfoMapper.insert(info);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public boolean isVIP(Long uid) {
|
| | |
| | | return map;
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<UserVIPInfo> listQuery(int page, int count, String key, Integer state) {
|
| | | return userVIPInfoMapper.listQuery((page - 1) * count, count, key, state);
|
| | |
| | | public long countQuery(String key, Integer state) {
|
| | | return userVIPInfoMapper.countQuery(key, state);
|
| | | }
|
| | |
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | |
| | |
|
| | | if (!verifyVip(uid))
|
| | | throw new UserVIPInfoException(1, "系统验证:不满足升级条件");
|
| | | |
| | |
|
| | | Date upgradeTime = new Date();
|
| | | // 通过超级会员
|
| | | UserVIPInfo info = new UserVIPInfo();
|
| | |
| | | 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);
|
| | |
| | | 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());
|
| | | 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
|
| | |
| | | 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 = "返利+分享订单";
|
| | |
| | | }
|
| | | return item;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 验证是否符合VIP
|
| | | * @param uid
|
| | |
| | | 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)) {
|
| | |
|
| | | if (doneOrder >= limitOrder || (doneFirst >= limitFirst && doneSecond >= limitSecond)) {
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | |
| | | userAccountMsgNotificationService.vipUpgradeFail(uid, reason);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteByPrimaryKey(Long id) {
|
| | | userVIPInfoMapper.deleteByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | |
| | | try {
|
| | | twoProcess(uid, limitZiGou7, null);
|
| | | } catch (UserVIPPreInfoException e) {
|
| | | |
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | try {
|
| | | twoProcess(bossId, limitFirst7, limitSecond7);
|
| | | } catch (UserVIPPreInfoException e) {
|
| | | |
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | * @param secondTeam
|
| | | */
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private void twoProcess(Long uid, long limit1, Long limit2) throws UserVIPPreInfoException{
|
| | | private void twoProcess(Long uid, long limit1, Long limit2) throws UserVIPPreInfoException {
|
| | | String item = null;
|
| | | if (limit2 == null) {
|
| | | item = "返利+分享订单";
|
| | |
| | | return userVIPPreInfoMapper.selectByUidAndProcess(uid, process);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteByPrimaryKey(Long id) {
|
| | | userVIPPreInfoMapper.deleteByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | |
|
| | | /**
|
| | | * 团队用户
|
| | |
| | | * @throws
|
| | | */
|
| | | public void updateUserLevel(Long uid);
|
| | |
|
| | | /**
|
| | | * 设置用户等级
|
| | | * @Title: setUserLevel
|
| | | * @Description: |
| | | * @param uid
|
| | | * @param level |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void setUserLevel(Long uid, UserLevelEnum level);
|
| | | }
|
| | |
| | | */
|
| | | public void addUserVIPInfo(UserVIPInfo info) throws UserVIPInfoException;
|
| | |
|
| | |
|
| | | /**
|
| | | * 是否为VIP
|
| | | *
|
| | |
| | | * @return
|
| | | */
|
| | | public boolean isVIP(Long uid);
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 在某个时间是否为VIP
|
| | | * @Title: isVIP
|
| | |
| | | * boolean 返回类型
|
| | | * @throws
|
| | | */
|
| | | public boolean isVIP(Long uid,Long time);
|
| | | public boolean isVIP(Long uid, Long time);
|
| | |
|
| | | /**
|
| | | * 根据UID检索
|
| | |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public Map<Long,Boolean> listByUids(List<Long> uid);
|
| | |
|
| | | public Map<Long, Boolean> listByUids(List<Long> uid);
|
| | |
|
| | | /**
|
| | | * 待审核列表
|
| | |
| | | public List<UserVIPInfo> listQuery(int page, int count, String key, Integer state);
|
| | |
|
| | | public long countQuery(String key, Integer state);
|
| | |
|
| | |
|
| | | /**
|
| | | * 超级会员申请通过
|
| | |
| | | */
|
| | | public void applyVIP(Long uid) throws UserVIPInfoException;
|
| | |
|
| | | /**
|
| | | * 根据主键删除
|
| | | * @Title: deleteByPrimaryKey
|
| | | * @Description: |
| | | * @param id |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void deleteByPrimaryKey(Long id);
|
| | |
|
| | | }
|
| | |
| | | * @param uid 粉丝id
|
| | | */
|
| | | public void upgradeVipByTeamNum(Long uid);
|
| | | |
| | | |
| | | /**
|
| | | * 根据主键删除
|
| | | * @Title: deleteByPrimaryKey
|
| | | * @Description: |
| | | * @param id |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void deleteByPrimaryKey(Long id);
|
| | |
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | int state = getOrderState(stateSet);
|
| | |
|
| | | /**
|
| | |
| | | case HongBaoV2.TYPE_ERJI:
|
| | |
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | |
|
| | | case HongBaoV2.TYPE_SHARE_YIJI:
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_ERJI:
|
| | |
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | 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;
|
| | | }
|
| | |
|
| | |
| | | // 获取子红包
|
| | | 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)
|
| | |
| | | // 获取子红包
|
| | | 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;
|
| | |
| | | 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;
|
| | |
|
| | |
| | | * @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())
|
| | |
| | | * @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())
|
| | |
| | | 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();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | 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;
|
| | |
|
| | |
| | | }
|
| | | } 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());
|
| | |
| | | }
|
| | |
|
| | | } 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())) {
|