String amount1 = orderDTO.getAmount();
BigDecimal amount2 = new BigDecimal(amount1);
//支付金额是四舍五入,所以订单表里的金额四舍五入后进行比较
amount2 = amount2.setScale(2, BigDecimal.ROUND_HALF_UP);
if (!(new BigDecimal(amount).compareTo(amount2) == 0)) {
return false;
}
BigDecimal使用
最新推荐文章于 2023-04-19 22:41:46 发布