diff --git a/order/src/main/java/com/order/controller/OrderController.java b/order/src/main/java/com/order/controller/OrderController.java index 615426f..370e62b 100644 --- a/order/src/main/java/com/order/controller/OrderController.java +++ b/order/src/main/java/com/order/controller/OrderController.java @@ -30,6 +30,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -95,6 +96,10 @@ public class OrderController { } } + public static void main(String[] args) { + System.out.println(new BigDecimal("500").compareTo(new BigDecimal("0"))); + } + @RequestMapping(value="/cancel",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "取消订单") diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java index 08ce9e1..d0ad445 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java @@ -195,8 +195,9 @@ public class BsOrderServiceImpl implements BsOrderService { } /************ 交易优惠 **************/ - order.setPayRealPrice(totalPrice.subtract(order.getDeduction().getTotalDeductionPrice())); - order.setOrderStatus(order.getPayRealPrice().equals(new BigDecimal("0"))?OrderStatusEnum.status2.getCode():OrderStatusEnum.status1.getCode()); + BigDecimal payRealPrice = totalPrice.subtract(order.getDeduction().getTotalDeductionPrice()); + order.setPayRealPrice(payRealPrice.compareTo(new BigDecimal("0")) < 0 ?payRealPrice:new BigDecimal("0")); + order.setOrderStatus(order.getPayRealPrice().compareTo(new BigDecimal("0")) == 0?OrderStatusEnum.status2.getCode():OrderStatusEnum.status1.getCode()); // 订单入库前处理 for (OrderChildModel childOrder : order.getOrderChildList()) { childOrder.setSurplusRefundCount(childOrder.getProductCount());