/**
  * Description:重设手机提交方法<br>
  *
  * @author justin.xu
  * @version 0.1 2014年4月25日
  * @param session
  * @param request
  * @return ModelAndView
  */
 @RequestMapping(value = "toModifyPhone")
 public ModelAndView toModifyPhone(
     HttpSession session, HttpServletRequest request, String resetActiveCode) {
   ModelAndView mv = new ModelAndView("account/approve/mobile/resetMobile");
   try {
     ShiroUser shiroUser = currentUser();
     MobileApproVo mobileApproVo =
         mobileApproService.queryMobileApproByUserId(shiroUser.getUserId());
     mv.addObject("mobileAppro", mobileApproVo);
     // 验证验证码是否正确
     String valiateResult =
         phoneService.compareSmsValidate(
             mobileApproVo.getMobileNum(),
             resetActiveCode,
             BusinessConstants.MOBILE_APPRO_RESET_FUNCTION);
     if (valiateResult != "success") {
       mv.addObject("errorMsg", valiateResult);
     } else {
       mv.setViewName("account/approve/mobile/newMobile");
     }
   } catch (Exception e) {
     mv.addObject("errorMsg", "网络异常,请刷新页面或稍候重试");
     e.printStackTrace();
   }
   return mv;
 }
  /**
   * Description:手机短信验证码<br>
   *
   * @author yubin
   * @version 0.1 2015年9月18日
   * @return MessageBox
   */
  @RequestMapping(value = "/isMobileCode")
  public @ResponseBody MessageBox isMobileCode() {
    String result = "success";
    try {
      String mobileCode = currentRequest().getParameter("mobileCode");
      String mobileNum = currentRequest().getParameter("mobileNum");
      if (null == mobileCode) {
        return new MessageBox("0", "请输入手机验证码");
      }
      if (null != mobileCode && !"".equals(mobileCode.trim())) {
        // 验证手机验证码是否输入正确
        // 验证验证码是否正确
        String valiateResult =
            phoneService.compareSmsValidate(
                mobileNum, mobileCode, BusinessConstants.MOBILE_APPRO_FUNCTION);
        if (valiateResult != "success") {
          return new MessageBox("0", valiateResult);
        }
      }

    } catch (Exception e) {
      result = "failer";
      logger.error("手机验证码错误");
    }
    if (!BusinessConstants.SUCCESS.equals(result)) {
      return new MessageBox("0", result);
    }

    return new MessageBox("1", result);
  }
  /**
   * Description:执行会员基本信息录入,即注册流程第一步<br>
   *
   * @author hujianpan
   * @version 0.1 2014年8月30日
   * @param memberRegisterCnd
   * @return String
   */
  @RequestMapping(value = "/registMemberInfo")
  @ResponseBody
  public MessageBox registMemberInfo(
      Member member,
      HttpServletRequest request,
      HttpSession session,
      HttpServletResponse response) {
    String result = BusinessConstants.SUCCESS;
    try {
      if (null == member.getActiveCode() && !"".equals(member.getActiveCode().trim().trim())) {
        return new MessageBox("0", "请输入手机验证码");
      }
      // 验证手机验证码是否输入正确
      // 验证验证码是否正确
      String valiateResult =
          phoneService.compareSmsValidate(
              member.getMobileNum(),
              member.getActiveCode(),
              BusinessConstants.MOBILE_APPRO_FUNCTION);
      if (valiateResult != "success") {
        return new MessageBox("0", valiateResult);
      }

      if (verifyUserNameLength(member)) {
        return new MessageBox("0", "用户名称长度应该位于2~16位之间");
      }
      if (!VerifyContainSpecialChar.isContainSpecialChars(member.getUsername())) {
        return new MessageBox("0", "用户名包含特殊字符串");
      }
      if (null == member.getLogpassword() || "".equals(member.getLogpassword().trim())) {
        return new MessageBox("0", "密码输入有误!");
      }
      // 校验红包ID是否存在  liutao 20151103
      if (null != member.getRedId()
          && StringUtils.isNotEmpty(member.getRedId())
          && null != member.getInviterid()) {
        int membercount = redAccountMapper.isExistRed(member);
        if (membercount <= 0) {
          return new MessageBox("0", "尊敬的用户,您好!推荐您注册的红包不存在");
        }
      }
      String inviterName = request.getParameter("inviterName");
      member.setPlatform(BusinessConstants.MEMBER_OPERATE_ON_PORTAL);
      member.setIp(HttpTookit.getRealIpAddr(request));
      result =
          memberRegisterService.insertMemberWithoutEmail(member, inviterName, request, session);
      if (!"success".equals(result)) {
        return new MessageBox("0", result);
      }
      // 注册借款用户需后台审核,审核通过才能登录系统
      if (member.getIsFinancialUser() != null
          && member.getIsFinancialUser() == Integer.parseInt(Constants.IS_FINANCIAL_USER)) {
        if ("success".equals(result)) {
          cookieRetrievingCookieGenerator.addCookie(
              request, response, TicketCryptor.encrypt(currentUser().getSsoTicket()));
          return new MessageBox("1", result);
        }
      } else {
        return new MessageBox("2", "尊敬的用户,您好!您注册的用户是借款用户,需要审核后才能登录系统进行下一步操作!");
      }

    } catch (Exception e) {
      logger.error("register", e);
      return new MessageBox("0", e.getMessage());
    }

    return new MessageBox("0", result);
  }