package com.style24.batch.biz.web;

import com.style24.batch.biz.job.naverpay.*;
import com.style24.core.support.controller.TscBaseController;
import lombok.extern.slf4j.Slf4j;
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;

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

	@Autowired
	private TsbNaverPayRecvOrderCompleteJob recvOrderCompleteJob;

	@Autowired
	private TsbNaverPayRecvOrderConfirmJob recvOrderConfirmJob;

	@Autowired
	private TsbNaverPayRecvOrderCancelReqJob recvOrderCancelReqJob;

	@Autowired
	TsbNaverPayRecvOrderCancelCompleteJob recvOrderCancelCompleteJob;

	@Autowired
	TsbNaverPayRecvOrderExchangeReqJob recvOrderExchangeReqJob;

	@Autowired
	TsbNaverPayRecvOrderReturnReqJob recvOrderReturnReqJob;

	@Autowired
	TsbNaverPayRecvWdInvoiceNoJob recvWdInvoiceNoJob;

	@Autowired
	TsbNaverPaySendReadyDeliveryJob sendReadyDeliveryJob;

	/**
	 * 네이버페이 주문완료 정보 수신
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 05. 27
	 */
	@GetMapping("/recv/order/complete")
	@ResponseBody
	public String recvOrderComplete() throws Exception {
		recvOrderCompleteJob.runById("cron.naverpay.recv.order");
		return "OK";
	}

	/**
	 * 네이버페이 구매확정 주문 정보 수신
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 06. 11
	 */
	@GetMapping("/recv/order/decide")
	@ResponseBody
	public String resvOrderConfirm() throws Exception {
		recvOrderConfirmJob.runById("cron.naverpay.recv.order.decide");
		return "OK";
	}

	/**
	 * 네이버페이 취소 접수 데이터 수신
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 06. 09
	 */
	@GetMapping("/recv/cancel/req")
	@ResponseBody
	public String recvCancelReq() throws Exception {
		recvOrderCancelReqJob.runById("cron.naverpay.recv.cancel.req");
		return "OK";
	}

	/**
	 * 네이버페이 취소 완료 데이터 수신
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 06. 11
	 */
	@GetMapping("/recv/cancel/complete")
	@ResponseBody
	public String recvCancelComplete() throws Exception {
		recvOrderCancelCompleteJob.runById("cron.naverpay.recv.cancel.complete");
		return "OK";
	}

	/**
	 * 네이버페이 교환 접수 데이터 수신
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 06. 22
	 */
	@GetMapping("/recv/exchange/req")
	@ResponseBody
	public String recvExchangeReq() throws Exception {
		recvOrderExchangeReqJob.runById("cron.naverpay.recv.exchange.req");
		return "OK";
	}

	/**
	 * 네이버페이 반품 접수 데이터 수신
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 06. 25
	 */
	@GetMapping("/recv/return/req")
	@ResponseBody
	public String recvReturnReq() throws Exception {
		recvOrderReturnReqJob.runById("cron.naverpay.recv.return.req");
		return "OK";
	}

	/**
	 * 네이버페이 회수송장번호 데이터 수신
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 06. 25
	 */
	@GetMapping("/recv/wd/invoice/no")
	@ResponseBody
	public String recvWdInvoiceNo() throws Exception {
		recvWdInvoiceNoJob.runById("cron.naverpay.recv.wd.invoice.no");
		return "OK";
	}

	/**
	 * 네이버페이 배송준비중 주문 정보 송신
	 *
	 * @throws Exception - 예외처리
	 * @author xodud1202
	 * @since 2021. 06. 11
	 */
	@GetMapping("/send/ready/delivery")
	@ResponseBody
	public String sendReadyDelivery() throws Exception {
		sendReadyDeliveryJob.runById("cron.naverpay.send.ready.delivery");
		return "OK";
	}
}
