From 688fb1c93eabaea3facf4e7ace1b27b1bac53fbe Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 20 九月 2023 16:54:59 +0800
Subject: [PATCH] 代码提交
---
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java | 200 +++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 180 insertions(+), 20 deletions(-)
diff --git a/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java b/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java
index 32b0637..aae29db 100644
--- a/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java
+++ b/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java
@@ -1,14 +1,20 @@
package com.ruoyi.project.service.impl;
import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
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 com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.ruoyi.common.tax.TaxtUtils;
+import com.ruoyi.common.utils.bean.DtoConversionUtils;
import com.ruoyi.project.domain.*;
-import com.ruoyi.project.domain.vo.TaxMoneyVO;
+import com.ruoyi.project.domain.vo.*;
import com.ruoyi.project.mapper.ServiceFundMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,6 +25,7 @@
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.project.mapper.ServiceFunddetailMapper;
import com.ruoyi.project.service.IServiceFunddetailService;
+import org.springframework.transaction.annotation.Transactional;
/**
* 璐圭敤鐢宠鏄庣粏Service涓氬姟灞傚鐞�
@@ -93,22 +100,69 @@
return dataBybeneficiaryNo;
}
+ /**
+ * 鏍规嵁鍙楃泭浜虹紪鍙疯幏鍙栫◣璐归噾棰�
+ *
+ * @param taxMoneyVo
+ * @return
+ */
@Override
- public Double getTaxBeforeByBeneFiciaryNo(TaxMoneyVO taxMoneyVo) {
+ public Double getTaxByBeneFiciaryNo(TaxMoneyVO taxMoneyVo) {
+ Double sum = 0.00;
+ Double totalScore = 0.00;
List<ServiceFunddetail> taxationByBeneFiciaryNo = serviceFunddetailMapper.getTaxBeforeByBeneFiciaryNo(taxMoneyVo);
- if (CollectionUtils.isEmpty(taxationByBeneFiciaryNo) && taxMoneyVo.getMoney() == 0) {
- //閮戒负0浜嗭紝灏辨病鏈夊繀瑕佸啀璁$畻浜�
- return 0.00;
+ if (CollectionUtils.isNotEmpty(taxationByBeneFiciaryNo)) {
+ //璁$畻鐢宠閲戦鎬诲拰锛屼笉鍖呮嫭褰撳墠浼犺繘鏉ョ殑
+ sum = taxationByBeneFiciaryNo.stream().mapToDouble(ServiceFunddetail::getAmount).sum();
+ //涓嶅姞鏈钖叕鐨勪釜绋�
+ totalScore = taxationByBeneFiciaryNo.stream().mapToDouble(ServiceFunddetail::getTaxamount).sum();
}
- double sum = taxationByBeneFiciaryNo.stream().mapToDouble(ServiceFunddetail::getAmount).sum();
+
sum = sum + new Double(taxMoneyVo.getMoney());
- //鍔犱笂鏈钖叕鐨勪釜绋�
+ //鍔犱笂鏈钖叕鐨勬�讳釜绋�
String taxation = TaxtUtils.getTaxation(new BigDecimal(sum));
- //涓嶅姞鏈钖叕鐨勪釜绋�
- Double totalScore = taxationByBeneFiciaryNo.stream().mapToDouble(ServiceFunddetail::getTaxamount).sum();
Double tax = Double.valueOf(taxation) - totalScore;
return tax;
+ }
+
+ /**
+ * 鏍规嵁绋庡悗宸ヨ祫锛岀畻鍑虹◣鍓嶅伐璧�
+ *
+ * @param taxMoneyVo
+ * @return
+ */
+ @Override
+ public TaxedMoneyVO getTaxBeforeByAfterMoney(TaxMoneyVO taxMoneyVo) {
+ TaxedMoneyVO taxedMoneyVO = new TaxedMoneyVO();
+ Double sum = 0.00;
+ Double totalScore = 0.00;
+ List<ServiceFunddetail> taxationByBeneFiciaryNo = serviceFunddetailMapper.getTaxBeforeByBeneFiciaryNo(taxMoneyVo);
+ if (CollectionUtils.isNotEmpty(taxationByBeneFiciaryNo)) {
+ //璁$畻鍑虹◣鍚庢�婚噾棰濓紙涓嶅寘鍚湰娆★級
+ sum = taxationByBeneFiciaryNo.stream().mapToDouble(ServiceFunddetail::getTaxedamount).sum();
+ //姹傚嚭涔嬪墠鐨勬�荤殑涓◣
+ totalScore = taxationByBeneFiciaryNo.stream().mapToDouble(ServiceFunddetail::getTaxamount).sum();
+ }
+ //璁$畻鍑烘�荤殑绋庡悗钖叕锛堝寘鍚湰娆★級
+ sum = sum + Double.valueOf(taxMoneyVo.getMoney());
+ //绋庡墠鎬婚噾棰�
+ String taxationBefore = TaxtUtils.getTaxationBefore(new BigDecimal(sum));
+ //鎬讳釜绋�
+ BigDecimal tax = new BigDecimal(taxationBefore).subtract(new BigDecimal(sum));
+
+ //鏈鐨勭◣鍓嶉噾棰�
+ String nowTaxMoney = TaxtUtils.getTaxationBefore(new BigDecimal(taxMoneyVo.getMoney()));
+ //鏈鐨勭◣璐�
+ BigDecimal subtract = new BigDecimal(nowTaxMoney).subtract(new BigDecimal(taxMoneyVo.getMoney()));
+
+ taxedMoneyVO.setAllTax(tax.toString());
+ taxedMoneyVO.setAllTaxbeforeMoney(taxationBefore);
+ taxedMoneyVO.setAllAaxAfterMoney(sum.toString());
+ taxedMoneyVO.setNowTaxBeforeMoney(nowTaxMoney);
+ taxedMoneyVO.setNowTax(subtract.toString());
+
+ return taxedMoneyVO;
}
@@ -152,20 +206,126 @@
ServiceFunddetail serviceFunddetail = serviceFunddetailMapper.selectById(id);
Long fundid = serviceFunddetail.getFundid();
ServiceFund serviceFund = serviceFundMapper.selectById(fundid);
+ if (ObjectUtils.isNotEmpty(serviceFund)) {
+ Double pretax = serviceFund.getPretaxcost();
+ Double aftertax = serviceFund.getTaxedcost();
+ pretax = pretax - serviceFunddetail.getAmount();
+ aftertax = aftertax - serviceFunddetail.getTaxedamount();
+ Double amount = pretax + aftertax;
- Double pretax = serviceFund.getPretaxcost();
- Double aftertax = serviceFund.getTaxedcost();
- pretax = pretax - serviceFunddetail.getAmount();
- aftertax = aftertax - serviceFunddetail.getTaxedamount();
- Double amount = pretax + aftertax;
-
- serviceFund.setPretaxcost(pretax);
- serviceFund.setTaxedcost(aftertax);
- serviceFund.setAmountrequested(amount);
- int updateAmount = serviceFundMapper.updateById(serviceFund);
-
+ serviceFund.setPretaxcost(pretax);
+ serviceFund.setTaxedcost(aftertax);
+ serviceFund.setAmountrequested(amount);
+ int updateAmount = serviceFundMapper.updateById(serviceFund);
+ }
return serviceFunddetailMapper.deleteById(id);
}
+ @Override
+ public List<ServiceFunddetailVO> getFundDetail(Long id) {
+ List<ServiceFunddetail> serviceFunddetails = serviceFunddetailMapper.selectFundDetailListById(id);
+ List<ServiceFunddetailVO> serviceFunddetailVOS = DtoConversionUtils.sourceToTarget(serviceFunddetails, ServiceFunddetailVO.class);
+ for (ServiceFunddetailVO serviceFunddetailVO : serviceFunddetailVOS) {
+ if (!StringUtils.isEmpty(serviceFunddetailVO.getAnnexfiles())) {
+ List<RbDetailFile> rbDetailFiles = JSONArray.parseArray(serviceFunddetailVO.getAnnexfiles(), RbDetailFile.class);
+ serviceFunddetailVO.setAnnexfilesList(rbDetailFiles);
+ }
+ }
+ return serviceFunddetailVOS;
+ }
+
+ /**
+ * 鏍规嵁鏉′欢绠楃◣
+ *
+ * @param serviceFunddetails
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public Boolean calculateTax(List<ServiceFunddetail> serviceFunddetails) {
+ //鐢ㄤ簬涓存椂淇濆瓨宸茬粡绠楀ソ鐨�"璐圭敤璇︽儏鏁版嵁"
+ List<ServiceFunddetail> temporarySave = new ArrayList<>();
+
+ for (ServiceFunddetail serviceFunddetail : serviceFunddetails) {
+ //鑾峰彇褰撴湀鐨勭涓�澶�
+ 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();
+
+ taxMoneyVO.setTaxTime(new Date());
+ taxMoneyVO.setFirstDay(firstDay);
+ taxMoneyVO.setApplyType(Long.valueOf(serviceFunddetail.getApplytype()));
+ taxMoneyVO.setFundID(serviceFunddetail.getFundid());
+ taxMoneyVO.setBeneficiaryNo(serviceFunddetail.getBeneficiaryno());
+ //鏌ュ嚭绋庡墠銆佺◣銆佺◣鍚庣殑鎬婚锛堜笉鍖呭惈鏈锛�
+ TaxMoneySumEO taxSum = serviceFunddetailMapper.getTaxSum(taxMoneyVO);
+ if (ObjectUtils.isEmpty(taxSum)) {
+ taxSum = new TaxMoneySumEO();
+ }
+
+ //鍒ゆ柇涓存椂闆嗗悎temporarySave涓紝鏈夋病鏈夊凡缁忕畻杩囩殑鏁版嵁
+ if (CollectionUtils.isNotEmpty(temporarySave)) {
+ for (ServiceFunddetail serviceFunddetail1 : temporarySave) {
+ //濡傛灉鏈鐨勨�濅汉鍛樼被鍨嬧�溿�佲�濆彈鐩婁汉缂栧彿鈥滃湪涓存椂闆嗗悎涓瓨鍦紝鍒欏皢闆嗗悎鏁版嵁涓殑璇ュ彈鐩婁汉鐨勶紝绋庡墠銆佺◣閲戙�佺◣鍚庯紝鍜屾�荤殑鐩稿姞锛屽苟灏嗚�佺殑瑕嗙洊
+ if (serviceFunddetail1.getApplytype().equals(serviceFunddetail.getApplytype()) && serviceFunddetail1.getBeneficiaryno().equals(serviceFunddetail.getBeneficiaryno())) {
+ //灏嗛泦鍚堟暟鎹腑鐨勮鍙楃泭浜虹殑锛岀◣鍓嶃�佺◣閲戙�佺◣鍚庯紝鍜屾�荤殑鐩稿姞
+ BigDecimal amounts = BigDecimal.valueOf(taxSum.getAmounts()).add(new BigDecimal(String.valueOf(serviceFunddetail1.getAmount())));
+ BigDecimal taxAmounts = BigDecimal.valueOf(taxSum.getTaxAmounts()).add(new BigDecimal(String.valueOf(serviceFunddetail1.getTaxamount())));
+ BigDecimal TaxedAmounts = BigDecimal.valueOf(taxSum.getTaxedAmounts()).add(new BigDecimal(String.valueOf(serviceFunddetail1.getTaxedamount())));
+ //灏嗚�佺殑瑕嗙洊
+ taxSum.setAmounts(amounts.doubleValue());
+ taxSum.setTaxAmounts(taxAmounts.doubleValue());
+ taxSum.setTaxedAmounts(TaxedAmounts.doubleValue());
+ }
+ continue;
+ }
+ }
+
+ if (!serviceFunddetail.getServicesscopename().contains("绋庡悗")) {
+ // 濡備綍绋庡墠閲戦涓嶄负绌猴紝鐢ㄤ箣鍓嶇殑鈥濇�荤◣鍓嶉噾棰濃�滐紝鍔犱笂褰撳墠鈥濈◣鍓嶉噾棰濃��
+ BigDecimal newAmounts = BigDecimal.valueOf(taxSum.getAmounts()).add(BigDecimal.valueOf(serviceFunddetail.getAmount()));
+
+ // 璁$畻鎬荤◣閲戯紙鍖呭惈鏈锛�
+ String taxation = TaxtUtils.getTaxation(newAmounts);
+ //璁$畻鏈绋庨噾锛堟�荤◣閲戯紙鍖呭惈鏈锛� - 鎬荤◣閲戯紙涓嶅寘鍚湰娆★級锛�
+ BigDecimal taxAmountNow = new BigDecimal(taxation).subtract(new BigDecimal(String.valueOf(taxSum.getTaxAmounts())));
+
+ //璁$畻鏈鐨勭◣鍚庨噾棰�(鏈鐨勭◣鍓嶉噾棰� - 绋庨噾)
+ BigDecimal texdAfterNow = BigDecimal.valueOf(serviceFunddetail.getAmount()).subtract(taxAmountNow);
+
+ //灏嗗惊鐜殑鏁版嵁閲嶆柊鏀惧埌涓�涓柊瀵硅薄涓�
+ ServiceFunddetail serviceFunddetail3 = DtoConversionUtils.sourceToTarget(serviceFunddetail, ServiceFunddetail.class);
+ serviceFunddetail3.setTaxamount(taxAmountNow.doubleValue());
+ serviceFunddetail3.setTaxedamount(texdAfterNow.doubleValue());
+ serviceFunddetail3.setTaxTime(new Date());
+ // 灏嗚鏉℃暟鎹洿鏂�
+ updateById(serviceFunddetail3);
+ // 鎶婅鏁版嵁锛屾斁鍒颁复鏃剁殑闆嗗悎涓�
+ temporarySave.add(serviceFunddetail3);
+ } else if (serviceFunddetail.getServicesscopename().contains("绋庡悗")) {
+ //绋庡悗涓嶄负绌�, 鐢ㄤ箣鍓嶇殑鈥濇�荤◣鍚庨噾棰濃�滐紝鍔犱笂褰撳墠鈥濈◣鍚庨噾棰濃��
+ BigDecimal newTaxedAmounts = BigDecimal.valueOf(taxSum.getTaxedAmounts()).add(BigDecimal.valueOf(serviceFunddetail.getTaxedamount()));
+
+ //閫氳繃鎬荤◣鍚庯紙鍖呭惈鏈锛夌畻鍑烘�荤◣鍓�
+ String taxationBefore = TaxtUtils.getTaxationBefore(newTaxedAmounts);
+ //绠楀嚭鏈绋庡墠锛堟�荤◣鍓嶏紙鍖呭惈鏈锛� - 鎬荤◣鍓嶏紙涓嶅寘鍚湰娆★級锛�
+ BigDecimal amountNow = new BigDecimal(taxationBefore).subtract(BigDecimal.valueOf(taxSum.getAmounts()));
+
+ //绠楀嚭鏈绋庨噾(鏈绋庡墠 - 鏈绋庡悗)
+ BigDecimal tax = amountNow.subtract(BigDecimal.valueOf(serviceFunddetail.getTaxedamount()));
+
+ //灏嗗惊鐜殑鏁版嵁閲嶆柊鏀惧埌涓�涓柊瀵硅薄涓�
+ ServiceFunddetail serviceFunddetail3 = DtoConversionUtils.sourceToTarget(serviceFunddetail, ServiceFunddetail.class);
+ serviceFunddetail3.setAmount(amountNow.doubleValue());
+ serviceFunddetail3.setTaxamount(tax.doubleValue());
+ serviceFunddetail3.setTaxTime(new Date());
+ // 灏嗚鏉℃暟鎹洿鏂�
+ updateById(serviceFunddetail3);
+ // 鎶婅鏁版嵁锛屾斁鍒颁复鏃剁殑闆嗗悎涓�
+ temporarySave.add(serviceFunddetail3);
+ }
+ }
+ return true;
+ }
}
--
Gitblit v1.9.3