From 8749db96edc44e76a9b2ecaf0332e8c0f34fbb5b Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 08 八月 2023 14:58:59 +0800
Subject: [PATCH] 优化代码
---
service-fee/src/main/java/com/java110/fee/smo/impl/FeeDiscountInnerServiceSMOImpl.java | 71 ++++++++++++++++++++++++++++++-----
1 files changed, 60 insertions(+), 11 deletions(-)
diff --git a/service-fee/src/main/java/com/java110/fee/smo/impl/FeeDiscountInnerServiceSMOImpl.java b/service-fee/src/main/java/com/java110/fee/smo/impl/FeeDiscountInnerServiceSMOImpl.java
index ae4ca0f..6d09941 100755
--- a/service-fee/src/main/java/com/java110/fee/smo/impl/FeeDiscountInnerServiceSMOImpl.java
+++ b/service-fee/src/main/java/com/java110/fee/smo/impl/FeeDiscountInnerServiceSMOImpl.java
@@ -2,31 +2,30 @@
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
-import com.java110.dto.applyRoomDiscount.ApplyRoomDiscountDto;
+import com.java110.dto.room.ApplyRoomDiscountDto;
import com.java110.dto.fee.FeeDetailDto;
import com.java110.dto.fee.FeeDto;
-import com.java110.dto.feeDiscount.ComputeDiscountDto;
-import com.java110.dto.feeDiscount.FeeDiscountDto;
-import com.java110.dto.feeDiscount.FeeDiscountSpecDto;
-import com.java110.dto.payFeeConfigDiscount.PayFeeConfigDiscountDto;
+import com.java110.dto.fee.ComputeDiscountDto;
+import com.java110.dto.fee.FeeDiscountDto;
+import com.java110.dto.fee.FeeDiscountRuleDto;
+import com.java110.dto.fee.FeeDiscountSpecDto;
+import com.java110.dto.payFee.PayFeeConfigDiscountDto;
import com.java110.fee.dao.IFeeDiscountServiceDao;
import com.java110.fee.discount.IComputeDiscount;
import com.java110.intf.fee.*;
-import com.java110.po.feeDiscount.FeeDiscountPo;
+import com.java110.po.fee.FeeDiscountPo;
import com.java110.utils.cache.MappingCache;
import com.java110.utils.factory.ApplicationContextFactory;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.MoneyUtil;
import com.java110.utils.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
/**
* @ClassName FloorInnerServiceSMOImpl
@@ -54,12 +53,16 @@
@Autowired
private IApplyRoomDiscountInnerServiceSMO applyRoomDiscountInnerServiceSMOImpl;
+ @Autowired
+ private IFeeDiscountRuleInnerServiceSMO feeDiscountRuleInnerServiceSMOImpl;
+
//鍩�
public static final String DOMAIN_COMMON = "DOMAIN.COMMON";
//閿�
public static final String DISCOUNT_MODE = "DISCOUNT_MODE";
+ private static final String SPEC_RATE = "89002020980015"; // 璧犻�佹湀浠�
@Override
public int saveFeeDiscount(@RequestBody FeeDiscountPo feeDiscountPo) {
@@ -159,7 +162,7 @@
payFeeConfigDiscountDto.setStatusCd("0");
Date currentTime = new Date();
payFeeConfigDiscountDto.setCurrentTime(currentTime);
- //鏍规嵁璐圭敤鏌ヨ鎶樻墸
+ //鏍规嵁璐圭敤椤规煡璇㈡姌鎵o紙璇ヨ垂鐢ㄩ」涓嬬殑鎵�鏈夋姌鎵d俊鎭級
List<PayFeeConfigDiscountDto> payFeeConfigDiscountDtos =
payFeeConfigDiscountInnerServiceSMOImpl.queryPayFeeConfigDiscounts(payFeeConfigDiscountDto);
if (payFeeConfigDiscountDtos == null || payFeeConfigDiscountDtos.size() < 1) {
@@ -169,6 +172,14 @@
List<ComputeDiscountDto> computeDiscountDtoList = new ArrayList<>();
for (ComputeDiscountDto computeDiscountDto : computeDiscountDtos) {
computeDiscountDto.setValue(value);
+
+ computeDiscountDto.setDiscountPrice(
+ MoneyUtil.computePriceScale(
+ computeDiscountDto.getDiscountPrice(),
+ feeDtos.get(0).getScale(),
+ Integer.parseInt(feeDtos.get(0).getDecimalPlace())
+ )
+ );
if (!StringUtil.isEmpty(computeDiscountDto.getDiscountType()) && "3003".equals(computeDiscountDto.getDiscountType())) {
computeDiscountDto.setArdId(feeDetailDto.getArdId());
}
@@ -184,6 +195,36 @@
for (PayFeeConfigDiscountDto tmpPayFeeConfigDiscountDto : payFeeConfigDiscountDtos) {
//鑾峰彇缂磋垂鏈�澶ф埅姝㈡椂闂�
Date payMaxEndTime = tmpPayFeeConfigDiscountDto.getPayMaxEndTime();
+ FeeDiscountDto feeDiscountDto = new FeeDiscountDto();
+ feeDiscountDto.setDiscountId(tmpPayFeeConfigDiscountDto.getDiscountId());
+ //鏌ヨ鎵撴姌琛�
+ List<FeeDiscountDto> feeDiscountInfo = BeanConvertUtil.covertBeanList(feeDiscountServiceDaoImpl.getFeeDiscountInfo(BeanConvertUtil.beanCovertMap(feeDiscountDto)), FeeDiscountDto.class);
+ //Assert.listOnlyOne(feeDiscountInfo, "鏌ヨ鎵撴姌琛ㄩ敊璇紒");
+ if(feeDiscountInfo == null || feeDiscountInfo.size() < 1){
+ continue;
+ }
+ FeeDiscountRuleDto feeDiscountRuleDto = new FeeDiscountRuleDto();
+ feeDiscountRuleDto.setRuleId(feeDiscountInfo.get(0).getRuleId());
+ //鏌ヨ鎵撴姌瑙勫垯琛�
+ List<FeeDiscountRuleDto> feeDiscountRuleDtos = feeDiscountRuleInnerServiceSMOImpl.queryFeeDiscountRules(feeDiscountRuleDto);
+ //Assert.listOnlyOne(feeDiscountRuleDtos, "鏌ヨ鎵撴姌瑙勫垯琛ㄩ敊璇紒");
+ if(feeDiscountRuleDtos == null || feeDiscountRuleDtos.size() < 1){
+ continue;
+ }
+ if (!StringUtil.isEmpty(feeDiscountRuleDtos.get(0).getBeanImpl()) && feeDiscountRuleDtos.get(0).getBeanImpl().equals("reductionMonthFeeRule")) { //璧犻�佽鍒�
+ FeeDiscountSpecDto feeDiscountSpecDto = new FeeDiscountSpecDto();
+ feeDiscountSpecDto.setDiscountId(tmpPayFeeConfigDiscountDto.getDiscountId());
+ feeDiscountSpecDto.setSpecId(SPEC_RATE);
+ //鏌ヨ鎵撴姌瑙勬牸
+ List<FeeDiscountSpecDto> feeDiscountSpecDtos = feeDiscountSpecInnerServiceSMOImpl.queryFeeDiscountSpecs(feeDiscountSpecDto);
+ Assert.listOnlyOne(feeDiscountSpecDtos, "鏌ヨ鎵撴姌瑙勬牸琛ㄩ敊璇紒");
+ //鑾峰彇璧犻�佹湀浠�
+ String specValue = feeDiscountSpecDtos.get(0).getSpecValue();
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(finishTime);
+ cal.add(Calendar.MONTH, Integer.parseInt(specValue));
+ finishTime = cal.getTime();
+ }
if (payMaxEndTime == null) {
doCompute(tmpPayFeeConfigDiscountDto, Double.parseDouble(feeDetailDto.getCycles()), computeDiscountDtos, feeDetailDto.getFeeId());
} else if (payMaxEndTime.getTime() >= finishTime.getTime()) {
@@ -191,6 +232,7 @@
} else {
continue;
}
+ finishTime = c.getTime();
}
computeApplyRoomDiscount(feeDetailDto, simpleDateFormat, c, computeDiscountDtos);
//鍙栧嚭寮�鍏虫槧灏勭殑鍊�
@@ -198,6 +240,13 @@
List<ComputeDiscountDto> computeDiscountDtoList = new ArrayList<>();
for (ComputeDiscountDto computeDiscountDto : computeDiscountDtos) {
computeDiscountDto.setValue(value);
+ computeDiscountDto.setDiscountPrice(
+ MoneyUtil.computePriceScale(
+ computeDiscountDto.getDiscountPrice(),
+ feeDtos.get(0).getScale(),
+ Integer.parseInt(feeDtos.get(0).getDecimalPlace())
+ )
+ );
if (!StringUtil.isEmpty(computeDiscountDto.getDiscountType()) && "3003".equals(computeDiscountDto.getDiscountType())) {
computeDiscountDto.setArdId(feeDetailDto.getArdId());
}
--
Gitblit v1.8.0