|
|
@@ -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)) {
|