admin
2020-07-01 c54fb6a88876be994906d57d2d18e844686964d0
fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java
@@ -38,6 +38,7 @@
import com.yeshi.fanli.service.inter.user.vip.UserLevelUpgradedNotifyService;
import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
import com.yeshi.fanli.service.manger.msg.RocketMQManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
@@ -88,12 +89,13 @@
   @Resource(name = "taskExecutor")
   private TaskExecutor executor;
   @Resource(name = "producer")
   private Producer producer;
   @Resource
   private RocketMQManager rocketMQManager;
   @Resource
   private TeamUserLevelStatisticService teamUserLevelStatisticService;
   @Transactional
   @Override
   public void addUserVIPPreInfo(UserVIPPreInfo info) throws UserVIPPreInfoException {
      if (info == null || info.getUid() == null || info.getProcess() == null || info.getSourceType() == null)
@@ -108,9 +110,32 @@
         throw new UserVIPPreInfoException(2, "进度已存在");
      if (info.getCreateTime() == null)
         info.setCreateTime(new Date());
      UserVIPPreInfo old = getLatestProcessInfo(info.getUid());
      userVIPPreInfoMapper.insertSelective(info);
      // 设置统计数据
      teamUserLevelStatisticService.setUserLevel(info.getUid(), UserLevelUtil.getByLevel(info.getProcess()));
      // 发送等级变化消息
      if (!Constant.IS_TEST) {
         UserLevelEnum oldLevel = null;
         if (old == null)
            oldLevel = UserLevelEnum.daRen;
         else {
            oldLevel = UserLevelUtil.getByLevel(old.getProcess());
         }
         if (oldLevel == UserLevelEnum.normalVIP)
            oldLevel = UserLevelEnum.daRen;
         UserLevelChangedMQMsg msg = new UserLevelChangedMQMsg(info.getUid(), oldLevel,
               UserLevelUtil.getByLevel(info.getProcess()), new Date());
         Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userLevelChanged, msg);
         //延时10s发送
         rocketMQManager.sendNormalMsg(message,1000*10L, null);
      }
   }
   @Override
@@ -315,12 +340,6 @@
         LogHelper.error(e);
      }
      if (!Constant.IS_TEST) {
         UserLevelChangedMQMsg msg = new UserLevelChangedMQMsg(uid, UserLevelEnum.daRen, UserLevelEnum.highVIP,
               new Date());
         Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userLevelChanged, msg);
         producer.send(message);
      }
   }
   @Override