liusheng
2023-10-13 22655ad10d386f0fc3c38389f519d3d188b46f19
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java
@@ -5,12 +5,11 @@
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.ruoyi.common.tax.PerformanceTaxtUtils;
import com.ruoyi.common.tax.TaxtUtils;
import com.ruoyi.common.utils.bean.DtoConversionUtils;
import com.ruoyi.project.domain.*;
@@ -81,6 +80,18 @@
        }
        if (serviceFunddetail.getUploadtime() != null) {
            wrappers.eq(ServiceFunddetail::getUploadtime, serviceFunddetail.getUploadtime());
        }
        if (serviceFunddetail.getJxrq() != null) {
            wrappers.like(ServiceFunddetail::getJxrq, serviceFunddetail.getJxrq());
        }
        if (StringUtils.isNotBlank(serviceFunddetail.getIdcardno())) {
            wrappers.eq(ServiceFunddetail::getIdcardno, serviceFunddetail.getIdcardno());
        }
        if (StringUtils.isNotBlank(serviceFunddetail.getApplytype())) {
            wrappers.eq(ServiceFunddetail::getApplytype, serviceFunddetail.getApplytype());
        }
        if (serviceFunddetail.getDel_flag() != null) {
            wrappers.eq(ServiceFunddetail::getDel_flag, serviceFunddetail.getDel_flag());
        }
        return this.list(wrappers);
    }
@@ -256,7 +267,8 @@
            taxMoneyVO.setFirstDay(firstDay);
//            taxMoneyVO.setApplyType(Long.valueOf(serviceFunddetail.getApplytype()));
            taxMoneyVO.setFundID(serviceFunddetail.getFundid());
            taxMoneyVO.setBeneficiaryNo(serviceFunddetail.getBeneficiaryno());
//            taxMoneyVO.setBeneficiaryNo(serviceFunddetail.getBeneficiaryno());
            taxMoneyVO.setIDCard(serviceFunddetail.getIdcardno());
            //查出税前、税、税后的总额(不包含本次)
            TaxMoneySumEO taxSum = serviceFunddetailMapper.getTaxSum(taxMoneyVO);
            if (ObjectUtils.isEmpty(taxSum)) {
@@ -329,4 +341,61 @@
        return true;
    }
    @Override
    public Map<String, Double> performance(ServiceFunddetail serviceFunddetail) {
        //根据"身份证号"和"绩效日期(年份)"查询个人历史绩效
        ServiceFunddetail serviceFunddetailEo = new ServiceFunddetail();
        serviceFunddetailEo.setIdcardno(serviceFunddetail.getIdcardno());
        serviceFunddetailEo.setApplytype("5");
        Calendar cal = Calendar.getInstance();
        //默认本年度
        serviceFunddetailEo.setJxrq(String.valueOf(cal.get(Calendar.YEAR)));
        List<ServiceFunddetail> serviceFunddetails = queryList(serviceFunddetailEo);
        //统计历史的税
        BigDecimal historyTax = BigDecimal.valueOf(0.00);
        //计算扣去每月5000的历史税前金额
        BigDecimal historyTaxBefore = BigDecimal.valueOf(0.00);
        //本月是否已经算过绩效(下面扣除5000需要用到这个,如果本月已经扣过5000,就不再扣了)
        Boolean deduct = false;
        //获取当前月份
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
        String nowMonth = sdf.format(date);
        for (ServiceFunddetail serviceFunddetail1 : serviceFunddetails) {
            historyTaxBefore = historyTaxBefore.add(BigDecimal.valueOf(serviceFunddetail1.getAmount())).subtract(BigDecimal.valueOf(5000));
            historyTax = historyTax.add(BigDecimal.valueOf(serviceFunddetail1.getTaxamount()));
            if (serviceFunddetail1.getJxrq().equals(nowMonth)) {
                deduct = true;
            }
        }
        BigDecimal allValue = BigDecimal.valueOf(0.00);
        //先查询一下本月是否已经算过绩效(一个月只减一次5000,如果上一次已经减过,这一次就不在减了)
        if (deduct == true) {
            //本月已经减过5000了
            allValue = historyTaxBefore.add(BigDecimal.valueOf(serviceFunddetail.getAmount()));
        } else {
            BigDecimal subtract = BigDecimal.valueOf(serviceFunddetail.getAmount()).subtract(BigDecimal.valueOf(5000));
            allValue = historyTaxBefore.add(subtract);
        }
        //计算加上本次的税前金额的总税
        BigDecimal personTaxation = PerformanceTaxtUtils.getPersonTaxation(allValue);
        //计算本次的税
        BigDecimal nowSingleTax = personTaxation.subtract(historyTax);
        //计算本次的税后
        BigDecimal taxAfter = BigDecimal.valueOf(serviceFunddetail.getAmount()).subtract(nowSingleTax);
        //将计算出来的数据放到serviceFunddetail中
        serviceFunddetail.setTaxamount(nowSingleTax.doubleValue());
        serviceFunddetail.setTaxedamount(taxAfter.doubleValue());
        serviceFunddetail.setJxrq(nowMonth);
        save(serviceFunddetail);
        Map map = new HashMap();
        map.put("amount", serviceFunddetail.getAmount());
        map.put("taxedamount", taxAfter.doubleValue());
        return map;
    }
}