| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/get/confirm") |
| | | @ApiOperation(value = "校验当前活动是否过期", tags = {"线下推广页面"}, notes = "") |
| | | @ApiImplicitParams( |
| | | {@ApiImplicitParam(value = "活动Id", name = "acId", required = true, dataType = "int") |
| | | }) |
| | | public ResultUtil confirm(Integer acId){ |
| | | TActivityGeneralization tActivityGeneralization = activityGeneralizationService.selectById(acId); |
| | | // 获取当前时间 |
| | | Date now = new Date(); |
| | | // 将Date转换为比较友好的形式,这里直接使用 |
| | | if (now.after(tActivityGeneralization.getStartTime()) && now.before(tActivityGeneralization.getEndTime())) { |
| | | return ResultUtil.success(); |
| | | } else { |
| | | return ResultUtil.error("该活动已失效"); |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/get/coupon") |
| | | @ApiOperation(value = "获取优惠卷", tags = {"线下推广页面"}, notes = "") |
| | | @ApiImplicitParams({ |
| | |
| | | @ApiImplicitParam(value = "验证码", name = "code", required = true, dataType = "String") |
| | | }) |
| | | public ResultUtil coupon(String phone,String code,Integer acId){ |
| | | //判断验证码是否正确 |
| | | // 校验验证码是否正确 |
| | | String redisCode = redisUtil.getValue("code:"+phone); |
| | | if (redisCode==null&&!code.equals("111111")){ |
| | | return ResultUtil.error("验证码错误"); |
| | | } |
| | | if (!code.equals(redisCode)&&!code.equals("111111")) { |
| | | return ResultUtil.error("验证码错误"); |
| | | } |
| | | |
| | | |
| | | //判断该手机号是否注册 |
| | | UserInfo byAccount = userInfoService.selectList(new EntityWrapper<UserInfo>().eq("phone",phone).ne("flag",3)).get(0); |
| | | //已注册直接添加优惠卷 |
| | | TActivityGeneralization tActivityGeneralization = activityGeneralizationService.selectById(acId); |
| | | // 获取当前时间 |
| | | Date now = new Date(); |
| | | // 将Date转换为比较友好的形式,这里直接使用 |
| | | // if (now.after(tActivityGeneralization.getStartTime()) && now.before(tActivityGeneralization.getEndTime())) { |
| | | // System.out.println("当前时间在活动的开始时间和结束时间之间"); |
| | | // } else { |
| | | // return ResultUtil.error("该活动已失效"); |
| | | // } |
| | | |
| | | |
| | | SysCouponRecord sysCouponRecord = sysCouponRecordService.selectById(tActivityGeneralization.getCouponId()); |
| | | if (byAccount != null){ |
| | | //判断该账号是否领取 |
| | | List<UserCouponRecord> userCouponRecords = userCouponRecordService.selectList(new EntityWrapper<UserCouponRecord>().eq("activityType", 5).eq("couponActivityId", acId)); |
| | | List<UserCouponRecord> userCouponRecords = userCouponRecordService.selectList(new EntityWrapper<UserCouponRecord>().eq("userId", byAccount.getId()).eq("activityType", 5).eq("couponActivityId", acId)); |
| | | if (!userCouponRecords.isEmpty()){ |
| | | return ResultUtil.error("当前用户已领取"); |
| | | } |
| | |
| | | aliSms.setCode(code); |
| | | String json = JSONObject.toJSONString(aliSms); |
| | | try { |
| | | redisUtil.setStrValue("code:"+phone, code,15 * 60 * 1000); |
| | | aLiSendSms.sendSms(phone, "SMS_467580138", json); |
| | | |
| | | } catch (Exception e) { |