ソースを参照

fix 油管按比例退余额

zoujiajian 8 ヶ月 前
コミット
14d3cd72c3

+ 17 - 7
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -2553,22 +2553,26 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		}
 		//剩余几个月
 		Long remainMonths = DateUtil.betweenMonth(now, expiryTime, false) + 1;
+		//剩余几天
+		Long remainDays = DateUtil.betweenDay(now, expiryTime, false) + 1;
 		BigDecimal refundBalance = BigDecimal.ZERO;
 		BigDecimal refundMoney = BigDecimal.ZERO;
 		//订单金额
 		BigDecimal money = orderDon.getMoney();
 		BigDecimal balance = Optional.ofNullable(orderDon.getBalance()).orElse(BigDecimal.ZERO);
 		BigDecimal orderTotalMoney = money.add(balance);
+		//兑换码订单
+		if (orderTotalMoney.compareTo(BigDecimal.ZERO) == 0) {
+			orderTotalMoney = sku.getPrice();
+		}
 		BigDecimal orderRateMoney = orderTotalMoney;
+		//总天数
+		Integer totalDays = 365;
 		//2年
 		if ((sku.getDays() != null && sku.getDays() == 730) || (sku.getMonths() != null && sku.getMonths() == 24)) {
 			if (remainMonths > 12) {
-				//兑换码订单
-				if (orderTotalMoney.compareTo(BigDecimal.ZERO) == 0) {
-					orderTotalMoney = sku.getPrice();
-				}
-				BigDecimal totalRefundMoney = orderTotalMoney.divide(BigDecimal.valueOf(2), RoundingMode.DOWN);
-				//计算比例的订单金额
+				BigDecimal totalRefundMoney = orderTotalMoney.divide(BigDecimal.valueOf(2), 0, RoundingMode.DOWN);
+				//计算比例的订单金额 超过一年后剩余可退金额
 				orderRateMoney = totalRefundMoney;
 				if (money.compareTo(BigDecimal.ZERO) == 0) {
 					refundBalance = refundBalance.add(totalRefundMoney);
@@ -2580,9 +2584,15 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 					}
 				}
 				remainMonths = remainMonths - 12;
+				remainDays = remainDays - 365;
+			} else {
+				totalDays = totalDays * 2;
 			}
 		}
-		BigDecimal monthRateRefundBalance = BigDecimal.valueOf(remainMonths).multiply(orderRateMoney).divide(BigDecimal.valueOf(12), RoundingMode.DOWN);
+		if (relationView.getIsFrozen()) {
+			remainDays = Long.valueOf(relationView.getReservedDays());
+		}
+		BigDecimal monthRateRefundBalance = BigDecimal.valueOf(remainDays).multiply(orderRateMoney).divide(BigDecimal.valueOf(totalDays), 0, RoundingMode.DOWN);
 		//剩余月份限制最高可退余额
 		BigDecimal remainMonthsRefundBalance;
 		if (remainMonths >= 1 && remainMonths <= 6) {