Пример #1
0
  /**
   * 加载邀请的好友列表
   *
   * @return
   */
  public String FriendManagerList() {
    // 获取用户的信息
    try {
      AccountUserDo user = (AccountUserDo) session().getAttribute(IConstants.SESSION_USER);
      Long userId = user.getId();
      recommendUserService.queryfindRecommendUserPage(pageBean, userId);
    } catch (Exception e) {
      log.error(e);
      e.printStackTrace();
    }

    return SUCCESS;
  }
Пример #2
0
  /**
   * * 手机注册
   *
   * @return
   * @throws Exception
   */
  public String cellreginfo() throws Exception {
    JSONObject obj = new JSONObject();
    // 判断手机验证码是否正确 start
    /** 判定用户是否已存在记录 */
    // 验证手机的唯一性
    String cellphone = SqlInfusion.FilteSqlInfusion(paramMap.get("cellphone"));
    Map<String, String> phonemap = null;
    Map<String, String> cellMap = null;
    try {
      phonemap = beVipService.queryIsPhoneonUser(cellphone);
      cellMap = cellPhoneService.queryCellPhone(cellphone);

      if (phonemap != null && cellMap != null) {
        obj.put("mailAddress", "手机已存在");
        JSONUtils.printObject(obj);
        return null;
      }
      if (phonemap == null) {
        String phonecode = null;
        try {
          Object obje = session().getAttribute("phone");
          if (obje != null) {
            phonecode = obje.toString();
          } else {
            if ("2".equals(IConstants.ISDEMO)) {
              obj.put("mailAddress", "请输入正确的验证码");
              JSONUtils.printObject(obj);
              return null;
            }
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
        if (phonecode != null) {
          if (!phonecode.trim().equals(cellphone.trim())) {
            obj.put("mailAddress", "与获取验证码手机号不一致");
            JSONUtils.printObject(obj);
            return null;
          }
        }
        if (!"1".equals(IConstants.ISDEMO)) {
          // 验证码
          String vilidataNum = SqlInfusion.FilteSqlInfusion(paramMap.get("cellcode"));
          if (StringUtils.isBlank(vilidataNum)) {
            obj.put("mailAddress", "请填写验证码");
            JSONUtils.printObject(obj);
            return null;
          }

          String randomCode = null;
          Object objec = session().getAttribute("randomCode");
          if (objec != null) {
            randomCode = objec.toString();
          } else {
            obj.put("mailAddress", "请输入正确的验证码");
            JSONUtils.printObject(obj);
            return null;
          }
          if (randomCode != null) {
            if (!randomCode.trim().equals(vilidataNum.trim())) {

              obj.put("mailAddress", "请输入正确的验证码");
              JSONUtils.printObject(obj);
              return null;
            }
          }
        }
      }
      String userName = SqlInfusion.FilteSqlInfusion(paramMap.get("userName")); // 用户名
      if (userName.length() < 2 || userName.length() > 20) {
        obj.put("mailAddress", "18");
        JSONUtils.printObject(obj);
        return null;
      }
      if (StringUtils.isBlank(userName)) {
        obj.put("mailAddress", "13");
        JSONUtils.printObject(obj);
        return null;
      }
      // 验证用户名木含有特殊字符串处理第一个字符不可以是下划线开始 ^[^@\/\'\\\"#$%&\^\*]+$
      if (userName.replaceAll("^[\u4E00-\u9FA5A-Za-z0-9_]+$", "").length() != 0) {
        obj.put("mailAddress", "20");
        JSONUtils.printObject(obj);
        return null;
      }
      // 判断第一个字符串不能使以下划线开头的
      String fristChar = userName.substring(0, 1);
      if (fristChar.equals("_")) {
        obj.put("mailAddress", "21");
        JSONUtils.printObject(obj);
        return null;
      }
      String password = SqlInfusion.FilteSqlInfusion(paramMap.get("password")); // 用户密码
      String md5Password = password;
      if (StringUtils.isBlank(password)) {
        obj.put("mailAddress", "14");
        JSONUtils.printObject(obj);
        return null;
      }
      String confirmPassword =
          SqlInfusion.FilteSqlInfusion(paramMap.get("confirmPassword")); // 用户密码
      if (StringUtils.isBlank(confirmPassword)) {
        obj.put("mailAddress", "15");
        JSONUtils.printObject(obj);
        return null;
      }
      String refferee = SqlInfusion.FilteSqlInfusion(paramMap.get("refferee"));
      @SuppressWarnings("unused")
      String param = SqlInfusion.FilteSqlInfusion(paramMap.get("param")); // 邀请好友链接携带的参数
      Map<String, Object> map = null;
      long recommendUserId = -1;
      if (StringUtils.isNotBlank(refferee)) {
        Map<String, String> userIdMap = userService.queryIdByUser(refferee); // 根据用户查询用户明细
        if (userIdMap != null) {
          recommendUserId = Convert.strToLong(userIdMap.get("id"), -1);
        }
        map = relationService.isPromoter(refferee);
        if (map == null) {
          refferee = null;
        }
        if (userIdMap == null && map == null) {
          obj.put("mailAddress", "5");
          JSONUtils.printObject(obj);
          return null;
        }
      }
      // 判断密码是否一致
      if (!password.equals(confirmPassword)) {
        obj.put("mailAddress", "1");
        JSONUtils.printObject(obj);
        return null;
      }
      Long userId = -1L;
      Long result = userService.isExistEmailORUserName(null, userName);
      boolean isExist = adminService.isExistUserName(userName);
      if (result > 0 || isExist) { // 用户名重复
        obj.put("mailAddress", "2");
        JSONUtils.printObject(obj);
        return null;
      }
      int typelen = -1;
      Map<String, String> lenMap = null;
      lenMap = userService.querymaterialsauthtypeCount(); // 查询证件类型主表有多少种类型
      if (lenMap != null && lenMap.size() > 0) {
        typelen = Convert.strToInt(lenMap.get("cccc"), -1);
        // 调用service
        if (typelen != -1) {
          // 判断是否使用了加密字符串
          if ("1".equals(IConstants.ENABLED_PASS)) {
            md5Password = com.shove.security.Encrypt.MD5(md5Password.trim());
          } else {
            md5Password = com.shove.security.Encrypt.MD5(md5Password.trim() + IConstants.PASS_KEY);
          }
          userId =
              cellPhoneService.usercellRegister(
                  cellphone, userName, md5Password, refferee, map, typelen); // 注册用户 和  初始化图片资料
        }
      }
      if (userId < 0) { // 注册失败
        obj.put("mailAddress", "4");
        JSONUtils.printObject(obj);
        return null;
      } else {
        // 添加通知默认方法
        homeInfoSettingService.addNotes(userId, true, false, false);
        homeInfoSettingService.addNotesSetting(
            userId, true, true, true, true, true, false, false, false, false, false, false, false,
            false, false, false);
        // ====
        obj.put("mailAddress", "注册成功"); // 注册成功
        JSONUtils.printObject(obj);
      }

      // 修改之前的推荐
      try {
        if (recommendUserId > 0) { // 判断是否为空

          List<Map<String, Object>> list =
              recommendUserService.queryRecommendUser(null, userId, null); // 查询用户是否已经存在关系了。
          if (list != null && list.size() > 0) { // 判断之前是否已经有关系了。
            return null;
          }
          recommendUserService.addRecommendUser(userId, recommendUserId);
        }
      } catch (Exception e) {
        log.error(e);
        e.printStackTrace();
      }
      AccountUserDo user = new AccountUserDo();
      user.setUsername(userName);
      user.setPassword(password);
      user.setEmail("*****@*****.**");
      bbsRegisterService.doRegisterByAsynchronousMode(user);
    } catch (Exception e) {
      obj.put("mailAddress", "16");
      JSONUtils.printObject(obj);
      e.printStackTrace();
      throw e;
    }

    return null;
  }