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

import com.red.circle.order.domain.gateway.UserRechargeCountGateway;
import com.red.circle.order.infra.database.rds.service.count.UserMonthlyRechargeService;
import com.red.circle.order.inner.model.cmd.UserRechargeMonthQryCmd;
import com.red.circle.order.inner.model.dto.MonthlyRechargeUserDTO;
import com.red.circle.order.inner.model.dto.TotalRechargeUserDTO;
import com.red.circle.order.inner.model.enums.MonthlyRechargeType;
import com.red.circle.order.inner.service.UserRechargeCountClientService;
import java.math.BigDecimal;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 用户充值统计.
 *
 * @author pengliang on 2023/9/13
 */
@Service
@RequiredArgsConstructor
public class UserRechargeCountClientServiceImpl implements UserRechargeCountClientService {

  private final UserRechargeCountGateway userRechargeCountGateway;
  private final UserMonthlyRechargeService userMonthlyRechargeService;


  @Override
  public List<TotalRechargeUserDTO> listUserRechargeTotal(String sysOrigin) {
    return userRechargeCountGateway.listUserRechargeTotal(sysOrigin);
  }

  @Override
  public List<MonthlyRechargeUserDTO> listMonthlyRecharge(UserRechargeMonthQryCmd cmd) {
    return userRechargeCountGateway.listMonthlyRecharge(cmd);
  }

  @Override
  public void count(Long userId, BigDecimal amount, MonthlyRechargeType type) {
    userRechargeCountGateway.count(userId, amount, type);
  }

  @Override
  public void decr(Long userId, BigDecimal amount, MonthlyRechargeType type) {
    userRechargeCountGateway.decr(userId, amount, type);
  }

  @Override
  public BigDecimal getThisMonthTotalPersonalRecharge(Long userId) {
    return userMonthlyRechargeService.getThisMonthTotalPersonalRecharge(userId);
  }
}
