From dc1347184fba2f5feec1a86fe34c35f48c9b3ee5 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 4 Oct 2023 00:47:17 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=EF=BC=9A=E6=8B=BC=E5=9B=A2?= =?UTF-8?q?=E3=80=81=E7=A0=8D=E4=BB=B7=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CombinationRecordServiceImpl.java | 3 ++ .../module/trade/api/order/TradeOrderApi.java | 1 + .../vo/AppTradeOrderSettlementReqVO.java | 3 +- .../order/handler/TradeBargainHandler.java | 2 +- .../handler/TradeCombinationHandler.java | 2 +- .../handler/TradeOrderDefaultHandler.java | 34 ------------------- .../order/handler/TradeOrderHandler.java | 8 ++--- .../order/handler/TradeSeckillHandler.java | 2 +- .../price/bo/TradePriceCalculateRespBO.java | 19 +---------- .../TradePriceCalculatorHelper.java | 3 -- .../TradeSeckillActivityPriceCalculator.java | 2 +- 11 files changed, 15 insertions(+), 64 deletions(-) delete mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderDefaultHandler.java diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java index e56271445..eef7d5992 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java @@ -102,6 +102,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { return recordDO; } + // TODO @芋艿:在详细预览下; @Override public void validateCombinationRecord(Long activityId, Long userId, Long skuId, Integer count) { // 1.1 校验拼团活动是否存在 @@ -132,12 +133,14 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { } // 5.1、查询关联的订单是否已经支付 // 当前 activityId 已经有未支付的订单,不允许在发起新的;要么支付,要么去掉先; + // TODO 芋艿:看看是不是可以删除掉; Integer orderStatus = tradeOrderApi.getOrderStatus(record.getOrderId()); if (ObjectUtil.equal(orderStatus, TradeOrderStatusEnum.UNPAID.getStatus())) { throw exception(COMBINATION_RECORD_FAILED_ORDER_STATUS_UNPAID); } } + // TODO 芋艿:在详细 review 下; @Override @Transactional(rollbackFor = Exception.class) public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java index d1f49cd80..643ed88fb 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java @@ -7,6 +7,7 @@ package cn.iocoder.yudao.module.trade.api.order; */ public interface TradeOrderApi { + // TODO 芋艿:看看是不是可以删除掉; /** * 获取订单状态 * diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java index 06b7f11fb..1ce00ab26 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.trade.controller.app.order.vo; +import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.validation.InEnum; import cn.iocoder.yudao.framework.common.validation.Mobile; import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; @@ -67,7 +68,7 @@ public class AppTradeOrderSettlementReqVO { @JsonIgnore public boolean isValidActivityItems() { // 校验是否是活动订单 - if (seckillActivityId == null && combinationActivityId == null && combinationHeadId == null) { + if (ObjUtil.isAllEmpty(seckillActivityId, combinationActivityId, combinationHeadId)) { return true; } // 校验订单项是否超出 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBargainHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBargainHandler.java index 4f5dc15e6..29082a2c4 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBargainHandler.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBargainHandler.java @@ -14,7 +14,7 @@ import javax.annotation.Resource; * @author HUIHUI */ @Component -public class TradeBargainHandler extends TradeOrderDefaultHandler { +public class TradeBargainHandler implements TradeOrderHandler { @Resource private BargainActivityApi bargainActivityApi; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationHandler.java index 3887f97a9..e8757ee22 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationHandler.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationHandler.java @@ -17,7 +17,7 @@ import javax.annotation.Resource; * @author HUIHUI */ @Component -public class TradeCombinationHandler extends TradeOrderDefaultHandler { +public class TradeCombinationHandler implements TradeOrderHandler { @Resource private CombinationRecordApi combinationRecordApi; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderDefaultHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderDefaultHandler.java deleted file mode 100644 index 824ad803c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderDefaultHandler.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.iocoder.yudao.module.trade.service.order.bo.TradeAfterOrderCreateReqBO; -import cn.iocoder.yudao.module.trade.service.order.bo.TradeAfterPayOrderReqBO; -import cn.iocoder.yudao.module.trade.service.order.bo.TradeBeforeOrderCreateReqBO; - -/** - * 订单活动特殊逻辑处理器 handler 默认抽象实现类 - * - * @author HUIHUI - */ -public abstract class TradeOrderDefaultHandler implements TradeOrderHandler { - - @Override - public void beforeOrderCreate(TradeBeforeOrderCreateReqBO reqBO) { - - } - - @Override - public void afterOrderCreate(TradeAfterOrderCreateReqBO reqBO) { - - } - - @Override - public void afterPayOrder(TradeAfterPayOrderReqBO reqBO) { - - } - - @Override - public void cancelOrder() { - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderHandler.java index 5429b1add..190be6c32 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderHandler.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderHandler.java @@ -17,25 +17,25 @@ public interface TradeOrderHandler { * * @param reqBO 请求 */ - void beforeOrderCreate(TradeBeforeOrderCreateReqBO reqBO); + default void beforeOrderCreate(TradeBeforeOrderCreateReqBO reqBO) {} /** * 订单创建后 * * @param reqBO 请求 */ - void afterOrderCreate(TradeAfterOrderCreateReqBO reqBO); + default void afterOrderCreate(TradeAfterOrderCreateReqBO reqBO) {} /** * 支付订单后 * * @param reqBO 请求 */ - void afterPayOrder(TradeAfterPayOrderReqBO reqBO); + default void afterPayOrder(TradeAfterPayOrderReqBO reqBO) {} /** * 订单取消 */ - void cancelOrder(); + default void cancelOrder() {} } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeSeckillHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeSeckillHandler.java index c7d89037b..50d683114 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeSeckillHandler.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeSeckillHandler.java @@ -14,7 +14,7 @@ import javax.annotation.Resource; * @author HUIHUI */ @Component -public class TradeSeckillHandler extends TradeOrderDefaultHandler { +public class TradeSeckillHandler implements TradeOrderHandler { @Resource private SeckillActivityApi seckillActivityApi; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateRespBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateRespBO.java index 0527a120e..af73332de 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateRespBO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateRespBO.java @@ -98,19 +98,9 @@ public class TradePriceCalculateRespBO { * VIP 减免金额,单位:分 */ private Integer vipPrice; - /** - * 秒杀、拼团、砍价活动商品的总金额,单位:分 - * - * 基于 {@link OrderItem#getActivityPrice()} ()} * {@link OrderItem#getCount()} 求和 - */ - private Integer activityPrice; /** * 最终购买金额(总),单位:分 * - * ==========活动情况=========== - * = {@link #activityPrice} - * + {@link #deliveryPrice} - * ==========正常情况=========== * = {@link #totalPrice} * - {@link #couponPrice} * - {@link #pointPrice} @@ -186,16 +176,9 @@ public class TradePriceCalculateRespBO { * VIP 减免金额,单位:分 */ private Integer vipPrice; - /** - * 秒杀、拼团、砍价活动商品的金额,单位:分 - */ - private Integer activityPrice; /** * 应付金额(总),单位:分 - * ==========活动情况=========== - * = {@link #activityPrice} * {@link #count} - * + {@link #deliveryPrice} - * ==========正常情况=========== + * * = {@link #price} * {@link #count} * - {@link #couponPrice} * - {@link #pointPrice} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java index aed6a8f22..efe96f876 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java @@ -105,9 +105,6 @@ public class TradePriceCalculatorHelper { if (!item.getSelected()) { return; } - // TODO puhui: 需要在这里计算活动的价格 - // ========== 一、活动情况 ========== - // ========== 二、正常情况 ========== price.setTotalPrice(price.getTotalPrice() + item.getPrice() * item.getCount()); price.setDiscountPrice(price.getDiscountPrice() + item.getDiscountPrice()); price.setDeliveryPrice(price.getDeliveryPrice() + item.getDeliveryPrice()); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeSeckillActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeSeckillActivityPriceCalculator.java index 457419443..10cd235ee 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeSeckillActivityPriceCalculator.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeSeckillActivityPriceCalculator.java @@ -46,7 +46,7 @@ public class TradeSeckillActivityPriceCalculator implements TradePriceCalculator orderItem.getSkuId(), orderItem.getCount()); // 3.1 记录优惠明细 - Integer discountPrice = orderItem.getPayPrice() - seckillActivity.getSeckillPrice(); + Integer discountPrice = orderItem.getPayPrice() - seckillActivity.getSeckillPrice() * orderItem.getCount(); TradePriceCalculatorHelper.addPromotion(result, orderItem, param.getSeckillActivityId(), seckillActivity.getName(), PromotionTypeEnum.SECKILL_ACTIVITY.getType(), StrUtil.format("秒杀活动:省 {} 元", TradePriceCalculatorHelper.formatPrice(discountPrice)),