防止电费大于总金额,服务费出现负数

This commit is contained in:
yuyang 2022-03-04 10:40:38 +08:00
parent 67466d5ba0
commit 37a47ad193

View File

@ -308,8 +308,14 @@ public class XhpcPileOrderController extends BaseController {
powerPrice=powerPrice.add(multiply);
}
powerPrice =powerPrice.setScale(2,BigDecimal.ROUND_HALF_UP);
//总服务费
BigDecimal servicePrice = money.subtract(powerPrice);
//防止出现负数
if(powerPrice.compareTo(money)>0){
powerPrice =money;
servicePrice = money.subtract(powerPrice);
}
//剩余的电费
BigDecimal surplusPowerPrice = powerPrice;
//剩余的服务费