package com.yiqi.task;

import cn.hutool.core.date.DateUtil;
import com.yiqi.common.utils.DateUtils;
import com.yiqi.core.service.ISettlementFactoryStatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 工厂订单衣服每日结算
 *
 * @author ruoyi
 */
@Component
@Slf4j
public class SettlementStoreClothTask {

    @Autowired
    private ISettlementFactoryStatisticsService settlementFactoryStatisticsService;

    public void run(String dateStr) {
        Date date = DateUtils.addDays(new Date(), -1);
        if (StringUtils.isNotBlank(dateStr)) {
            date = DateUtils.parseDate(dateStr);
        }
        log.info("*****开始执行工厂衣服"+ DateUtil.formatDate(date) +"日结算任务*****");
        settlementFactoryStatisticsService.generateDayStatistics(date);
        log.info("*****结束执行工厂衣服"+ DateUtil.formatDate(date) +"日结算任务*****");
    }
}
