|
|
@@ -2559,6 +2559,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
BigDecimal money = orderDon.getMoney();
|
|
|
BigDecimal balance = Optional.ofNullable(orderDon.getBalance()).orElse(BigDecimal.ZERO);
|
|
|
BigDecimal orderTotalMoney = money.add(balance);
|
|
|
+ BigDecimal orderRateMoney = orderTotalMoney;
|
|
|
//2年
|
|
|
if ((sku.getDays() != null && sku.getDays() == 730) || (sku.getMonths() != null && sku.getMonths() == 24)) {
|
|
|
if (remainMonths > 12) {
|
|
|
@@ -2567,6 +2568,8 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
orderTotalMoney = sku.getPrice();
|
|
|
}
|
|
|
BigDecimal totalRefundMoney = orderTotalMoney.divide(BigDecimal.valueOf(2), RoundingMode.DOWN);
|
|
|
+ //计算比例的订单金额
|
|
|
+ orderRateMoney = totalRefundMoney;
|
|
|
if (money.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
refundBalance = refundBalance.add(totalRefundMoney);
|
|
|
} else {
|
|
|
@@ -2579,16 +2582,24 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
remainMonths = remainMonths - 12;
|
|
|
}
|
|
|
}
|
|
|
+ BigDecimal monthRateRefundBalance = BigDecimal.valueOf(remainMonths).multiply(orderRateMoney).divide(BigDecimal.valueOf(12), RoundingMode.DOWN);
|
|
|
+ //剩余月份限制最高可退余额
|
|
|
+ BigDecimal remainMonthsRefundBalance;
|
|
|
if (remainMonths >= 1 && remainMonths <= 6) {
|
|
|
//1-6月买的 退100余额
|
|
|
- refundBalance = refundBalance.add(BigDecimal.valueOf(10000));
|
|
|
+ remainMonthsRefundBalance = BigDecimal.valueOf(10000);
|
|
|
} else if (remainMonths >= 7 && remainMonths <= 11) {
|
|
|
//7-11月买的 退150余额
|
|
|
- refundBalance = refundBalance.add(BigDecimal.valueOf(15000));
|
|
|
+ remainMonthsRefundBalance = BigDecimal.valueOf(15000);
|
|
|
} else {
|
|
|
//12月买的 退200余额
|
|
|
- refundBalance = refundBalance.add(BigDecimal.valueOf(20000));
|
|
|
+ remainMonthsRefundBalance = BigDecimal.valueOf(20000);
|
|
|
}
|
|
|
+ //按比例退款余额超过对应剩余月份可退余额限制
|
|
|
+ if (monthRateRefundBalance.compareTo(remainMonthsRefundBalance) > 0) {
|
|
|
+ monthRateRefundBalance = remainMonthsRefundBalance;
|
|
|
+ }
|
|
|
+ refundBalance = refundBalance.add(monthRateRefundBalance);
|
|
|
//超过订单金额 计算剩余的余额 排除兑换码
|
|
|
if (orderTotalMoney.compareTo(BigDecimal.ZERO) > 0 && refundMoney.add(refundBalance).compareTo(orderTotalMoney) > 0) {
|
|
|
refundBalance = orderTotalMoney.subtract(refundMoney);
|