|
|
@@ -1,7 +1,6 @@
|
|
|
package com.kym.service.miniapp.impl;
|
|
|
|
|
|
import com.kym.common.utils.CommUtil;
|
|
|
-import com.kym.entity.admin.RechargeRights;
|
|
|
import com.kym.entity.miniapp.Account;
|
|
|
import com.kym.entity.miniapp.ChargeOrder;
|
|
|
import com.kym.entity.miniapp.UserRechargeRights;
|
|
|
@@ -53,8 +52,8 @@ public class NoDiscountHandle implements DiscountService {
|
|
|
for (UserRechargeRights userRechargeRights : userRechargeRightsList) {
|
|
|
// 权益余额金额足够支付本次订单
|
|
|
if (userRechargeRights.getRightsBalance() >= totalMoney) {
|
|
|
- // 这里还会二次扣减,按比例扣减
|
|
|
- var discountAmountPart = (int) Math.ceil(((userRechargeRights.getDiscountAmount() * totalMoney / (userRechargeRights.getRightsBalance() + 0.00))));
|
|
|
+ // 这里权益的余额还会二次扣减,按订单金额和权益余额的比例扣减
|
|
|
+ var discountAmountPart = (int) Math.ceil(userRechargeRights.getDiscountAmount() * totalMoney / (userRechargeRights.getRightsBalance() + 0.00));
|
|
|
discountAmount += discountAmountPart;
|
|
|
userRechargeRights.setDiscountAmount(userRechargeRights.getDiscountAmount() - discountAmountPart);
|
|
|
userRechargeRights.setRightsBalance(userRechargeRights.getRightsBalance() - totalMoney);
|
|
|
@@ -74,7 +73,12 @@ public class NoDiscountHandle implements DiscountService {
|
|
|
// 更新自然过期的权益余额数据
|
|
|
userRechargeRightsService.updateBatchById(userRechargeRightsUpdates);
|
|
|
// 更新账户优惠金额
|
|
|
- account.setDiscountAmount(account.getDiscountAmount() - discountAmount);
|
|
|
+ var accountDiscountAmount = account.getDiscountAmount() - discountAmount;
|
|
|
+ if (accountDiscountAmount < 0) {
|
|
|
+ accountDiscountAmount = 0;
|
|
|
+ log.error("异常数据:账户优惠余额为负数,进行置零");
|
|
|
+ }
|
|
|
+ account.setDiscountAmount(accountDiscountAmount);
|
|
|
}
|
|
|
|
|
|
|