Commit a0fc7d06 authored by Junling Bu's avatar Junling Bu
Browse files

fix[litemall-wx]: 大额优惠券导致订单费用为负

parent 92eaf10c
......@@ -318,7 +318,7 @@ public class WxOrderService {
BigDecimal integralPrice = new BigDecimal(0.00);
// 订单费用
BigDecimal orderTotalPrice = checkedGoodsPrice.add(freightPrice).subtract(couponPrice);
BigDecimal orderTotalPrice = checkedGoodsPrice.add(freightPrice).subtract(couponPrice).max(new BigDecimal(0.00));
// 最终支付费用
BigDecimal actualPrice = orderTotalPrice.subtract(integralPrice);
......
......@@ -495,7 +495,8 @@ public class WxCartController {
BigDecimal integralPrice = new BigDecimal(0.00);
// 订单费用
BigDecimal orderTotalPrice = checkedGoodsPrice.add(freightPrice).subtract(couponPrice);
BigDecimal orderTotalPrice = checkedGoodsPrice.add(freightPrice).subtract(couponPrice).max(new BigDecimal(0.00));
BigDecimal actualPrice = orderTotalPrice.subtract(integralPrice);
Map<String, Object> data = new HashMap<>();
......
package org.linlinjava.litemall.wx;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.math.BigDecimal;
@RunWith(SpringJUnit4ClassRunner.class)
public class BigDecimalTest {
@Test
public void test() {
BigDecimal a = new BigDecimal(0);
BigDecimal b = new BigDecimal(1);
BigDecimal c = a.subtract(b);
BigDecimal d = c.max(new BigDecimal(0));
System.out.println(c);
System.out.println(d);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment