package com.red.circle.wallet.inner.service.wallet.impl;

import com.red.circle.wallet.infra.database.mongo.service.bank.UserBankBalanceService;
import com.red.circle.wallet.inner.model.cmd.UserBankBalanceDecrCmd;
import com.red.circle.wallet.inner.model.cmd.UserBankBalanceIncrCmd;
import com.red.circle.wallet.inner.model.cmd.UserBankBalanceQryCmd;
import com.red.circle.wallet.inner.model.dto.BankBalanceDTO;
import com.red.circle.wallet.inner.model.dto.UserBankBalanceDTO;
import com.red.circle.wallet.inner.service.wallet.UserBankBalanceClientService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 用户银行卡余额 实现
 *
 * @author pengliang on 2023/9/22
 */
@Service
@RequiredArgsConstructor
public class UserBankBalanceClientServiceImpl implements UserBankBalanceClientService {

  private final UserBankBalanceService userBankBalanceService;

  @Override
  public BankBalanceDTO getBalance(Long userId) {
    return userBankBalanceService.getBalance(userId);
  }

  @Override
  public boolean exists(Long userId) {
    return userBankBalanceService.existsPrimary(userId);
  }

  @Override
  public boolean incr(UserBankBalanceIncrCmd cmd) {
    return userBankBalanceService.incr(cmd.getUserId(), cmd.getSysOrigin(), cmd.getAmount());
  }

  @Override
  public BankBalanceDTO decr(UserBankBalanceDecrCmd cmd) {
    return userBankBalanceService.decr(cmd.getUserId(), cmd.getAmount());
  }


  @Override
  public List<UserBankBalanceDTO> listBalance(UserBankBalanceQryCmd query) {
    return userBankBalanceService.listBalance(query);
  }

}
