|
|
@@ -413,17 +413,16 @@ public class OrderInfoService {
|
|
|
// 分销
|
|
|
Package aPackage = packageRepo.findById(orderInfo.getPackageId()).orElseThrow(new BusinessException("无记录"));
|
|
|
// 售价-结算价
|
|
|
- int balance;
|
|
|
+ BigDecimal balance;
|
|
|
if (ObjectUtil.isNotNull(orderInfo.getStockId())) {
|
|
|
Stock stock = stockRepo.findById(orderInfo.getStockId()).orElseThrow(new BusinessException("无规格"));
|
|
|
- balance = stock.getPrice().compareTo(stock.getSettlementPrice());
|
|
|
+ balance = stock.getPrice().subtract(stock.getSettlementPrice());
|
|
|
} else {
|
|
|
- balance = aPackage.getAmount().compareTo(aPackage.getSettlementPrice());
|
|
|
+ balance = aPackage.getAmount().subtract(aPackage.getSettlementPrice());
|
|
|
}
|
|
|
- if (balance <= 0) {
|
|
|
+ if (BigDecimal.ZERO.compareTo(balance) >= 0) {
|
|
|
return;
|
|
|
}
|
|
|
- BigDecimal balanceAmount = BigDecimal.valueOf(balance);
|
|
|
|
|
|
Long userId = orderInfo.getUserId();
|
|
|
User user = userRepo.findById(userId).orElseThrow(new BusinessException("无用户"));
|
|
|
@@ -435,14 +434,14 @@ public class OrderInfoService {
|
|
|
if (ObjectUtil.isNull(one)) {
|
|
|
return;
|
|
|
}
|
|
|
- this.getDistribution(orderInfo, one, 1, balanceAmount, aPackage, TransactionType.PROMOTE);
|
|
|
+ this.getDistribution(orderInfo, one, 1, balance, aPackage, TransactionType.PROMOTE);
|
|
|
} else {
|
|
|
- this.getDistribution(orderInfo, one, 1, balanceAmount, aPackage, TransactionType.SELF_PURCHASE);
|
|
|
+ this.getDistribution(orderInfo, one, 1, balance, aPackage, TransactionType.SELF_PURCHASE);
|
|
|
}
|
|
|
|
|
|
two = this.getParent(one);
|
|
|
if (ObjectUtil.isNotNull(two)) {
|
|
|
- this.getDistribution(orderInfo, two, 2, balanceAmount, aPackage, TransactionType.CHILD_PROMOTE);
|
|
|
+ this.getDistribution(orderInfo, two, 2, balance, aPackage, TransactionType.CHILD_PROMOTE);
|
|
|
}
|
|
|
|
|
|
}
|