|
|
@@ -407,8 +407,8 @@ public class ParkingWalletFeeService {
|
|
|
|
|
|
// 本次预计服务费 = 采购数量 * 实际计费单价,金额保留2位小数;开关关闭时固定返回0。
|
|
|
BigDecimal estimatedServiceFee = chargeStrategySwitchOpen
|
|
|
- ? param.getPurchaseQuantity().multiply(currentStrategyUnitFee).setScale(2, RoundingMode.HALF_UP)
|
|
|
- : ZERO_AMOUNT;
|
|
|
+ ? formatMoney(param.getPurchaseQuantity().multiply(currentStrategyUnitFee))
|
|
|
+ : formatMoney(ZERO_AMOUNT);
|
|
|
log.info("服务费预估金额计算完成,企业id:{}, 采购数量:{}, 实际计费单价:{}, 预计服务费:{}",
|
|
|
entId, param.getPurchaseQuantity(), currentStrategyUnitFee, estimatedServiceFee);
|
|
|
|
|
|
@@ -418,13 +418,23 @@ public class ParkingWalletFeeService {
|
|
|
entId, param.getPurchaseQuantity(), serviceFeeBalance, estimatedServiceFee, maxPurchaseQuantity);
|
|
|
|
|
|
ParkingWalletFeeEstimateResp resp = new ParkingWalletFeeEstimateResp();
|
|
|
- resp.setServiceFeeBalance(serviceFeeBalance);
|
|
|
+ resp.setServiceFeeBalance(formatMoney(serviceFeeBalance));
|
|
|
resp.setEstimatedServiceFee(estimatedServiceFee);
|
|
|
resp.setMaxPurchaseQuantity(maxPurchaseQuantity);
|
|
|
log.info("服务费预估结束,企业id:{}, 响应结果:{}", entId, resp);
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 金额统一保留两位小数,确保 0 金额返回 0.00。
|
|
|
+ *
|
|
|
+ * @param amount 金额
|
|
|
+ * @return 两位小数金额
|
|
|
+ */
|
|
|
+ private BigDecimal formatMoney(BigDecimal amount) {
|
|
|
+ return Optional.ofNullable(amount).orElse(ZERO_AMOUNT).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 贸易订单下单应用收费策略并冻结服务费
|