package com.ruoyi.bst.pay.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.pay.domain.PayQuery;
import com.ruoyi.bst.pay.domain.enums.PayBstType;
import com.ruoyi.bst.pay.domain.enums.PayStatus;
import com.ruoyi.bst.pay.mapper.PayMapper;
import com.ruoyi.bst.pay.service.PayDashboard;
import com.ruoyi.common.domain.vo.StringDecimalVO;
import com.ruoyi.common.utils.MathUtils;
import com.ruoyi.common.utils.bean.BeanUtils;

@Service
public class PayDashboardImpl implements PayDashboard {

    @Autowired
    private PayMapper payMapper;

    @Override
    public BigDecimal selectSumofOrderPayedAmount(PayQuery query) {
        PayQuery payQuery = new PayQuery();
        BeanUtils.copyBeanProp(payQuery, query);
        payQuery.setBstType(PayBstType.ORDER.getType());
        payQuery.setStatusList(PayStatus.payedList());
        return MathUtils.dv(payMapper.selectSumofAmount(payQuery));
    }

    @Override
    public BigDecimal selectSumOfChannelCost(PayQuery query) {
        return MathUtils.dv(payMapper.selectSumOfChannelCost(query));
    }

    @Override
    public List<StringDecimalVO> selectSumOfPayedAmountGroupByBstType(PayQuery query) {
        return payMapper.selectSumOfPayedAmountGroupByBstType(query);
    }
}
