java110 лет назад: 5
Родитель
Сommit
31bd44345b

+ 37 - 3
java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java

@@ -774,9 +774,15 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
         Calendar newFrom = Calendar.getInstance();
         newFrom.setTime(fromDate);
         newFrom.add(Calendar.MONTH, result);
+        //如果加月份后 大于了到期时间 默认加 月份 -1 情况 12-19  21-01-10
+        if (newFrom.getTime().getTime() > toDate.getTime()) {
+            newFrom.setTime(fromDate);
+            result = result - 1;
+            newFrom.add(Calendar.MONTH, result);
+        }
 
-        long t1 = newFrom.getTimeInMillis();
-        long t2 = to.getTimeInMillis();
+        long t1 = newFrom.getTime().getTime();
+        long t2 = to.getTime().getTime();
         double days = (t2 - t1) * 1.00 / (24 * 60 * 60 * 1000);
         BigDecimal tmpDays = new BigDecimal(days);
         BigDecimal monthDay = null;
@@ -792,7 +798,7 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
         days = (newFromMaxDay.getTimeInMillis() - t1) * 1.00 / (24 * 60 * 60 * 1000);
         tmpDays = new BigDecimal(days);
         monthDay = new BigDecimal(newFrom.getActualMaximum(Calendar.DAY_OF_MONTH));
-        BigDecimal preRresMonth = tmpDays.divide(monthDay, 2, BigDecimal.ROUND_HALF_UP).add(new BigDecimal(result));
+        BigDecimal preRresMonth = tmpDays.divide(monthDay, 2, BigDecimal.ROUND_HALF_UP);
 
         //下月天数
         days = (t2 - newFromMaxDay.getTimeInMillis()) * 1.00 / (24 * 60 * 60 * 1000);
@@ -822,4 +828,32 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
         return endDate.getTime();
     }
 
+    public static void main(String[] args) {
+        ComputeFeeSMOImpl computeFeeSMO = new ComputeFeeSMOImpl();
+        try {
+            double month = computeFeeSMO.dayCompare(
+
+                    DateUtil.getDateFromString("2020-12-19 00:00:00", DateUtil.DATE_FORMATE_STRING_A),
+                    DateUtil.getDateFromString("2021-1-10 00:00:00", DateUtil.DATE_FORMATE_STRING_A)
+            );
+
+            System.out.println(month);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+    }
+
+//    public static void main(String[] args) {
+//        ComputeFeeSMOImpl computeFeeSMO = new ComputeFeeSMOImpl();
+//        try {
+//            Date startTime = DateUtil.getDateFromString("2020-12-31 00:00:00", DateUtil.DATE_FORMATE_STRING_A);
+//            Date endTime = DateUtil.getDateFromString("2021-1-2 00:00:00", DateUtil.DATE_FORMATE_STRING_A);
+//            double day = (endTime.getTime() - startTime.getTime()) * 1.00 / (24 * 60 * 60 * 1000);
+//
+//            System.out.println(day);
+//
+//        } catch (ParseException e) {
+//            e.printStackTrace();
+//        }
+//    }
 }

+ 58 - 1
service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java

@@ -11,6 +11,7 @@ import com.java110.dto.report.ReportFeeDto;
 import com.java110.dto.report.ReportRoomDto;
 import com.java110.dto.reportFeeMonthStatistics.ReportFeeMonthStatisticsDto;
 import com.java110.intf.report.IGeneratorFeeMonthStatisticsInnerServiceSMO;
+import com.java110.intf.user.IOwnerCarInnerServiceSMO;
 import com.java110.po.reportFeeMonthStatistics.ReportFeeMonthStatisticsPo;
 import com.java110.report.dao.IReportCommunityServiceDao;
 import com.java110.report.dao.IReportFeeMonthStatisticsServiceDao;
@@ -53,6 +54,9 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
     @Autowired
     private IComputeFeeSMO computeFeeSMOImpl;
 
+    @Autowired
+    private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
+
     @Override
     public int generatorData(@RequestBody ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo) {
 
@@ -219,7 +223,7 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
                 && receivedAmount == 0) {
             return;
         }
-        double receivableAmount = getReceivableAmount(tmpReportFeeDto, null, tmpReportCarDto); //应收
+        double receivableAmount = getReceivableAmountByCar(tmpReportFeeDto, null, tmpReportCarDto); //应收
         double oweAmount = getOweAmount(tmpReportFeeDto, receivableAmount, receivedAmount); //欠费
         FeeDto feeDto = BeanConvertUtil.covertBean(tmpReportFeeDto, FeeDto.class);
         OwnerCarDto ownerCarDto = BeanConvertUtil.covertBean(tmpReportCarDto, OwnerCarDto.class);
@@ -404,6 +408,59 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
         return receivedAmount;
     }
 
+    /**
+     * 获取当月应收
+     *
+     * @param tmpReportFeeDto
+     * @return
+     */
+    private double getReceivableAmountByCar(ReportFeeDto tmpReportFeeDto, ReportRoomDto reportRoomDto, ReportCarDto reportCarDto) {
+
+        double feePrice = computeFeeSMOImpl.getReportFeePrice(tmpReportFeeDto, reportRoomDto, reportCarDto);
+        BigDecimal feePriceDec = new BigDecimal(feePrice);
+
+        if (DateUtil.getCurrentDate().getTime() < tmpReportFeeDto.getStartTime().getTime()) {
+            return 0.0;
+        }
+
+        if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeTypeCd())) {
+            return feePrice;
+        }
+        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 = ownerCarDtos.get(0).getEndTime();
+
+        //1.0 费用到期时间和费用结束时间 都不在当月
+        if (!belongCurMonth(tmpReportFeeDto.getEndTime())
+                && !belongCurMonth(endTime)
+                && tmpReportFeeDto.getEndTime().getTime() < DateUtil.getFirstDate().getTime()) {
+            return feePrice;
+        }
+
+        //2.0 费用到期时间 在当月,费用结束时间不在当月
+        if (belongCurMonth(tmpReportFeeDto.getEndTime())
+                && !belongCurMonth(endTime)) {
+            //算天数
+            double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), DateUtil.getNextMonthFirstDate());
+            BigDecimal curDegree = new BigDecimal(month);
+            return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        }
+        //3.0 费用到期时间 不在当月,费用结束时间在当月
+        if (!belongCurMonth(tmpReportFeeDto.getEndTime())
+                && belongCurMonth(endTime)) {
+            //算天数
+            double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), tmpReportFeeDto.getConfigEndTime());
+            BigDecimal curDegree = new BigDecimal(month);
+            return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        }
+        return 0.0;
+    }
+
     /**
      * 获取当月应收
      *