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 | 197 +++++++++++++++++++++++++++++++++----------------
1 files changed, 132 insertions(+), 65 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 05283d1..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
@@ -5,20 +5,26 @@
import com.java110.api.bmo.ApiBaseBMO;
import com.java110.api.bmo.fee.IFeeBMO;
import com.java110.core.context.DataFlowContext;
-import com.java110.core.smo.fee.IFeeConfigInnerServiceSMO;
-import com.java110.core.smo.fee.IFeeInnerServiceSMO;
-import com.java110.core.smo.common.ICarInoutInnerServiceSMO;
-import com.java110.core.smo.community.IParkingSpaceInnerServiceSMO;
-import com.java110.core.smo.community.IRoomInnerServiceSMO;
+import com.java110.core.factory.GenerateCodeFactory;
import com.java110.dto.RoomDto;
import com.java110.dto.fee.FeeConfigDto;
import com.java110.dto.fee.FeeDto;
import com.java110.dto.machine.CarInoutDto;
+import com.java110.dto.owner.OwnerCarDto;
import com.java110.dto.parking.ParkingSpaceDto;
+import com.java110.intf.common.ICarInoutInnerServiceSMO;
+import com.java110.intf.community.IParkingSpaceInnerServiceSMO;
+import com.java110.intf.community.IRoomInnerServiceSMO;
+import com.java110.intf.fee.IFeeConfigInnerServiceSMO;
+import com.java110.intf.fee.IFeeInnerServiceSMO;
+import com.java110.intf.user.IOwnerCarInnerServiceSMO;
import com.java110.po.car.CarInoutPo;
import com.java110.po.fee.PayFeeConfigPo;
import com.java110.po.fee.PayFeeDetailPo;
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;
@@ -26,6 +32,7 @@
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -60,7 +67,14 @@
private ICarInoutInnerServiceSMO carInoutInnerServiceSMOImpl;
@Autowired
+ private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
+
+ @Autowired
private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
+
+
+ @Autowired
+ private IComputeFeeSMO computeFeeSMOImpl;
/**
* 娣诲姞灏忓尯淇℃伅
@@ -89,13 +103,10 @@
super.delete(dataFlowContext, payFeePo, BusinessTypeConstant.BUSINESS_TYPE_DELETE_FEE_INFO);
}
- public JSONObject updateFee(JSONObject paramInJson, DataFlowContext dataFlowContext) {
- JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
- business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_FEE_INFO);
- business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ + 1);
- business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
- business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeePo.class.getSimpleName(), paramInJson);
- return business;
+ public void updateFee(JSONObject paramInJson, DataFlowContext dataFlowContext) {
+ PayFeePo payFeePo = BeanConvertUtil.covertBean(paramInJson, PayFeePo.class);
+
+ super.update(dataFlowContext, payFeePo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_FEE_INFO);
}
/**
@@ -105,7 +116,7 @@
* @param dataFlowContext 鏁版嵁涓婁笅鏂�
* @return 璁㈠崟鏈嶅姟鑳藉鎺ュ彈鐨勬姤鏂�
*/
- public JSONObject addFeeDetail(JSONObject paramInJson, DataFlowContext dataFlowContext) {
+ public JSONObject addFeeDetail(JSONObject paramInJson, DataFlowContext dataFlowContext, FeeReceiptDetailPo feeReceiptDetailPo, FeeReceiptPo feeReceiptPo) {
JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
@@ -127,57 +138,24 @@
}
feeDto = feeDtos.get(0);
+ businessFeeDetail.put("startTime", DateUtil.getFormatTimeString(feeDto.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
+ 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 {
+ targetEndTime = computeFeeSMOImpl.getFeeEndTimeByCycles(feeDto, paramInJson.getString("cycles"));
+ }
+ 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();
- 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, "鏈煡鍒版埧灞嬩俊鎭紝鏌ヨ澶氭潯鏁版嵁");
- }
- roomDto = roomDtos.get(0);
- //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 {
- 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 {
- throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
- }
- }
BigDecimal cycles = null;
//BigDecimal receivableAmount = feePrice;
if ("-101".equals(paramInJson.getString("cycles"))) {//鑷畾涔夌即璐�
@@ -194,9 +172,44 @@
business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeeDetailPo.class.getSimpleName(), businessFeeDetail);
+ feeReceiptDetailPo.setAmount(businessFeeDetail.getString("receivableAmount"));
+ feeReceiptDetailPo.setCommunityId(feeDto.getCommunityId());
+ feeReceiptDetailPo.setCycle(businessFeeDetail.getString("cycles"));
+ feeReceiptDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
+ feeReceiptDetailPo.setEndTime(businessFeeDetail.getString("endTime"));
+ feeReceiptDetailPo.setFeeId(feeDto.getFeeId());
+ feeReceiptDetailPo.setFeeName(StringUtil.isEmpty(feeDto.getImportFeeName()) ? feeDto.getFeeName() : feeDto.getImportFeeName());
+ feeReceiptDetailPo.setStartTime(businessFeeDetail.getString("startTime"));
+ feeReceiptDetailPo.setReceiptId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_receiptId));
+ feeReceiptPo.setAmount(feeReceiptDetailPo.getAmount());
+ feeReceiptPo.setCommunityId(feeReceiptDetailPo.getCommunityId());
+ feeReceiptPo.setReceiptId(feeReceiptDetailPo.getReceiptId());
+ feeReceiptPo.setObjType(feeDto.getPayerObjType());
+ feeReceiptPo.setObjId(feeDto.getPayerObjId());
+ feeReceiptPo.setObjName(computeFeeSMOImpl.getFeeObjName(feeDto));
return business;
}
+
+ /**
+ * 娣诲姞璐圭敤鏄庣粏淇℃伅
+ *
+ * @param payFeeDetailPo 璐圭敤鏄庣粏
+ * @param dataFlowContext 鏁版嵁涓婁笅鏂�
+ * @return 璁㈠崟鏈嶅姟鑳藉鎺ュ彈鐨勬姤鏂�
+ */
+ public JSONObject addSimpleFeeDetail(PayFeeDetailPo payFeeDetailPo, DataFlowContext dataFlowContext) {
+
+
+ JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
+ business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FEE_DETAIL);
+ business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
+ business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
+ JSONObject businessFeeDetail = JSONObject.parseObject(JSONObject.toJSONString(payFeeDetailPo));
+ business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeeDetailPo.class.getSimpleName(), businessFeeDetail);
+
+ return business;
+ }
/**
* 淇敼璐圭敤淇℃伅
@@ -234,6 +247,12 @@
businessFee.putAll(feeMap);
business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeePo.class.getSimpleName(), businessFee);
+ //涓哄仠杞﹁垂鍗曠嫭澶勭悊
+ paramInJson.put("carFeeEndTime", feeInfo.getEndTime());
+ paramInJson.put("carPayerObjType", feeInfo.getPayerObjType());
+ paramInJson.put("carPayerObjId", feeInfo.getPayerObjId());
+
+
return business;
}
@@ -267,6 +286,27 @@
feeDto = feeDtos.get(0);
paramInJson.put("feeInfo", feeDto);
+ 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;
+ if ("-101".equals(paramInJson.getString("cycles"))) {
+ hours = new Double(Double.parseDouble(paramInJson.getString("tmpCycles")) * DateUtil.getCurrentMonthDay() * 24).intValue();
+ endCalender.add(Calendar.HOUR, hours);
+ } 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());
+ }
+ }
+ }
+ businessFeeDetail.put("endTime", DateUtil.getFormatTimeString(endCalender.getTime(), DateUtil.DATE_FORMATE_STRING_A));
BigDecimal feePrice = new BigDecimal("0.00");
@@ -290,6 +330,8 @@
//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("鏆備笉鏀寔璇ョ被鍏紡");
}
@@ -313,6 +355,8 @@
//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("鏆備笉鏀寔璇ョ被鍏紡");
}
@@ -504,7 +548,7 @@
* @param dataFlowContext 鏁版嵁涓婁笅鏂�
* @return 璁㈠崟鏈嶅姟鑳藉鎺ュ彈鐨勬姤鏂�
*/
- public JSONObject addFee(ParkingSpaceDto parkingSpaceDto, JSONObject paramInJson, DataFlowContext dataFlowContext) {
+ public JSONObject addFee(OwnerCarDto ownerCarDto, JSONObject paramInJson, DataFlowContext dataFlowContext) {
JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
@@ -520,10 +564,32 @@
businessUnit.put("startTime", DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
businessUnit.put("endTime", DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
businessUnit.put("communityId", paramInJson.getString("communityId"));
- businessUnit.put("payerObjId", parkingSpaceDto.getPsId());
- businessUnit.put("payerObjType", "6666");
+ businessUnit.put("payerObjId", ownerCarDto.getCarId());
+ businessUnit.put("payerObjType", FeeDto.PAYER_OBJ_TYPE_CAR);
businessUnit.put("feeFlag", paramInJson.getString("feeFlag"));
businessUnit.put("state", "2008001");
+ businessUnit.put("userId", dataFlowContext.getRequestCurrentHeaders().get(CommonConstant.HTTP_USER_ID));
+ business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeePo.class.getSimpleName(), businessUnit);
+
+ return business;
+ }
+
+ /**
+ * 娣诲姞璐圭敤
+ *
+ * @param payFeePo 鎺ュ彛璋冪敤鏀句紶鍏ュ叆鍙�
+ * @param dataFlowContext 鏁版嵁涓婁笅鏂�
+ * @return 璁㈠崟鏈嶅姟鑳藉鎺ュ彈鐨勬姤鏂�
+ */
+ public JSONObject addSimpleFee(PayFeePo payFeePo, DataFlowContext dataFlowContext) {
+
+
+ JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
+ business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FEE_INFO);
+ business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ + 1);
+ business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
+ JSONObject businessUnit = null;
+ businessUnit = JSONObject.parseObject(JSONObject.toJSONString(payFeePo));
businessUnit.put("userId", dataFlowContext.getRequestCurrentHeaders().get(CommonConstant.HTTP_USER_ID));
business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeePo.class.getSimpleName(), businessUnit);
@@ -551,7 +617,8 @@
businessUnit.put("incomeObjId", paramInJson.getString("storeId"));
businessUnit.put("amount", "-1.00");
businessUnit.put("startTime", DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
- businessUnit.put("endTime", DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+ businessUnit.put("endTime", paramInJson.containsKey("feeEndDate") ? paramInJson.getString("feeEndDate")
+ : DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
businessUnit.put("communityId", paramInJson.getString("communityId"));
businessUnit.put("payerObjId", roomDto.getRoomId());
businessUnit.put("payerObjType", "3333");
--
Gitblit v1.8.0