liusheng
2024-03-15 4c42cd3d556ea72d70ea43a734cc38acd6b81e74
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFundtaxServiceImpl.java
@@ -3,11 +3,20 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.project.domain.ServiceFund;
import com.ruoyi.project.domain.ServiceFunddetail;
import com.ruoyi.project.domain.ServiceFundtax;
import com.ruoyi.project.domain.vo.FundTaxVO;
import com.ruoyi.project.mapper.ServiceFunddetailMapper;
import com.ruoyi.project.mapper.ServiceFundtaxMapper;
import com.ruoyi.project.service.IServiceFundService;
import com.ruoyi.project.service.IServiceFunddetailService;
import com.ruoyi.project.service.IServiceFundtaxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -18,8 +27,16 @@
 * @date 2024-03-13
 */
@Service
public class ServiceFundtaxServiceImpl extends ServiceImpl<ServiceFundtaxMapper, ServiceFundtax> implements IServiceFundtaxService
{
public class ServiceFundtaxServiceImpl extends ServiceImpl<ServiceFundtaxMapper, ServiceFundtax> implements IServiceFundtaxService {
    @Autowired
    private ServiceFunddetailMapper serviceFunddetailMapper;
    @Autowired
    private IServiceFunddetailService serviceFunddetailService;
    @Autowired
    private IServiceFundService serviceFundService;
    @Autowired
    private ServiceFundtaxMapper serviceFundtaxMapper;
    /**
@@ -130,4 +147,35 @@
        return this.list(wrappers);
    }
    @Override
    public Integer getMaxFundTaxId() {
        return serviceFundtaxMapper.getMaxFundTaxId();
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean batchFundTax(FundTaxVO fundTaxVO) {
        if (fundTaxVO.getFundTaxId() == null) {
            throw new BaseException("分批算税出问题了,请检查后再进行计算");
        }
        if (fundTaxVO.getAddOrupdate() == 1) {
            Integer maxFundTaxId = serviceFundtaxMapper.getMaxFundTaxId();
            if (fundTaxVO.getFundTaxId() != maxFundTaxId.longValue()) {
                throw new BaseException("该批数据不能算税");
            }
        }
        ServiceFund serviceFund = new ServiceFund();
        serviceFund.setFundTaxId(fundTaxVO.getFundTaxId());
        serviceFund.setDel_flag(0);
        List<ServiceFund> serviceFunds = serviceFundService.selectServiceFundList(serviceFund);
        for (ServiceFund serviceFund1 : serviceFunds) {
            ServiceFunddetail serviceFunddetail = new ServiceFunddetail();
            serviceFunddetail.setFundid(serviceFund1.getId());
            List<ServiceFunddetail> serviceFunddetails = serviceFunddetailMapper.selectServiceFunddetailList(serviceFunddetail);
            serviceFunddetailService.calculateTax(serviceFunddetails);
        }
        return true;
    }
}