package cn.van.business.util.jdReq;

import org.springframework.stereotype.Component;

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

@Component
public class Days0714Strategy implements OrderFetchStrategy {
    @Override
   public TimeRange calculateRange(LocalDateTime baseTime) {
        LocalDateTime end = baseTime.truncatedTo(ChronoUnit.HOURS).minusDays(7);
       LocalDateTime start = end.minusDays(14).truncatedTo(ChronoUnit.HOURS);
       if (start.isAfter(end)) { // 防御性校验
           throw new IllegalArgumentException(strategyName()+"时间范围错误");
       }
       return new TimeRange(start, end);
   }


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

    @Override
    public Boolean isRealTime() {
        return false;
    }

}
