From 551c810af9ce3e2b801abf09aba98f96ae9857ff Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 27 May 2024 14:27:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/order/controller/OrderController.java | 5 +++++ .../java/com/hfkj/service/order/impl/BsOrderServiceImpl.java | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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());