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

import java.util.Collection;

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

import com.gagaframework.web.parameter.GagaMap;
import com.style24.batch.biz.job.TsbAbstractJob;
import com.style24.batch.biz.service.TsbDeliveryService;
import com.style24.batch.biz.service.TsbWmsDeliveryService;
import com.style24.persistence.domain.Delivery;

import lombok.extern.slf4j.Slf4j;

/**
 * 매장상품재고 수신 (erp to mall) 
 *
 * @author moon
 * @since 2021. 03. 28
 */
@Component
@Slf4j
public class TsbShopGoodsStockJob extends TsbAbstractJob<Delivery, Delivery, Delivery> {

	@Autowired
	private TsbDeliveryService deliveryService;

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

	@Override
	public Delivery read() throws Exception {

		Delivery delivery = new Delivery();
		return delivery;
	}

	@Override
	public Delivery process(Delivery delivery) throws Exception {
		succCnt = 0;
		failCnt = 1;
		
		// 1.wms  출고결과 조회 
		deliveryService.saveErpGoodsStock();
		
		succCnt = 1;
		failCnt = 0;
		
		return delivery;
	}

	@Override
	public Delivery write(Delivery delivery) throws Exception {

		return delivery;
	}

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

}