package com.style24.admin.biz.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gagaframework.web.parameter.GagaMap;
import com.style24.admin.support.controller.TsaBaseController;
import com.style24.core.biz.service.TscOrderRefundService;
import com.style24.core.support.message.TscMessageByLocale;
import com.style24.persistence.domain.Order;

import lombok.extern.slf4j.Slf4j;

/**
 * 취소관리 Controller
 *
 * @author jsh77b
 * @since 2020. 11. 16
 */
@Controller
@RequestMapping("/refund")
@Slf4j
public class TsaOrderRefundController extends TsaBaseController {
	
	@Autowired
	private TscMessageByLocale message;
	
	@Autowired
	private TscOrderRefundService orderRefundService;

	/**
	 * 주문 취소/반품 신청환불금액 계산
	 * @param Collection<Order>- 주문취소신청목록
	 * @return
	 * @author jsh77b
	 * @since 2020. 12. 29
	 */
	@PostMapping("/refundAmt")
	@ResponseBody
	public GagaMap orderCancelRefundAmt(@RequestBody List<Order> cancelReqList) {
		
		GagaMap mav = new GagaMap();
		
		if (cancelReqList == null || cancelReqList.isEmpty()) {
			throw new IllegalStateException(message.getMessage("FAIL_1001"));
		}
		
		// 1. 환불금액계산
		mav = orderRefundService.cnclRtnRefundAmt(cancelReqList);
		
		return mav;
	}
}










