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

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.bst.bonus.domain.BonusQuery;
import com.ruoyi.bst.bonus.domain.vo.BonusDailyStatVO;
import com.ruoyi.bst.bonus.domain.vo.BonusStatVO;
import com.ruoyi.bst.bonus.mapper.BonusMapper;
import com.ruoyi.bst.bonus.service.BonusDashboard;
import com.ruoyi.common.utils.MathUtils;
import com.ruoyi.dashboard.constants.StatKeys;

@Service
public class BonusDashboardImpl implements BonusDashboard {

    @Autowired
    private BonusMapper bonusMapper;

    @Override
    public BonusStatVO selectStat(BonusQuery query, List<String> keys) {
        BonusStatVO vo = new BonusStatVO();
        if (keys.contains(StatKeys.BONUS_COUNT)) {
            vo.setCount(MathUtils.dv(bonusMapper.selectCount(query)));
        }
        if (keys.contains(StatKeys.BONUS_AMOUNT)) {
            vo.setAmount(MathUtils.dv(bonusMapper.selectSumOfAmount(query)));
        }
        if (keys.contains(StatKeys.BONUS_WAIT_DIVIDE_AMOUNT)) {
            vo.setWaitDivideAmount(MathUtils.dv(bonusMapper.selectSumOfWaitAmount(query)));
        }
        return vo;
    }

    @Override
    public List<BonusDailyStatVO> selectDailyStat(BonusQuery query, List<String> keys) {
        return bonusMapper.selectDailyStat(query, keys);
    }

}
