package com.style24.admin.biz.service;

import java.util.Collection;

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

import com.style24.admin.biz.dao.TsaOcmDao;
import com.style24.admin.support.security.session.TsaSession;
import com.style24.core.support.message.TscMessageByLocale;
import com.style24.persistence.domain.Extmall;
import com.style24.persistence.domain.ExtmallNoti;
import com.style24.persistence.domain.ExtmallOrigin;
import com.style24.persistence.domain.ExtmallPriceSync;

import lombok.extern.slf4j.Slf4j;

/**
 * 영업망관리 Service
 *
 * @author gagamel
 * @since 2020. 11. 4
 */
@Service
@Slf4j
public class TsaOcmService {

    @Autowired
    private TscMessageByLocale message;

    @Autowired
    private TsaOcmDao ocmDao;


    /**
     * 제휴몰 목록
     * @param extmall - 제휴몰 정보
     * @return
     * @author gagamel
     * @since 2020. 11. 5
     */
    public Collection<Extmall> getExtmallList(Extmall extmall) {
        return ocmDao.getExtmallList(extmall);
    }

    /**
     * 제휴몰 등록/수정 처리
     * @param extmall - 제휴몰 정보
     * @author gagamel
     * @since 2020. 11. 5
     */
    @Transactional("shopTxnManager")
    public void saveExtmall(Extmall extmall) {
        extmall.setRegNo(TsaSession.getInfo().getUserNo());
        extmall.setUpdNo(TsaSession.getInfo().getUserNo());
        ocmDao.saveExtmall(extmall);
    }

    /**
     * 제휴몰 고시정보 목록
     * @param extmallNoti - 제휴몰고시정보
     * @return
     * @author gagamel
     * @since 2020. 11. 6
     */
    public Collection<ExtmallNoti> getExtmallNotiinfoList(ExtmallNoti extmallNoti) {
        return ocmDao.getExtmallNotiinfoList(extmallNoti);
    }

    /**
     * 제휴몰 원산지 목록
     * @param extmallOrigin - 제휴몰원산지 정보
     * @return
     * @author gagamel
     * @since 2020. 11. 12
     */
    public Collection<ExtmallOrigin> getExtmallOriginList(ExtmallOrigin extmallOrigin) {
        return ocmDao.getExtmallOriginList(extmallOrigin);
    }

    /**
     * 제휴몰가격연계 목록
     * @param extmallPriceSync - 제휴몰가격연계 정보
     * @return
     * @author gagamel
     * @since 2020. 11. 7
     */
    public Collection<ExtmallPriceSync> getExtmallPriceSyncList(ExtmallPriceSync extmallPriceSync) {
        return ocmDao.getExtmallPriceSyncList(extmallPriceSync);
    }

    /**
     * 제휴몰가격연계 등록/수정
     * @param extmallPriceSyncList - 제휴몰가격연계 목록
     * @author gagamel
     * @since 2020. 11. 7
     */
    public void saveExtmallPriceSync(Collection<ExtmallPriceSync> extmallPriceSyncList) {
        for (ExtmallPriceSync extmallPriceSync : extmallPriceSyncList) {
            extmallPriceSync.setRegNo(TsaSession.getInfo().getUserNo());
            extmallPriceSync.setUpdNo(TsaSession.getInfo().getUserNo());
            ocmDao.saveExtmallPriceSync(extmallPriceSync);
        }
    }

}
