package com.tax.file.service.async.apply.repeat;


import com.tax.file.constants.FileConstants;
import com.tax.file.service.async.apply.ApplyContext;
import com.yxcheng.token.utils.DateUtils;
import org.apache.commons.lang.StringUtils;

import java.util.Date;
import java.util.Map;

public class RepeatApplyContext {

    boolean init = false;
    boolean fixLackApply = false;

//
//    public Date getLastNationFirstDate(){
//        Date lastNationFirstDate = null;
//        Date[] nationDates = getNationDates();
//        if(nationDates == null){
//            Date preDateEnd = DateUtils.getPreLastDay(new Date(), 1);
//            Date preDateStart = DateUtils.getApplyStartDate(preDateEnd, FileConstants.applyCycle);
//            lastNationFirstDate = fixDate(preDateStart);
//        }else{
//
//            int nowCycle = DateUtils.getDayCycle(FileConstants.applyCycle, new Date());
//            if(nowCycle>2){
//
//            }
//        }
//        return lastNationFirstDate;
//    }

    //往前补偿若干天
    public Date fixDate(Date date){
       return  DateUtils.getPreApplyDate(date,FileConstants.preApplyRange);
    }


    public static void main(String[] args) {
        Date date = DateUtils.getPreFirstDay(new Date(),1);
        System.out.println(DateUtils.toDate(date,"yyyy-MM-dd").getTime());
    }


    public Date getLastMonthLastDay() {
        return  DateUtils.getPreLastDay(new Date(),1);
    }


    public  Date getFixLackApplyStartDate(Date preDateStart){
        if(this.fixLackApply){
            preDateStart =  DateUtils.getPreFirstDay(preDateStart,0);
        }else{
            //往前补偿三天
            preDateStart =  DateUtils.getPreApplyDate(preDateStart,FileConstants.preApplyRange);
        }
        return preDateStart;
    }
}
