yujian
2019-08-20 df300df7832cc3d24f1b09297998e8bee8cfd126
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java
@@ -650,67 +650,4 @@
      }
      return inviter;
   }
   @Override
   public String activateUser(Long uid, String inviteUid) throws UserInfoExtraException{
      if (uid == null || inviteUid == null) {
         throw new UserInfoExtraException(1, "传递id不能为空");
      }
      // 被邀请人信息
      UserInfo invitee = userInfoService.selectByPKey(uid);
      if (invitee == null) {
         throw new UserInfoExtraException(1, "用户不存在");
      }
      UserInfoExtra extra = userInfoExtraMapper.getInfoExtraByUid(uid);
      if (extra != null) {
         String inviteCodeHas = extra.getInviteCode();
         if (inviteCodeHas != null && inviteCodeHas.trim().length() > 0) {
            throw new UserInfoExtraException(1, "已存在邀请码,请刷新页面");
         }
      }
      // 邀请人信息
      UserInfo inviter = userInfoService.getInfoByPhoneOrInviteCode(inviteCode, inviteCode);
      if (inviter == null) {
         throw new UserInfoExtraException(1, "上级邀请码不存在");
      }
      // 绑定关系
      try {
         threeSaleSerivce.bindRelationshipByInviteCode(invitee, inviter);
      } catch (ThreeSaleException e) {
         try {
            LogHelper.errorDetailInfo(e);
         } catch (Exception e1) {
            e1.printStackTrace();
         }
         throw new UserInfoExtraException(1, "激活失败");
      }
      // 邀请码有效、生成邀请码
      String code = UserUtil.getInviteCode(uid);
      if (code == null || code.trim().length() == 0) {
         throw new UserInfoExtraException(1, "激活码生成失败");
      }
      UserInfoExtra userInfoExtra = new UserInfoExtra();
      userInfoExtra.setUserInfo(invitee);
      userInfoExtra.setInviteCode(code);
      // 保存额外信息
      saveUserInfoExtra(userInfoExtra);
      Long id = userInfoExtra.getId();
      if (id == null) {
         throw new UserInfoExtraException(1, "激活码生成失败");
      }
      return code;
   }
}