| | |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.tax.PerformanceTaxtUtils; |
| | | import com.ruoyi.common.tax.TaxtUtils; |
| | | import com.ruoyi.common.utils.bean.DtoConversionUtils; |
| | | import com.ruoyi.project.domain.*; |
| | | import com.ruoyi.project.domain.vo.*; |
| | | import com.ruoyi.project.mapper.ServiceFundMapper; |
| | | import com.ruoyi.project.mapper.SpStatBonusMapper; |
| | | import lombok.extern.flogger.Flogger; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | * @author ruoyi |
| | | * @date 2022-01-25 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ServiceFunddetailServiceImpl extends ServiceImpl<ServiceFunddetailMapper, ServiceFunddetail> implements IServiceFunddetailService { |
| | | protected final Logger logger = LoggerFactory.getLogger(this.getClass()); |
| | |
| | | |
| | | @Autowired |
| | | ServiceFundMapper serviceFundMapper; |
| | | |
| | | @Autowired |
| | | SpStatBonusMapper spStatBonusMapper; |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | if (serviceFunddetail.getDel_flag() != null) { |
| | | wrappers.eq(ServiceFunddetail::getDel_flag, serviceFunddetail.getDel_flag()); |
| | | } |
| | | if (serviceFunddetail.getDeptId() != null) { |
| | | wrappers.eq(ServiceFunddetail::getDeptId, serviceFunddetail.getDeptId()); |
| | | } |
| | | if (serviceFunddetail.getDeptName() != null) { |
| | | wrappers.eq(ServiceFunddetail::getDeptName, serviceFunddetail.getDeptName()); |
| | | } |
| | | return this.list(wrappers); |
| | | } |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean calculateTax(List<ServiceFunddetail> serviceFunddetails) { |
| | | //用于临时保存已经算好的"费用详情数据" |
| | | List<ServiceFunddetail> temporarySave = new ArrayList<>(); |
| | | if (CollectionUtils.isEmpty(serviceFunddetails)) { |
| | | throw new BaseException("算税条件为空,请检查后,再进行计算"); |
| | | } |
| | | // 先对serviceFunddetails排序 |
| | | Comparator<ServiceFunddetail> customComparator = Comparator.comparing(obj -> { |
| | | if (ObjectUtils.isEmpty(obj.getTaxTime())) { |
| | | return 1; // 返回1表示字段为空的对象排在后面 |
| | | } else { |
| | | return 0; // 返回0表示字段不为空的对象保持原顺序 |
| | | } |
| | | }); |
| | | Collections.sort(serviceFunddetails, customComparator); |
| | | |
| | | //这个是为了获取fund_tax_time |
| | | Long fundid = serviceFunddetails.get(0).getFundid(); |
| | | log.info("算税的fundid的值为:{}", fundid); |
| | | ServiceFund serviceFund1 = serviceFundMapper.selectById(fundid); |
| | | log.info("fund表的fundtextime值为:{}", serviceFund1.getFundtaxtime()); |
| | | |
| | | // //用于临时保存已经算好的"费用详情数据" |
| | | List<ServiceFunddetail> temporarySave = new ArrayList<>(); |
| | | //保存总税前金额(用于更新fund表里的) |
| | | BigDecimal pretaxcost = BigDecimal.valueOf(0.00); |
| | | BigDecimal taxedcost = BigDecimal.valueOf(0.00); |
| | | for (ServiceFunddetail serviceFunddetail : serviceFunddetails) { |
| | | if (StringUtils.isEmpty(serviceFunddetail.getIdcardno())) { |
| | | logger.info("serviceFunddetail数据入参 : {}", serviceFunddetail); |
| | |
| | | } else { |
| | | serviceFunddetail.setAmount(serviceFunddetail.getTaxedamount()); |
| | | } |
| | | //公司的申请金额也要加进去 |
| | | pretaxcost = pretaxcost.add(BigDecimal.valueOf(serviceFunddetail.getAmount())); |
| | | taxedcost = taxedcost.add(BigDecimal.valueOf(serviceFunddetail.getTaxedamount())); |
| | | |
| | | serviceFunddetail.setTaxamount(0.0); |
| | | logger.info("serviceFunddetail更新后的数据 : {}", serviceFunddetail); |
| | | boolean b = this.updateById(serviceFunddetail); |
| | |
| | | |
| | | //获取当月的第一天 |
| | | Date firstDay = Date.from(LocalDate.now().with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String firstDatStr = dateFormat.format(firstDay); |
| | | TaxMoneyByItemEO taxMoneyVO = new TaxMoneyByItemEO(); |
| | | //获取到当前人的本月算税序号最大值 |
| | | TaxMoneyByItemEO taxMoneyByItemEO = new TaxMoneyByItemEO(); |
| | | taxMoneyByItemEO.setFirstDay(firstDay); |
| | | taxMoneyByItemEO.setIDCard(serviceFunddetail.getIdcardno()); |
| | | taxMoneyByItemEO.setTaxTime(new Date()); |
| | | Long maxXH = serviceFunddetailMapper.getMaxXH(taxMoneyByItemEO); |
| | | if (maxXH == null) { |
| | | maxXH = 0L; |
| | | } |
| | | |
| | | taxMoneyVO.setTaxTime(new Date()); |
| | | TaxMoneyByItemEO taxMoneyVO = new TaxMoneyByItemEO(); |
| | | if (serviceFund1.getFundtaxtime() != null) { |
| | | taxMoneyVO.setTaxTime(serviceFund1.getFundtaxtime()); |
| | | } else { |
| | | taxMoneyVO.setTaxTime(new Date()); |
| | | } |
| | | taxMoneyVO.setFirstDay(firstDay); |
| | | // taxMoneyVO.setApplyType(Long.valueOf(serviceFunddetail.getApplytype())); |
| | | taxMoneyVO.setFundID(serviceFunddetail.getFundid()); |
| | | // taxMoneyVO.setBeneficiaryNo(serviceFunddetail.getBeneficiaryno()); |
| | | taxMoneyVO.setIDCard(serviceFunddetail.getIdcardno()); |
| | | if (serviceFunddetail.getXh() != null) { |
| | | taxMoneyVO.setXh(serviceFunddetail.getXh()); |
| | | } else { |
| | | taxMoneyVO.setXh(maxXH + 1); |
| | | } |
| | | //查出税前、税、税后的总额(不包含本次) |
| | | TaxMoneySumEO taxSum = serviceFunddetailMapper.getTaxSum(taxMoneyVO); |
| | | logger.info("查询的taxSum的值 : {}", taxSum); |
| | |
| | | continue; |
| | | } |
| | | } |
| | | if (serviceFunddetail.getXh() == null) { |
| | | serviceFunddetail.setXh(maxXH + 1); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(serviceFunddetail.getServicesscopename()) || !serviceFunddetail.getServicesscopename().contains("税后")) { |
| | | logger.info("计算税前信息开始:{}", serviceFunddetail); |
| | |
| | | ServiceFunddetail serviceFunddetail3 = DtoConversionUtils.sourceToTarget(serviceFunddetail, ServiceFunddetail.class); |
| | | serviceFunddetail3.setTaxamount(taxAmountNow.doubleValue()); |
| | | serviceFunddetail3.setTaxedamount(texdAfterNow.doubleValue()); |
| | | serviceFunddetail3.setTaxTime(new Date()); |
| | | if (ObjectUtils.isEmpty(serviceFund1.getFundtaxtime())) { |
| | | serviceFunddetail3.setTaxTime(new Date()); |
| | | } else { |
| | | serviceFunddetail3.setTaxTime(serviceFund1.getFundtaxtime()); |
| | | } |
| | | logger.info("打印税前serviceFunddetail3数据 :{}", serviceFunddetail3); |
| | | |
| | | // 将该条数据更新 |
| | | |
| | | boolean b = this.updateById(serviceFunddetail3); |
| | | pretaxcost = pretaxcost.add(BigDecimal.valueOf(serviceFunddetail.getAmount())); |
| | | // 把该数据,放到临时的集合中 |
| | | taxedcost = taxedcost.add(BigDecimal.valueOf(serviceFunddetail.getTaxedamount())); |
| | | // // 把该数据,放到临时的集合中 |
| | | temporarySave.add(serviceFunddetail3); |
| | | } else if (serviceFunddetail.getServicesscopename().contains("税后")) { |
| | | logger.info("计算税后信息开始:{}", serviceFunddetail); |
| | |
| | | ServiceFunddetail serviceFunddetail3 = DtoConversionUtils.sourceToTarget(serviceFunddetail, ServiceFunddetail.class); |
| | | serviceFunddetail3.setAmount(amountNow.doubleValue()); |
| | | serviceFunddetail3.setTaxamount(tax.doubleValue()); |
| | | serviceFunddetail3.setTaxTime(new Date()); |
| | | if (ObjectUtils.isEmpty(serviceFund1.getFundtaxtime())) { |
| | | serviceFunddetail3.setTaxTime(new Date()); |
| | | } else { |
| | | serviceFunddetail3.setTaxTime(serviceFund1.getFundtaxtime()); |
| | | } |
| | | logger.info("打印serviceFunddetail3:{}", serviceFunddetail3); |
| | | //获取到当前人的本月算税序号最大值 |
| | | TaxMoneyByItemEO byItemEO = new TaxMoneyByItemEO(); |
| | | byItemEO.setFirstDay(firstDay); |
| | | byItemEO.setIDCard(serviceFunddetail.getIdcardno()); |
| | | byItemEO.setTaxTime(new Date()); |
| | | // 将该条数据更新 |
| | | updateById(serviceFunddetail3); |
| | | pretaxcost = pretaxcost.add(BigDecimal.valueOf(serviceFunddetail3.getAmount())); |
| | | // 把该数据,放到临时的集合中 |
| | | taxedcost = taxedcost.add(BigDecimal.valueOf(serviceFunddetail3.getTaxedamount())); |
| | | // // 把该数据,放到临时的集合中 |
| | | temporarySave.add(serviceFunddetail3); |
| | | } |
| | | } |
| | | ServiceFund serviceFund = new ServiceFund(); |
| | | serviceFund.setPretaxcost(pretaxcost.doubleValue()); |
| | | serviceFund.setTaxedcost(taxedcost.doubleValue()); |
| | | serviceFund.setId(serviceFunddetails.get(0).getFundid()); |
| | | if (ObjectUtils.isEmpty(serviceFund1.getFundtaxtime())) { |
| | | serviceFund.setFundtaxtime(new Date()); |
| | | } |
| | | // 1 已算税 |
| | | serviceFund.setIstax(1); |
| | | serviceFundMapper.updateById(serviceFund); |
| | | |
| | | return true; |
| | |
| | | return map; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<SpStatBonus> getListBySpStatBonus(SpStatBonusReq spStatBonusReq) { |
| | | return spStatBonusMapper.getListBySpStatBonus(spStatBonusReq.getPabegtime(), spStatBonusReq.getPaendtime(), spStatBonusReq.getPadeptno(), spStatBonusReq.getPausername(), spStatBonusReq.getPabonustype()); |
| | | } |
| | | } |