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

import java.math.BigDecimal;

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.mapper.RefundMapper;
import com.ruoyi.bst.refund.service.RefundDashboard;
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 selectSumofOrderRefundedAmount(RefundQuery refundQuery) {
        RefundQuery query = new RefundQuery();
        BeanUtils.copyBeanProp(query, refundQuery);
        query.setPayBstType(PayBstType.ORDER.getType());
        query.setStatusList(RefundStatus.valid());
        return MathUtils.dv(refundMapper.selectSumofAmount(query));
    }

}
