|
|
@@ -50,17 +50,21 @@ public class NoDiscountHandle implements DiscountService {
|
|
|
while (totalMoney > 0) {
|
|
|
for (UserRechargeRights userRechargeRights : userRechargeRightsList) {
|
|
|
// 权益余额金额足够支付本次订单
|
|
|
- if (totalMoney > userRechargeRights.getRightsBalance()) {
|
|
|
- totalMoney = 0;
|
|
|
- userRechargeRights.setRightsBalance(0);
|
|
|
+ if (userRechargeRights.getRightsBalance() >= totalMoney) {
|
|
|
+ // 这里还会二次扣减,按比例扣减
|
|
|
+ var discountAmountPart = (int) Math.ceil(((userRechargeRights.getDiscountAmount() * totalMoney / (userRechargeRights.getRightsBalance() + 0.00))));
|
|
|
+ discountAmount += discountAmountPart;
|
|
|
+ userRechargeRights.setDiscountAmount(userRechargeRights.getDiscountAmount() - discountAmountPart);
|
|
|
+ userRechargeRights.setRightsBalance(userRechargeRights.getRightsBalance() - totalMoney);
|
|
|
userRechargeRightsUpdates.add(userRechargeRights);
|
|
|
- discountAmount += userRechargeRights.getDiscountAmount();
|
|
|
+ totalMoney = 0;
|
|
|
break;
|
|
|
} else {
|
|
|
+ discountAmount += userRechargeRights.getDiscountAmount();
|
|
|
totalMoney -= userRechargeRights.getRightsBalance();
|
|
|
- userRechargeRights.setRightsBalance(userRechargeRights.getRightsBalance() - totalMoney);
|
|
|
+ userRechargeRights.setDiscountAmount(0);
|
|
|
+ userRechargeRights.setRightsBalance(0);
|
|
|
userRechargeRightsUpdates.add(userRechargeRights);
|
|
|
- discountAmount += userRechargeRights.getDiscountAmount();
|
|
|
}
|
|
|
}
|
|
|
|