|
|
@@ -47,25 +47,23 @@ public class NoDiscountHandle implements DiscountService {
|
|
|
.list();
|
|
|
|
|
|
if (CommUtil.isNotEmptyAndNull(userRechargeRightsList)) {
|
|
|
- while (totalMoney > 0) {
|
|
|
- for (UserRechargeRights userRechargeRights : userRechargeRightsList) {
|
|
|
- // 权益余额金额足够支付本次订单
|
|
|
- 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);
|
|
|
- totalMoney = 0;
|
|
|
- break;
|
|
|
- } else {
|
|
|
- discountAmount += userRechargeRights.getDiscountAmount();
|
|
|
- totalMoney -= userRechargeRights.getRightsBalance();
|
|
|
- userRechargeRights.setDiscountAmount(0);
|
|
|
- userRechargeRights.setRightsBalance(0);
|
|
|
- userRechargeRightsUpdates.add(userRechargeRights);
|
|
|
- }
|
|
|
+ for (UserRechargeRights userRechargeRights : userRechargeRightsList) {
|
|
|
+ // 权益余额金额足够支付本次订单
|
|
|
+ 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);
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ // 权益余额不足以支付本次订单,所以权益本次支付后失效
|
|
|
+ discountAmount += userRechargeRights.getDiscountAmount();
|
|
|
+ totalMoney -= userRechargeRights.getRightsBalance();
|
|
|
+ userRechargeRights.setDiscountAmount(0);
|
|
|
+ userRechargeRights.setRightsBalance(0);
|
|
|
+ userRechargeRightsUpdates.add(userRechargeRights);
|
|
|
}
|
|
|
|
|
|
}
|