package com.style24.batch.biz.job.statistics;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.style24.batch.biz.job.TsbAbstractJob;
import com.style24.batch.biz.service.TsbStatisticsService;
import com.style24.persistence.domain.Goods;

import lombok.extern.slf4j.Slf4j;

/**
 * 사이트 제휴코드 전날 유입집계 (일배치)
 *
 * @author card007
 * @since 2020. 08. 26
 */
@Component
@Slf4j
public class TsbInflowYesterdayStatisticsJob extends TsbAbstractJob<Goods, Goods, Goods> {

	@Autowired
	private TsbStatisticsService statisticsService;

	private int succCnt = 0;
	private int failCnt = 0;
	private int totalCnt = 0;

	@Override
	public Goods read() throws Exception {

		Goods goods = new Goods();
		return goods;
	}

	@Override
	public Goods process(Goods goods) throws Exception {
		return goods;
	}

	@Override
	public Goods write(Goods goods) throws Exception {

		int result = statisticsService.createInflowDaily("yesterday");
		totalCnt = result;
		succCnt = result;

		return goods;
	}

	@Override
	public void notify(Goods goods) throws Exception {
		super.printResult(succCnt, failCnt);
	}

}
