From ca8a2f9555863313d4e5a85deac214f91cbd16eb Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期一, 12 六月 2023 10:36:07 +0800
Subject: [PATCH] optimize code
---
service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java | 478 +++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 334 insertions(+), 144 deletions(-)
diff --git a/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java b/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java
old mode 100644
new mode 100755
index bb79343..c04fc49
--- a/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java
+++ b/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java
@@ -1,10 +1,11 @@
package com.java110.report.smo.impl;
-import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.core.log.LoggerFactory;
import com.java110.core.smo.IComputeFeeSMO;
import com.java110.dto.RoomDto;
+import com.java110.dto.fee.FeeConfigDto;
import com.java110.dto.fee.FeeDto;
import com.java110.dto.owner.OwnerCarDto;
import com.java110.dto.report.ReportCarDto;
@@ -12,30 +13,26 @@
import com.java110.dto.report.ReportFeeDto;
import com.java110.dto.report.ReportRoomDto;
import com.java110.dto.reportFeeMonthStatistics.ReportFeeMonthStatisticsDto;
+import com.java110.intf.community.IFloorInnerServiceSMO;
+import com.java110.intf.community.IRoomInnerServiceSMO;
+import com.java110.intf.community.IUnitInnerServiceSMO;
import com.java110.intf.report.IGeneratorFeeMonthStatisticsInnerServiceSMO;
+import com.java110.intf.report.IReportFeeMonthStatisticsInnerServiceSMO;
import com.java110.intf.user.IOwnerCarInnerServiceSMO;
import com.java110.po.reportFeeMonthStatistics.ReportFeeMonthStatisticsPo;
import com.java110.report.dao.IReportCommunityServiceDao;
import com.java110.report.dao.IReportFeeMonthStatisticsServiceDao;
import com.java110.report.dao.IReportFeeServiceDao;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.BeanConvertUtil;
-import com.java110.utils.util.DateUtil;
-import com.java110.utils.util.ListUtil;
-import com.java110.utils.util.StringUtil;
+import com.java110.utils.constant.FeeConfigConstant;
+import com.java110.utils.util.*;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* @ClassName GeneratorFeeMonthStatisticsInnerServiceSMOImpl
@@ -56,6 +53,9 @@
private IReportFeeMonthStatisticsServiceDao reportFeeMonthStatisticsServiceDaoImpl;
@Autowired
+ private IReportFeeMonthStatisticsInnerServiceSMO reportFeeMonthStatisticsInnerServiceSMOImpl;
+
+ @Autowired
private IReportCommunityServiceDao reportCommunityServiceDaoImpl;
@Autowired
@@ -67,6 +67,15 @@
@Autowired
private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
+ @Autowired
+ private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
+
+ @Autowired
+ private IUnitInnerServiceSMO unitInnerServiceSMOImpl;
+
+ @Autowired
+ private IFloorInnerServiceSMO floorInnerServiceSMOImpl;
+
@Override
public int generatorData(@RequestBody ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo) {
@@ -75,10 +84,13 @@
}
@Async
- private void doGeneratorData(ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo) {
+ public void doGeneratorData(ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo) {
String communityId = reportFeeMonthStatisticsPo.getCommunityId();
Assert.hasLength(communityId, "鏈寘鍚皬鍖轰俊鎭�");
+
+ //杩欓噷澶勭悊 鎶ヨ〃涓殑璐圭敤鏄惁琚汉涓� 鍙栨秷 鎴栬�呰垂鐢ㄩ」鏄惁琚垹闄わ紝杩欑鏁版嵁 鎶ヨ〃涓仛娓呯悊锛屼互闃插奖鍝� 鎶ヨ〃鐨勫噯纭害
+ feeDataFiltering(communityId);
//澶勭悊鎴垮眿璐圭敤
dealRoomFee(reportFeeMonthStatisticsPo);
@@ -88,6 +100,31 @@
//澶勭悊缂磋垂缁撴潫鐨勬儏鍐�
dealFinishFee(communityId);
+ }
+
+ private void feeDataFiltering(String communityId) {
+ Map reportFeeDto = new HashMap();
+ reportFeeDto.put("communityId", communityId);
+ List<Map> feeDtos = reportFeeMonthStatisticsServiceDaoImpl.queryInvalidFeeMonthStatistics(reportFeeDto);
+
+ List<String> feeIds = new ArrayList<>();
+ for (Map feeDto : feeDtos) {
+ if (!feeDto.containsKey("feeId") || StringUtil.isNullOrNone(feeDto.get("feeId"))) {
+ continue;
+ }
+
+ feeIds.add(feeDto.get("feeId").toString());
+
+ if (feeIds.size() >= 50) {
+ reportFeeDto.put("feeIds", feeIds);
+ reportFeeMonthStatisticsServiceDaoImpl.deleteInvalidFee(reportFeeDto);
+ feeIds = new ArrayList<>();
+ }
+ }
+ reportFeeDto.put("feeIds", feeIds);
+ if (feeIds.size() > 0) {
+ reportFeeMonthStatisticsServiceDaoImpl.deleteInvalidFee(reportFeeDto);
+ }
}
private void dealFinishFee(String communityId) {
@@ -130,6 +167,7 @@
ReportCarDto reportCarDto = new ReportCarDto();
reportCarDto.setCommunityId(reportFeeMonthStatisticsPo.getCommunityId());
+ reportCarDto.setLeaseTypes(new String[]{OwnerCarDto.LEASE_TYPE_MONTH,OwnerCarDto.LEASE_TYPE_INNER,OwnerCarDto.LEASE_TYPE_SALE,OwnerCarDto.LEASE_TYPE_NO_MONEY});
int count = reportCommunityServiceDaoImpl.getCarCount(reportCarDto);
@@ -208,7 +246,7 @@
try {
doDealCarFee(tmpReportCarDto, tmpReportFeeDto);
} catch (Exception e) {
- logger.error("澶勭悊鎴垮眿璐圭敤澶辫触" + JSONObject.toJSONString(tmpReportFeeDto), e);
+ logger.error("澶勭悊杞﹁締璐圭敤澶辫触" + JSONObject.toJSONString(tmpReportFeeDto), e);
}
}
}
@@ -224,7 +262,7 @@
reportFeeMonthStatisticsDto.setCommunityId(tmpReportCarDto.getCommunityId());
reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
- reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
+ reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());//杩欓噷涓嶈兘娉ㄩ噴 濡傛灉涓�涓垂鐢ㄥ垱寤哄鏉℃椂浼氭湁bug
reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
reportFeeMonthStatisticsDto.setFeeYear(DateUtil.getYear() + "");
reportFeeMonthStatisticsDto.setFeeMonth(DateUtil.getMonth() + "");
@@ -242,24 +280,36 @@
tmpReportFeeDto.setDeadlineTime(targetEndDate);
double oweAmount = getOweAmountByCar(tmpReportFeeDto, null, tmpReportCarDto); //搴旀敹
- dealBeforeUploadCarFee(tmpReportFeeDto, tmpReportCarDto);
- double receivableAmount = getReceivableAmount(tmpReportFeeDto,receivedAmount); //娆犺垂
+ //dealBeforeUploadCarFee(tmpReportFeeDto, tmpReportCarDto);
+ //double receivableAmount = getReceivableAmount(tmpReportFeeDto, receivedAmount); //娆犺垂
+ double feePrice = computeFeeSMOImpl.getReportFeePrice(tmpReportFeeDto, null, tmpReportCarDto);
+ tmpReportFeeDto.setFeePrice(feePrice);
ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
reportFeeMonthStatisticsPo.setDeadlineTime(DateUtil.getFormatTimeString(targetEndDate, DateUtil.DATE_FORMATE_STRING_A));
if (!ListUtil.isNull(statistics)) {
ReportFeeMonthStatisticsDto statistic = statistics.get(0);
reportFeeMonthStatisticsPo.setStatisticsId(statistic.getStatisticsId());
- reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
- reportFeeMonthStatisticsPo.setReceivedAmount(receivedAmount + "");
+// reportFeeMonthStatisticsPo.setReceivableAmount("0");
+// reportFeeMonthStatisticsPo.setReceivedAmount("0");
reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+ // 缂磋垂浜嗗氨寰楀埛
+ reportFeeMonthStatisticsPo.setHisOweAmount(getHisOweAmount(tmpReportFeeDto) + "");
+ //鏈夊彲鑳芥槸鏈堝唴鍒涘缓鐨勮垂鐢� 姣斿鐢佃垂姘磋垂
+ reportFeeMonthStatisticsPo.setCurReceivableAmount(getCurFeeReceivableAmount(tmpReportFeeDto) + "");
+ reportFeeMonthStatisticsPo.setCurReceivedAmount(getReceivedAmount(tmpReportFeeDto, 1) + "");
+ reportFeeMonthStatisticsPo.setHisOweReceivedAmount(getReceivedAmount(tmpReportFeeDto, 2) + "");
+ reportFeeMonthStatisticsPo.setPreReceivedAmount(getReceivedAmount(tmpReportFeeDto, 3) + "");
+ if (!StringUtil.isEmpty(statistic.getObjType()) && statistic.getObjType().equals("3333")) { //鎴垮眿
+ reportFeeMonthStatisticsPo.setObjNameNum(statistic.getFloorNum() + "-" + statistic.getUnitNum() + "-" + statistic.getRoomNum());
+ }
reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
} else {
reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
- reportFeeMonthStatisticsPo.setReceivedAmount(receivedAmount + "");
- reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
+ reportFeeMonthStatisticsPo.setReceivedAmount("0");
+ reportFeeMonthStatisticsPo.setReceivableAmount("0");
reportFeeMonthStatisticsPo.setStatisticsId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_statisticsId));
reportFeeMonthStatisticsPo.setCommunityId(tmpReportFeeDto.getCommunityId());
reportFeeMonthStatisticsPo.setConfigId(tmpReportFeeDto.getConfigId());
@@ -267,11 +317,18 @@
reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
reportFeeMonthStatisticsPo.setFeeMonth(DateUtil.getMonth() + "");
reportFeeMonthStatisticsPo.setFeeYear(DateUtil.getYear() + "");
+ reportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getNextMonthFirstDay(DateUtil.DATE_FORMATE_STRING_A));
reportFeeMonthStatisticsPo.setObjId(tmpReportCarDto.getCarId());
reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_CAR);
reportFeeMonthStatisticsPo.setFeeName(tmpReportFeeDto.getFeeName());
reportFeeMonthStatisticsPo.setObjName(tmpReportCarDto.getCarNum() + "(" + tmpReportCarDto.getAreaNum() + "鍋滆溅鍦�" + tmpReportCarDto.getNum() + "杞︿綅)");
+ reportFeeMonthStatisticsPo.setObjNameNum(tmpReportCarDto.getAreaNum() + "-" + tmpReportCarDto.getNum() + "-" + tmpReportCarDto.getCarNum());
reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+ reportFeeMonthStatisticsPo.setHisOweAmount(getHisOweAmount(tmpReportFeeDto) + "");
+ reportFeeMonthStatisticsPo.setCurReceivableAmount(getCurFeeReceivableAmount(tmpReportFeeDto) + "");
+ reportFeeMonthStatisticsPo.setCurReceivedAmount(getReceivedAmount(tmpReportFeeDto, 1) + "");
+ reportFeeMonthStatisticsPo.setHisOweReceivedAmount(getReceivedAmount(tmpReportFeeDto, 2) + "");
+ reportFeeMonthStatisticsPo.setPreReceivedAmount(getReceivedAmount(tmpReportFeeDto, 3) + "");
reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
}
@@ -280,91 +337,12 @@
Calendar calender = Calendar.getInstance();
calender.setTime(endTime);
- int year = calender.get(Calendar.YEAR);
- int month = calender.get(Calendar.MONTH);
ReportFeeMonthStatisticsPo tmpReportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
tmpReportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
- tmpReportFeeMonthStatisticsPo.setFeeYear(year + "");
- tmpReportFeeMonthStatisticsPo.setFeeMonth(month + "");
+ tmpReportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(endTime, DateUtil.DATE_FORMATE_STRING_A));
tmpReportFeeMonthStatisticsPo.setOweAmount("0");
reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsOwe(BeanConvertUtil.beanCovertMap(tmpReportFeeMonthStatisticsPo));
- }
-
- /**
- * 瑙e喅涓婄嚎鍓� 娆犺垂鏁版嵁
- *
- * @param tmpReportCarDto
- * @param tmpReportFeeDto
- */
- private void dealBeforeUploadCarFee(ReportFeeDto tmpReportFeeDto, ReportCarDto tmpReportCarDto) {
-
-
- Calendar preMonthDate = Calendar.getInstance();
- preMonthDate.set(Calendar.DAY_OF_MONTH, 1);
- preMonthDate.add(Calendar.DAY_OF_MONTH, -1);
-
- //褰撴湀涓�鏃�
- Calendar curMonthDate = Calendar.getInstance();
- curMonthDate.set(Calendar.DAY_OF_MONTH, 1);
- curMonthDate.set(Calendar.HOUR_OF_DAY, 0);
- curMonthDate.set(Calendar.MINUTE, 0);
- curMonthDate.set(Calendar.SECOND, 0);
- if (tmpReportFeeDto.getEndTime().getTime() > curMonthDate.getTime().getTime()) { //璇存槑娌℃湁娆犺垂
- return;
- }
-
- ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto = new ReportFeeMonthStatisticsDto();
- reportFeeMonthStatisticsDto.setCommunityId(tmpReportCarDto.getCommunityId());
- reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
- reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
- reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
- reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
- reportFeeMonthStatisticsDto.setFeeYear(preMonthDate.get(Calendar.YEAR) + "");
- reportFeeMonthStatisticsDto.setFeeMonth((preMonthDate.get(Calendar.MONTH) + 1) + "");
- List<ReportFeeMonthStatisticsDto> statistics = BeanConvertUtil.covertBeanList(
- reportFeeMonthStatisticsServiceDaoImpl.getReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsDto)),
- ReportFeeMonthStatisticsDto.class);
- //涓婁釜鏈堟湁鏁版嵁 涓嶅鐞�
- if (statistics != null && statistics.size() > 0) {
- return;
- }
-
- if (tmpReportFeeDto.getDeadlineTime().getTime() < curMonthDate.getTime().getTime()) {
- curMonthDate.setTime(tmpReportFeeDto.getDeadlineTime());
- }
-
- double receivableAmount = 0.0;
- if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeFlag())) {
- receivableAmount = tmpReportFeeDto.getFeePrice();
- } else {
- double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), curMonthDate.getTime());
- BigDecimal curDegree = new BigDecimal(month);
- receivableAmount = curDegree.multiply(new BigDecimal(tmpReportFeeDto.getFeePrice())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
- }
-
-
- ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
- reportFeeMonthStatisticsPo.setDeadlineTime(DateUtil.getFormatTimeString(curMonthDate.getTime(), DateUtil.DATE_FORMATE_STRING_A));
-
- reportFeeMonthStatisticsPo.setOweAmount(receivableAmount + "");
- reportFeeMonthStatisticsPo.setReceivedAmount("0");
- reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
- reportFeeMonthStatisticsPo.setStatisticsId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_statisticsId));
- reportFeeMonthStatisticsPo.setCommunityId(tmpReportFeeDto.getCommunityId());
- reportFeeMonthStatisticsPo.setConfigId(tmpReportFeeDto.getConfigId());
- reportFeeMonthStatisticsPo.setFeeCreateTime(DateUtil.getFormatTimeString(tmpReportFeeDto.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
- reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
- reportFeeMonthStatisticsPo.setFeeMonth((preMonthDate.get(Calendar.MONTH) + 1) + "");
- reportFeeMonthStatisticsPo.setFeeYear(preMonthDate.get(Calendar.YEAR) + "");
- reportFeeMonthStatisticsPo.setObjId(tmpReportCarDto.getCarId());
- reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_CAR);
- reportFeeMonthStatisticsPo.setFeeName(tmpReportFeeDto.getFeeName());
- reportFeeMonthStatisticsPo.setObjName(tmpReportCarDto.getCarNum() + "(" + tmpReportCarDto.getAreaNum() + "鍋滆溅鍦�" + tmpReportCarDto.getNum() + "杞︿綅)");
- reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
- reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
-
-
}
/**
@@ -387,6 +365,7 @@
try {
doDealRoomFee(reportRoomDto, tmpReportFeeDto);
} catch (Exception e) {
+ e.printStackTrace();
logger.error("澶勭悊鎴垮眿璐圭敤澶辫触" + JSONObject.toJSONString(tmpReportFeeDto), e);
}
}
@@ -406,16 +385,18 @@
reportFeeMonthStatisticsDto.setCommunityId(reportRoomDto.getCommunityId());
reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
- reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
+ reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId()); //杩欓噷涓嶈兘娉ㄩ噴锛屽洜涓轰竴涓垂鐢ㄥ娆″垱寤烘椂浼氬瓨鍦ㄨ鐩� 瀛樺湪bug闂
reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
+
reportFeeMonthStatisticsDto.setFeeYear(DateUtil.getYear() + "");
reportFeeMonthStatisticsDto.setFeeMonth(DateUtil.getMonth() + "");
List<ReportFeeMonthStatisticsDto> statistics = BeanConvertUtil.covertBeanList(
reportFeeMonthStatisticsServiceDaoImpl.getReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsDto)),
ReportFeeMonthStatisticsDto.class);
+ //List<ReportFeeMonthStatisticsDto> statistics = reportFeeMonthStatisticsInnerServiceSMOImpl.queryReportFeeMonthStatisticss(reportFeeMonthStatisticsDto);
- double receivedAmount = getReceivedAmount(tmpReportFeeDto); //瀹炴敹
+ //double receivedAmount = getReceivedAmount(tmpReportFeeDto); //瀹炴敹
FeeDto feeDto = BeanConvertUtil.covertBean(tmpReportFeeDto, FeeDto.class);
Map<String, Object> targetEndDateAndOweMonth = computeFeeSMOImpl.getTargetEndDateAndOweMonth(feeDto, null);
@@ -423,29 +404,45 @@
Date targetEndDate = (Date) targetEndDateAndOweMonth.get("targetEndDate");
tmpReportFeeDto.setDeadlineTime(targetEndDate);
double oweAmount = getOweAmount(tmpReportFeeDto, reportRoomDto, null); //娆犺垂
-
- double receivableAmount = getReceivableAmount(tmpReportFeeDto, receivedAmount); //搴旀敹
- //瑙e喅涓婄嚎鏃� 涔嬪墠娆犺垂娌℃湁鍒峰叆瀵艰嚧璐圭敤閲戦瀵逛笉涓婇棶棰樺鐞�
- dealBeforeUploadRoomFee(reportRoomDto, tmpReportFeeDto, receivableAmount);
-
-
+ double feePrice = computeFeeSMOImpl.getReportFeePrice(tmpReportFeeDto, reportRoomDto, null);
+ tmpReportFeeDto.setFeePrice(feePrice);
ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
reportFeeMonthStatisticsPo.setDeadlineTime(DateUtil.getFormatTimeString(targetEndDate, DateUtil.DATE_FORMATE_STRING_A));
if (!ListUtil.isNull(statistics)) {
ReportFeeMonthStatisticsDto statistic = statistics.get(0);
reportFeeMonthStatisticsPo.setStatisticsId(statistic.getStatisticsId());
- //reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
- reportFeeMonthStatisticsPo.setReceivedAmount(receivedAmount + "");
+
reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
reportFeeMonthStatisticsPo.setFeeName(StringUtil.isEmpty(tmpReportFeeDto.getImportFeeName()) ? tmpReportFeeDto.getFeeName() : tmpReportFeeDto.getImportFeeName());
+ // 缂磋垂浜嗗氨寰楀埛
+ reportFeeMonthStatisticsPo.setHisOweAmount(MoneyUtil.computePriceScale(getHisOweAmount(tmpReportFeeDto),
+ tmpReportFeeDto.getScale(),
+ Integer.parseInt(tmpReportFeeDto.getDecimalPlace())) + "");
+ //鏈夊彲鑳芥槸鏈堝唴鍒涘缓鐨勮垂鐢� 姣斿鐢佃垂姘磋垂
+ reportFeeMonthStatisticsPo.setCurReceivableAmount(
+ MoneyUtil.computePriceScale(getCurFeeReceivableAmount(tmpReportFeeDto),
+ tmpReportFeeDto.getScale(),
+ Integer.parseInt(tmpReportFeeDto.getDecimalPlace())) + "");
+ reportFeeMonthStatisticsPo.setCurReceivedAmount(
+ MoneyUtil.computePriceScale(getReceivedAmount(tmpReportFeeDto, 1),
+ tmpReportFeeDto.getScale(),
+ Integer.parseInt(tmpReportFeeDto.getDecimalPlace())) + "");
+ reportFeeMonthStatisticsPo.setHisOweReceivedAmount(
+ MoneyUtil.computePriceScale(getReceivedAmount(tmpReportFeeDto, 2),
+ tmpReportFeeDto.getScale(),
+ Integer.parseInt(tmpReportFeeDto.getDecimalPlace())) + "");
+ reportFeeMonthStatisticsPo.setPreReceivedAmount(MoneyUtil.computePriceScale(getReceivedAmount(tmpReportFeeDto, 3),
+ tmpReportFeeDto.getScale(),
+ Integer.parseInt(tmpReportFeeDto.getDecimalPlace())) + "");
reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
} else {
+
reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
- reportFeeMonthStatisticsPo.setReceivedAmount(receivedAmount + "");
- reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
+ reportFeeMonthStatisticsPo.setReceivedAmount("0");
+ reportFeeMonthStatisticsPo.setReceivableAmount("0");
reportFeeMonthStatisticsPo.setStatisticsId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_statisticsId));
reportFeeMonthStatisticsPo.setCommunityId(tmpReportFeeDto.getCommunityId());
reportFeeMonthStatisticsPo.setConfigId(tmpReportFeeDto.getConfigId());
@@ -453,42 +450,205 @@
reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
reportFeeMonthStatisticsPo.setFeeMonth(DateUtil.getMonth() + "");
reportFeeMonthStatisticsPo.setFeeYear(DateUtil.getYear() + "");
+ reportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getNextMonthFirstDay(DateUtil.DATE_FORMATE_STRING_A));
reportFeeMonthStatisticsPo.setObjId(reportRoomDto.getRoomId());
reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
reportFeeMonthStatisticsPo.setFeeName(StringUtil.isEmpty(tmpReportFeeDto.getImportFeeName()) ? tmpReportFeeDto.getFeeName() : tmpReportFeeDto.getImportFeeName());
if (RoomDto.ROOM_TYPE_ROOM.equals(reportRoomDto.getRoomType())) {
reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "鏍�" + reportRoomDto.getUnitNum() + "鍗曞厓" + reportRoomDto.getRoomNum() + "瀹�");
+ reportFeeMonthStatisticsPo.setObjNameNum(reportRoomDto.getFloorNum() + "-" + reportRoomDto.getUnitNum() + "-" + reportRoomDto.getRoomNum());
} else {
reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "鏍�" + reportRoomDto.getRoomNum() + "瀹�");
+ reportFeeMonthStatisticsPo.setObjNameNum(reportRoomDto.getFloorNum() + "-" + reportRoomDto.getRoomNum());
}
+ //璁$畻鍘嗗彶娆犺垂
+ reportFeeMonthStatisticsPo.setHisOweAmount(getHisOweAmount(tmpReportFeeDto) + "");
+ reportFeeMonthStatisticsPo.setCurReceivableAmount(getCurFeeReceivableAmount(tmpReportFeeDto) + "");
+ reportFeeMonthStatisticsPo.setCurReceivedAmount(getReceivedAmount(tmpReportFeeDto, 1) + "");
+ reportFeeMonthStatisticsPo.setHisOweReceivedAmount(getReceivedAmount(tmpReportFeeDto, 2) + "");
+ reportFeeMonthStatisticsPo.setPreReceivedAmount(getReceivedAmount(tmpReportFeeDto, 3) + "");
reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
- reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
+ //濡傛灉鏄� 姘磋垂 鐢佃垂 鐓ゆ皵璐�
+ if (!FeeConfigDto.FEE_TYPE_CD_METER.equals(tmpReportFeeDto.getFeeTypeCd())
+ && !FeeConfigDto.FEE_TYPE_CD_WATER.equals(tmpReportFeeDto.getFeeTypeCd())
+ && !FeeConfigDto.FEE_TYPE_CD_GAS.equals(tmpReportFeeDto.getFeeTypeCd())
+ ) {
+ reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
+ } else {
+ //澶勭悊姘寸數璐癸紝姘寸數璐规牴鎹紑濮嬫椂闂磋鍦ㄧ浉搴旀湀琛ュ厖鏁版嵁
+ dealMeteWater(reportFeeMonthStatisticsPo, tmpReportFeeDto);
+ }
}
//灏嗙即璐� 鍒版湡鏃堕棿涔嬪墠寰楁瑺璐瑰埛涓�0
Date endTime = tmpReportFeeDto.getEndTime();
- Calendar calender = Calendar.getInstance();
- calender.setTime(endTime);
- int year = calender.get(Calendar.YEAR);
- int month = calender.get(Calendar.MONTH);
-
ReportFeeMonthStatisticsPo tmpReportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
tmpReportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
- tmpReportFeeMonthStatisticsPo.setFeeYear(year + "");
- tmpReportFeeMonthStatisticsPo.setFeeMonth(month + "");
+ tmpReportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(endTime, DateUtil.DATE_FORMATE_STRING_A));
tmpReportFeeMonthStatisticsPo.setOweAmount("0");
reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsOwe(BeanConvertUtil.beanCovertMap(tmpReportFeeMonthStatisticsPo));
}
- public static void main(String[] args) {
- ReportFeeDetailDto feeDetailDto = new ReportFeeDetailDto();
- feeDetailDto.setStartTime(DateUtil.getFormatTimeString(DateUtil.getFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
- feeDetailDto.setEndTime(DateUtil.getFormatTimeString(DateUtil.getNextMonthFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
+ /**
+ * 澶勭悊姘寸數璐�
+ *
+ * @param reportFeeMonthStatisticsPo
+ * @param tmpReportFeeDto
+ */
+ private void dealMeteWater(ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo, ReportFeeDto tmpReportFeeDto) {
- System.out.println(JSONObject.toJSONString(feeDetailDto));
+ //濡傛灉鏄� 姘磋垂 鐢佃垂 鐓ゆ皵璐�
+ if (!FeeConfigDto.FEE_TYPE_CD_METER.equals(tmpReportFeeDto.getFeeTypeCd())
+ && !FeeConfigDto.FEE_TYPE_CD_WATER.equals(tmpReportFeeDto.getFeeTypeCd())
+ && !FeeConfigDto.FEE_TYPE_CD_GAS.equals(tmpReportFeeDto.getFeeTypeCd())
+ ) {
+ return;
+ }
+ //鏍规嵁璐圭敤寮�濮嬫椂闂� 璁$畻鏈堜唤
+ Date endTime = tmpReportFeeDto.getEndTime();
+ //鍘婚櫎 0 鍥犱负琛ㄩ噷鐨勬湀浠芥槸娌℃湁闆�
+ String curMonth = Integer.parseInt(DateUtil.getFormatTimeString(endTime, "MM")) + "";
+ String curYear = DateUtil.getFormatTimeString(endTime, "YYYY");
+ //鏌ヨ鏄惁瀛樺湪 鏁版嵁
+ ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto = new ReportFeeMonthStatisticsDto();
+ reportFeeMonthStatisticsDto.setCommunityId(tmpReportFeeDto.getCommunityId());
+ reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
+ reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
+ reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
+ reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
+ reportFeeMonthStatisticsDto.setFeeYear(curYear);
+ reportFeeMonthStatisticsDto.setFeeMonth(curMonth);
+ List<ReportFeeMonthStatisticsDto> statistics = BeanConvertUtil.covertBeanList(
+ reportFeeMonthStatisticsServiceDaoImpl.getReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsDto)),
+ ReportFeeMonthStatisticsDto.class);
+ if (!ListUtil.isNull(statistics)) {
+ return;
+ }
+ reportFeeMonthStatisticsPo.setStatisticsId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_statisticsId));
+ reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
}
+
+
+ /**
+ * @return
+ */
+ private double getReceivedAmount(ReportFeeDto tmpReportFeeDto, int flag) {
+ Map paramIn = new HashMap();
+ paramIn.put("startTime", DateUtil.getFormatTimeString(DateUtil.getFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
+ paramIn.put("endTime", DateUtil.getFormatTimeString(DateUtil.getNextMonthFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
+ paramIn.put("feeId", tmpReportFeeDto.getFeeId());
+ paramIn.put("yearMonth", DateUtil.getFormatTimeString(DateUtil.getFirstDate(), DateUtil.DATE_FORMATE_STRING_M));
+ paramIn.put("flag", flag);
+ double curReceivedAmount = reportFeeMonthStatisticsServiceDaoImpl.getReceivedAmountByMonth(paramIn);
+ return curReceivedAmount;
+ }
+
+ /**
+ * 褰撴湀搴旀敹
+ *
+ * @param tmpReportFeeDto
+ * @return
+ */
+ private double getCurFeeReceivableAmount(ReportFeeDto tmpReportFeeDto) {
+ BigDecimal feePriceDec = new BigDecimal(tmpReportFeeDto.getFeePrice());
+
+ Date curDate = DateUtil.getFirstDate();
+ Date nowDate = DateUtil.getCurrentDate();
+ double month = 0.0;
+ //宸茬粡瓒呰繃鎴鏃堕棿 鍜� 杩樻病鏈夊埌寮�濮嬫椂闂�
+ if (curDate.getTime() > tmpReportFeeDto.getDeadlineTime().getTime()
+ || nowDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
+ return 0.0;
+ }
+
+ //濡傛灉 1鍙峰皬浜� 璁¤垂璧峰鏃堕棿 閭d箞 灏哻urDate 鏀逛负 褰撳墠鏃堕棿
+ if (curDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
+ curDate = tmpReportFeeDto.getEndTime();
+ }
+
+ //杩欓噷闇�瑕佸垽鏂� 缁撴潫鏃堕棿 鏄惁 澶т簬浜嗗綋鏈堟渶鍚庝竴澶╋紝褰撴湀澶╂暟 * 姣忓ぉ閲戦
+ Calendar nextDateC = Calendar.getInstance();
+ nextDateC.setTime(curDate);
+ nextDateC.add(Calendar.MONTH, 1);
+ Date nextDate = nextDateC.getTime();
+
+ if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeFlag())) {
+ double allDays = computeFeeSMOImpl.daysBetween(tmpReportFeeDto.getEndTime(), tmpReportFeeDto.getDeadlineTime());
+ allDays = Math.ceil(allDays);
+ if (allDays == 0) { // 闃叉闄ゆ暟涓�0
+ return 0;
+ }
+ BigDecimal moneyPreDay = feePriceDec.divide(new BigDecimal(allDays), FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN);
+ if (tmpReportFeeDto.getDeadlineTime().getTime() > nextDate.getTime()) {
+ int day = DateUtil.getCurrentMonthDay();
+ return moneyPreDay.multiply(new BigDecimal(day)).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP).doubleValue();
+ }
+ // 缁撴潫鏃堕棿 鍦ㄥ綋鏈堝唴
+ double hisDays = computeFeeSMOImpl.daysBetween(tmpReportFeeDto.getEndTime(), curDate);
+ BigDecimal hisDayDec = moneyPreDay.multiply(new BigDecimal(hisDays)).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
+ return feePriceDec.subtract(hisDayDec).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP).doubleValue();
+ }
+
+ month = computeFeeSMOImpl.dayCompare(curDate, tmpReportFeeDto.getDeadlineTime());
+ if (month < 0) {
+ return 0;
+ }
+ if (month < 1) {
+ return feePriceDec.multiply(new BigDecimal(month)).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ }
+
+ return tmpReportFeeDto.getFeePrice();
+ }
+
+
+ /**
+ * 璁$畻鍘嗗彶娆犺垂
+ *
+ * @param tmpReportFeeDto
+ * @return
+ */
+ private double getHisOweAmount(ReportFeeDto tmpReportFeeDto) {
+
+ BigDecimal feePriceDec = new BigDecimal(tmpReportFeeDto.getFeePrice());
+ Date curDate = DateUtil.getFirstDate();//11鏈�1鏃�
+ //璇存槑娌℃湁鍘嗗彶娆犺垂
+ if (curDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
+ return 0.0;
+ }
+ if(FeeDto.STATE_FINISH.equals(tmpReportFeeDto.getState())){
+ return 0.0;
+ }
+
+ if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeFlag())) {
+ //璇存槑涓�娆℃�ц垂鐢ㄩ兘娆犱簡
+ if (tmpReportFeeDto.getDeadlineTime().getTime() < curDate.getTime()) {
+ return tmpReportFeeDto.getFeePrice();
+ }
+ double allDays = computeFeeSMOImpl.daysBetween(tmpReportFeeDto.getEndTime(), tmpReportFeeDto.getDeadlineTime());
+ allDays = Math.ceil(allDays);
+ if (allDays == 0) { // 闃叉闄ゆ暟涓�0
+ return 0;
+ }
+ //杩欐槸姣忓ぉ鐨勯挶
+ BigDecimal moneyPreDay = feePriceDec.divide(new BigDecimal(allDays), FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN);
+
+ double hisDays = computeFeeSMOImpl.daysBetween(tmpReportFeeDto.getEndTime(), curDate);
+
+ return moneyPreDay.multiply(new BigDecimal(hisDays)).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP).doubleValue();
+ }
+
+ double month = 0.0;
+ if (tmpReportFeeDto.getDeadlineTime().getTime() < curDate.getTime()) {
+ month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), tmpReportFeeDto.getDeadlineTime());
+ } else {
+ month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), curDate);
+ }
+ BigDecimal curDegree = new BigDecimal(month);
+ return curDegree.multiply(feePriceDec).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ }
+
/**
* 瑙e喅涓婄嚎鍓� 娆犺垂鏁版嵁
@@ -496,7 +656,7 @@
* @param reportRoomDto
* @param tmpReportFeeDto
*/
- private void dealBeforeUploadRoomFee(ReportRoomDto reportRoomDto, ReportFeeDto tmpReportFeeDto, double curMonthReceivableAmount) {
+ private void dealBeforeUploadRoomFee(ReportRoomDto reportRoomDto, ReportFeeDto tmpReportFeeDto) {
Calendar preMonthDate = Calendar.getInstance();
@@ -539,7 +699,7 @@
} else {
double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), curMonthDate.getTime());
BigDecimal curDegree = new BigDecimal(month);
- receivableAmount = curDegree.multiply(new BigDecimal(tmpReportFeeDto.getFeePrice())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ receivableAmount = curDegree.multiply(new BigDecimal(tmpReportFeeDto.getFeePrice())).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue();
}
ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
reportFeeMonthStatisticsPo.setDeadlineTime(DateUtil.getFormatTimeString(curMonthDate.getTime(), DateUtil.DATE_FORMATE_STRING_A));
@@ -554,14 +714,25 @@
reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
reportFeeMonthStatisticsPo.setFeeMonth((preMonthDate.get(Calendar.MONTH) + 1) + "");
reportFeeMonthStatisticsPo.setFeeYear(preMonthDate.get(Calendar.YEAR) + "");
+ reportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(DateUtil.getFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
+
reportFeeMonthStatisticsPo.setObjId(reportRoomDto.getRoomId());
reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
reportFeeMonthStatisticsPo.setFeeName(StringUtil.isEmpty(tmpReportFeeDto.getImportFeeName()) ? tmpReportFeeDto.getFeeName() : tmpReportFeeDto.getImportFeeName());
if (RoomDto.ROOM_TYPE_ROOM.equals(reportRoomDto.getRoomType())) {
reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "鏍�" + reportRoomDto.getUnitNum() + "鍗曞厓" + reportRoomDto.getRoomNum() + "瀹�");
+ reportFeeMonthStatisticsPo.setObjNameNum(reportRoomDto.getFloorNum() + "-" + reportRoomDto.getUnitNum() + "-" + reportRoomDto.getRoomNum());
} else {
reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "鏍�" + reportRoomDto.getRoomNum() + "瀹�");
+ reportFeeMonthStatisticsPo.setObjNameNum(reportRoomDto.getFloorNum() + "-" + reportRoomDto.getRoomNum());
}
+ //璁$畻鍘嗗彶娆犺垂
+ reportFeeMonthStatisticsPo.setHisOweAmount("0");
+ reportFeeMonthStatisticsPo.setCurReceivableAmount(receivableAmount + "");
+ reportFeeMonthStatisticsPo.setCurReceivedAmount("0");
+ reportFeeMonthStatisticsPo.setHisOweReceivedAmount("0");
+ reportFeeMonthStatisticsPo.setPreReceivedAmount("0");
+
reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
@@ -639,14 +810,23 @@
if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeFlag())) {
return computeOnceFee(tmpReportFeeDto);
}
- OwnerCarDto ownerCarDto = new OwnerCarDto();
- ownerCarDto.setCommunityId(tmpReportFeeDto.getCommunityId());
- ownerCarDto.setCarId(tmpReportFeeDto.getCarId());
- List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
- if (ownerCarDtos == null || ownerCarDtos.size() < 1) {
+// OwnerCarDto ownerCarDto = new OwnerCarDto();
+// ownerCarDto.setCommunityId(tmpReportFeeDto.getCommunityId());
+// ownerCarDto.setCarId(tmpReportFeeDto.getCarId());
+// List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
+// if (ownerCarDtos == null || ownerCarDtos.size() < 1) {
+// return 0.0;
+// }
+ Date endTime = reportCarDto.getEndTime();
+
+ if(endTime == null){
return 0.0;
}
- Date endTime = ownerCarDtos.get(0).getEndTime();
+
+ Date maxEndDate = tmpReportFeeDto.getDeadlineTime();
+ if (FeeDto.FEE_FLAG_CYCLE.equals(tmpReportFeeDto.getFeeFlag())) {
+ maxEndDate = tmpReportFeeDto.getConfigEndTime();
+ }
//1.0 璐圭敤鍒版湡鏃堕棿鍜岃垂鐢ㄧ粨鏉熸椂闂� 閮戒笉鍦ㄥ綋鏈�
if (!belongCurMonth(tmpReportFeeDto.getEndTime())
@@ -661,15 +841,15 @@
//绠楀ぉ鏁�
double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), DateUtil.getNextMonthFirstDate());
BigDecimal curDegree = new BigDecimal(month);
- return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ return curDegree.multiply(feePriceDec).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue();
}
//3.0 璐圭敤鍒版湡鏃堕棿 涓嶅湪褰撴湀锛岃垂鐢ㄧ粨鏉熸椂闂村湪褰撴湀
if (!belongCurMonth(tmpReportFeeDto.getEndTime())
&& belongCurMonth(endTime)) {
//绠楀ぉ鏁�
- double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), tmpReportFeeDto.getConfigEndTime());
+ double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), maxEndDate);
BigDecimal curDegree = new BigDecimal(month);
- return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ return curDegree.multiply(feePriceDec).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue();
}
return 0.0;
}
@@ -683,8 +863,13 @@
double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getDeadlineTime(), tmpReportFeeDto.getEndTime());
month = Math.ceil(month);
+ if (month == 0) {
+ logger.debug("鐩稿樊鏈堜唤涓�0锛寋}", JSONObject.toJSONString(tmpReportFeeDto));
+ return tmpReportFeeDto.getFeePrice();
+ }
+
BigDecimal feePriceDec = new BigDecimal(tmpReportFeeDto.getFeePrice());
- double money = feePriceDec.divide(new BigDecimal(month),2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ double money = feePriceDec.divide(new BigDecimal(month), FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue();
return money;
}
@@ -708,28 +893,33 @@
return computeOnceFee(tmpReportFeeDto);
}
+ Date maxEndDate = tmpReportFeeDto.getDeadlineTime();
+ if (FeeDto.FEE_FLAG_CYCLE.equals(tmpReportFeeDto.getFeeFlag())) {
+ maxEndDate = tmpReportFeeDto.getConfigEndTime();
+ }
+
//1.0 璐圭敤鍒版湡鏃堕棿鍜岃垂鐢ㄧ粨鏉熸椂闂� 閮戒笉鍦ㄥ綋鏈�
if (!belongCurMonth(tmpReportFeeDto.getEndTime())
- && !belongCurMonth(tmpReportFeeDto.getConfigEndTime())
+ && !belongCurMonth(maxEndDate)
&& tmpReportFeeDto.getEndTime().getTime() < DateUtil.getFirstDate().getTime()) {
return feePrice;
}
//2.0 璐圭敤鍒版湡鏃堕棿 鍦ㄥ綋鏈堬紝璐圭敤缁撴潫鏃堕棿涓嶅湪褰撴湀
if (belongCurMonth(tmpReportFeeDto.getEndTime())
- && !belongCurMonth(tmpReportFeeDto.getConfigEndTime())) {
+ && !belongCurMonth(maxEndDate)) {
//绠楀ぉ鏁�
double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), DateUtil.getNextMonthFirstDate());
BigDecimal curDegree = new BigDecimal(month);
- return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ return curDegree.multiply(feePriceDec).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue();
}
//3.0 璐圭敤鍒版湡鏃堕棿 涓嶅湪褰撴湀锛岃垂鐢ㄧ粨鏉熸椂闂村湪褰撴湀
if (!belongCurMonth(tmpReportFeeDto.getEndTime())
- && belongCurMonth(tmpReportFeeDto.getConfigEndTime())) {
+ && belongCurMonth(maxEndDate)) {
//绠楀ぉ鏁�
- double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), tmpReportFeeDto.getConfigEndTime());
+ double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), maxEndDate);
BigDecimal curDegree = new BigDecimal(month);
- return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ return curDegree.multiply(feePriceDec).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue();
}
return 0.0;
}
--
Gitblit v1.8.0