0007暴力拉取

This commit is contained in:
Leo
2025-03-16 18:40:57 +08:00
parent 9834dcb2b9
commit 3e93ab2506
6 changed files with 32 additions and 9 deletions

View File

@@ -144,7 +144,7 @@ public class JDScheduleJob {
* @param startTime 开始时间
* isRealTime 是否是实时订单 是的话不会判断是否拉取过
* page 分页页码
* isMinutes 是否是分钟级订单 分钟的每次加10分钟小时每小时加1小时
* isRealTime 是否是分钟级订单 分钟的每次加10分钟小时每小时加1小时
*/
public UnionOpenOrderRowQueryResponse fetchOrdersForDateTime(LocalDateTime startTime, boolean isRealTime, Integer page, boolean isMinutes, String appKey, String secretKey) {
@@ -158,7 +158,8 @@ public class JDScheduleJob {
// 检查这个小时或分钟是否已经被处理过
if (hashOps.hasKey(newTimeTag, hourMinuteTag)) {
if (!isMinutes) {
// 0007需要暴力拉取
if (!isMinutes && !isRealTime) {
return null;
}
}
@@ -212,7 +213,7 @@ public class JDScheduleJob {
while (hasMore) {
try {
// 30-60 天 ,非实时,非分钟
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(current, false, pageIndex, false, appKey, secretKey);
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(current, strategy.isRealTime(), pageIndex, false, appKey, secretKey);
if (response != null && response.getQueryResult() != null) {
if (response.getQueryResult().getCode() == 200) {
OrderRowResp[] orderRowResps = response.getQueryResult().getData();

View File

@@ -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;
}
}

View File

@@ -22,4 +22,10 @@ public class Days0714Strategy implements OrderFetchStrategy {
public String strategyName() {
return "07-14天历史订单抓取策略";
}
@Override
public Boolean isRealTime() {
return false;
}
}

View File

@@ -19,6 +19,8 @@ public class Days1430Strategy implements OrderFetchStrategy {
public String strategyName() {
return "14-30天历史订单抓取策略";
}
@Override
public Boolean isRealTime() {
return false;
}
}
// 其他策略类类似实现

View File

@@ -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;
}
}

View File

@@ -14,5 +14,7 @@ public interface OrderFetchStrategy {
* 策略标识
*/
String strategyName();
Boolean isRealTime() ;
}