Skip to content

Commit

Permalink
【代码评审】商城:纯积分兑换时,直接设置为待发货
Browse files Browse the repository at this point in the history
  • Loading branch information
YunaiV committed Oct 4, 2024
1 parent e604cba commit 2c4d829
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ private void afterCreateTradeOrder(TradeOrderDO order, List<TradeOrderItemDO> or
}

// 3. 生成预支付
createPayOrder(order, orderItems);
// 特殊情况:积分兑换时,可能支付金额为零
if (order.getPayPrice() > 0) {
createPayOrder(order, orderItems);
}

// 4. 插入订单日志
TradeOrderLogUtils.setOrderInfo(order.getId(), null, order.getStatus());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
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} 实现类
Expand All @@ -33,6 +35,11 @@ public void beforeOrderCreate(TradeOrderDO order, List<TradeOrderItemDO> orderIt
// 扣减积分商城活动的库存
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
Expand Down

0 comments on commit 2c4d829

Please sign in to comment.