package com.style24.batch.biz.task;


import com.style24.batch.biz.job.marketing.TsbCombackCouponNoticeJob;
import com.style24.batch.biz.job.marketing.TsbExpectCouponJob;

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.customer.TsbDormantScheduleJob;
import com.style24.batch.biz.job.customer.TsbDormantTransformJob;
import com.style24.batch.biz.job.customer.TsbGradeChangeJob;
import com.style24.batch.biz.job.customer.TsbMarketingAgreeNoticeJob;
import com.style24.batch.biz.job.customer.TsbNetpathyMailJob;
import com.style24.batch.biz.job.customer.TsbPrivacyPolicyNoticeJob;
import com.style24.batch.biz.job.customer.TsbSecedeProcessJob;
import com.style24.batch.biz.job.marketing.TsbAutoBuyConfirmJob;
import com.style24.batch.biz.job.marketing.TsbBirthdayCouponNoticeJob;
import com.style24.batch.biz.job.marketing.TsbExpectGiftcardJob;
import com.style24.batch.biz.job.marketing.TsbExpectPointJob;
import com.style24.batch.biz.job.marketing.TsbExpireGiftcardJob;
import com.style24.batch.biz.job.marketing.TsbExpirePointJob;
import com.style24.batch.biz.job.marketing.TsbReviewGuideJob;

import lombok.extern.slf4j.Slf4j;

/**
 * 회원(고객) Task
 * @author jsshin
 * @since 2021. 03. 08
 */
@Component
@Slf4j
public class TsbCustomerTask {

	@Autowired
	private TsbDormantScheduleJob dormantScheduleJob;

	@Autowired
	private TsbDormantTransformJob dormantTransformJob;

	@Autowired
	private TsbSecedeProcessJob secedeProcessJob;

	@Autowired
	private TsbPrivacyPolicyNoticeJob privacyPolicyNoticeJob;

	@Autowired
	private TsbMarketingAgreeNoticeJob marketingAgreeNoticeJob;

	@Autowired
	private TsbGradeChangeJob gradeChangeJob;

	@Autowired
	private TsbNetpathyMailJob netpathyJob;

	@Autowired
	private TsbAutoBuyConfirmJob autoBuyConfirmJob;

	@Autowired
	private TsbBirthdayCouponNoticeJob birthdayCouponNoticeJob;

	@Autowired
	private TsbCombackCouponNoticeJob combackCouponNoticeJob;

	@Autowired
	private TsbExpirePointJob expirePointJob;
	
	@Autowired
	private TsbExpectPointJob expectPointJob;

	@Autowired
	private TsbExpireGiftcardJob expireGiftcardJob;
	
	@Autowired
	private TsbExpectGiftcardJob expectGiftcardJob;
	
	@Autowired
	private TsbExpectCouponJob expectCouponJob;

	@Autowired
	private TsbReviewGuideJob reviewGuideJob;

	/**
	 * 휴면전환 예정 대상 메일 발송
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 03. 08
	 */
	@Scheduled(cron = "${cron.customer.dormant.create}")
	@Async
	public void dormantCustomerCreateJob() throws Exception {
		dormantScheduleJob.runById("cron.customer.dormant.create");
	}

	/**
	 * 휴면전환
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 03. 08
	 */
	@Scheduled(cron = "${cron.customer.dormant.transform}")
	@Async
	public void dormantCustomerTransformJob() throws Exception {
		dormantTransformJob.runById("cron.customer.dormant.transform");
	}

	/**
	 * 탈퇴회원 처리
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 03. 08
	 */
	@Scheduled(cron = "${cron.customer.secede.transform}")
	@Async
	public void secedeCustomerTransformJob() throws Exception {
		secedeProcessJob.runById("cron.customer.secede.transform");
	}

	/**
	 * 개인정보 이용내역 안내 발송
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 05. 06
	 */
	@Scheduled(cron = "${cron.customer.privacy.info.notify}")
	@Async
	public void privacyInfoNotifyJob() throws Exception {
		privacyPolicyNoticeJob.runById("cron.customer.privacy.info.notify");
	}

