|
|
@@ -274,37 +274,48 @@ public class CalculateCommissionUtils {
|
|
|
CommissionValues values = calculateCommonValues(grade, userId, rules,type,userId3,userId4);
|
|
|
BigDecimal numberBD = values.number;
|
|
|
BigDecimal sumPremium = values.sumPremium;
|
|
|
+ BigDecimal grBf = values.grBf;
|
|
|
for (PartnerRulesRatio ratio : sortedList) {
|
|
|
int allSatisfied = ratio.getAllSatisfied();
|
|
|
List<PartnerRatio> ratioList = ratio.getPartnerRatioList();
|
|
|
if (CollectionUtil.isEmpty(ratioList)) continue;
|
|
|
BigDecimal min = ratioList.get(0).getMin();
|
|
|
BigDecimal min1 = ratioList.get(1).getMin();
|
|
|
+ BigDecimal grb = ratioList.get(2).getMin();
|
|
|
boolean ry = ratioList.get(0).isRy();
|
|
|
boolean bf = ratioList.get(1).isBf();
|
|
|
- if (ry && bf) {
|
|
|
+ boolean gr = ratioList.get(2).isGr();
|
|
|
+ if (ry && bf && gr) {
|
|
|
if (allSatisfied == 1) {
|
|
|
- if (numberBD.compareTo(min) >= 0 && sumPremium.compareTo(min1) >= 0) {
|
|
|
- return "邀请人达" + min + "人,累计保费达" + min1 + "元";
|
|
|
+ if (numberBD.compareTo(min) >= 0 && sumPremium.compareTo(min1) >= 0 && grBf.compareTo(grb) >= 0) {
|
|
|
+ return "邀请人达" + min + "人,累计保费达" + min1 + "元" + ",个人保费达" + grb + "元";
|
|
|
}
|
|
|
} else {
|
|
|
if (numberBD.compareTo(min) >= 0) {
|
|
|
return "邀请人达" + min + "人";
|
|
|
}else if(sumPremium.compareTo(min1) >= 0){
|
|
|
return "累计保费达" + min1 + "元";
|
|
|
+ }else if(grBf.compareTo(grb) >= 0){
|
|
|
+ return "个人保费达" + grb + "元";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- }else if (ry && !bf){
|
|
|
+ }else if (ry && gr && !bf ){
|
|
|
if (allSatisfied != 1) {
|
|
|
- if (numberBD.compareTo(min) >= 0) {
|
|
|
- return "邀请人达" + min + "人";
|
|
|
+ if (numberBD.compareTo(min) >= 0 && grBf.compareTo(grb) >= 0) {
|
|
|
+ return "邀请人达" + min + "人" + ",个人保费达" + grb + "元";
|
|
|
}
|
|
|
}
|
|
|
- }else if (!ry && bf){
|
|
|
+ }else if (!ry && gr && bf){
|
|
|
if (allSatisfied != 1) {
|
|
|
- if (sumPremium.compareTo(min1) >= 0) {
|
|
|
- return "累计保费达" + min1 + "元";
|
|
|
+ if (sumPremium.compareTo(min1) >= 0 && grBf.compareTo(grb) >= 0) {
|
|
|
+ return "累计保费达" + min1 + "元" + ",个人保费达" + grb + "元";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if (ry && !gr && bf){
|
|
|
+ if (allSatisfied != 1) {
|
|
|
+ if (numberBD.compareTo(min) >= 0 && sumPremium.compareTo(min1) >= 0) {
|
|
|
+ return "邀请人达" + min + "人" + ",累计保费达" + min1 + "元";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -348,12 +359,12 @@ public class CalculateCommissionUtils {
|
|
|
return period;
|
|
|
}
|
|
|
}
|
|
|
- if (!isWithinDays(assessmentTime, rules.getFixedDays())) {
|
|
|
+ if (!PartnerDateUtils.isWithinDays(assessmentTime, rules.getFixedDays())) {
|
|
|
updateAssessmentTimeRecursively(assessmentTime,rules.getFixedDays(),userId,grade );
|
|
|
assessmentTime = partnerUserMapper.selectAssessmentTime(userId, grade);
|
|
|
}
|
|
|
period.setStartDate(dateFormat.format(assessmentTime));
|
|
|
- period.setEndDate(dateFormat.format(addDays(assessmentTime, rules.getFixedDays())));
|
|
|
+ period.setEndDate(dateFormat.format(PartnerDateUtils.addDays(assessmentTime, rules.getFixedDays())));
|
|
|
} else if (StringUtils.equals("3", rules.getValidityPeriod())) {
|
|
|
Date fixedCycle = partnerUserMapper.selectFixedCycleTime(userId, grade);
|
|
|
if (fixedCycle == null) {
|
|
|
@@ -373,46 +384,14 @@ public class CalculateCommissionUtils {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static boolean isWithinDays(Date date, int days) {
|
|
|
- LocalDate targetDate = date.toInstant()
|
|
|
- .atZone(ZoneId.systemDefault())
|
|
|
- .toLocalDate();
|
|
|
- return Math.abs(ChronoUnit.DAYS.between(LocalDate.now(), targetDate)) <= days;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
private static void updateAssessmentTimeRecursively(Date assessmentTime, int days, String userId,String grade) {
|
|
|
- Date newDate = addDaysToday(assessmentTime, days);
|
|
|
- while (!isWithinDays(newDate, days)) {
|
|
|
- newDate = addDaysToday(newDate, days);
|
|
|
+ Date newDate = PartnerDateUtils.addDaysToday(assessmentTime, days);
|
|
|
+ while (!PartnerDateUtils.isWithinDays(newDate, days)) {
|
|
|
+ newDate = PartnerDateUtils.addDaysToday(newDate, days);
|
|
|
}
|
|
|
partnerUserMapper.updateAssessmentTimeByDate(userId,newDate,grade);
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static Date addDaysToday(Date date, int days) {
|
|
|
- LocalDateTime localDate = date.toInstant()
|
|
|
- .atZone(ZoneId.systemDefault())
|
|
|
- .toLocalDateTime();
|
|
|
- LocalDateTime newLocalDate = localDate.plusDays(days);
|
|
|
- LocalDateTime newDateTime = newLocalDate.withHour(0)
|
|
|
- .withMinute(0)
|
|
|
- .withSecond(0)
|
|
|
- .withNano(0);
|
|
|
- return Date.from(newDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
|
|
- }
|
|
|
-
|
|
|
- public static Date addDays(Date date, int days) {
|
|
|
- LocalDateTime localDate = date.toInstant()
|
|
|
- .atZone(ZoneId.systemDefault())
|
|
|
- .toLocalDateTime();
|
|
|
- LocalDateTime newLocalDate = localDate.plusDays(days);
|
|
|
- LocalDateTime endOfDay = newLocalDate.withHour(23)
|
|
|
- .withMinute(59)
|
|
|
- .withSecond(59)
|
|
|
- .withNano(999_999_999);
|
|
|
- return Date.from(endOfDay.atZone(ZoneId.systemDefault()).toInstant());
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
}
|