ouyang 3 anni fa
parent
commit
9d38a44125

+ 4 - 4
src/main/java/com/izouma/nineth/repo/CollectionRepo.java

@@ -148,13 +148,13 @@ public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpec
     Integer getVipQuota(Long id);
 
 
-    List<Collection> findAllByStartTimeGreaterThanAndStartTimeEquals(LocalDateTime startTime,LocalDateTime endTime);
+    List<Collection> findAllByStartTimeGreaterThanAndStartTimeLessThanEqual(LocalDateTime startTime,LocalDateTime endTime);
 
-    List<Collection> findAllByEndTimeGreaterThanAndEndTimeEquals(LocalDateTime startTime, LocalDateTime endTime);
+    List<Collection> findAllByEndTimeGreaterThanAndEndTimeLessThanEqual(LocalDateTime startTime, LocalDateTime endTime);
 
-    List<Collection> findAllByPublishTimeGreaterThanAndPublishTimeEquals(LocalDateTime endTime, LocalDateTime publishTime);
+    List<Collection> findAllByPublishTimeGreaterThanAndPublishTimeLessThanEqual(LocalDateTime endTime, LocalDateTime publishTime);
 
-    List<Collection> findAllByPurchaseTimeGreaterThanAndPurchaseTimeEquals(LocalDateTime publishTime, LocalDateTime purchaseTime);
+    List<Collection> findAllByPurchaseTimeGreaterThanAndPurchaseTimeLessThanEqual(LocalDateTime publishTime, LocalDateTime purchaseTime);
 
 
     //筛选

+ 7 - 6
src/main/java/com/izouma/nineth/service/scheduledTask/SubscribeTask.java

@@ -16,6 +16,7 @@ import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
@@ -30,15 +31,15 @@ public class SubscribeTask {
     @Autowired
     private SubscribeRepo subscribeRepo;
 
-    @Scheduled(cron = "0/5 * * * * ?")
+    @Scheduled(cron = "5/5 * * * * ?")
     public void subscriberTask() {
         //首先获取当前时间
         LocalDateTime startTime = LocalDateTime.now();
         //获取5秒钟以后的时间
-        LocalDateTime endTime = startTime.plusSeconds(5);
+        LocalDateTime endTime = startTime.plusSeconds(6);
         //根据开始时间和结束时间去数据库把这两个时间段中 符合的预约发布时间中获取藏品
         List<Collection> ongoingList = collectionRepo
-                .findAllByStartTimeGreaterThanAndStartTimeEquals(startTime, endTime);
+                .findAllByStartTimeGreaterThanAndStartTimeLessThanEqual(startTime, endTime);
         //预约发布时间判断
         if (!Collections.isEmpty(ongoingList)) {
             for (Collection collection : ongoingList) {
@@ -50,7 +51,7 @@ public class SubscribeTask {
         }
         //预约结束时间判断
         List<Collection> subscribeEndingList = collectionRepo
-                .findAllByEndTimeGreaterThanAndEndTimeEquals(startTime, endTime);
+                .findAllByEndTimeGreaterThanAndEndTimeLessThanEqual(startTime, endTime);
         if (!Collections.isEmpty(subscribeEndingList)) {
             for (Collection collection : subscribeEndingList) {
                 if (collection.getEndTime().isAfter(startTime)) {
@@ -83,7 +84,7 @@ public class SubscribeTask {
         }
         //购买资格公布时间
         List<Collection> announcingList = collectionRepo
-                .findAllByPublishTimeGreaterThanAndPublishTimeEquals(startTime, endTime);
+                .findAllByPublishTimeGreaterThanAndPublishTimeLessThanEqual(startTime, endTime);
         if (!Collections.isEmpty(announcingList)) {
             for (Collection collection : announcingList) {
                 if (collection.getPublishTime().isAfter(startTime)) {
@@ -94,7 +95,7 @@ public class SubscribeTask {
         }
         //购买时间
         List<Collection> onSaleList = collectionRepo
-                .findAllByPurchaseTimeGreaterThanAndPurchaseTimeEquals(startTime, endTime);
+                .findAllByPurchaseTimeGreaterThanAndPurchaseTimeLessThanEqual(startTime, endTime);
         if (!Collections.isEmpty(onSaleList)) {
             for (Collection collection : onSaleList) {
                 if (collection.getPurchaseTime().isAfter(startTime)) {