fix: 比例计算根据可退金额计算

This commit is contained in:
张松 2024-11-22 15:26:06 +08:00
parent 389e852f27
commit 77c895dbb2
1 changed files with 10 additions and 1 deletions

View File

@ -2821,7 +2821,12 @@ public class TbShopTableServiceImpl implements TbShopTableService {
if (oldOrderInfo.getRefundAmount() == null) {
oldOrderInfo.setRefundAmount(BigDecimal.ZERO);
}
returnAmount = returnAmount.add(oldOrderInfo.getPayAmount().subtract(oldOrderInfo.getRefundAmount()).multiply(ratio));
if (ratio.compareTo(BigDecimal.ONE) == 0) {
returnAmount = oldOrderInfo.getPayAmount().subtract(oldOrderInfo.getRefundAmount());
}else {
returnAmount = returnAmount.add(oldOrderInfo.getPayAmount().subtract(oldOrderInfo.getRefundAmount()).multiply(ratio));
}
saleAmount = saleAmount.add(orderDetail.getPrice());
packAMount = packAMount.add(orderDetail.getPackAmount()
.divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP)
@ -2838,6 +2843,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
.divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP)
.multiply(returnNum)).setScale(2, RoundingMode.HALF_UP);
}
returnAmount = returnAmount.setScale(2, RoundingMode.DOWN);
orderDetail.setNum(returnNum);
orderDetail.setPriceAmount(currentDetailAMount);
@ -2904,6 +2910,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
totalAmount = totalAmount.add(item.getPriceAmount());
}
}
if (orderDetail.getPriceAmount().compareTo(totalAmount) == 0) {
return BigDecimal.ONE;
}
return orderDetail.getPriceAmount().divide(totalAmount, 10, RoundingMode.DOWN)
.divide(orderDetail.getNum(), 10, RoundingMode.DOWN).multiply(returnNum).setScale(2, RoundingMode.DOWN);