package com.xunhong.erp.turbo.biz.app.executor.cmd;

import com.xunhong.erp.turbo.api.biz.dto.cmd.OrderFinalApproveCmd;
import com.xunhong.erp.turbo.biz.domain.gateway.ExpenseRecordGateway;
import com.xunhong.erp.turbo.biz.domain.gateway.OrderGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author shenyifei
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class OrderFinalApproveCmdExe {

	private final OrderGateway orderGateway;

	private final ExpenseRecordGateway expenseRecordGateway;

	@Transactional
	public void execute(OrderFinalApproveCmd orderFinalApproveCmd) {
		orderGateway.finalApprove(orderFinalApproveCmd);

		// 计提费计入发货日期的花销
		expenseRecordGateway.addProvision(orderFinalApproveCmd.getOrderId());
	}
}
