package com.fjhx.account.service.tax.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjhx.account.entity.tax.dto.TaxRefundDetailsSelectDto;
import com.fjhx.account.entity.tax.po.TaxRefundDetails;
import com.fjhx.account.entity.tax.vo.TaxRefundDetailsVo;
import com.fjhx.account.mapper.tax.TaxRefundDetailsMapper;
import com.fjhx.account.service.tax.TaxRefundDetailsService;
import com.ruoyi.common.utils.wrapper.IWrapper;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>
 * 退税明细表 服务实现类
 * </p>
 *
 * @author
 * @since 2023-06-30
 */
@Service
public class TaxRefundDetailsServiceImpl extends ServiceImpl<TaxRefundDetailsMapper, TaxRefundDetails> implements TaxRefundDetailsService {

    @Override
    public Page<TaxRefundDetailsVo> getPage(TaxRefundDetailsSelectDto dto) {
        IWrapper<TaxRefundDetails> wrapper = getWrapper();
        wrapper.orderByDesc("trd", TaxRefundDetails::getId);
        Page<TaxRefundDetailsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

    /**
     * 获取总退税金额
     * @param contractIds
     * @return
     */
    @Override
    public List<TaxRefundDetails> getSumMoneyByContractIds(List<Long> contractIds) {
        IWrapper<TaxRefundDetails> wrapper = getWrapper();
        wrapper.in("t1",TaxRefundDetails::getContractId,contractIds);
        return baseMapper.getSumMoneyByContractIds(wrapper);
    }

}
