yujian
2020-04-18 b803abf95ed0cc721f8f9e767283e5ac6b8ca090
fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/ThreeSaleSerivceImpl.java
@@ -21,7 +21,6 @@
import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg;
import com.yeshi.fanli.entity.bus.user.ThreeSale;
import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
import com.yeshi.fanli.entity.bus.user.UserActiveLog;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.exception.user.ThreeSaleException;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
@@ -35,7 +34,6 @@
import com.yeshi.fanli.service.inter.user.invite.UserInviteMsgNotificationService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
import com.yeshi.fanli.util.rocketmq.MQTopicName;
@@ -230,7 +228,7 @@
         // if (inviter != null)
         // reComputeUserRank(inviter.getId());
         // 添加到队列
         inviteSuccess(oldSale.getBoss().getId(), worker);
         inviteSuccess(worker.getId(), oldSale.getBoss().getId());
      }
   }
@@ -269,20 +267,7 @@
      return threeSaleMapper.deleteByPrimaryKey(id);
   }
   @Override
   public List<Long> queryLongTimeFailed(int daysNum) {
      return threeSaleMapper.queryLongTimeFailed(daysNum);
   }
   @Override
   public List<ThreeSale> queryLongTimeSuccess(int daysNum) {
      return threeSaleMapper.queryLongTimeSuccess(daysNum);
   }
   @Override
   public int updateExpire(List<Long> list) {
      return threeSaleMapper.updateExpire(list);
   }
   @Override
   public List<ThreeSale> listFirstTeamQuery(long start, int count, Long uid, Integer state, String startTime,
@@ -491,35 +476,17 @@
      return threeSaleMapper.getSuccessRelationshipNum(uid);
   }
   @Override
   @Transactional(rollbackFor = Exception.class)
   public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter) throws ThreeSaleException {
      if (invitee == null || inviter == null)
         throw new ThreeSaleException(1, "用户信息为空");
      // 新建立确定关系
      ThreeSale threeSale = new ThreeSale();
      threeSale.setBoss(inviter);
      threeSale.setWorker(invitee);
      threeSale.setState(true);
      threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
      threeSale.setSucceedTime(java.lang.System.currentTimeMillis());
      threeSale.setCreateTime(java.lang.System.currentTimeMillis());
      threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
      threeSaleMapper.insertSelective(threeSale);
      inviteSuccess(inviter.getId(), invitee);
   }
   @Override
   @Transactional(rollbackFor = Exception.class)
   public void bindRelationshipByWX(UserInfo invitee, Long inviterId) throws ThreeSaleException {
      if (invitee == null || inviterId == null)
   public void bindInviteRelationship(Long workerId, Long bossId) throws ThreeSaleException {
      if (workerId == null || bossId == null)
         throw new ThreeSaleException(1, "用户信息为空");
      // 新建立确定关系
      ThreeSale threeSale = new ThreeSale();
      threeSale.setBoss(new UserInfo(inviterId));
      threeSale.setWorker(invitee);
      threeSale.setBoss(new UserInfo(bossId));
      threeSale.setWorker(new UserInfo(workerId));
      threeSale.setState(true);
      threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
      threeSale.setSucceedTime(java.lang.System.currentTimeMillis());
@@ -528,16 +495,16 @@
      threeSaleMapper.insertSelective(threeSale);
      // 邀请成功:消息、相关处理
      inviteSuccess(inviterId, invitee);
      inviteSuccess(workerId, bossId);
   }
   /**
    * 邀请成功
    */
   @Transactional
   private void inviteSuccess(Long bossId, UserInfo invitee) {
   private void inviteSuccess(Long workerId, Long bossId) {
      if (!Constant.IS_TEST) {
         UserInviteMQMsg msg = new UserInviteMQMsg(bossId, invitee.getId(), null, new Date(), UserInviteMQMsg.STATE_SUCCESS);
         UserInviteMQMsg msg = new UserInviteMQMsg(bossId, workerId, null, new Date(), UserInviteMQMsg.STATE_SUCCESS);
         Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteSuccess, msg);
         producer.send(message);
      }
@@ -545,15 +512,15 @@
      executor.execute(new Runnable() {
         @Override
         public void run() {
            try {
               // 邀请金币
               integralGetService.addInviteLevelOne(bossId, invitee.getId());
            try { // 邀请金币
               integralGetService.addInviteLevelOne(bossId, workerId);
            } catch (Exception e) {
               e.printStackTrace();
            }
            
            try {
               // 直接粉丝邀请成功
               UserInfo invitee = userInfoService.selectByPKey(workerId);
               userInviteMsgNotificationService.directInviteSuccess(bossId, invitee.getNickName(),
                     invitee.getPortrait(), new Date());
               
@@ -561,8 +528,8 @@
               ThreeSale myBoss = threeSaleMapper.getMyBoss(bossId);
               if (myBoss != null) {
                  UserInfo boss = userInfoService.selectByPKey(bossId);
                  userInviteMsgNotificationService.indirectInviteSuccess(bossId, boss.getNickName(),
                        invitee.getNickName(), invitee.getPortrait(), new Date());
                  userInviteMsgNotificationService.indirectInviteSuccess(myBoss.getBoss().getId(),
                        boss.getNickName(),   invitee.getNickName(), invitee.getPortrait(), new Date());
               }
            } catch (Exception e) {
               e.printStackTrace();