package com.ruoyi.bst.withdraw.service.impl;

import com.ruoyi.bst.withdraw.domain.WithdrawQuery;
import com.ruoyi.bst.withdraw.domain.enums.WithdrawStatus;
import com.ruoyi.bst.withdraw.domain.vo.WithdrawStatVO;
import com.ruoyi.bst.withdraw.mapper.WithdrawMapper;
import com.ruoyi.bst.withdraw.service.WithdrawDashboard;
import com.ruoyi.common.utils.MathUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class WithdrawDashboardImpl implements WithdrawDashboard {

    @Autowired
    private WithdrawMapper withdrawMapper;

    @Override
    public BigDecimal selectSuccessAmount(WithdrawQuery query) {
        WithdrawQuery successQuery = new WithdrawQuery();
        BeanUtils.copyProperties(query, successQuery);
        successQuery.setStatus(WithdrawStatus.SUCCESS.getCode());
        return MathUtils.dv(withdrawMapper.selectSumOfAmount(successQuery));
    }

    private int selectWaitVerifyCount(WithdrawQuery query) {
        WithdrawQuery waitVerifyQuery = new WithdrawQuery();
        BeanUtils.copyProperties(query, waitVerifyQuery);
        waitVerifyQuery.setStatus(WithdrawStatus.WAIT_VERIFY.getCode());
        return MathUtils.dv(withdrawMapper.selectCount(waitVerifyQuery));
    }
}
