From 7b7bb4e3a7b5fb171a0c4d6fef983902e06a22a5 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期五, 13 六月 2025 15:34:44 +0800 Subject: [PATCH] 川易充 --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/TaskUtil.java | 109 +++++++++++++++++++++++++----------------------------- 1 files changed, 50 insertions(+), 59 deletions(-) diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/TaskUtil.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/TaskUtil.java index 122ca09..f9c97c4 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/TaskUtil.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/TaskUtil.java @@ -5,8 +5,6 @@ import com.ruoyi.account.api.model.TAppUserVipDetail; import com.ruoyi.account.service.TAppUserService; import com.ruoyi.account.service.TAppUserVipDetailService; -import org.intellij.lang.annotations.RegExp; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -21,61 +19,54 @@ */ @Component public class TaskUtil { - - @Resource - private TAppUserVipDetailService tAppUserVipDetailService; - - @Resource - private TAppUserService appUserService; - - - /** - * 每隔一分钟去处理的定时任务 - */ - @Scheduled(fixedRate = 1000 * 60) - public void sendVipCoupon(){ - try { - //首先获取当前的月份,用int类型标识 - LocalDate currentDate = LocalDate.now(); - int monthNum = currentDate.getMonthValue(); - //获取在当前时间内生效的vipDetail - List<TAppUserVipDetail> recentDetails = tAppUserVipDetailService.lambdaQuery() - .ge(TAppUserVipDetail::getStartTime, currentDate) - .le(TAppUserVipDetail::getEndTime, currentDate) - .orderByDesc(TAppUserVipDetail::getStartTime).list(); - //判断sendNum是否包括当前月份 - for (TAppUserVipDetail recentDetail : recentDetails) { - - //赠送优惠卷 - tAppUserVipDetailService.giveVipCoupun(recentDetail.getAppUserId(), recentDetail.getVipId(),recentDetail.getId(),monthNum); - - - } - } catch (Exception e) { - e.printStackTrace(); - } - - - - - } - - @Scheduled(fixedRate = 1000 * 60) - public void changeVipId(){ - LocalDateTime currentDate = LocalDateTime.now(); - List<TAppUserVipDetail> recentDetails = tAppUserVipDetailService.lambdaQuery() - .le(TAppUserVipDetail::getStartTime, currentDate) - .ge(TAppUserVipDetail::getEndTime, currentDate) - .orderByDesc(TAppUserVipDetail::getStartTime).list(); - for (TAppUserVipDetail recentDetail : recentDetails) { - TAppUser byId = appUserService.getById(recentDetail.getAppUserId()); - if (byId!=null) { - byId.setVipId(recentDetail.getVipId()); - appUserService.updateById(byId); - } - } - - } - - + + @Resource + private TAppUserVipDetailService tAppUserVipDetailService; + + @Resource + private TAppUserService appUserService; + + + /** + * 每隔一分钟去处理的定时任务 + */ + @Scheduled(fixedRate = 1000 * 60) + public void sendVipCoupon() { + try { + //会员优惠次数使用完后重新续次数 + LocalDateTime currentDate = LocalDateTime.now(); + List<TAppUserVipDetail> recentDetails = tAppUserVipDetailService.lambdaQuery() + .le(TAppUserVipDetail::getStartTime, currentDate) + .ge(TAppUserVipDetail::getEndTime, currentDate) + .ne(TAppUserVipDetail::getVipType, 1) + .le(TAppUserVipDetail::getMonthEndTime, currentDate) + .orderByDesc(TAppUserVipDetail::getStartTime).list(); + for (TAppUserVipDetail recentDetail : recentDetails) { + tAppUserVipDetailService.giveVipCoupun(recentDetail); + } + } catch (Exception e) { + e.printStackTrace(); + } + + + } + + @Scheduled(fixedRate = 1000 * 60) + public void changeVipId() { + LocalDateTime currentDate = LocalDateTime.now(); + List<TAppUserVipDetail> recentDetails = tAppUserVipDetailService.lambdaQuery() + .le(TAppUserVipDetail::getStartTime, currentDate) + .ge(TAppUserVipDetail::getEndTime, currentDate) + .orderByDesc(TAppUserVipDetail::getStartTime).list(); + for (TAppUserVipDetail recentDetail : recentDetails) { + TAppUser byId = appUserService.getById(recentDetail.getAppUserId()); + if (byId != null) { + byId.setVipId(recentDetail.getVipId()); + appUserService.updateById(byId); + } + } + + } + + } -- Gitblit v1.7.1