From 84d4c6a03969974cfabfbfa19c8e2a55b9cd255c Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期三, 24 六月 2020 15:48:04 +0800
Subject: [PATCH] 优化出账
---
service-job/src/main/java/com/java110/job/task/fee/GenerateBillTemplate.java | 66 ++++++++++++++++++++++++++++----
1 files changed, 57 insertions(+), 9 deletions(-)
diff --git a/service-job/src/main/java/com/java110/job/task/fee/GenerateBillTemplate.java b/service-job/src/main/java/com/java110/job/task/fee/GenerateBillTemplate.java
index 7e0902e..2324921 100644
--- a/service-job/src/main/java/com/java110/job/task/fee/GenerateBillTemplate.java
+++ b/service-job/src/main/java/com/java110/job/task/fee/GenerateBillTemplate.java
@@ -1,13 +1,13 @@
package com.java110.job.task.fee;
import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.core.smo.community.IParkingSpaceInnerServiceSMO;
+import com.java110.core.smo.community.IRoomInnerServiceSMO;
import com.java110.core.smo.fee.IFeeConfigInnerServiceSMO;
import com.java110.core.smo.fee.IFeeDetailInnerServiceSMO;
import com.java110.core.smo.fee.IFeeInnerServiceSMO;
-import com.java110.core.smo.owner.IOwnerCarInnerServiceSMO;
-import com.java110.core.smo.owner.IOwnerRoomRelInnerServiceSMO;
-import com.java110.core.smo.parkingSpace.IParkingSpaceInnerServiceSMO;
-import com.java110.core.smo.room.IRoomInnerServiceSMO;
+import com.java110.core.smo.user.IOwnerCarInnerServiceSMO;
+import com.java110.core.smo.user.IOwnerRoomRelInnerServiceSMO;
import com.java110.dto.RoomDto;
import com.java110.dto.community.CommunityDto;
import com.java110.dto.fee.BillDto;
@@ -118,12 +118,13 @@
*/
private void GenerateBillByFeeConfig(TaskDto taskDto, FeeConfigDto feeConfigDto) throws Exception {
-
//褰撳墠璐圭敤椤规槸鍚�
BillDto tmpBillDto = new BillDto();
tmpBillDto.setCurBill("T");
tmpBillDto.setConfigId(feeConfigDto.getConfigId());
tmpBillDto.setCommunityId(feeConfigDto.getCommunityId());
+ Date startTime = getDefaultStartTime(feeConfigDto.getBillType());
+ tmpBillDto.setCurBillTime(DateUtil.getFormatTimeString(startTime, DateUtil.DATE_FORMATE_STRING_A));
List<BillDto> billDtos = feeInnerServiceSMOImpl.queryBills(tmpBillDto);
//Assert.listOnlyOne(billDtos, "褰撳墠瀛樺湪澶氫釜鏈夋晥璐﹀崟" + feeConfigDto.getConfigId());
@@ -139,8 +140,15 @@
billDto.setCommunityId(feeConfigDto.getCommunityId());
billDto.setConfigId(feeConfigDto.getConfigId());
billDto.setCurBill("T");
+ //鏌ヨ鍘嗗彶鏈夋晥璐﹀崟
+ tmpBillDto = new BillDto();
+ tmpBillDto.setCurBill("T");
+ tmpBillDto.setConfigId(feeConfigDto.getConfigId());
+ tmpBillDto.setCommunityId(feeConfigDto.getCommunityId());
+ billDtos = feeInnerServiceSMOImpl.queryBills(tmpBillDto);
- Date startTime = billDtos == null ? getDefaultStartTime(feeConfigDto.getBillType()) : DateUtil.getDateFromString(billDtos.get(0).getBillTime(), DateUtil.DATE_FORMATE_STRING_A);
+ startTime = (billDtos == null || billDtos.size() < 1) ? getDefaultStartTime(feeConfigDto.getBillType())
+ : DateUtil.getDateFromString(billDtos.get(0).getBillTime(), DateUtil.DATE_FORMATE_STRING_A);
FeeDto feeDto = new FeeDto();
feeDto.setConfigId(feeConfigDto.getConfigId());
@@ -156,10 +164,11 @@
generateFee(startTime, tmpFeeDto, billDto);
}
+
//鐢熸垚鏈璐﹀崟
Date billEndTime = DateUtil.getCurrentDate();
- billDto.setRemark(DateUtil.getFormatTimeString(startTime,DateUtil.DATE_FORMATE_STRING_A) +
- "-"+DateUtil.getFormatTimeString(billEndTime,DateUtil.DATE_FORMATE_STRING_A) + "璐﹀崟鏁版嵁");
+ billDto.setRemark(DateUtil.getFormatTimeString(startTime, DateUtil.DATE_FORMATE_STRING_A) +
+ "-" + DateUtil.getFormatTimeString(billEndTime, DateUtil.DATE_FORMATE_STRING_A) + "璐﹀崟鏁版嵁");
feeInnerServiceSMOImpl.insertBill(billDto);
}
@@ -192,7 +201,14 @@
return;
}
- computeFeePriceByRoom(feeDto);
+ if ("3333".equals(feeDto.getPayerObjType())) {
+ computeFeePriceByRoom(feeDto);
+ } else if ("6666".equals(feeDto.getPayerObjType())) {
+ computeFeePriceByParkingSpace(feeDto);
+ } else {
+ return;//杩欎釜娌℃湁娆犺垂鍙畻
+ //throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍨嬪嚭璐�" + feeDto.getFeeId());
+ }
if (feeDto.getFeePrice() <= 0) {
return;//杩欎釜娌℃湁娆犺垂鍙畻
@@ -408,6 +424,38 @@
}
/**
+ * 鏍规嵁杞︿綅鏉ョ畻鍗曚环
+ *
+ * @param feeDto
+ */
+ private void computeFeePriceByParkingSpace(FeeDto feeDto) {
+ ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
+ parkingSpaceDto.setCommunityId(feeDto.getCommunityId());
+ parkingSpaceDto.setPsId(feeDto.getPayerObjId());
+ List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto);
+
+ if (parkingSpaceDtos == null || parkingSpaceDtos.size() < 1) { //鏁版嵁鏈夐棶棰�
+ return;
+ }
+
+ String computingFormula = feeDto.getComputingFormula();
+ double feePrice = 0.00;
+ if ("1001".equals(computingFormula)) { //闈㈢Н*鍗曚环+闄勫姞璐�
+ 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).doubleValue();
+ } else if ("2002".equals(computingFormula)) { // 鍥哄畾璐圭敤
+ BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
+ feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ } else {
+ feePrice = -1.00;
+ }
+
+ feeDto.setFeePrice(feePrice);
+ }
+
+ /**
* 璁$畻2涓棩鏈熶箣闂寸浉宸殑 浠ュ勾銆佹湀銆佹棩涓哄崟浣嶏紝鍚勮嚜璁$畻缁撴灉鏄灏�
* 姣斿锛�2011-02-02 鍒� 2017-03-02
* 浠ュ勾涓哄崟浣嶇浉宸负锛�6骞�
--
Gitblit v1.8.0