0007暴力拉取
This commit is contained in:
@@ -9,8 +9,8 @@ import java.time.temporal.ChronoUnit;
|
||||
public class Days0007Strategy implements OrderFetchStrategy {
|
||||
@Override
|
||||
public TimeRange calculateRange(LocalDateTime baseTime) {
|
||||
LocalDateTime end = baseTime.minusHours(1).truncatedTo(ChronoUnit.HOURS);
|
||||
LocalDateTime start = end.minusDays(7).truncatedTo(ChronoUnit.HOURS);
|
||||
LocalDateTime end = baseTime.truncatedTo(ChronoUnit.MINUTES);
|
||||
LocalDateTime start = end.minusDays(7).truncatedTo(ChronoUnit.MINUTES);
|
||||
if (start.isAfter(end)) { // 防御性校验
|
||||
throw new IllegalArgumentException(strategyName()+"时间范围错误");
|
||||
}
|
||||
@@ -22,4 +22,10 @@ public class Days0007Strategy implements OrderFetchStrategy {
|
||||
public String strategyName() {
|
||||
return "00-07天历史订单抓取策略";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isRealTime() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,4 +22,10 @@ public class Days0714Strategy implements OrderFetchStrategy {
|
||||
public String strategyName() {
|
||||
return "07-14天历史订单抓取策略";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isRealTime() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ public class Days1430Strategy implements OrderFetchStrategy {
|
||||
public String strategyName() {
|
||||
return "14-30天历史订单抓取策略";
|
||||
}
|
||||
@Override
|
||||
public Boolean isRealTime() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 其他策略类类似实现
|
||||
|
||||
@@ -3,13 +3,14 @@ package cn.van.business.util.jdReq;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
@Component
|
||||
public class Days3090Strategy implements OrderFetchStrategy {
|
||||
@Override
|
||||
public TimeRange calculateRange(LocalDateTime baseTime) {
|
||||
LocalDateTime end = baseTime.minusMonths(1);
|
||||
LocalDateTime start = end.minusMonths(2);
|
||||
LocalDateTime end = baseTime.minusMonths(1).truncatedTo(ChronoUnit.HOURS);
|
||||
LocalDateTime start = end.minusMonths(2).truncatedTo(ChronoUnit.HOURS);
|
||||
if (start.isAfter(end)) { // 防御性校验
|
||||
throw new IllegalArgumentException(strategyName()+"时间范围错误");
|
||||
}
|
||||
@@ -21,4 +22,9 @@ public class Days3090Strategy implements OrderFetchStrategy {
|
||||
public String strategyName() {
|
||||
return "30-90天历史订单抓取策略";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isRealTime() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,7 @@ public interface OrderFetchStrategy {
|
||||
* 策略标识
|
||||
*/
|
||||
String strategyName();
|
||||
|
||||
Boolean isRealTime() ;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user