From 9c79e522d700285598ee2ea3b0b7c69c0f0edbc9 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Thu, 12 Jan 2023 14:17:22 +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 --- .../order/service/impl/OrderServiceImpl.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index 250737e3..d2926b44 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -330,7 +330,7 @@ public class OrderServiceImpl implements OrderService { order.setPayPrice(order.getPayablePrice()); // 积分抵扣 - if (createOrderModel.getPayGold() != null && createOrderModel.getPayGold().compareTo(0) == 1) { + if (createOrderModel.getPayGold() != null && createOrderModel.getPayGold() > 0) { // 查询用户 HighUser user = userService.findByUserId(order.getMemId()); if (user == null) { @@ -345,17 +345,11 @@ public class OrderServiceImpl implements OrderService { if (goldPrice.compareTo(order.getPayablePrice()) == 1) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付的积分金额大于支付金额"); } - // 应付金额 减去 积分抵扣金额 = 支付金额 + // 支付金额 减去 积分抵扣金额 = 应付金额 order.setPayPrice(order.getPayablePrice().subtract(goldPrice)); - // 积分金额小于应付金额 - if (goldPrice.compareTo(order.getPayablePrice()) == -1) { - // 扣除用户积分 - userService.goldHandle(order.getMemId(), createOrderModel.getPayGold(), 2, 2, order.getId(), - "抵扣积分订单:" + order.getOrderNo() + ",使用积分:" + order.getPayGold()); - } // 积分金额等于应付金额 - if (goldPrice.compareTo(order.getPayablePrice()) == 0) { + if (order.getPayPrice().compareTo(new BigDecimal("0")) == 0) { if (StringUtils.isBlank(createOrderModel.getPayPwd())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, ""); } @@ -370,7 +364,7 @@ public class OrderServiceImpl implements OrderService { } // 扣除用户积分 userService.goldHandle(order.getMemId(), createOrderModel.getPayGold(), 2, 2, order.getId(), - "抵扣积分订单:" + order.getOrderNo() + ",使用积分:" + order.getPayGold()); + "积分抵扣金额,交易订单:" + order.getOrderNo() + ",使用积分:" + order.getPayGold()); order.setOrderStatus(OrderStatus.STATUS2.getNumber()); order.setPayRealPrice(order.getPayPrice()); @@ -379,6 +373,10 @@ public class OrderServiceImpl implements OrderService { for (HighChildOrder childOrder : order.getHighChildOrderList()) { childOrder.setChildOrderStatus(OrderChildStatus.STATUS2.getNumber()); } + } else { + // 扣除用户积分 + userService.goldHandle(order.getMemId(), createOrderModel.getPayGold(), 2, 2, order.getId(), + "积分抵扣金额,交易订单:" + order.getOrderNo() + ",使用积分:" + order.getPayGold()); } }