From 2c4d8298cfe3d349149ab76729bf77d1c453542a Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 4 Oct 2024 19:17:16 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=E3=80=91=E5=95=86=E5=9F=8E=EF=BC=9A=E7=BA=AF=E7=A7=AF=E5=88=86?= =?UTF-8?q?=E5=85=91=E6=8D=A2=E6=97=B6=EF=BC=8C=E7=9B=B4=E6=8E=A5=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=B8=BA=E5=BE=85=E5=8F=91=E8=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trade/service/order/TradeOrderUpdateServiceImpl.java | 5 ++++- .../service/order/handler/TradePointOrderHandler.java | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java index e0c303ed3..74a2643e3 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java @@ -245,7 +245,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { } // 3. 生成预支付 - createPayOrder(order, orderItems); + // 特殊情况:积分兑换时,可能支付金额为零 + if (order.getPayPrice() > 0) { + createPayOrder(order, orderItems); + } // 4. 插入订单日志 TradeOrderLogUtils.setOrderInfo(order.getId(), null, order.getStatus()); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradePointOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradePointOrderHandler.java index 11ca73f6b..9c60accef 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradePointOrderHandler.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradePointOrderHandler.java @@ -5,11 +5,13 @@ import cn.hutool.core.lang.Assert; import cn.iocoder.yudao.module.promotion.api.point.PointActivityApi; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; import jakarta.annotation.Resource; import org.springframework.stereotype.Component; import java.util.List; +import java.util.Objects; /** * 积分商城活动订单的 {@link TradeOrderHandler} 实现类 @@ -33,6 +35,11 @@ public class TradePointOrderHandler implements TradeOrderHandler { // 扣减积分商城活动的库存 pointActivityApi.updatePointStockDecr(order.getPointActivityId(), orderItems.get(0).getSkuId(), orderItems.get(0).getCount()); + + // 如果支付金额为 0,则直接设置为已支付 + if (Objects.equals(order.getPayPrice(), 0)) { + order.setPayStatus(true).setStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()); + } } @Override