package cn.van.business.util.jdReq;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

// 在jdReq包中补充策略类
public class Days1430Strategy implements OrderFetchStrategy {
    @Override
    public TimeRange calculateRange(LocalDateTime baseTime) {
        LocalDateTime end = baseTime.minusDays(14).truncatedTo(ChronoUnit.HOURS);
        LocalDateTime start = baseTime.minusDays(30).truncatedTo(ChronoUnit.HOURS);
        if (start.isAfter(end)) { // 防御性校验
            throw new IllegalArgumentException(strategyName()+"时间范围错误");
        }
        return new TimeRange(start, end);
    }

    @Override
    public String strategyName() {
        return "14-30天历史订单抓取策略";
    }
    @Override
    public Boolean isRealTime() {
        return false;
    }
}
