Esempio n. 1
0
 @RequestMapping(value = "/apply.do")
 @ResponseBody
 public AjaxJson apply(String telephone) { // 进行申请
   AjaxJson j = new AjaxJson();
   String message = "";
   j.setSuccess(false);
   try {
     String validTel = GZipUtils.gzip_decompress(telephone);
     if (WechatConstant.validate_none.equals(validTel)) {
       message = "还没有进行验证,首先进行验证操作";
     } else if (WechatConstant.validate_failure.equals(validTel)) {
       message = "号码验证失败,请重新验证";
     } else {
       if (wechatRegisterServiceImpl.hasGet(validTel)) {
         message = "hasget";
         j.setSuccess(true);
       } else {
         WechatRegHasget get = new WechatRegHasget();
         get.setTelephone(validTel);
         get.setGetTime(DateProcess.geTimestamp());
         wechatRegisterServiceImpl.saveHasGet(get);
         message = "已经有" + wechatRegisterServiceImpl.getRegisterNums() + "人参与了流量申请";
         j.setSuccess(true);
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   j.setMsg(message);
   return j;
 }
Esempio n. 2
0
 @RequestMapping(value = "/submit.do")
 @ResponseBody
 public AjaxJson submit(HttpServletRequest request, RegisterEntity register, String validateCode) {
   AjaxJson j = new AjaxJson();
   String message = "";
   String openId =
       (String) request.getSession().getAttribute(WechatConstant.register_session_openId);
   String code =
       (String)
           request
               .getSession()
               .getAttribute( // 获取session中的code
                   WechatConstant.validate_session_code);
   j.setSuccess(false);
   if (code == null) {
     message = "验证码已经过期,请重新获取";
   } else if (!validateCode.equals(code)) {
     message = "验证码不正确!请重新输入";
   } else {
     if ((WechatConstant.has_register).equals(openId)) {
       message = "您已经登记过了,不需要再次登记";
     } else {
       register.setOpenId(openId);
       register.setBindTime(DateProcess.geTimestamp());
       try {
         wechatRegisterServiceImpl.saveRegisterInfo(register);
       } catch (Exception e) {
         e.printStackTrace();
       }
       j.setObj(register.getTelephone());
       // message = WechatConstant.register_success;
       message = "恭喜你登记成功,点击\"确定\"跳转到大学生寒假特惠活动链接";
       j.setSuccess(true);
       remove(request); // 最后登记成功后删除session释放内存
     }
   }
   j.setMsg(message);
   return j;
 }