package com.xunhong.erp.turbo.biz.app.service;

import com.xunhong.erp.turbo.api.biz.api.OrderServiceI;
import com.xunhong.erp.turbo.api.biz.dto.cmd.*;
import com.xunhong.erp.turbo.api.biz.dto.qry.*;
import com.xunhong.erp.turbo.api.biz.dto.vo.OrderVO;
import com.xunhong.erp.turbo.base.dto.PageDTO;
import com.xunhong.erp.turbo.biz.app.executor.cmd.*;
import com.xunhong.erp.turbo.biz.app.executor.query.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shenyifei
 */
@Slf4j
@Service
@DubboService(interfaceClass = OrderServiceI.class, version = "1.0.0")
@RequiredArgsConstructor
public class OrderServiceImpl implements OrderServiceI {

	private final OrderCreateCmdExe orderCreateCmdExe;
	private final OrderUpdateCmdExe orderUpdateCmdExe;
	private final OrderPageQryExe orderPageQryExe;
	private final OrderListQryExe orderListQryExe;
	private final OrderShowQryExe orderShowQryExe;
	private final OrderDestroyCmdExe orderDestroyCmdExe;
	private final OrderApproveCmdExe orderApproveCmdExe;
	private final OrderSubmitReviewCmdExe orderSubmitReviewCmdExe;
	private final OrderWithdrawReviewCmdExe orderWithdrawReviewCmdExe;
	private final OrderRejectApproveCmdExe orderRejectApproveCmdExe;
	private final OrderFinalApproveCmdExe orderFinalApproveCmdExe;
	private final OrderRejectFinalCmdExe orderRejectFinalCmdExe;
	private final OrderCountQryExe orderCountQryExe;

	// 新增分步提交执行器
	private final OrderStep1CmdExe orderStep1CmdExe;
	private final OrderStep2CmdExe orderStep2CmdExe;
	private final OrderStep3CmdExe orderStep3CmdExe;

	private final LastVehicleNoQryExe lastVehicleNoQryExe;

	@Override
	public OrderVO create(OrderCreateCmd orderCreateCmd) {
		return orderCreateCmdExe.execute(orderCreateCmd);
	}

	@Override
	public PageDTO<OrderVO> page(OrderPageQry orderPageQry) {
		return PageDTO.of(orderPageQryExe.execute(orderPageQry));
	}

	@Override
	public List<OrderVO> list(OrderListQry orderListQry) {
		return orderListQryExe.execute(orderListQry);
	}

	@Override
	public OrderVO update(OrderUpdateCmd orderUpdateCmd) {
		return orderUpdateCmdExe.execute(orderUpdateCmd);
	}

	@Override
	public OrderVO show(OrderShowQry orderShowQry) {
		return orderShowQryExe.execute(orderShowQry);
	}

	@Override
	public void destroy(OrderDestroyCmd orderDestroyCmd) {
		orderDestroyCmdExe.execute(orderDestroyCmd);
	}

	@Override
	public void approve(OrderApproveCmd orderApproveCmd) {
		orderApproveCmdExe.execute(orderApproveCmd);
	}

	@Override
	public void submitReview(OrderSubmitReviewCmd orderSubmitReviewCmd) {
		orderSubmitReviewCmdExe.execute(orderSubmitReviewCmd);
	}

	@Override
	public void withdrawReview(OrderWithdrawReviewCmd orderWithdrawReviewCmd) {
		orderWithdrawReviewCmdExe.execute(orderWithdrawReviewCmd);
	}

	@Override
	public void rejectApprove(OrderRejectApproveCmd orderRejectApproveCmd) {
		orderRejectApproveCmdExe.execute(orderRejectApproveCmd);
	}

	@Override
	public void finalApprove(OrderFinalApproveCmd orderFinalApproveCmd) {
		orderFinalApproveCmdExe.execute(orderFinalApproveCmd);
	}

	@Override
	public void rejectFinal(OrderRejectFinalCmd orderRejectFinalCmd) {
		orderRejectFinalCmdExe.execute(orderRejectFinalCmd);
	}

	@Override
	public Long countOrderByState(OrderCountQry orderCountQry) {
		return orderCountQryExe.execute(orderCountQry);
	}

	// 新增分步提交方法
	@Override
	public OrderVO saveStep1(OrderStep1Cmd orderStep1Cmd) {
		return orderStep1CmdExe.execute(orderStep1Cmd);
	}

	@Override
	public void saveStep2(OrderStep2Cmd orderStep2Cmd) {
		orderStep2CmdExe.execute(orderStep2Cmd);
	}

	@Override
	public void saveStep3(OrderStep3Cmd orderStep3Cmd) {
		orderStep3CmdExe.execute(orderStep3Cmd);
	}

	@Override
	public String getLastVehicleNo(LastVehicleNoQry lastVehicleNoQry) {
		return lastVehicleNoQryExe.execute(lastVehicleNoQry);
	}
}
