package com.style24.batch.biz.web;

import com.style24.batch.biz.job.order.*;
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.core.support.controller.TscBaseController;

import lombok.extern.slf4j.Slf4j;

/**
 * 주문 Controller
 * 
 * @author gagamel
 * @since 2021. 5. 24
 */
@Controller
@RequestMapping("/order")
@CrossOrigin(origins = "${domain.admin}")
@Slf4j
public class TsbOrderController extends TscBaseController {

	@Autowired
	private TsbCartExpirationJob cartExpirationJob;

	@Autowired
	private TsbOrderDepositExpirationJob orderDepositExpirationJob;

	@Autowired
	private TsbOrderGiftExpirationJob orderGiftExpirationJob;

	@Autowired
	private TsbCartUnpurchasePushJob cartUnpurchasePushJob;

	@Autowired
	private TsbCartAddCouponPushJob cartAddCouponPushJob;

	@Autowired
	private TsbWishAddCouponPushJob wishAddCouponPushJob;

	@Autowired
	private TsbOrderDepositWaitingNotifyJob orderDepositWaitingNotifyJob;

	/**
	 * 장바구니 30일 초과 만료 데이터 삭제
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 05. 03
	 */
	@GetMapping("/cart/deadline/expire")
	@ResponseBody
	public String expireCartDeadline() throws Exception {
		cartExpirationJob.runById("cron.order.cart.deadline.expire");
		return "OK";
	}

	/**
	 * 무통장입금 입금 기한 만료 데이터 취소
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 05. 03
	 */
	@GetMapping("/deposit/deadline/expire")
	@ResponseBody
	public String expireDepositDeadline() throws Exception {
		orderDepositExpirationJob.runById("cron.order.deposit.deadline.expire");
		return "OK";
	}

	/**
	 * 선물하기 배송지 등록 기간 만료 주문 취소
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 05. 03
	 */
	@GetMapping("/gift/deadline/expire")
	@ResponseBody
	public String expireGiftDeadline() throws Exception {
		orderGiftExpirationJob.runById("cron.order.gift.deadline.expire");
		return "OK";
	}

	/**
	 * 장바구니 미구매상품(삭제 10일전) 알림 푸시
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 07. 09
	 */
	@GetMapping("/cart/unpurchase/push")
	@ResponseBody
	public String cartUnpurchasePush() throws Exception {
		cartUnpurchasePushJob.runById("cron.order.cart.unpurchase.push");
		return "OK";
	}

	/**
	 * 장바구니 미구매상품(삭제 10일전) 알림 푸시
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 07. 09
	 */
	@GetMapping("/cart/benefit/push")
	@ResponseBody
	public String cartBenefitPush() throws Exception {
		cartAddCouponPushJob.runById("cron.order.cart.benefit.push");
		return "OK";
	}

	/**
	 * 장바구니 미구매상품(삭제 10일전) 알림 푸시
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 07. 12
	 */
	@GetMapping("/wish/benefit/push")
	@ResponseBody
	public String wishBenefitPush() throws Exception {
		wishAddCouponPushJob.runById("cron.order.wish.benefit.push");
		return "OK";
	}

	/**
	 * 무통장입금 입금요청 알림톡 송부
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 07. 12
	 */
	@GetMapping("/deposit/waiting/notify")
	@ResponseBody
	public String orderDepositWaitingNotify() throws Exception {
		orderDepositWaitingNotifyJob.runById("cron.order.deposit.waiting.notify");
		return "OK";
	}
}
