yujian
2019-08-16 b2901a0793cfe3a1eb04318c1f8786c988e83108
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java
@@ -322,7 +322,7 @@
   }
   
   @Override
   public String activateInviteCode(Long uid, String inviteCode, String platform, String version) throws UserInfoExtraException{
   public String activateInviteCode(Long uid, String inviteCode) throws UserInfoExtraException{
      if (uid == null || inviteCode == null) {
         throw new UserInfoExtraException(1, "用户id、邀请码不能为空");
      }
@@ -349,7 +349,7 @@
      
      // 绑定关系
      try {
         threeSaleSerivce.bindRelationshipByInviteCode(invitee, inviter, platform, version);
         threeSaleSerivce.bindRelationshipByInviteCode(invitee, inviter);
      } catch (ThreeSaleException e) {
         try {
            LogHelper.errorDetailInfo(e);
@@ -384,7 +384,7 @@
   
   
   @Override
   public void activationInviteWX(Long uid, String code, String platform, String version) throws UserInfoExtraException{
   public void activationInviteWX(Long uid, String code) throws UserInfoExtraException{
      if (uid == null || code == null) {
         throw new UserInfoExtraException(1, "激活信息不完整");
      }
@@ -465,7 +465,7 @@
      
      // 绑定关系
      try {
         threeSaleSerivce.bindRelationshipByWX(invitee, inviterId, threeSale, platform, version);
         threeSaleSerivce.bindRelationshipByWX(invitee, inviterId, threeSale);
      } catch (ThreeSaleException e) {
         try {
            LogHelper.errorDetailInfo(e);
@@ -650,4 +650,67 @@
      }
      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;
   }
}