From 7958f1dddb8a7f4e70d232b07a7703955ecedae0 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: 星期六, 26 八月 2023 12:45:33 +0800
Subject: [PATCH] 优化diamante
---
service-fee/src/main/java/com/java110/fee/smo/impl/FeeDiscountInnerServiceSMOImpl.java | 84 ++++++++++++++++++++++++++++++++++++-----
1 files changed, 73 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 798d666..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,17 @@
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());
+ }
computeDiscountDtoList.add(computeDiscountDto);
}
return computeDiscountDtos;
@@ -181,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()) {
@@ -188,6 +232,7 @@
} else {
continue;
}
+ finishTime = c.getTime();
}
computeApplyRoomDiscount(feeDetailDto, simpleDateFormat, c, computeDiscountDtos);
//鍙栧嚭寮�鍏虫槧灏勭殑鍊�
@@ -195,6 +240,16 @@
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());
+ }
computeDiscountDtoList.add(computeDiscountDto);
}
return computeDiscountDtoList;
@@ -206,6 +261,8 @@
ApplyRoomDiscountDto applyRoomDiscountDto = new ApplyRoomDiscountDto();
//瀹℃牳宸查�氳繃
applyRoomDiscountDto.setState("4");
+ //鏄惁鍙敤鐘舵�佹爣璇�(0琛ㄧず鍦ㄧ敤锛�1琛ㄧず涓嶅彲鐢�)
+ applyRoomDiscountDto.setInUse("0");
//灏忓尯ID
applyRoomDiscountDto.setCommunityId(feeDetailDto.getCommunityId());
//鎴垮眿id
@@ -214,17 +271,22 @@
applyRoomDiscountDto.setStartTime(simpleDateFormat.format(feeDetailDto.getStartTime()));
//缁撴潫鏃堕棿
c.setTime(feeDetailDto.getStartTime());
+ c.add(Calendar.DAY_OF_MONTH, 2);//寮�濮嬫椂闂达紝娣诲姞1锛�2澶╃殑鍐椾綑锛屽彧瑕佹瘮5灏忓嵆鍙�
+ applyRoomDiscountDto.setStartTime(simpleDateFormat.format(c.getTime()));//閲嶆柊璁剧疆寮�濮嬫椂闂�
double month = Double.parseDouble(feeDetailDto.getCycles());
c.add(Calendar.MONTH, (int) month);
c.add(Calendar.DAY_OF_MONTH, -5);//杩欓噷鏍规嵁璁剧疆鏃堕棿鑽h獕5澶�
Date endTime = c.getTime();
applyRoomDiscountDto.setEndTime(simpleDateFormat.format(endTime));
+ applyRoomDiscountDto.setFeeId(feeDetailDto.getFeeId());
//鏌ヨ鎶樻墸鐢宠琛�
List<ApplyRoomDiscountDto> applyRoomDiscountDtos = applyRoomDiscountInnerServiceSMOImpl.queryApplyRoomDiscounts(applyRoomDiscountDto);
//鍒ゆ柇鏌ヨ鐨勬姌鎵g敵璇疯〃鏄惁鏈夋暟鎹�
if (applyRoomDiscountDtos != null && applyRoomDiscountDtos.size() > 0) {
//鑾峰彇浼樻儬id
String discountId = applyRoomDiscountDtos.get(0).getDiscountId();
+ String ardId = applyRoomDiscountDtos.get(0).getArdId();
+ feeDetailDto.setArdId(ardId);
PayFeeConfigDiscountDto payFeeConfigDiscount = new PayFeeConfigDiscountDto();
payFeeConfigDiscount.setCommunityId(applyRoomDiscountDtos.get(0).getCommunityId());
payFeeConfigDiscount.setDiscountId(discountId);
--
Gitblit v1.8.0