package com.style24.batch.biz.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.style24.batch.biz.job.shoplinker.TsbShoplinkerInvoiceJob;
import com.style24.batch.biz.job.shoplinker.TsbShoplinkerOrderJob;
import com.style24.batch.biz.job.shoplinker.TsbShoplinkerStockJob;

import lombok.extern.slf4j.Slf4j;

/**
 * 샵링커 Task
 * @author jmh
 * @since 2021. 06. 22
 */
@Component
@Slf4j
public class TsbShoplinkerTask {

	@Autowired
	private TsbShoplinkerStockJob shoplinkerStockJob;

	@Autowired
	private TsbShoplinkerOrderJob shoplinkerOrderJob;

	@Autowired
	private TsbShoplinkerInvoiceJob shoplinkerInvoiceJob;


	/**
	 * 재고전송 10시
	 * @throws Exception
	 * @author jmh
	 * @since 2021. 06. 22
	 */
	@Scheduled(cron = "${cron.shoplinker.stock.send10}")
	@Async
	public void stockSendJob10() throws Exception {
		shoplinkerStockJob.runById("cron.shoplinker.stock.send10");
	}

	/**
	 * 재고전송 15시
	 * @throws Exception
	 * @author jmh
	 * @since 2021. 06. 22
	 */
	@Scheduled(cron = "${cron.shoplinker.stock.send15}")
	@Async
	public void stockSendJob15() throws Exception {
		shoplinkerStockJob.runById("cron.shoplinker.stock.send15");
	}

	/**
	 * 주문수집
	 * @throws Exception
	 * @author jmh
	 * @since 2021. 06. 22
	 */
	@Scheduled(cron = "${cron.shoplinker.order.receive}")
	@Async
	public void orderReceiveJob() throws Exception {
		shoplinkerOrderJob.runById("cron.shoplinker.order.receive");
	}

	/**
	 * 송장전송
	 * @throws Exception
	 * @author jmh
	 * @since 2021. 06. 22
	 */
	@Scheduled(cron = "${cron.shoplinker.invoice.send}")
	@Async
	public void invoiceSendJob() throws Exception {
		shoplinkerInvoiceJob.runById("cron.shoplinker.invoice.send");
	}

}
