@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; }
@RequestMapping(value = "/validate.do") @ResponseBody public AjaxJson validate(String telephone) { // 验证手机号码 AjaxJson j = new AjaxJson(); String message = WechatConstant.validate_failed; // 验证失败时候提示 try { if (wechatRegisterServiceImpl.validateRegisterBytel(telephone)) { message = WechatConstant.validate_success; // 验证成功时候提供 j.setObj(GZipUtils.gzip_compress(telephone)); j.setSuccess(true); } else { j.setObj(GZipUtils.gzip_compress(WechatConstant.validate_failure)); j.setSuccess(false); } } catch (Exception e) { e.printStackTrace(); } j.setMsg(message); return j; }
@RequestMapping(value = "/share.do") public ModelAndView share( HttpServletRequest request, String openId) { // 普通朋友圈分享入口,从这里进入页面必须验证手机号码 int count = 0; try { if (openId == null) { // 从朋友圈中进入 request.setAttribute("telephone", GZipUtils.gzip_compress(WechatConstant.validate_none)); } else { RegisterEntity register = wechatRegisterServiceImpl.findRegisterInfoByOpenId(openId); if (register == null) { return new ModelAndView("register/error"); // 非法操作,修改了指定路径 } else { request.setAttribute( "telephone", GZipUtils.gzip_compress(register.getTelephone())); // 从自己微信端口进入 } } count = wechatRegisterServiceImpl.getRegisterNums(); } catch (Exception e) { e.printStackTrace(); } request.setAttribute("regCount", count); return new ModelAndView("/register/share"); }
// 登记号后直接进入 @RequestMapping(value = "/shareWe.do") public ModelAndView shareWe(HttpServletRequest request) { String openId = (String) request.getSession().getAttribute(WechatConstant.register_session_openId); int count = 0; try { if (openId == null) { return new ModelAndView("register/error"); } else { RegisterEntity register = wechatRegisterServiceImpl.findRegisterInfoByOpenId(openId); request.setAttribute("telephone", GZipUtils.gzip_compress(register.getTelephone())); } count = wechatRegisterServiceImpl.getRegisterNums(); } catch (Exception e) { e.printStackTrace(); } request.setAttribute("regCount", count); return new ModelAndView("/register/share"); }