| | |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | //import com.stylefeng.guns.modular.system.util.ICBCPayUtil; |
| | | import com.stylefeng.guns.modular.system.service.impl.UserServiceImpl; |
| | | import com.stylefeng.guns.modular.system.util.ALiSendSms; |
| | | import com.stylefeng.guns.modular.system.util.PayMoneyUtil; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | 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>().ne("flag",3)).get(0); |
| | | List<UserInfo> userInfos = userInfoService.selectList(new EntityWrapper<UserInfo>().eq("phone", phone).ne("flag", 3)); |
| | | //已注册直接添加优惠卷 |
| | | TActivityGeneralization tActivityGeneralization = activityGeneralizationService.selectById(acId); |
| | | if (tActivityGeneralization.getState()==4){ |
| | | return ResultUtil.error("当前活动已暂停"); |
| | | } |
| | | // 获取当前时间 |
| | | 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){ |
| | | |
| | | int i1 = userCouponRecordService.selectCount(new EntityWrapper<UserCouponRecord>().eq("activityType", 5).eq("couponActivityId", acId).groupBy("userId")); |
| | | if (tActivityGeneralization.getParticipateCount()<=i1){ |
| | | return ResultUtil.error("当前参与人数已满"); |
| | | } |
| | | |
| | | if (!userInfos.isEmpty()){ |
| | | //判断该账号是否领取 |
| | | List<UserCouponRecord> userCouponRecords = userCouponRecordService.selectList(new EntityWrapper<UserCouponRecord>().eq("activityType", 5).eq("couponActivityId", acId)); |
| | | List<UserCouponRecord> userCouponRecords = userCouponRecordService.selectList(new EntityWrapper<UserCouponRecord>().eq("userId", userInfos.get(0).getId()).eq("activityType", 5).eq("couponActivityId", acId)); |
| | | if (!userCouponRecords.isEmpty()){ |
| | | return ResultUtil.error("当前用户已领取"); |
| | | return ResultUtil.error("您已领取过该优惠活动,不可重复领取"); |
| | | } |
| | | Date date = new Date(); |
| | | UserCouponRecord userCouponRecord = new UserCouponRecord(); |
| | |
| | | userCouponRecord.setState(1); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + sysCouponRecord.getEffective()); |
| | | calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + tActivityGeneralization.getEffective()); |
| | | userCouponRecord.setExpirationTime(calendar.getTime()); |
| | | userCouponRecord.setCouponType(Integer.valueOf(String.valueOf(sysCouponRecord.getCouponType()))); |
| | | userCouponRecord.setCouponUseType(sysCouponRecord.getCouponUseType()); |
| | | userCouponRecord.setInsertTime(date); |
| | | userCouponRecord.setFullMoney(Double.valueOf(String.valueOf(sysCouponRecord.getFullMoney()))); |
| | | userCouponRecord.setFullMoney(Double.valueOf(String.valueOf(sysCouponRecord.getFullMoney()==null?0:sysCouponRecord.getFullMoney()))); |
| | | userCouponRecord.setMoney(Double.valueOf(String.valueOf(sysCouponRecord.getMoney()))); |
| | | userCouponRecord.setCompanyId(byAccount.getCompanyId()); |
| | | userCouponRecord.setUserId(byAccount.getId()); |
| | | userCouponRecord.setCompanyId(sysCouponRecord.getCompanyId()); |
| | | userCouponRecord.setUserId(userInfos.get(0).getId()); |
| | | |
| | | Integer userGrantCount = tActivityGeneralization.getUserGrantCount(); |
| | | // userCouponRecordService.insert(userCouponRecord); |
| | | if (userGrantCount != null && userGrantCount > 0) { |
| | | for (int i = 0; i < userGrantCount; i++) {// ... |
| | | for (int i = 0; i < userGrantCount; i++) { |
| | | userCouponRecordService.insert(userCouponRecord); |
| | | } |
| | | } |
| | |
| | | //判断当前用户是否领取 |
| | | String value = redisUtil.getValue("counpon:" + phone); |
| | | if (value!=null){ |
| | | return ResultUtil.error("当前用户已领取"); |
| | | String[] split = value.split(","); |
| | | for (String s : split) { |
| | | if (s.equals(String.valueOf(acId))){ |
| | | return ResultUtil.error("您已领取过该优惠活动,不可重复领取"); |
| | | } |
| | | } |
| | | redisUtil.setStrValue("counpon:"+phone, value+","+String.valueOf(acId)); |
| | | } |
| | | //未注册将优惠卷信息存入缓存,待用户注册时调用来添加优惠卷 |
| | | redisUtil.setStrValue("counpon:"+phone, String.valueOf(acId)); |
| | |
| | | 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) { |
| | |
| | | @PostMapping("/get/coupon/info") |
| | | @ApiOperation(value = "使用说明", tags = {"线下推广页面"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "电话", name = "phone", required = true, dataType = "String"), |
| | | @ApiImplicitParam(value = "验证码", name = "code", required = true, dataType = "String") |
| | | |
| | | }) |
| | | public ResultUtil coupon(Integer acId){ |
| | | TActivityGeneralization tActivityGeneralization = activityGeneralizationService.selectById(acId); |
| | |
| | | return ResultUtil.success(tActivityGeneralization.getUseExplain()); |
| | | } |
| | | |
| | | @Autowired |
| | | private WeChatUtil weChatUtil; |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/get/coupon/toWe") |
| | | @ApiOperation(value = "获取微信链接", tags = {"线下推广页面"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | |
| | | }) |
| | | public ResultUtil toWe(){ |
| | | try { |
| | | String urlLink = weChatUtil.getUrlLink(null, null); |
| | | return ResultUtil.success(urlLink); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return ResultUtil.error("请稍后再试"); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/get/driverQr") |
| | | @ApiOperation(value = "获取司机二维码新", tags = {"线下推广页面"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | |
| | | }) |
| | | public ResultUtil driverQr(){ |
| | | try { |
| | | String urlLink = weChatUtil.getUrlLink("pages/areaDetails/areaDetails", null); |
| | | return ResultUtil.success(urlLink); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return ResultUtil.error("请稍后再试"); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/get/rid") |
| | | @ApiOperation(value = "获取司机二维码新", tags = {"线下推广页面"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | |
| | | }) |
| | | public ResultUtil rid(){ |
| | | try { |
| | | String urlLink = weChatUtil.rid("/pages/home/scanPage/scanPage", null); |
| | | return ResultUtil.success(urlLink); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return ResultUtil.error("请稍后再试"); |
| | | } |
| | | |
| | | |
| | | |