/**
   * Description:进入手机认证页面<br>
   *
   * @author justin.xu
   * @version 0.1 2014年4月25日
   * @param session
   * @param request
   * @return ModelAndView
   */
  @RequiresAuthentication
  @RequestMapping(value = "mobileforinsert")
  public ModelAndView mobileforinsert(HttpSession session, HttpServletRequest request) {
    ModelAndView mv = new ModelAndView();
    try {
      ShiroUser shiroUser = currentUser();
      // 手机认证
      MobileApproVo mobileAppro =
          mobileApproService.queryMobileApproByUserId(shiroUser.getUserId());
      // 邮件认证
      EmailApproVo emailApproVo = emailApprService.queryEmailApproByUserId(shiroUser.getUserId());
      mv.addObject("mobileAppro", mobileAppro);
      mv.addObject("emailApproVo", emailApproVo);

      // 修改手机号时原有手机号是否验证通过,不为空代表通过
      if (null
          != session.getAttribute(
              BusinessConstants.MOBILE_APPRO_RESET_FUNCTION + shiroUser.getUserId())) {
        mv.setViewName("account/approve/mobile/newMobile");
        return mv;
      }
      if (null != mobileAppro
          && null != mobileAppro.getPassed()
          && mobileAppro.getPassed() == Constants.YES) {
        mv.setViewName("account/approve/mobile/verifyOldMobile");
      } else {
        mv.setViewName("account/approve/mobile/newMobile");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return mv;
  }
 /**
  * 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 justin.xu
  * @version 0.1 2014年4月30日
  * @param request
  * @param session
  * @param mobile 手机号
  * @param activeCode 验证码
  * @return String
  */
 @RequestMapping(value = "activeMobile")
 @ResponseBody
 public MessageBox activeMobile(
     HttpServletRequest request, HttpSession session, String mobile, String activeCode) {
   String result = "success";
   try {
     ShiroUser shiroUser = currentUser();
     MobileApproVo mobileApproVo =
         mobileApproService.queryMobileApproByUserId(shiroUser.getUserId());
     // 修改手机号码操作
     if (null != mobileApproVo
         && null != mobileApproVo.getPassed()
         && mobileApproVo.getPassed() == Constants.YES) {
       return new MessageBox("0", "手机号码已认证通过");
     }
     MemberCnd memberCnd = new MemberCnd();
     memberCnd.setId(shiroUser.getUserId());
     MemberVo memberVo = memberService.queryMemberByCnd(memberCnd);
     result =
         mobileApproService.saveMobileAppro(
             memberVo, mobile, activeCode, request, BusinessConstants.MOBILE_APPRO_FUNCTION);
   } catch (AppException ae) {
     result = ae.getMessage();
   } catch (Exception e) {
     result = "网络连接异常,请刷新页面或稍后重试!";
     e.printStackTrace();
   }
   if (BusinessConstants.SUCCESS.equals(result)) {
     return new MessageBox("1", "短信认证成功!");
   }
   return new MessageBox("0", result);
 }
  /**
   * Description:安全中心-验证账户信息-发送手机认证验证码<br>
   *
   * @author hujianpan
   * @version 0.1 2014年8月30日
   * @param request
   * @param session
   * @return String
   */
  @RequiresAuthentication
  @RequestMapping(value = "/sendMobailActiveInSaftCenter")
  @ResponseBody
  public MessageBox sendMobailActiveInSaftCenter(HttpServletRequest request, HttpSession session) {
    String result = BusinessConstants.SUCCESS;
    Member member = currentMember();
    if (StringUtils.isEmpty(member.getUsername())) {
      return new MessageBox("0", "请先登入!");
    }
    String mobile = request.getParameter("mobile");
    String activeCode = request.getParameter("activeCode");
    try {
      MobileApproVo mobileApproVo = mobileApproService.queryMobileApproByUserId(member.getId());
      // 修改手机号码操作
      if (null
              == session.getAttribute(
                  BusinessConstants.MOBILE_APPRO_RESET_FUNCTION + member.getId())
          && (null != mobileApproVo
              && null != mobileApproVo.getPassed()
              && mobileApproVo.getPassed() == Constants.YES)) {
        return new MessageBox("0", "手机号码已认证通过");
      }
      result =
          mobileApproService.sendMobileApprValidate(
              mobile, request, member.getUsername(), BusinessConstants.MOBILE_APPRO_FUNCTION);
      if (!BusinessConstants.SUCCESS.equals(result)) {
        return new MessageBox("0", result);
      }
      ShiroUser shiroUser = currentUser();
      MemberVo memberVo = new MemberVo();
      memberVo.setId(shiroUser.getUserId());

      mobileApproService.packageMobileApproCode(memberVo, mobile, activeCode, request);
      // 删除验证原有手机号码session
      session.removeAttribute(BusinessConstants.MOBILE_APPRO_RESET_FUNCTION + member.getId());
    } catch (Exception e) {
      result = "发送验证码出错,请联系客服";
      e.printStackTrace();
    }
    if (!BusinessConstants.SUCCESS.equals(result)) {
      return new MessageBox("0", result);
    }
    return new MessageBox("1", "发送成功,请注意查收");
  }
 /**
  * Description:根据当前用户的手机号发送验证码<br>
  *
  * @author justin.xu
  * @version 0.1 2014年4月30日
  * @param request
  * @param session
  * @return String
  */
 @RequestMapping(value = "sendResetMsg")
 @ResponseBody
 public MessageBox sendResetMsg(HttpServletRequest request, HttpSession session) {
   String result = BusinessConstants.SUCCESS;
   try {
     ShiroUser shiroUser = currentUser();
     MobileApproVo mobileApproVo =
         mobileApproService.queryMobileApproByUserId(shiroUser.getUserId());
     result =
         mobileApproService.sendMobileApprValidate(
             mobileApproVo.getMobileNum(),
             request,
             shiroUser.getUserName(),
             BusinessConstants.MOBILE_APPRO_RESET_FUNCTION,
             BusinessConstants.SMS_TEMPLATE_TYPE_VERIFY_MOBILE_CODE);
   } catch (Exception e) {
     result = "网络连接异常,请刷新页面或稍后重试!";
     e.printStackTrace();
   }
   if (BusinessConstants.SUCCESS.equals(result)) {
     return new MessageBox("1", "验证码发送成功,请查收手机短信。");
   }
   return new MessageBox("0", result);
 }