|
@@ -5,7 +5,6 @@ import com.java110.api.listener.AbstractServiceApiListener;
|
|
|
import com.java110.core.annotation.Java110Listener;
|
|
import com.java110.core.annotation.Java110Listener;
|
|
|
import com.java110.core.context.DataFlowContext;
|
|
import com.java110.core.context.DataFlowContext;
|
|
|
import com.java110.core.event.service.api.ServiceDataFlowEvent;
|
|
import com.java110.core.event.service.api.ServiceDataFlowEvent;
|
|
|
-import com.java110.dto.RoomDto;
|
|
|
|
|
import com.java110.dto.fee.FeeDto;
|
|
import com.java110.dto.fee.FeeDto;
|
|
|
import com.java110.dto.owner.OwnerCarDto;
|
|
import com.java110.dto.owner.OwnerCarDto;
|
|
|
import com.java110.dto.parking.ParkingSpaceDto;
|
|
import com.java110.dto.parking.ParkingSpaceDto;
|
|
@@ -14,11 +13,11 @@ import com.java110.intf.community.IRoomInnerServiceSMO;
|
|
|
import com.java110.intf.fee.IFeeConfigInnerServiceSMO;
|
|
import com.java110.intf.fee.IFeeConfigInnerServiceSMO;
|
|
|
import com.java110.intf.fee.IFeeInnerServiceSMO;
|
|
import com.java110.intf.fee.IFeeInnerServiceSMO;
|
|
|
import com.java110.intf.user.IOwnerCarInnerServiceSMO;
|
|
import com.java110.intf.user.IOwnerCarInnerServiceSMO;
|
|
|
|
|
+import com.java110.service.smo.IComputeFeeSMO;
|
|
|
import com.java110.utils.constant.ServiceCodeFeeConfigConstant;
|
|
import com.java110.utils.constant.ServiceCodeFeeConfigConstant;
|
|
|
import com.java110.utils.util.Assert;
|
|
import com.java110.utils.util.Assert;
|
|
|
import com.java110.utils.util.BeanConvertUtil;
|
|
import com.java110.utils.util.BeanConvertUtil;
|
|
|
import com.java110.utils.util.DateUtil;
|
|
import com.java110.utils.util.DateUtil;
|
|
|
-import com.java110.utils.util.StringUtil;
|
|
|
|
|
import com.java110.vo.api.fee.ApiFeeDataVo;
|
|
import com.java110.vo.api.fee.ApiFeeDataVo;
|
|
|
import com.java110.vo.api.fee.ApiFeeVo;
|
|
import com.java110.vo.api.fee.ApiFeeVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -27,8 +26,10 @@ import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
|
|
-import java.util.*;
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -52,6 +53,9 @@ public class ListFeeListener extends AbstractServiceApiListener {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
|
|
private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IComputeFeeSMO computeFeeSMOImpl;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public String getServiceCode() {
|
|
public String getServiceCode() {
|
|
@@ -133,11 +137,11 @@ public class ListFeeListener extends AbstractServiceApiListener {
|
|
|
for (FeeDto feeDto : feeDtos) {
|
|
for (FeeDto feeDto : feeDtos) {
|
|
|
|
|
|
|
|
// 轮数 * 周期 * 30 + 开始时间 = 目标 到期时间
|
|
// 轮数 * 周期 * 30 + 开始时间 = 目标 到期时间
|
|
|
- Map<String, Object> targetEndDateAndOweMonth = getTargetEndDateAndOweMonth(feeDto);
|
|
|
|
|
|
|
+ Map<String, Object> targetEndDateAndOweMonth = computeFeeSMOImpl.getTargetEndDateAndOweMonth(feeDto);
|
|
|
Date targetEndDate = (Date) targetEndDateAndOweMonth.get("targetEndDate");
|
|
Date targetEndDate = (Date) targetEndDateAndOweMonth.get("targetEndDate");
|
|
|
double oweMonth = (double) targetEndDateAndOweMonth.get("oweMonth");
|
|
double oweMonth = (double) targetEndDateAndOweMonth.get("oweMonth");
|
|
|
//一次性费用
|
|
//一次性费用
|
|
|
- if ("3333".equals(feeDto.getPayerObjType())) { //房屋相关
|
|
|
|
|
|
|
+ if (FeeDto.PAYER_OBJ_TYPE_ROOM.equals(feeDto.getPayerObjType())) { //房屋相关
|
|
|
computeFeePriceByRoom(feeDto, oweMonth);
|
|
computeFeePriceByRoom(feeDto, oweMonth);
|
|
|
} else if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())) {//车位相关
|
|
} else if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())) {//车位相关
|
|
|
computeFeePriceByCar(feeDto, oweMonth);
|
|
computeFeePriceByCar(feeDto, oweMonth);
|
|
@@ -147,93 +151,6 @@ public class ListFeeListener extends AbstractServiceApiListener {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private Map getTargetEndDateAndOweMonth(FeeDto feeDto) {
|
|
|
|
|
- Date targetEndDate = null;
|
|
|
|
|
- double oweMonth = 0.0;
|
|
|
|
|
-
|
|
|
|
|
- Map<String, Object> targetEndDateAndOweMonth = new HashMap<>();
|
|
|
|
|
-
|
|
|
|
|
- if (FeeDto.STATE_FINISH.equals(feeDto.getState())) {
|
|
|
|
|
- targetEndDate = feeDto.getEndTime();
|
|
|
|
|
- targetEndDateAndOweMonth.put("oweMonth", oweMonth);
|
|
|
|
|
- targetEndDateAndOweMonth.put("targetEndDate", targetEndDate);
|
|
|
|
|
- return targetEndDateAndOweMonth;
|
|
|
|
|
- }
|
|
|
|
|
- if (FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) {
|
|
|
|
|
- if (!StringUtil.isEmpty(feeDto.getCurDegrees())) {
|
|
|
|
|
- targetEndDate = feeDto.getCurReadingTime();
|
|
|
|
|
- } else if (feeDto.getImportFeeEndTime() == null) {
|
|
|
|
|
- targetEndDate = feeDto.getConfigEndTime();
|
|
|
|
|
- } else {
|
|
|
|
|
- targetEndDate = feeDto.getImportFeeEndTime();
|
|
|
|
|
- }
|
|
|
|
|
- //判断当前费用是不是导入费用
|
|
|
|
|
- oweMonth = 1.0;
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- //当前时间
|
|
|
|
|
- Date billEndTime = DateUtil.getCurrentDate();
|
|
|
|
|
- //开始时间
|
|
|
|
|
- Date startDate = feeDto.getStartTime();
|
|
|
|
|
- //到期时间
|
|
|
|
|
- Date endDate = feeDto.getEndTime();
|
|
|
|
|
- if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())) {
|
|
|
|
|
- OwnerCarDto ownerCarDto = new OwnerCarDto();
|
|
|
|
|
- ownerCarDto.setCommunityId(feeDto.getCommunityId());
|
|
|
|
|
- ownerCarDto.setCarId(feeDto.getPayerObjId());
|
|
|
|
|
- List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
|
|
|
|
|
-
|
|
|
|
|
- if (ownerCarDtos == null || ownerCarDtos.size() != 1) {
|
|
|
|
|
- targetEndDateAndOweMonth.put("oweMonth", 0);
|
|
|
|
|
- targetEndDateAndOweMonth.put("targetEndDate", "");
|
|
|
|
|
- return targetEndDateAndOweMonth;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- targetEndDate = ownerCarDtos.get(0).getEndTime();
|
|
|
|
|
- //说明没有欠费
|
|
|
|
|
- if (endDate.getTime() >= targetEndDate.getTime()) {
|
|
|
|
|
- // 目标到期时间 - 到期时间 = 欠费月份
|
|
|
|
|
- oweMonth = 0;
|
|
|
|
|
- targetEndDateAndOweMonth.put("oweMonth", oweMonth);
|
|
|
|
|
- targetEndDateAndOweMonth.put("targetEndDate", targetEndDate);
|
|
|
|
|
- return targetEndDateAndOweMonth;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //缴费周期
|
|
|
|
|
- long paymentCycle = Long.parseLong(feeDto.getPaymentCycle());
|
|
|
|
|
- // 当前时间 - 开始时间 = 月份
|
|
|
|
|
- double mulMonth = 0.0;
|
|
|
|
|
- mulMonth = dayCompare(startDate, billEndTime);
|
|
|
|
|
-
|
|
|
|
|
- // 月份/ 周期 = 轮数(向上取整)
|
|
|
|
|
- double round = 0.0;
|
|
|
|
|
- if ("1200".equals(feeDto.getPaymentCd())) { // 预付费
|
|
|
|
|
- round = Math.floor(mulMonth / paymentCycle) + 1;
|
|
|
|
|
- } else { //后付费
|
|
|
|
|
- round = Math.floor(mulMonth / paymentCycle);
|
|
|
|
|
- }
|
|
|
|
|
- // 轮数 * 周期 * 30 + 开始时间 = 目标 到期时间
|
|
|
|
|
- targetEndDate = getTargetEndTime(round * paymentCycle, startDate);
|
|
|
|
|
- //费用 快结束了
|
|
|
|
|
- if (feeDto.getConfigEndTime().getTime() < targetEndDate.getTime()) {
|
|
|
|
|
- targetEndDate = feeDto.getConfigEndTime();
|
|
|
|
|
- }
|
|
|
|
|
- //说明没有欠费
|
|
|
|
|
- if (endDate.getTime() < targetEndDate.getTime()) {
|
|
|
|
|
- // 目标到期时间 - 到期时间 = 欠费月份
|
|
|
|
|
- oweMonth = dayCompare(endDate, targetEndDate);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (feeDto.getEndTime().getTime() > targetEndDate.getTime()) {
|
|
|
|
|
- targetEndDate = feeDto.getEndTime();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- targetEndDateAndOweMonth.put("oweMonth", oweMonth);
|
|
|
|
|
- targetEndDateAndOweMonth.put("targetEndDate", targetEndDate);
|
|
|
|
|
- return targetEndDateAndOweMonth;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
private void computeFeePriceByCar(FeeDto feeDto, double oweMonth) {
|
|
private void computeFeePriceByCar(FeeDto feeDto, double oweMonth) {
|
|
|
OwnerCarDto ownerCarDto = new OwnerCarDto();
|
|
OwnerCarDto ownerCarDto = new OwnerCarDto();
|
|
@@ -247,40 +164,12 @@ public class ListFeeListener extends AbstractServiceApiListener {
|
|
|
parkingSpaceDto.setCommunityId(feeDto.getCommunityId());
|
|
parkingSpaceDto.setCommunityId(feeDto.getCommunityId());
|
|
|
parkingSpaceDto.setPsId(ownerCarDtos.get(0).getPsId());
|
|
parkingSpaceDto.setPsId(ownerCarDtos.get(0).getPsId());
|
|
|
List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto);
|
|
List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto);
|
|
|
-
|
|
|
|
|
if (parkingSpaceDtos == null || parkingSpaceDtos.size() < 1) { //数据有问题
|
|
if (parkingSpaceDtos == null || parkingSpaceDtos.size() < 1) { //数据有问题
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
String computingFormula = feeDto.getComputingFormula();
|
|
String computingFormula = feeDto.getComputingFormula();
|
|
|
double feePrice = 0.00;
|
|
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 if ("4004".equals(computingFormula)) {
|
|
|
|
|
- feePrice = Double.parseDouble(feeDto.getAmount());
|
|
|
|
|
- } else if ("5005".equals(computingFormula)) {
|
|
|
|
|
- if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
|
|
|
|
|
- feePrice = -1.00;
|
|
|
|
|
- } 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).doubleValue();
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- feePrice = -1.00;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ feePrice = computeFeeSMOImpl.getFeePrice(feeDto);
|
|
|
feeDto.setFeePrice(feePrice);
|
|
feeDto.setFeePrice(feePrice);
|
|
|
BigDecimal curFeePrice = new BigDecimal(feeDto.getFeePrice());
|
|
BigDecimal curFeePrice = new BigDecimal(feeDto.getFeePrice());
|
|
|
curFeePrice = curFeePrice.multiply(new BigDecimal(oweMonth));
|
|
curFeePrice = curFeePrice.multiply(new BigDecimal(oweMonth));
|
|
@@ -298,49 +187,13 @@ public class ListFeeListener extends AbstractServiceApiListener {
|
|
|
* @param feeDto
|
|
* @param feeDto
|
|
|
*/
|
|
*/
|
|
|
private void computeFeePriceByRoom(FeeDto feeDto, double oweMonth) {
|
|
private void computeFeePriceByRoom(FeeDto feeDto, double oweMonth) {
|
|
|
- RoomDto roomDto = new RoomDto();
|
|
|
|
|
- roomDto.setCommunityId(feeDto.getCommunityId());
|
|
|
|
|
- roomDto.setRoomId(feeDto.getPayerObjId());
|
|
|
|
|
- List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto);
|
|
|
|
|
-
|
|
|
|
|
- if (roomDtos == null || roomDtos.size() < 1) { //数据有问题
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
String computingFormula = feeDto.getComputingFormula();
|
|
String computingFormula = feeDto.getComputingFormula();
|
|
|
double feePrice = 0.00;
|
|
double feePrice = 0.00;
|
|
|
- if ("1001".equals(computingFormula)) { //面积*单价+附加费
|
|
|
|
|
- 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).doubleValue();
|
|
|
|
|
- } else if ("2002".equals(computingFormula)) { // 固定费用
|
|
|
|
|
- BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
|
|
|
|
|
- feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
|
|
|
|
|
- } else if ("4004".equals(computingFormula)) {
|
|
|
|
|
- feePrice = Double.parseDouble(feeDto.getAmount());
|
|
|
|
|
- } else if ("5005".equals(computingFormula)) {
|
|
|
|
|
-
|
|
|
|
|
- if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
|
|
|
|
|
- feePrice = -1.00;
|
|
|
|
|
- } 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).doubleValue();
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- feePrice = -1.00;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ feePrice = computeFeeSMOImpl.getFeePrice(feeDto);
|
|
|
feeDto.setFeePrice(feePrice);
|
|
feeDto.setFeePrice(feePrice);
|
|
|
BigDecimal curFeePrice = new BigDecimal(feeDto.getFeePrice());
|
|
BigDecimal curFeePrice = new BigDecimal(feeDto.getFeePrice());
|
|
|
curFeePrice = curFeePrice.multiply(new BigDecimal(oweMonth));
|
|
curFeePrice = curFeePrice.multiply(new BigDecimal(oweMonth));
|
|
|
feeDto.setAmountOwed(curFeePrice.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() + "");
|
|
feeDto.setAmountOwed(curFeePrice.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() + "");
|
|
|
-
|
|
|
|
|
//动态费用
|
|
//动态费用
|
|
|
if ("4004".equals(computingFormula)) {
|
|
if ("4004".equals(computingFormula)) {
|
|
|
feeDto.setAmountOwed(feeDto.getFeePrice() + "");
|
|
feeDto.setAmountOwed(feeDto.getFeePrice() + "");
|
|
@@ -348,44 +201,4 @@ public class ListFeeListener extends AbstractServiceApiListener {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 计算2个日期之间相差的 以年、月、日为单位,各自计算结果是多少
|
|
|
|
|
- * 比如:2011-02-02 到 2017-03-02
|
|
|
|
|
- * 以年为单位相差为:6年
|
|
|
|
|
- * 以月为单位相差为:73个月
|
|
|
|
|
- * 以日为单位相差为:2220天
|
|
|
|
|
- *
|
|
|
|
|
- * @param fromDate
|
|
|
|
|
- * @param toDate
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- public static double dayCompare(Date fromDate, Date toDate) {
|
|
|
|
|
- Calendar from = Calendar.getInstance();
|
|
|
|
|
- from.setTime(fromDate);
|
|
|
|
|
- Calendar to = Calendar.getInstance();
|
|
|
|
|
- to.setTime(toDate);
|
|
|
|
|
- int result = to.get(Calendar.MONTH) - from.get(Calendar.MONTH);
|
|
|
|
|
- int month = (to.get(Calendar.YEAR) - from.get(Calendar.YEAR)) * 12;
|
|
|
|
|
-
|
|
|
|
|
- result = result + month;
|
|
|
|
|
- Calendar newFrom = Calendar.getInstance();
|
|
|
|
|
- newFrom.setTime(fromDate);
|
|
|
|
|
- newFrom.add(Calendar.MONTH, result);
|
|
|
|
|
-
|
|
|
|
|
- long t1 = newFrom.getTimeInMillis();
|
|
|
|
|
- long t2 = to.getTimeInMillis();
|
|
|
|
|
- long days = (t2 - t1) / (24 * 60 * 60 * 1000);
|
|
|
|
|
-
|
|
|
|
|
- BigDecimal tmpDays = new BigDecimal(days);
|
|
|
|
|
- BigDecimal monthDay = new BigDecimal(30);
|
|
|
|
|
-
|
|
|
|
|
- return tmpDays.divide(monthDay, 2, RoundingMode.HALF_UP).doubleValue() + result;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private Date getTargetEndTime(double v, Date startDate) {
|
|
|
|
|
- Calendar endDate = Calendar.getInstance();
|
|
|
|
|
- endDate.setTime(startDate);
|
|
|
|
|
- endDate.add(Calendar.MONTH, (int) v);
|
|
|
|
|
- return endDate.getTime();
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|