package com.tax.file.service.async.strategy;

import com.tax.file.constants.FileConstants;
import com.yxcheng.token.utils.DateUtils;

import java.util.Calendar;
import java.util.Date;

public class LastMonthFixStrategy {

    public static boolean isNeedFix(Date fixDate){
        if(!isComeNextMonth())return false;
        //补偿时间如果是今天，说明已经申请过
        //补偿时间+周期值>当前日期， 说明这个周期内已经补偿过
        if(isFixReady(fixDate,FileConstants.applyCycle))return false;
        return true;
    }

    public static boolean isFixReady(Date fixDate, String applyCycle) {
        if(fixDate == null) return false;

        if(DateUtils.isToday(fixDate) ||  DateUtils.addDate(fixDate,Integer.valueOf(applyCycle)).after(new Date()))return true;

        return false;
    }

    public static boolean isComeNextMonth(){
        return DateUtils.getApplyFixDays(new Date(),FileConstants.applyCycle) >=0 ;
    }

    public static void main(String[] args) {

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.set(Calendar.DATE,7);

        if(!LastMonthFixStrategy.isNeedFix(calendar.getTime())) return;
        System.out.println("$56");
    }
}
