package com.red.circle.wallet.app.command.freight.query;

import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.other.inner.asserts.user.UserErrorCode;
import com.red.circle.wallet.infra.database.rds.service.freight.FreightBalanceService;
import java.math.BigDecimal;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 货运代理是否为首次充值.
 *
 * @author pengliang on 2022/10/10
 */
@Component
@RequiredArgsConstructor
public class FreightFirstRechargeCheckCmdExe {

  private final FreightBalanceService freightBalanceService;

  public Boolean execute(AppUserIdCmd cmd) {

    // 账号已关闭
    ResponseAssert.isFalse(UserErrorCode.ACCOUNT_CLOSED,
        freightBalanceService.checkClose(cmd.requireReqSysOriginEnum(), cmd.getUserId()));

    return BigDecimal.valueOf(100).compareTo(freightBalanceService.getEarnPoints(cmd.getUserId()))
        >= 0;
  }

}
