|
@@ -2,19 +2,29 @@ package com.iamberry.wechat.handles.thanksgiving;
|
|
|
|
|
|
import com.iamberry.wechat.core.entity.ResultMsg;
|
|
import com.iamberry.wechat.core.entity.ResultMsg;
|
|
import com.iamberry.wechat.core.entity.WechatUtils;
|
|
import com.iamberry.wechat.core.entity.WechatUtils;
|
|
|
|
+import com.iamberry.wechat.core.entity.coupon.CouponItemDto;
|
|
|
|
+import com.iamberry.wechat.core.entity.coupon.CouponType;
|
|
import com.iamberry.wechat.core.entity.member.Member;
|
|
import com.iamberry.wechat.core.entity.member.Member;
|
|
import com.iamberry.wechat.core.entity.thanksgiving.ThanksGiving;
|
|
import com.iamberry.wechat.core.entity.thanksgiving.ThanksGiving;
|
|
|
|
+import com.iamberry.wechat.face.coupon.CouponItemService;
|
|
|
|
+import com.iamberry.wechat.face.coupon.CouponTypeService;
|
|
import com.iamberry.wechat.face.member.MemberService;
|
|
import com.iamberry.wechat.face.member.MemberService;
|
|
import com.iamberry.wechat.face.order.CodeService;
|
|
import com.iamberry.wechat.face.order.CodeService;
|
|
import com.iamberry.wechat.face.thanksgiving.ThanksGivingService;
|
|
import com.iamberry.wechat.face.thanksgiving.ThanksGivingService;
|
|
|
|
+import com.iamberry.wechat.service.ImberryConfig;
|
|
|
|
+import com.iamberry.wechat.tools.NameUtils;
|
|
import com.iamberry.wechat.tools.payUtil.RandomUtil;
|
|
import com.iamberry.wechat.tools.payUtil.RandomUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
+import javax.servlet.ServletException;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpSession;
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
+import java.io.IOException;
|
|
import java.text.MessageFormat;
|
|
import java.text.MessageFormat;
|
|
import java.util.Calendar;
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -35,7 +45,29 @@ public class ThanksGivingHandler {
|
|
private MemberService memberService;
|
|
private MemberService memberService;
|
|
|
|
|
|
|
|
|
|
- private final static String SEND_VERIFICATION_PHONE ="";
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 免费送滤芯
|
|
|
|
+ * @param request
|
|
|
|
+ * @param response
|
|
|
|
+ * @throws ServletException
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/free_collection", method = RequestMethod.GET)
|
|
|
|
+ public void freeCollection(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
|
+ request.getRequestDispatcher(NameUtils.getConfig("WECHAT_GO_FREE_COLLECTION")).forward(request, response);return;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 免费领取滤芯
|
|
|
|
+ * @param request
|
|
|
|
+ * @param response
|
|
|
|
+ * @throws ServletException
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/receiving_filter", method = RequestMethod.GET)
|
|
|
|
+ public void receivingFilter(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
|
+ request.getRequestDispatcher(NameUtils.getConfig("WECHAT_GO_RECEIVING_FILTER_CARTRIDGE")).forward(request, response);return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 发送验证码
|
|
* 发送验证码
|
|
@@ -86,14 +118,14 @@ public class ThanksGivingHandler {
|
|
thanksGiving.setThanksGivingPhone(phone);
|
|
thanksGiving.setThanksGivingPhone(phone);
|
|
List<ThanksGiving> thanksGivingList = thanksGivingService.getThanksGivingList(thanksGiving);
|
|
List<ThanksGiving> thanksGivingList = thanksGivingService.getThanksGivingList(thanksGiving);
|
|
if(thanksGivingList == null || thanksGivingList.size() < 1){
|
|
if(thanksGivingList == null || thanksGivingList.size() < 1){
|
|
- return new ResultMsg(false, ResultMsg.ERROR, "改电话号码不能领取!",null);
|
|
|
|
|
|
+ return new ResultMsg(false, ResultMsg.ERROR, "该电话号码不能领取!",null);
|
|
}
|
|
}
|
|
|
|
|
|
//获取验证码
|
|
//获取验证码
|
|
String num = RandomUtil.getRandom();
|
|
String num = RandomUtil.getRandom();
|
|
//使用request对象的getSession()获取session,如果session不存在则创建一个
|
|
//使用request对象的getSession()获取session,如果session不存在则创建一个
|
|
HttpSession session = request.getSession();
|
|
HttpSession session = request.getSession();
|
|
- String text = MessageFormat.format(SEND_VERIFICATION_PHONE, num);
|
|
|
|
|
|
+ String text = MessageFormat.format(ImberryConfig.PROBATION_VERIFICATION_CODE, num);
|
|
String result = codeService.sendOtherCMS(phone, text);
|
|
String result = codeService.sendOtherCMS(phone, text);
|
|
|
|
|
|
//将数据存储到session中
|
|
//将数据存储到session中
|
|
@@ -121,19 +153,20 @@ public class ThanksGivingHandler {
|
|
if(member.getUserStatus() != 2){
|
|
if(member.getUserStatus() != 2){
|
|
return new ResultMsg(false, ResultMsg.ERROR, "未关注不能领取!",null);
|
|
return new ResultMsg(false, ResultMsg.ERROR, "未关注不能领取!",null);
|
|
}
|
|
}
|
|
-
|
|
|
|
- if(phone.length() != 11){
|
|
|
|
- rm.setMessage(ResultMsg.ERROR);
|
|
|
|
- rm.setMessage("电话号码错误!");
|
|
|
|
- return rm;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
//判断验证码
|
|
//判断验证码
|
|
//使用request对象的getSession()获取session,如果session不存在则创建一个
|
|
//使用request对象的getSession()获取session,如果session不存在则创建一个
|
|
HttpSession session = request.getSession();
|
|
HttpSession session = request.getSession();
|
|
String verificationTel = (String) session.getAttribute("verification_tel");
|
|
String verificationTel = (String) session.getAttribute("verification_tel");
|
|
String verificationCode = (String) session.getAttribute("verification_code");
|
|
String verificationCode = (String) session.getAttribute("verification_code");
|
|
Date verificationDate = (Date) session.getAttribute("verification_date");
|
|
Date verificationDate = (Date) session.getAttribute("verification_date");
|
|
|
|
+ if(verificationTel == null || verificationCode == null || verificationDate == null){
|
|
|
|
+ return new ResultMsg(false, ResultMsg.ERROR, "领取出错,请重新获取验证码!",null);
|
|
|
|
+ }
|
|
|
|
+ if(phone.length() != 11 && phone.equals(verificationTel)){
|
|
|
|
+ rm.setMessage(ResultMsg.ERROR);
|
|
|
|
+ rm.setMessage("电话号码错误!");
|
|
|
|
+ return rm;
|
|
|
|
+ }
|
|
if(code == null || "".equals(code)){
|
|
if(code == null || "".equals(code)){
|
|
return new ResultMsg(false, ResultMsg.ERROR, "验证码为空!",null);
|
|
return new ResultMsg(false, ResultMsg.ERROR, "验证码为空!",null);
|
|
}
|
|
}
|
|
@@ -161,7 +194,7 @@ public class ThanksGivingHandler {
|
|
tg.setThanksGivingOpenId(member.getUserOpenid());
|
|
tg.setThanksGivingOpenId(member.getUserOpenid());
|
|
Integer flag = 0;
|
|
Integer flag = 0;
|
|
try{
|
|
try{
|
|
- thanksGivingService.update(tg);
|
|
|
|
|
|
+ flag = thanksGivingService.update(tg);
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
return new ResultMsg(false, ResultMsg.ERROR, e.getMessage(),null);
|
|
return new ResultMsg(false, ResultMsg.ERROR, e.getMessage(),null);
|
|
@@ -169,9 +202,13 @@ public class ThanksGivingHandler {
|
|
if(flag < 1){
|
|
if(flag < 1){
|
|
return new ResultMsg(false, ResultMsg.ERROR, "领取失败,请重新领取!",null);
|
|
return new ResultMsg(false, ResultMsg.ERROR, "领取失败,请重新领取!",null);
|
|
}
|
|
}
|
|
- rm.setMessage(ResultMsg.SUCCESS);
|
|
|
|
- rm.setStatus(true);
|
|
|
|
- return rm;
|
|
|
|
|
|
+
|
|
|
|
+ //领取成功 验证码失效,
|
|
|
|
+ session.setAttribute("verification_code",null );
|
|
|
|
+ session.setAttribute("verification_tel",null );
|
|
|
|
+ session.setAttribute("verification_date",null );
|
|
|
|
+
|
|
|
|
+ return new ResultMsg(true, ResultMsg.SUCCESS, "领取成功!",null);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|