From 3244b550596e0330031b3f4547356927df83b0ad Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期一, 19 五月 2025 11:48:35 +0800
Subject: [PATCH] 修改bug
---
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/TaskUtil.java | 110 +++++++++++++++++++++++++-----------------------------
1 files changed, 51 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 7e87177..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,13 +5,12 @@
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;
import javax.annotation.Resource;
import java.time.LocalDate;
+import java.time.LocalDateTime;
import java.util.List;
@@ -20,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(){
- LocalDate currentDate = LocalDate.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