From edca4324a5fc0d9f9731e020f7a841a7f8555859 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期三, 23 九月 2020 14:38:04 +0800
Subject: [PATCH] 优化代码
---
service-api/src/main/java/com/java110/api/bmo/fee/impl/FeeBMOImpl.java | 124 ++++------------------------------------
1 files changed, 14 insertions(+), 110 deletions(-)
diff --git a/service-api/src/main/java/com/java110/api/bmo/fee/impl/FeeBMOImpl.java b/service-api/src/main/java/com/java110/api/bmo/fee/impl/FeeBMOImpl.java
index 160d290..e429999 100644
--- a/service-api/src/main/java/com/java110/api/bmo/fee/impl/FeeBMOImpl.java
+++ b/service-api/src/main/java/com/java110/api/bmo/fee/impl/FeeBMOImpl.java
@@ -24,6 +24,7 @@
import com.java110.po.fee.PayFeePo;
import com.java110.po.feeReceipt.FeeReceiptPo;
import com.java110.po.feeReceiptDetail.FeeReceiptDetailPo;
+import com.java110.service.smo.IComputeFeeSMO;
import com.java110.utils.constant.BusinessTypeConstant;
import com.java110.utils.constant.CommonConstant;
import com.java110.utils.constant.ResponseConstant;
@@ -70,6 +71,10 @@
@Autowired
private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
+
+
+ @Autowired
+ private IComputeFeeSMO computeFeeSMOImpl;
/**
* 娣诲姞灏忓尯淇℃伅
@@ -132,127 +137,25 @@
throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "鏌ヨ璐圭敤淇℃伅澶辫触锛屾湭鏌ュ埌鏁版嵁鎴栨煡鍒板鏉℃暟鎹�");
}
-
feeDto = feeDtos.get(0);
businessFeeDetail.put("startTime", DateUtil.getFormatTimeString(feeDto.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
- Date endTime = feeDto.getEndTime();
- Calendar endCalender = Calendar.getInstance();
- endCalender.setTime(endTime);
int hours = 0;
+ Date targetEndTime = null;
if ("-101".equals(paramInJson.getString("cycles"))) {
+ Date endTime = feeDto.getEndTime();
+ Calendar endCalender = Calendar.getInstance();
+ endCalender.setTime(endTime);
hours = new Double(Double.parseDouble(paramInJson.getString("tmpCycles")) * DateUtil.getCurrentMonthDay() * 24).intValue();
endCalender.add(Calendar.HOUR, hours);
+ targetEndTime = endCalender.getTime();
} else {
- endCalender.add(Calendar.MONTH, Integer.parseInt(paramInJson.getString("cycles")));
- if (FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) {
- if (!StringUtil.isEmpty(feeDto.getCurDegrees())) {
- endCalender.setTime(feeDto.getCurReadingTime());
- } else if (feeDto.getImportFeeEndTime() == null) {
- endCalender.setTime(feeDto.getConfigEndTime());
- } else {
- endCalender.setTime(feeDto.getImportFeeEndTime());
- }
- }
+ targetEndTime = computeFeeSMOImpl.getFeeEndTimeByCycles(feeDto, paramInJson.getString("cycles"));
}
- businessFeeDetail.put("endTime", DateUtil.getFormatTimeString(endCalender.getTime(), DateUtil.DATE_FORMATE_STRING_A));
+ businessFeeDetail.put("endTime", DateUtil.getFormatTimeString(targetEndTime, DateUtil.DATE_FORMATE_STRING_A));
paramInJson.put("feeInfo", feeDto);
- BigDecimal feePrice = new BigDecimal("0.00");
+ BigDecimal feePrice = new BigDecimal(computeFeeSMOImpl.getFeePrice(feeDto));
- if ("3333".equals(feeDto.getPayerObjType())) { //鎴垮眿鐩稿叧
- String computingFormula = feeDto.getComputingFormula();
- RoomDto roomDto = new RoomDto();
- roomDto.setRoomId(feeDto.getPayerObjId());
- roomDto.setCommunityId(feeDto.getCommunityId());
- List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto);
- if (roomDtos == null || roomDtos.size() != 1) {
- throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "鏈煡鍒版埧灞嬩俊鎭紝鏌ヨ澶氭潯鏁版嵁");
- }
- roomDto = roomDtos.get(0);
- feeReceiptPo.setObjName(roomDto.getFloorNum() + "鏍�" + roomDto.getUnitNum() + "鍗曞厓" + roomDto.getRoomNum());
-
- if ("1001".equals(computingFormula)) { //闈㈢Н*鍗曚环+闄勫姞璐�
- //feePrice = Double.parseDouble(feeDto.getSquarePrice()) * Double.parseDouble(roomDtos.get(0).getBuiltUpArea()) + Double.parseDouble(feeDto.getAdditionalAmount());
- BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
- BigDecimal builtUpArea = new BigDecimal(Double.parseDouble(roomDtos.get(0).getBuiltUpArea()));
- BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
- feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
- feeReceiptDetailPo.setArea(roomDtos.get(0).getBuiltUpArea());
- } else if ("2002".equals(computingFormula)) { // 鍥哄畾璐圭敤
- //feePrice = Double.parseDouble(feeDto.getAdditionalAmount());
- BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
- feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN);
- } else if ("4004".equals(computingFormula)) {
- feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
- } else if ("5005".equals(computingFormula)) {
- if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
- throw new IllegalArgumentException("鎶勮〃鏁版嵁寮傚父");
- } else {
- BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
- BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
- BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
- BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
- BigDecimal sub = curDegree.subtract(preDegree);
- feePrice = sub.multiply(squarePrice)
- .add(additionalAmount)
- .setScale(2, BigDecimal.ROUND_HALF_EVEN);
- feeReceiptDetailPo.setArea(sub.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue() + "");
-
- }
- } else {
- throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
- }
- } else if ("6666".equals(feeDto.getPayerObjType())) {//杞︿綅鐩稿叧
- String computingFormula = feeDto.getComputingFormula();
-
- OwnerCarDto ownerCarDto = new OwnerCarDto();
- ownerCarDto.setCommunityId(feeDto.getCommunityId());
- ownerCarDto.setCarId(feeDto.getPayerObjId());
- List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
-
- if (ownerCarDtos != null && ownerCarDtos.size() > 0) {
- feeReceiptPo.setObjName(ownerCarDtos.get(0).getCarNum());
- }
- if ("1001".equals(computingFormula)) { //闈㈢Н*鍗曚环+闄勫姞璐�
- ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
- parkingSpaceDto.setCommunityId(feeDto.getCommunityId());
- parkingSpaceDto.setPsId(ownerCarDtos.get(0).getPsId());
- List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto);
-
- if (parkingSpaceDtos == null || parkingSpaceDtos.size() < 1) { //鏁版嵁鏈夐棶棰�
- throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "鏈煡鍒板仠杞︿綅淇℃伅锛屾煡璇㈠鏉℃暟鎹�");
- }
- //feePrice = Double.parseDouble(feeDto.getSquarePrice()) * Double.parseDouble(parkingSpaceDtos.get(0).getArea()) + Double.parseDouble(feeDto.getAdditionalAmount());
- BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
- BigDecimal builtUpArea = new BigDecimal(Double.parseDouble(parkingSpaceDtos.get(0).getArea()));
- BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
- feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
- feeReceiptDetailPo.setArea(parkingSpaceDtos.get(0).getArea());
-
- } else if ("2002".equals(computingFormula)) { // 鍥哄畾璐圭敤
- //feePrice = Double.parseDouble(feeDto.getAdditionalAmount());
- BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
- feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN);
- } else if ("4004".equals(computingFormula)) {
- feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
- } else if ("5005".equals(computingFormula)) {
- if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
- throw new IllegalArgumentException("鎶勮〃鏁版嵁寮傚父");
- } else {
- BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
- BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
- BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
- BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
- BigDecimal sub = curDegree.subtract(preDegree);
- feePrice = sub.multiply(squarePrice)
- .add(additionalAmount)
- .setScale(2, BigDecimal.ROUND_HALF_EVEN);
- feeReceiptDetailPo.setArea(sub.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue() + "");
- }
- } else {
- throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
- }
- }
BigDecimal cycles = null;
//BigDecimal receivableAmount = feePrice;
if ("-101".equals(paramInJson.getString("cycles"))) {//鑷畾涔夌即璐�
@@ -283,6 +186,7 @@
feeReceiptPo.setReceiptId(feeReceiptDetailPo.getReceiptId());
feeReceiptPo.setObjType(feeDto.getPayerObjType());
feeReceiptPo.setObjId(feeDto.getPayerObjId());
+ feeReceiptPo.setObjName(computeFeeSMOImpl.getFeeObjName(feeDto));
return business;
}
--
Gitblit v1.8.0