Sfoglia il codice sorgente

优化合同欠费工鞥

java110 5 anni fa
parent
commit
08061df02c

+ 36 - 18
java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java

@@ -4,11 +4,7 @@ import com.java110.core.smo.IComputeFeeSMO;
 import com.java110.dto.RoomDto;
 import com.java110.dto.community.CommunityDto;
 import com.java110.dto.contractRoom.ContractRoomDto;
-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.fee.*;
 import com.java110.dto.owner.OwnerCarDto;
 import com.java110.dto.owner.OwnerDto;
 import com.java110.dto.parking.ParkingSpaceDto;
@@ -38,12 +34,7 @@ import javax.script.ScriptEngine;
 import javax.script.ScriptEngineManager;
 import java.math.BigDecimal;
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 费用计算 服务类
@@ -143,6 +134,8 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
             computeFeePriceByRoom(feeDto, roomDto);
         } else if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())) {//车位相关
             computeFeePriceByParkingSpace(feeDto);
+        }else if(FeeDto.PAYER_OBJ_TYPE_CONTRACT.equals(feeDto.getPayerObjType())) { //房屋相关
+            computeFeePriceByContract(feeDto, roomDto);
         }
     }
 
@@ -201,6 +194,31 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
             //feeDto.setDeadlineTime(DateUtil.getCurrentDate()); 欠费日期不对先注释
         }
     }
+    /**
+     * 根据房屋来算单价
+     *
+     * @param feeDto
+     */
+    private void computeFeePriceByContract(FeeDto feeDto, RoomDto roomDto) {
+        Map<String, Object> targetEndDateAndOweMonth = getTargetEndDateAndOweMonth(feeDto);
+        Date targetEndDate = (Date) targetEndDateAndOweMonth.get("targetEndDate");
+        double oweMonth = (double) targetEndDateAndOweMonth.get("oweMonth");
+
+        String computingFormula = feeDto.getComputingFormula();
+        double feePrice = getFeePrice(feeDto, roomDto);
+        feeDto.setFeePrice(feePrice);
+        //double month = dayCompare(feeDto.getEndTime(), DateUtil.getCurrentDate());
+        BigDecimal price = new BigDecimal(feeDto.getFeePrice());
+        price = price.multiply(new BigDecimal(oweMonth));
+        feeDto.setFeePrice(price.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+        feeDto.setDeadlineTime(targetEndDate);
+
+        //动态费用
+        if ("4004".equals(computingFormula) && !FeeDto.STATE_FINISH.equals(feeDto.getState())) {
+            feeDto.setAmountOwed(feeDto.getFeePrice() + "");
+            //feeDto.setDeadlineTime(DateUtil.getCurrentDate()); 欠费日期不对先注释
+        }
+    }
 
 
     /**
@@ -368,13 +386,13 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
             return ownerDtos.get(0);
         }
 
-        if(FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())){
+        if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())) {
             OwnerCarDto ownerCarDto = new OwnerCarDto();
             ownerCarDto.setCarId(feeDto.getPayerObjId());
             ownerCarDto.setCommunityId(feeDto.getCommunityId());
             List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
 
-            Assert.listOnlyOne(ownerCarDtos,"车辆不存在");
+            Assert.listOnlyOne(ownerCarDtos, "车辆不存在");
             ownerDto = new OwnerDto();
             ownerDto.setOwnerId(ownerCarDtos.get(0).getOwnerId());
             ownerDto.setCommunityId(feeDto.getCommunityId());
@@ -795,10 +813,10 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 //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(0);
-                for(ContractRoomDto tmpContractRoomDto: contractRoomDtos){
+                for (ContractRoomDto tmpContractRoomDto : contractRoomDtos) {
                     builtUpArea = builtUpArea.add(new BigDecimal(Double.parseDouble(tmpContractRoomDto.getBuiltUpArea())));
                 }
-                feeDto.setBuiltUpArea(builtUpArea.doubleValue()+"");
+                feeDto.setBuiltUpArea(builtUpArea.doubleValue() + "");
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
                 feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_EVEN);
             } else if ("2002".equals(computingFormula)) { // 固定费用
@@ -904,9 +922,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
     private BigDecimal computeContractCustomizeFormula(FeeDto feeDto, List<ContractRoomDto> contractRoomDtos) {
 
         BigDecimal total = new BigDecimal(0.0);
-       for(ContractRoomDto contractRoomDto :contractRoomDtos){
-           total = total.add(computeRoomCustomizeFormula(feeDto,contractRoomDto));
-       }
+        for (ContractRoomDto contractRoomDto : contractRoomDtos) {
+            total = total.add(computeRoomCustomizeFormula(feeDto, contractRoomDto));
+        }
         return total;
     }