mall
mall copied to clipboard
优惠计算方法 calcPerCouponAmount 是否有问题
private void calcPerCouponAmount(List<OmsOrderItem> orderItemList, SmsCoupon coupon) { BigDecimal totalAmount = calcTotalAmount(orderItemList); for (OmsOrderItem orderItem : orderItemList) { //(商品价格/可用商品总价)*优惠券面额 BigDecimal couponAmount = orderItem.getProductPrice().divide(totalAmount, 3, RoundingMode.HALF_EVEN).multiply(coupon.getAmount()); orderItem.setCouponAmount(couponAmount);
在calcTotalAmount中计算总价时,算的是商品单价*商品数量 得出所有总价, 那在计算优惠分摊的时候, 是不是也需要乘以商品数量。
优惠金额 = (商品金额 * 商品数量) / 总金额 * 优惠券金额