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

+ 3 - 0
service-api/src/main/java/com/java110/api/listener/fee/ListFeeListener.java

@@ -279,6 +279,9 @@ public class ListFeeListener extends AbstractServiceApiListener {
         Calendar to = Calendar.getInstance();
         Calendar to = Calendar.getInstance();
         to.setTime(toDate);
         to.setTime(toDate);
         int result = to.get(Calendar.MONTH) - from.get(Calendar.MONTH);
         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();
         Calendar newFrom = Calendar.getInstance();
         newFrom.setTime(fromDate);
         newFrom.setTime(fromDate);
         newFrom.add(Calendar.MONTH, result);
         newFrom.add(Calendar.MONTH, result);

+ 11 - 3
service-job/src/main/java/com/java110/job/task/fee/GenerateBillProTemplate.java

@@ -321,7 +321,7 @@ public class GenerateBillProTemplate extends TaskSystemQuartz {
                 round = Math.floor(mulMonth / paymentCycle);
                 round = Math.floor(mulMonth / paymentCycle);
             }
             }
             // 轮数 * 周期 * 30 + 开始时间 = 目标 到期时间
             // 轮数 * 周期 * 30 + 开始时间 = 目标 到期时间
-            targetEndDate = getTargetEndTime(round * paymentCycle , startDate);
+            targetEndDate = getTargetEndTime(round * paymentCycle, startDate);
             //费用 快结束了
             //费用 快结束了
             if (feeDto.getConfigEndTime().getTime() < targetEndDate.getTime()) {
             if (feeDto.getConfigEndTime().getTime() < targetEndDate.getTime()) {
                 targetEndDate = feeDto.getConfigEndTime();
                 targetEndDate = feeDto.getConfigEndTime();
@@ -571,16 +571,24 @@ public class GenerateBillProTemplate extends TaskSystemQuartz {
         from.setTime(fromDate);
         from.setTime(fromDate);
         Calendar to = Calendar.getInstance();
         Calendar to = Calendar.getInstance();
         to.setTime(toDate);
         to.setTime(toDate);
+        int result = to.get(Calendar.MONTH) - from.get(Calendar.MONTH);
+        int month = (to.get(Calendar.YEAR) - from.get(Calendar.YEAR)) * 12;
 
 
-        long t1 = from.getTimeInMillis();
+        result = result + month;
+        Calendar newFrom = Calendar.getInstance();
+        newFrom.setTime(fromDate);
+        newFrom.add(Calendar.MONTH, result);
+
+        long t1 = newFrom.getTimeInMillis();
         long t2 = to.getTimeInMillis();
         long t2 = to.getTimeInMillis();
         long days = (t2 - t1) / (24 * 60 * 60 * 1000);
         long days = (t2 - t1) / (24 * 60 * 60 * 1000);
 
 
         BigDecimal tmpDays = new BigDecimal(days);
         BigDecimal tmpDays = new BigDecimal(days);
         BigDecimal monthDay = new BigDecimal(30);
         BigDecimal monthDay = new BigDecimal(30);
 
 
-        return tmpDays.divide(monthDay, 2, RoundingMode.HALF_UP).doubleValue();
+        return tmpDays.divide(monthDay, 2, RoundingMode.HALF_UP).doubleValue() + result;
     }
     }
 
 
 
 
+
 }
 }