	/**
	 * 마케팅 정보 수신동의 내역 안내 발송
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 05. 06
	 */
	@Scheduled(cron = "${cron.customer.marketing.info.notify}")
	@Async
	public void marketingInfoNotifyJob() throws Exception {
		marketingAgreeNoticeJob.runById("cron.customer.marketing.info.notify");
	}

	/**
	 * 회원등급 변경
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 05. 06
	 */
	@Scheduled(cron = "${cron.customer.grade.change}")
	@Async
	public void customerGradeChangeJob() throws Exception {
		gradeChangeJob.runById("cron.customer.grade.change");
	}

	/**
	 * 넷퍼시메일솔루션에 회원정보 연동
	 * @throws Exception - 예외처리
	 * @author gagamel
	 * @since 2021. 5. 10
	 */
	@Scheduled(cron = "${cron.customer.netpathy.mail.sync}")
	@Async
	public void customerInfoNetpathyMailSyncJob() throws Exception {
		netpathyJob.runById("cron.customer.netpathy.mail.sync");
	}

	/**
	 * 자동구매확정 포인트 지급
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 04. 23
	 */
	@Scheduled(cron = "${cron.customer.auto.buy.confirm}")
	@Async
	public void autoBuyConfirmJob() throws Exception {
		autoBuyConfirmJob.runById("cron.customer.auto.buy.confirm");
	}

	/**
	 * 생일쿠폰 다운로드 안내
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 05. 10
	 */
	@Scheduled(cron = "${cron.customer.birth.coupon.notify}")
	@Async
	public void birthCouponNotifyJob() throws Exception {
		birthdayCouponNoticeJob.runById("cron.customer.birth.coupon.notify");
	}

	/**
	 * 휴면/미접속자 방어 쿠폰
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 05. 10
	 */
	@Scheduled(cron = "${cron.customer.comback.coupon.notify}")
	@Async
	public void combackCouponNotify() throws Exception {
		combackCouponNoticeJob.runById("cron.customer.comback.coupon.notify");
	}

	/**
	 * 포인트 소멸처리
	 *
	 * @throws Exception - 예외처리
	 * @author sowon
	 * @since 2021. 04. 26
	 */
	@Scheduled(cron = "${cron.customer.point.expire}")
	@Async
	public void pointExpireJob() throws Exception {
		expirePointJob.runById("cron.customer.point.expire");
	}
	
	/**
	 * 포인트 기간만료 알림톡(30일)
	 *
	 * @throws Exception - 예외처리
	 * @author sowon
	 * @since 2021. 05. 28
	 */
	@Scheduled(cron = "${cron.customer.point.expect.notify}")
	@Async
	public void pointExpectJob() throws Exception {
		expectPointJob.runById("cron.customer.point.expect.notify");
	}

	/**
	 * 상품권 소멸처리
	 *
	 * @throws Exception - 예외처리
	 * @author sowon
	 * @since 2021. 05. 20
	 */
	@Scheduled(cron = "${cron.customer.giftcard.expire}")
	@Async
	public void giftcardExpireJob() throws Exception {
		expireGiftcardJob.runById("cron.customer.giftcard.expire");
	}
	
	/**
	 * 상품권 기간만료 알림톡(30일)
	 *
	 * @throws Exception - 예외처리
	 * @author sowon
	 * @since 2021. 05. 27
	 */
	@Scheduled(cron = "${cron.customer.giftcard.expect.notify}")
	@Async
	public void giftcardExpectJob() throws Exception {
		expectGiftcardJob.runById("cron.customer.giftcard.expect.notify");
	}
	
	/**
	 * 쿠폰 기간만료 알림톡(7일)
	 *
	 * @throws Exception - 예외처리
	 * @author sowon
	 * @since 2021. 05. 31
	 */
	@Scheduled(cron = "${cron.customer.coupon.expect.notify}")
	@Async
	public void couponExpectJob() throws Exception {
		expectCouponJob.runById("cron.customer.coupon.expect.notify");
	}


	/**
	 * 상품평등록안내발송 처리
	 * @throws Exception - 예외처리
	 * @author gagamel
	 * @since 2021. 5. 17
	 */
	@Scheduled(cron = "${cron.customer.review.register.notify}")
	@Async
	public void customerReviewRegisterNotifyJob() throws Exception {
		reviewGuideJob.runById("cron.customer.review.register.notify");
	}

}
