From 2bac44b5f569357beec90e6ce60940802432c5e6 Mon Sep 17 00:00:00 2001
From: jinhai <9314122@qq.com>
Date: 星期日, 13 九月 2020 17:34:29 +0800
Subject: [PATCH] 新增预存费用功能
---
service-fee/src/main/java/com/java110/fee/bmo/impl/PayOweFeeImpl.java | 101 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 98 insertions(+), 3 deletions(-)
diff --git a/service-fee/src/main/java/com/java110/fee/bmo/impl/PayOweFeeImpl.java b/service-fee/src/main/java/com/java110/fee/bmo/impl/PayOweFeeImpl.java
index 8e0fb38..04a5f63 100644
--- a/service-fee/src/main/java/com/java110/fee/bmo/impl/PayOweFeeImpl.java
+++ b/service-fee/src/main/java/com/java110/fee/bmo/impl/PayOweFeeImpl.java
@@ -4,13 +4,19 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Transactional;
import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.RoomDto;
+import com.java110.dto.fee.BillDto;
+import com.java110.dto.fee.BillOweFeeDto;
import com.java110.dto.fee.FeeAttrDto;
import com.java110.dto.fee.FeeConfigDto;
import com.java110.dto.fee.FeeDto;
+import com.java110.dto.parking.ParkingSpaceDto;
import com.java110.dto.repair.RepairDto;
import com.java110.fee.bmo.IPayOweFee;
import com.java110.fee.listener.fee.UpdateFeeInfoListener;
+import com.java110.intf.community.IParkingSpaceInnerServiceSMO;
import com.java110.intf.community.IRepairInnerServiceSMO;
+import com.java110.intf.community.IRoomInnerServiceSMO;
import com.java110.intf.fee.IFeeAttrInnerServiceSMO;
import com.java110.intf.fee.IFeeConfigInnerServiceSMO;
import com.java110.intf.fee.IFeeDetailInnerServiceSMO;
@@ -62,6 +68,12 @@
@Autowired
private IRepairInnerServiceSMO repairInnerServiceSMOImpl;
+ @Autowired
+ private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
+
+ @Autowired
+ private IParkingSpaceInnerServiceSMO parkingSpaceInnerServiceSMOImpl;
+
/**
* 娆犺垂缂磋垂
*
@@ -82,7 +94,7 @@
for (int feeIndex = 0; feeIndex < fees.size(); feeIndex++) {
feeObj = fees.getJSONObject(feeIndex);
Assert.hasKeyAndValue(feeObj, "feeId", "鏈寘鍚垂鐢ㄩ」ID");
- Assert.hasKeyAndValue(feeObj, "feeId", "鏈寘鍚垂鐢ㄩ」ID");
+ Assert.hasKeyAndValue(feeObj, "feePrice", "鏈寘鍚即璐归噾棰�");
feeObj.put("communityId", communityId);
doPayOweFee(feeObj);
@@ -100,6 +112,9 @@
addFeeDetail(feeObj);
modifyFee(feeObj);
+
+ //灏嗘湁璐﹀崟涓嬬殑 鐘舵�佹敼涓哄凡缁忕即璐�
+ modifyFeeBill(feeObj);
//鍒ゆ柇鏄惁鏈夋淳鍗曞睘鎬D
FeeAttrDto feeAttrDto = new FeeAttrDto();
@@ -129,6 +144,31 @@
/**
* @param feeObj
*/
+ private void modifyFeeBill(JSONObject feeObj) {
+
+ if (FeeConfigDto.BILL_TYPE_EVERY.equals(feeObj.getString("billType"))) {
+ return;
+ }
+ BillDto billDto = new BillDto();
+ billDto.setCommunityId(feeObj.getString("communityId"));
+ billDto.setConfigId(feeObj.getString("configId"));
+ billDto.setCurBill("T");
+ List<BillDto> billDtos = feeInnerServiceSMOImpl.queryBills(billDto);
+ if (billDtos == null || billDtos.size() < 1) {
+ return;
+ }
+ BillOweFeeDto billOweFeeDto = new BillOweFeeDto();
+ billOweFeeDto.setCommunityId(feeObj.getString("communityId"));
+ billOweFeeDto.setFeeId(feeObj.getString("feeId"));
+ billOweFeeDto.setState(BillOweFeeDto.STATE_FINISH_FEE);
+ billOweFeeDto.setBillId(billDtos.get(0).getBillId());
+ feeInnerServiceSMOImpl.updateBillOweFees(billOweFeeDto);
+
+ }
+
+ /**
+ * @param feeObj
+ */
private void modifyFee(JSONObject feeObj) throws ParseException {
PayFeePo payFeePo = new PayFeePo();
@@ -146,7 +186,9 @@
Assert.listOnlyOne(feeConfigDtos, "鏈壘鍒拌垂鐢ㄩ厤缃�");
payFeePo.setEndTime(DateUtil.getFormatTimeString(endCalender.getTime(), DateUtil.DATE_FORMATE_STRING_A));
- // 涓�娆℃�ф敹璐圭被鍨嬶紝缂磋垂鍚庯紝鍒欒缃垂鐢ㄧ姸鎬佷负鏀惰垂缁撴潫銆佽缃粨鏉熸棩鏈熶负璐圭敤椤圭粓姝㈡棩鏈�
+ feeObj.put("billType", feeConfigDtos.get(0).getBillType());
+ feeObj.put("configId", feeConfigDtos.get(0).getConfigId());
+ // 涓�娆℃�ф敹璐圭被鍨嬶紝缂磋垂鍚庯紝鍒欒缃垂鐢ㄧ姸鎬佷负鏀惰垂缁撴潫銆佽缃粨鏉熸棩鏈熶负璐圭敤 椤圭粓姝㈡棩鏈�
if (FeeFlagTypeConstant.ONETIME.equals(feeConfigDtos.get(0).getFeeFlag())) {
payFeePo.setState(FeeStateConstant.END);
payFeePo.setEndTime(feeConfigDtos.get(0).getEndTime());
@@ -159,8 +201,9 @@
}
}
payFeePo.setFeeId(feeObj.getString("feeId"));
- payFeePo.setEndTime(DateUtil.getFormatTimeString(feeInfo.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
+ //payFeePo.setEndTime(DateUtil.getFormatTimeString(feeInfo.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
payFeePo.setCommunityId(feeObj.getString("communityId"));
+ payFeePo.setStatusCd("0");
int saveFlag = feeInnerServiceSMOImpl.updateFee(payFeePo);
if (saveFlag < 1) {
throw new IllegalArgumentException("缂磋垂澶辫触" + payFeePo.toString());
@@ -192,6 +235,57 @@
BigDecimal feePrice = new BigDecimal("0.00");
+ if ("3333".equals(feeDto.getPayerObjType())) { //鎴垮眿鐩稿叧
+ String computingFormula = feeDto.getComputingFormula();
+ if ("1001".equals(computingFormula)) { //闈㈢Н*鍗曚环+闄勫姞璐�
+ 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, "鏈煡鍒版埧灞嬩俊鎭紝鏌ヨ澶氭潯鏁版嵁");
+ }
+ //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);
+ } 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 {
+ throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
+ }
+ } else if ("6666".equals(feeDto.getPayerObjType())) {//杞︿綅鐩稿叧
+ String computingFormula = feeDto.getComputingFormula();
+ if ("1001".equals(computingFormula)) { //闈㈢Н*鍗曚环+闄勫姞璐�
+ ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
+ parkingSpaceDto.setCommunityId(feeDto.getCommunityId());
+ parkingSpaceDto.setPsId(feeDto.getPayerObjId());
+ 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);
+ } 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 {
+ throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
+ }
+ }
+
BigDecimal receivedAmount = new BigDecimal(Double.parseDouble(paramInJson.getString("feePrice")));
BigDecimal cycles = receivedAmount.divide(feePrice, 2, BigDecimal.ROUND_HALF_EVEN);
paramInJson.put("tmpCycles", cycles);
@@ -199,6 +293,7 @@
payFeeDetailPo.setCycles(cycles.doubleValue() + "");
payFeeDetailPo.setReceivableAmount(receivedAmount.doubleValue() + "");
payFeeDetailPo.setReceivedAmount(receivedAmount.doubleValue() + "");
+ payFeeDetailPo.setFeeId(feeDto.getFeeId());
int saveFeeDetail = feeDetailInnerServiceSMOImpl.saveFeeDetail(payFeeDetailPo);
--
Gitblit v1.8.0