|
@@ -108,14 +108,16 @@ public class ApparatusHandler {
|
|
|
|
|
|
//使用request对象的getSession()获取session,如果session不存在则创建一个
|
|
|
HttpSession session = request.getSession();
|
|
|
- //将数据存储到session中
|
|
|
- session.setAttribute("verification_code",num );
|
|
|
- session.setAttribute("verification_date",new Date());
|
|
|
+
|
|
|
|
|
|
String text = MessageFormat.format(ImberryConfig.SEND_VERIFICATION_PHONE, num);
|
|
|
String result = codeService.informShipping(phone, text);
|
|
|
|
|
|
if ("SUCCESS".equals(result)) {
|
|
|
+ //将数据存储到session中
|
|
|
+ session.setAttribute("verification_code",num );
|
|
|
+ session.setAttribute("verification_tel",phone );
|
|
|
+ session.setAttribute("verification_date",new Date());
|
|
|
logger.info("短信发送成功,验证码为:" + num);
|
|
|
msg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
msg.setStatus(true);
|
|
@@ -123,7 +125,7 @@ public class ApparatusHandler {
|
|
|
logger.info("短信发送失败:" + result);
|
|
|
msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
msg.setStatus(false);
|
|
|
- msg.setMessage("获取验证码失败");
|
|
|
+ msg.setMessage("短信发送失败");
|
|
|
return msg;
|
|
|
}
|
|
|
return msg;
|
|
@@ -140,27 +142,33 @@ public class ApparatusHandler {
|
|
|
@RequestMapping("/add_apparatus")
|
|
|
public ResultMsg addApparatus(HttpServletRequest request,Member member,String code) throws Exception {
|
|
|
ResultMsg msg = new ResultMsg();
|
|
|
-
|
|
|
- //判断验证码
|
|
|
- //使用request对象的getSession()获取session,如果session不存在则创建一个
|
|
|
- HttpSession session = request.getSession();
|
|
|
- String verificationCode = (String) session.getAttribute("verification_code");
|
|
|
- code = code.trim();
|
|
|
-
|
|
|
- Date verificationDate = (Date) session.getAttribute("verification_date");
|
|
|
- Calendar nowTime = Calendar.getInstance();
|
|
|
- nowTime.setTime(verificationDate);
|
|
|
- nowTime.add(Calendar.MINUTE, 5);
|
|
|
- Date verData = nowTime.getTime();
|
|
|
- if(!verificationCode.equals(code) || (verData.getTime() < new Date().getTime()) ){
|
|
|
- msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
- msg.setStatus(false);
|
|
|
- msg.setMessage("验证码不正确或已失效,请重新获取!");
|
|
|
- return msg;
|
|
|
+ Member memberInfo = WechatUtils.getUserBySession(request);
|
|
|
+ memberInfo = memberService.getMemberByUserOpenId(memberInfo.getUserOpenid());
|
|
|
+ if(memberInfo.getUserTel() == null || !memberInfo.getUserTel().equals(member.getUserTel())){
|
|
|
+ //判断验证码
|
|
|
+ //使用request对象的getSession()获取session,如果session不存在则创建一个
|
|
|
+ HttpSession session = request.getSession();
|
|
|
+ String verificationTel = (String) session.getAttribute("verification_tel");
|
|
|
+ if(member.getUserTel() == null || !member.getUserTel().equals(verificationTel)){
|
|
|
+ return new ResultMsg(false, ResultInfo.ERRORCODE, "手机验证失败!",null);
|
|
|
+ }
|
|
|
+
|
|
|
+ String verificationCode = (String) session.getAttribute("verification_code");
|
|
|
+ if(code == null){
|
|
|
+ return new ResultMsg(false, ResultInfo.ERRORCODE, "未填写验证码!",null);
|
|
|
+ }
|
|
|
+ code = code.trim();
|
|
|
+ Date verificationDate = (Date) session.getAttribute("verification_date");
|
|
|
+ Calendar nowTime = Calendar.getInstance();
|
|
|
+ nowTime.setTime(verificationDate);
|
|
|
+ nowTime.add(Calendar.MINUTE, 5);
|
|
|
+ Date verData = nowTime.getTime();
|
|
|
+ if(!verificationCode.equals(code) || (verData.getTime() < new Date().getTime()) ){
|
|
|
+ //return new ResultMsg(false, ResultInfo.ERRORCODE, "验证码不正确或已失效,请重新获取!",null);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- Member memberInfo = WechatUtils.getUserBySession(request);
|
|
|
//获取换新时间期限
|
|
|
ShopSystemRule renewRule = systemService.selectOneShopRuleById(246);
|
|
|
member.setUserOpenid(memberInfo.getUserOpenid());
|
|
@@ -171,10 +179,7 @@ public class ApparatusHandler {
|
|
|
if (!StringUtil.isNotEmpty(barCode)
|
|
|
||!StringUtil.isNotEmpty(apparatusStore)
|
|
|
||!StringUtil.isNotEmpty(buyDate)) {
|
|
|
- msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
- msg.setStatus(false);
|
|
|
- msg.setMessage("注册数据为空,请重新提交!");
|
|
|
- return msg;
|
|
|
+ return new ResultMsg(false, ResultInfo.ERRORCODE, "注册数据为空,请重新提交!",null);
|
|
|
}
|
|
|
//拼接日期信息
|
|
|
buyDate = buyDate+" 00:00:00";
|
|
@@ -184,19 +189,13 @@ public class ApparatusHandler {
|
|
|
//获取机器信息
|
|
|
List<Apparatus> apparatusList = apparatusService.listApparatusPage(apparatus);
|
|
|
if (apparatusList != null && apparatusList.size() > 0) {
|
|
|
- msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
- msg.setStatus(false);
|
|
|
- msg.setMessage("该机器已被绑定!");
|
|
|
- return msg;
|
|
|
+ return new ResultMsg(false, ResultInfo.ERRORCODE, "该机器已被绑定!",null);
|
|
|
}
|
|
|
//获取rst系统产品信息,根据获取到的产品id查出对呀的产品颜色id
|
|
|
Integer productColorId = 0;
|
|
|
String json = HttpUtility.httpsGet(ResultInfo.GET_MACHINE_INFO+barCode);
|
|
|
if(json == null){
|
|
|
- msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
- msg.setStatus(false);
|
|
|
- msg.setMessage("会员注册失败,获取机器信息失败!");
|
|
|
- return msg;
|
|
|
+ return new ResultMsg(false, ResultInfo.ERRORCODE, "会员注册失败,获取机器信息失败!",null);
|
|
|
}
|
|
|
JSONObject machineJson = JSONObject.fromObject(json);
|
|
|
JSONObject message = machineJson.getJSONObject("message");
|
|
@@ -205,10 +204,7 @@ public class ApparatusHandler {
|
|
|
String productId = message.getString("productId");//产品id
|
|
|
productColorId = apparatusService.getColorIdByProductId(productId);
|
|
|
}else{
|
|
|
- msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
- msg.setStatus(false);
|
|
|
- msg.setMessage("会员注册失败,未找到该机器!");
|
|
|
- return msg;
|
|
|
+ return new ResultMsg(false, ResultInfo.ERRORCODE, "会员注册失败,未找到该机器!",null);
|
|
|
}
|
|
|
apparatus.setColorId(productColorId);
|
|
|
apparatus.setUserOpenid(memberInfo.getUserOpenid());
|
|
@@ -221,10 +217,7 @@ public class ApparatusHandler {
|
|
|
msg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
msg.setStatus(true);
|
|
|
} else {
|
|
|
- msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
- msg.setStatus(false);
|
|
|
- msg.setMessage("会员注册失败,请重新注册!");
|
|
|
- return msg;
|
|
|
+ return new ResultMsg(false, ResultInfo.ERRORCODE, "会员注册失败,请重新注册!",null);
|
|
|
}
|
|
|
return msg;
|
|
|
}
|