|
@@ -1,5 +1,4 @@
|
|
|
package com.awspaas.user.apps.donenow_ivt.utils;
|
|
package com.awspaas.user.apps.donenow_ivt.utils;
|
|
|
-
|
|
|
|
|
import com.actionsoft.sdk.local.SDK;
|
|
import com.actionsoft.sdk.local.SDK;
|
|
|
import com.actionsoft.sdk.local.api.Logger;
|
|
import com.actionsoft.sdk.local.api.Logger;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -29,7 +28,7 @@ public class PeriodCalculationUtil {
|
|
|
public static final String PERIOD_TYPE_HALFYEAR = "612"; // 按半年支付
|
|
public static final String PERIOD_TYPE_HALFYEAR = "612"; // 按半年支付
|
|
|
public static final String PERIOD_TYPE_YEAR = "613"; // 按年支付
|
|
public static final String PERIOD_TYPE_YEAR = "613"; // 按年支付
|
|
|
|
|
|
|
|
- public static final String PERIOD_TYPE_TWOYEAR = "614"; // 按2年支付
|
|
|
|
|
|
|
+ public static final String PERIOD_TYPE_TWOYEAR = "10614"; // 按2年支付
|
|
|
|
|
|
|
|
// 日期格式化器(复用避免重复创建)
|
|
// 日期格式化器(复用避免重复创建)
|
|
|
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
@@ -65,7 +64,7 @@ public class PeriodCalculationUtil {
|
|
|
* 613 按年支付 4592 开通日期后的完整一年 isNaturalMonth=false CALC_METHOD_1STYEAR=4637 userMonthDay=false 或者 CALC_METHOD_1STYEAR=4638 userMonthDay=true monthDayType=0 startMonth=0
|
|
* 613 按年支付 4592 开通日期后的完整一年 isNaturalMonth=false CALC_METHOD_1STYEAR=4637 userMonthDay=false 或者 CALC_METHOD_1STYEAR=4638 userMonthDay=true monthDayType=0 startMonth=0
|
|
|
*
|
|
*
|
|
|
*
|
|
*
|
|
|
- * 614 按两年付 4603/4604/4605
|
|
|
|
|
|
|
+ * 614 按两年付 14603/14604/14605
|
|
|
*
|
|
*
|
|
|
*CALC_METHOD_1STYEAR
|
|
*CALC_METHOD_1STYEAR
|
|
|
* 4637 (拆机时实际计费天数/当年天数(如365))*年费用
|
|
* 4637 (拆机时实际计费天数/当年天数(如365))*年费用
|
|
@@ -120,7 +119,7 @@ public class PeriodCalculationUtil {
|
|
|
case "4596":
|
|
case "4596":
|
|
|
case "4593":
|
|
case "4593":
|
|
|
case "4590":
|
|
case "4590":
|
|
|
- case "4603":
|
|
|
|
|
|
|
+ case "14603":
|
|
|
monthDayType = -1;
|
|
monthDayType = -1;
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
@@ -128,7 +127,7 @@ public class PeriodCalculationUtil {
|
|
|
case "4597":
|
|
case "4597":
|
|
|
case "4594":
|
|
case "4594":
|
|
|
case "4591":
|
|
case "4591":
|
|
|
- case "4604":
|
|
|
|
|
|
|
+ case "14604":
|
|
|
monthDayType = -2;
|
|
monthDayType = -2;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -275,11 +274,11 @@ public class PeriodCalculationUtil {
|
|
|
|
|
|
|
|
case PERIOD_TYPE_TWOYEAR://2年
|
|
case PERIOD_TYPE_TWOYEAR://2年
|
|
|
if (isNaturalMonth) {
|
|
if (isNaturalMonth) {
|
|
|
- currLastDay = getNaturalYearLastDay(periodBeginDate);
|
|
|
|
|
- totalPeriodDays = periodBeginDate.lengthOfYear();
|
|
|
|
|
|
|
+ currLastDay = getNaturalTwoYearLastDay(periodBeginDate);
|
|
|
|
|
+ totalPeriodDays = periodBeginDate.lengthOfYear()+currLastDay.lengthOfYear();
|
|
|
} else {
|
|
} else {
|
|
|
currLastDay = getActualTWOYearFirstEndDay(contractStartDate, periodBeginDate, periodEndDate);
|
|
currLastDay = getActualTWOYearFirstEndDay(contractStartDate, periodBeginDate, periodEndDate);
|
|
|
- totalPeriodDays = getActualYearTotalDays(contractStartDate, periodBeginDate);
|
|
|
|
|
|
|
+ totalPeriodDays = getActualTwoYearTotalDays(contractStartDate, periodBeginDate);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
@@ -288,8 +287,10 @@ public class PeriodCalculationUtil {
|
|
|
|
|
|
|
|
// 3.2 处理首个周期
|
|
// 3.2 处理首个周期
|
|
|
if (currLastDay != null) {
|
|
if (currLastDay != null) {
|
|
|
|
|
+
|
|
|
if(currLastDay.isAfter(periodEndDate))
|
|
if(currLastDay.isAfter(periodEndDate))
|
|
|
currLastDay=periodEndDate;
|
|
currLastDay=periodEndDate;
|
|
|
|
|
+
|
|
|
if (userMonthDay) {
|
|
if (userMonthDay) {
|
|
|
Period period = new Period();
|
|
Period period = new Period();
|
|
|
period.setPeriodBeginDate(periodBeginDate);
|
|
period.setPeriodBeginDate(periodBeginDate);
|
|
@@ -546,6 +547,12 @@ public class PeriodCalculationUtil {
|
|
|
: periodBeginDate.plusYears(1).minusDays(1);
|
|
: periodBeginDate.plusYears(1).minusDays(1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static LocalDate getNaturalTwoYearLastDay(LocalDate periodBeginDate) {
|
|
|
|
|
+ return (periodBeginDate.getDayOfMonth() != 1 || periodBeginDate.getMonthValue() != 1)
|
|
|
|
|
+ ? LocalDate.of(periodBeginDate.getYear()+1, 12, 31)
|
|
|
|
|
+ : periodBeginDate.plusYears(2).minusDays(1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// ------------------------------ 私有工具方法:实际月模式计算 ------------------------------
|
|
// ------------------------------ 私有工具方法:实际月模式计算 ------------------------------
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -714,6 +721,14 @@ public class PeriodCalculationUtil {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static int getActualTwoYearTotalDays(LocalDate contractStartDate, LocalDate periodBeginDate) {
|
|
|
|
|
+ if (contractStartDate.isAfter(periodBeginDate)) {
|
|
|
|
|
+ return getPeriodDays(contractStartDate.minusMonths(24), contractStartDate.minusDays(1));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return getPeriodDays(contractStartDate, contractStartDate.plusMonths(24).minusDays(1));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// ------------------------------ 私有工具方法:通用计算 ------------------------------
|
|
// ------------------------------ 私有工具方法:通用计算 ------------------------------
|
|
|
|
|
|
|
|
/**
|
|
/**
|