package com.style24.batch.biz.web;

import com.style24.batch.biz.job.marketing.TsbAutoBuyConfirmJob;
import com.style24.batch.biz.job.marketing.TsbBirthdayCouponNoticeJob;
import com.style24.batch.biz.job.marketing.TsbCombackCouponNoticeJob;
import com.style24.batch.biz.job.marketing.TsbExpectGiftcardJob;
import com.style24.batch.biz.job.marketing.TsbExpireGiftcardJob;
import com.style24.batch.biz.job.marketing.TsbExpectPointJob;
import com.style24.batch.biz.job.marketing.TsbExpirePointJob;
import com.style24.batch.biz.job.marketing.TsbReviewGuideJob;
import com.style24.batch.biz.job.marketing.TsbExpectCouponJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

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.core.support.controller.TscBaseController;

import lombok.extern.slf4j.Slf4j;

/**
 * 고객 Controller
 * 
 * @author gagamel
 * @since 2021. 5. 24
 */
@Controller
@RequestMapping("/customer")
@CrossOrigin(origins = "${domain.admin}")
@Slf4j
public class TsbCustomerController extends TscBaseController {

	@Autowired
	private TsbDormantScheduleJob dormantScheduleJob;

	@Autowired
	private TsbDormantTransformJob dormantTransformJob;

	@Autowired
	private TsbSecedeProcessJob secedeProcessJob;

	@Autowired
	private TsbPrivacyPolicyNoticeJob privacyPolicyNoticeJob;

	@Autowired
	private TsbMarketingAgreeNoticeJob marketingAgreementNoticeJob;

	@Autowired
	private TsbGradeChangeJob gradeChangeJob;

	@Autowired
	private TsbNetpathyMailJob netpathyJob;

	@Autowired
	private TsbAutoBuyConfirmJob autoBuyConfirmJob;

	@Autowired
	private TsbBirthdayCouponNoticeJob birthdayCouponNoticeJob;

	@Autowired
	private TsbExpirePointJob expirePointJob;

	@Autowired
	private TsbExpectPointJob expectPointJob;

	@Autowired
	private TsbExpireGiftcardJob expireGiftcardJob;

	@Autowired
	private TsbExpectGiftcardJob expectGiftcardJob;
	
	@Autowired
	private TsbReviewGuideJob reviewGuideJob;

	@Autowired
	private TsbExpectCouponJob expectCouponJob;

	@Autowired
	private TsbCombackCouponNoticeJob combackCouponNoticeJob;

	/**
	 * 휴면전환 예정 대상 메일 발송
	 * @throws Exception
	 * @author jsshin
	 * @since 2021. 03. 08
	 */
	@GetMapping("/dormant/create")
	@ResponseBody
	public String createDormantCustomer() throws Exception {
		dormantScheduleJob.runById("cron.customer.dormant.create");
		return "OK";
	}

	/**
	 * 휴면전환 처리
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 03. 08
	 */
	@GetMapping("/dormant/transform")
	@ResponseBody
	public String transformDormantCustomer() throws Exception {
		dormantTransformJob.runById("cron.customer.dormant.transform");
		return "OK";
	}

	/**
	 * 탈퇴회원 처리
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 03. 08
	 */
	@GetMapping("/secede/transform")
	@ResponseBody
	public String transformSecedeCustomer() throws Exception {
		secedeProcessJob.runById("cron.customer.secede.transform");
		return "OK";
	}

	/**
	 * 개인정보 이용내역 안내 발송
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 05. 06
	 */
	@GetMapping("/privacy/info/notify")
	@ResponseBody
	public String notifyCustomerPrivacyInfo() throws Exception {
		privacyPolicyNoticeJob.runById("cron.customer.privacy.info.notify");
		return "OK";
	}

	/**
	 * 마케팅 정보 수신동의 내역 안내 발송
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 05. 06
	 */
	@GetMapping("/marketing/info/notify")
	@ResponseBody
	public String notifyCustomerMarketingInfo() throws Exception {
		marketingAgreementNoticeJob.runById("cron.customer.marketing.info.notify");
		return "OK";
	}

