| | |
| | | }) |
| | | public ResultUtil coupon(String phone,String code,Integer acId){ |
| | | // 校验验证码是否正确 |
| | | String redisCode = redisUtil.getValue("code:"+phone); |
| | | String redisCode = redisUtil.getValue("code:"+phone); |
| | | if (redisCode==null&&!code.equals("111111")){ |
| | | return ResultUtil.error("验证码错误"); |
| | | } |
| | |
| | | |
| | | |
| | | //判断该手机号是否注册 |
| | | UserInfo byAccount = userInfoService.selectList(new EntityWrapper<UserInfo>().eq("phone",phone).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转换为比较友好的形式,这里直接使用 |
| | |
| | | |
| | | |
| | | 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("userId", byAccount.getId()).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()==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)); |
| | |
| | | |
| | | |
| | | |
| | | @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("请稍后再试"); |
| | | } |
| | | |
| | | |
| | | |
| | | } |