package com.style24.batch.biz.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.style24.batch.biz.dao.TsbSocialDao;
import com.style24.batch.support.env.TsbConstants;
import com.style24.persistence.domain.Social;

import lombok.extern.slf4j.Slf4j;

/**
 * 소셜 (핫딜)Service
 *
 * @author sowon
 * @since 2021. 3. 10
 */
@Service
@Slf4j
public class TsbSocialService {
	@Autowired
	private TsbSocialDao socialDao;
	
	/**
	 * 상품 가격정보 원복(before)
	 * 
	 * @throws DataAccessException
	 * @author sowon
	 * @since 2021. 3. 10
	 */
	@Transactional("shopTxnManager")
	public void updateGoodsBeforePriceInfo() throws DataAccessException {
		Social info = new Social();
		info.setUpdNo(TsbConstants.REG_NO);
		socialDao.updateGoodsBeforePriceInfo(info);
	}

	/**
	 * 원복(before) 상품 이력 생성
	 * 
	 * @throws DataAccessException
	 * @author sowon
	 * @since 2021. 3. 10
	 */
	@Transactional("shopTxnManager")
	public void createBeforeGoodsHst() throws DataAccessException {
		Social info = new Social();
		info.setUpdNo(TsbConstants.REG_NO);
		info.setRegNo(TsbConstants.REG_NO);
		socialDao.createBeforeGoodsHst(info);
	}

	/**
	 * 소셜 적용 여부 '종료'(적용->종료) 업데이트
	 * 
	 * @throws DataAccessException
	 * @author sowon
	 * @since 2021. 3. 10
	 */
	@Transactional("shopTxnManager")
	public void updateSocialApplyGbtoF() throws DataAccessException {
		Social info = new Social();
		info.setUpdNo(TsbConstants.REG_NO);
		socialDao.updateSocialApplyGbtoF(info);
	}

	/**
	 * 소셜상품 적용 전 가격정보 업데이트
	 * 
	 * @throws DataAccessException
	 * @author sowon
	 * @since 2021. 3. 10
	 */
//	@Transactional("shopTxnManager")
//	public void updateSocialGoodsBeforePriceInfo() throws DataAccessException {
//		socialDao.updateSocialGoodsBeforePriceInfo();
//	}

	/**
	 * 상품 가격정보 적용(after)
	 * 
	 * @throws DataAccessException
	 * @author sowon
	 * @since 2021. 3. 10
	 */
	@Transactional("shopTxnManager")
	public void updateGoodsAfterPriceInfo() throws DataAccessException {
		Social info = new Social();
		info.setUpdNo(TsbConstants.REG_NO);
		socialDao.updateGoodsAfterPriceInfo(info);
	}

	/**
	 * 적용(after) 상품 이력 생성
	 * 
	 * @throws DataAccessException
	 * @author sowon
	 * @since 2021. 3. 10
	 */
	@Transactional("shopTxnManager")
	public void createAfterGoodsHst() throws DataAccessException {
		Social info = new Social();
		info.setUpdNo(TsbConstants.REG_NO);
		info.setRegNo(TsbConstants.REG_NO);
		socialDao.createAfterGoodsHst(info);
	}

	/**
	 * 소셜 적용 여부 '적용'(대기->적용) 업데이트
	 * 
	 * @throws DataAccessException
	 * @author sowon
	 * @since 2021. 3. 10
	 */
	@Transactional("shopTxnManager")
	public void updateSocialApplyGbtoA() throws DataAccessException {
		Social info = new Social();
		info.setUpdNo(TsbConstants.REG_NO);
		socialDao.updateSocialApplyGbtoA(info);
	}


}