	/**
	 * 회원등급 변경
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 05. 06
	 */
	@GetMapping("/grade/change")
	@ResponseBody
	public String changeCustomerGrade() throws Exception {
		gradeChangeJob.runById("cron.customer.grade.change");
		return "OK";
	}

	/**
	 * 넷퍼시메일솔루션에 회원정보 연동
	 * @throws Exception - 예외처리
	 * @author gagamel
	 * @since 2021. 5. 10
	 */
	@GetMapping("/netpathy/mail/sync")
	@ResponseBody
	public String syncronizeCustomerInfoToNepathyMail() throws Exception {
		netpathyJob.runById("cron.customer.netpathy.mail.sync");
		return "OK";
	}

	/**
	 * 자동구매확정 포인트 지급
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 04. 23
	 */
	@GetMapping("/auto/buy/confirm")
	@ResponseBody
	public String confirmAutoBuy() throws Exception {
		autoBuyConfirmJob.runById("cron.customer.auto.buy.confirm");
		return "OK";
	}

	/**
	 * 생일쿠폰 다운로드 안내
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 05. 10
	 */
	@GetMapping("/birth/coupon/notify")
	@ResponseBody
	public String notifyBirthCoupon() throws Exception {
		birthdayCouponNoticeJob.runById("cron.customer.birth.coupon.notify");
		return "OK";
	}

	/**
	 * 포인트 소멸처리
	 *
	 * @throws Exception - 예외처리
	 * @author sowon
	 * @since 2021. 04. 26
	 */
	@GetMapping("/point/expire")
	@ResponseBody
	public String expirePoint() throws Exception {
		expirePointJob.runById("cron.customer.point.expire");
		return "OK";
	}
	
	/**
	 * 포인트 소멸예정 알림톡
	 *
	 * @throws Exception - 예외처리
	 * @author sowon
	 * @since 2021. 05. 28
	 */
	@GetMapping("/point/expect/notify")
	@ResponseBody
	public String expectpoint() throws Exception {
		expectPointJob.runById("cron.customer.point.expect.notify");
		return "OK";
	}

	/**
	 * 상품권 소멸처리
	 *
	 * @throws Exception - 예외처리
	 * @author sowon
	 * @since 2021. 05. 20
	 */
	@GetMapping("/giftcard/expire")
	@ResponseBody
	public String expireGiftcard() throws Exception {
		expireGiftcardJob.runById("cron.customer.giftcard.expire");
		return "OK";
	}
	
	/**
	 * 상품권 소멸예정 알림톡
	 *
	 * @throws Exception - 예외처리
	 * @author sowon
	 * @since 2021. 05. 27
	 */
	@GetMapping("/giftcard/expect/notify")
	@ResponseBody
	public String expectGiftcard() throws Exception {
		expectGiftcardJob.runById("cron.customer.giftcard.expect.notify");
		return "OK";
	}

	/**
	 * 상품평등록안내발송 처리
	 * @throws Exception - 예외처리
	 * @author gagamel
	 * @since 2021. 5. 17
	 */
	@GetMapping("/review/register/notify")
	@ResponseBody
	public String notifyReviewRegister() throws Exception {
		reviewGuideJob.runById("cron.customer.review.register.notify");
		return "OK";
	}

	/**
	 * 쿠폰 소멸예정 알림톡
	 *
	 * @throws Exception - 예외처리
	 * @author bin2107
	 * @since 2021. 07. 06
	 */
	@GetMapping("/coupon/expect/notify")
	@ResponseBody
	public String expectcoupon() throws Exception {
		expectCouponJob.runById("cron.customer.coupon.expect.notify");
		return "OK";
	}

	/**
	 * 휴면/미접속자 방어 쿠폰
	 *
	 * @throws Exception - 예외처리
	 * @author jsshin
	 * @since 2021. 07. 12
	 */
	@GetMapping("/comback/coupon/notify")
	@ResponseBody
	public String combackCouponNotify() throws Exception {
		combackCouponNoticeJob.runById("cron.customer.comback.coupon.notify");
		return "OK";
	}
}
