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

import com.red.circle.wallet.infra.database.mongo.service.bank.UserBankRunningWaterService;
import com.red.circle.wallet.infra.database.mongo.service.bank.UserBankWithdrawGoldApplyService;
import com.red.circle.wallet.infra.database.mongo.service.bank.UserBankWithdrawMoneyApplyService;
import com.red.circle.wallet.inner.convertor.UserBankInnerConvertor;
import com.red.circle.wallet.inner.model.cmd.UserBankApprovalMoneyApplyCmd;
import com.red.circle.wallet.inner.model.cmd.UserBankRunningWaterQryCmd;
import com.red.circle.wallet.inner.model.cmd.UserBankWithdrawGoldApplyQryCmd;
import com.red.circle.wallet.inner.model.cmd.UserBankWithdrawMoneyApplyQryCmd;
import com.red.circle.wallet.inner.model.dto.UserBankRunningWaterDTO;
import com.red.circle.wallet.inner.model.dto.UserBankWithdrawGoldApplyDTO;
import com.red.circle.wallet.inner.model.dto.UserBankWithdrawMoneyApplyDTO;
import com.red.circle.wallet.inner.service.bank.UserBankRunningWaterClientService;
import java.util.List;
import java.util.Map;
import java.util.Set;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 银行卡流水.
 *
 * @author pengliang on 2023/10/13
 */
@Service
@RequiredArgsConstructor
public class UserBankRunningWaterClientServiceImpl implements UserBankRunningWaterClientService {

  private final UserBankInnerConvertor userBankInnerConvertor;
  private final UserBankRunningWaterService userBankRunningWaterService;
  private final UserBankWithdrawGoldApplyService bankWithdrawGoldApplyService;
  private final UserBankWithdrawMoneyApplyService bankWithdrawMoneyApplyService;

  @Override
  public boolean existsTrackId(String trackId) {
    return userBankRunningWaterService.existsTrackId(trackId);
  }

  @Override
  public boolean existsTrackId(Long userId, String event, String trackId) {
    return userBankRunningWaterService.existsTrackId(userId, event, trackId);
  }

  @Override
  public void add(UserBankRunningWaterDTO runningWater) {
    userBankRunningWaterService.add(userBankInnerConvertor.toUserBankRunningWater(runningWater));
  }

  @Override
  public void addBatch(List<UserBankRunningWaterDTO> runningWaters) {
    userBankRunningWaterService.addBatch(
        userBankInnerConvertor.toListUserBankRunningWater(runningWaters));
  }

  @Override
  public List<UserBankRunningWaterDTO> pageRunningWater(UserBankRunningWaterQryCmd query) {
    return userBankInnerConvertor.toListUserBankRunningWaterDTO(
        userBankRunningWaterService.pageRunningWater(query));
  }

  @Override
  public String calculateTotal(UserBankRunningWaterQryCmd query) {
    return userBankRunningWaterService.calculateTotal(query);
  }

  @Override
  public List<UserBankWithdrawGoldApplyDTO> pageBankWithdrawGoldApply(
      UserBankWithdrawGoldApplyQryCmd query) {
    return userBankInnerConvertor.toListUserBankWithdrawGoldApplyDTO(
        bankWithdrawGoldApplyService.pageBankWithdrawGoldApply(query));
  }

  @Override
  public List<UserBankWithdrawMoneyApplyDTO> listBankWithdrawMoneyApply(
      UserBankWithdrawMoneyApplyQryCmd query) {
    return userBankInnerConvertor.toListUserBankWithdrawMoneyApplyDTO(
        bankWithdrawMoneyApplyService.listBankWithdrawMoneyApply(query));
  }

    @Override
    public Map<Long, UserBankWithdrawMoneyApplyDTO> mapByIds(Set<Long> ids) {
        return userBankInnerConvertor.toUserBankWithdrawMoneyApplyMap(
                bankWithdrawMoneyApplyService.mapByIds(ids));
    }


  @Override
  public UserBankWithdrawMoneyApplyDTO getWithdrawMoneyApplyById(Long id) {
    return userBankInnerConvertor.toUserBankWithdrawMoneyApplyDTO(
        bankWithdrawMoneyApplyService.getById(id));
  }

  @Override
  public void approvalMoneyApply(UserBankApprovalMoneyApplyCmd apply) {
    bankWithdrawMoneyApplyService.approvalMoneyApply(apply);
  }

  @Override
  public List<UserBankRunningWaterDTO> getMonthSalaryRunningWater(List<Long> userIds, String event, String month) {
    return userBankInnerConvertor.toListUserBankRunningWaterDTO(
        userBankRunningWaterService.getMonthSalaryRunningWater(userIds, event, month));
  }

}
