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

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

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

import com.ruoyi.bst.pay.domain.enums.PayBstType;
import com.ruoyi.bst.refund.domain.RefundQuery;
import com.ruoyi.bst.refund.domain.enums.RefundStatus;
import com.ruoyi.bst.refund.domain.vo.RefundDailyStatVO;
import com.ruoyi.bst.refund.mapper.RefundMapper;
import com.ruoyi.bst.refund.service.RefundDashboard;
import com.ruoyi.common.domain.vo.StringDecimalVO;
import com.ruoyi.common.utils.MathUtils;
import com.ruoyi.common.utils.bean.BeanUtils;

@Service
public class RefundDashboardImpl implements RefundDashboard {
    
    @Autowired
    private RefundMapper refundMapper;

    @Override
    public BigDecimal selectSumOfAmount(RefundQuery refundQuery) {
        RefundQuery query = new RefundQuery();
        BeanUtils.copyBeanProp(query, refundQuery);
        query.setPayBstTypes(Arrays.asList(PayBstType.ORDER.getType(), PayBstType.ORDER_RIDE.getType()));
        query.setStatusList(RefundStatus.valid());
        return MathUtils.dv(refundMapper.selectSumofAmount(query));
    }

    @Override
    public List<RefundDailyStatVO> selectDailyRefundStat(RefundQuery query, List<String> keys) {
        return refundMapper.selectDailyRefundStat(query, keys);
    }

    @Override
    public List<StringDecimalVO> selectSumOfAmountGroupByBstType(RefundQuery query) {
        return refundMapper.selectSumOfAmountGroupByBstType(query);
    }

}
