package com.red.circle.wallet.app.command.salary;

import com.red.circle.wallet.app.convertor.SalaryAccountConvertor;
import com.red.circle.wallet.app.dto.cmd.SalaryWithdrawCmd;
import com.red.circle.wallet.domain.gateway.SalaryAccountGateway;
import com.red.circle.wallet.domain.salary.SalaryReceipt;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 工资提现.
 */
@Component
@RequiredArgsConstructor
public class SalaryWithdrawRefundCmdExe {

  private final SalaryAccountGateway salaryAccountGateway;
  private final SalaryAccountConvertor salaryAccountConvertor;

  public void execute(SalaryWithdrawCmd cmd) {
      SalaryReceipt receipt = salaryAccountConvertor.toWithdrawRefundReceipt(cmd);
      salaryAccountGateway.changeBalance(receipt);
  }
}
