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

import com.style24.batch.biz.job.TsbAbstractJob;
import com.style24.batch.biz.service.TsbNaverPayService;
import com.style24.core.biz.checkout.base.ChangedProductOrderInfo;
import com.style24.core.biz.checkout.base.ProductOrderChangeType;
import com.style24.core.biz.service.TscNaverPayService;
import com.style24.persistence.domain.Order;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Collection;

/**
 * 네이버페이 회수송장번호 수신
 *
 * @author xodud1202
 * @since 2021. 06. 28
 */
@Component
@Slf4j
public class TsbNaverPayRecvWdInvoiceNoJob extends TsbAbstractJob<Collection<Order>, Collection<Order>, Order> {
	@Autowired
	private TsbNaverPayService naverPayService;

	@Autowired
	private TscNaverPayService coreNaverPayService;

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

	@Override
	public Collection<Order> read() throws Exception {
		log.info("<<<< 회수송장번호 수신 시작 >>>>");
		return naverPayService.getNotWriteWdInvoiceNoChangeList(); // 변경 상품주문 조회;
	}

	@Override
	public Collection<Order> process(Collection<Order> params) throws Exception {
		return params;
	}

	@Override
	public Order write(Collection<Order> params) throws Exception {
		Order result = new Order();
		if (params != null) {
			result = naverPayService.getNaverPayWdInvoiceNo(params);
		}

		log.info("<<<< 회수송장번호 수신 종료 >>>>");
		return result;
	}

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