java 用BigDecimal计算商品单价乘以折扣价

商品单价价格是单位是(分),用户下单金额=商品单价*折扣  代码如下

Integer discount = 5 折扣五折

Integer orderPrice = 1000  单位分

BigDecimal bigDecimal = new BigDecimal(discount * 0.1 + "");
BigDecimal multiply = bigDecimal.multiply(new BigDecimal(orderPrice));
orderPrice = multiply.setScale(0, BigDecimal.ROUND_HALF_UP).intValue();

 

posted @ 2019-07-31 15:54  阿若蜜意  阅读(2635)  评论(0编辑  收藏  举报