From e604cba3bf9ab489d6e4596a66713676982b85b1 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 4 Oct 2024 18:40:33 +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=A7=AF=E5=88=86=E5=95=86?= =?UTF-8?q?=E5=9F=8E=E7=9A=84=E4=B8=8B=E5=8D=95=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/app/point/AppPointActivityController.java | 9 ++++----- .../app/point/vo/AppPointActivityDetailRespVO.java | 2 +- .../trade/service/order/TradeOrderQueryService.java | 2 +- .../trade/service/order/TradeOrderQueryServiceImpl.java | 2 +- .../trade/service/price/TradePriceServiceImpl.java | 3 ++- .../calculator/TradePointActivityPriceCalculator.java | 2 +- .../calculator/TradeSeckillActivityPriceCalculator.java | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/AppPointActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/AppPointActivityController.java index f607aea77..1ffeb770f 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/AppPointActivityController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/AppPointActivityController.java @@ -73,12 +73,11 @@ public class AppPointActivityController { // 2. 拼接数据 List products = pointActivityService.getPointProductListByActivityIds(Collections.singletonList(id)); - AppPointActivityDetailRespVO respVO = BeanUtils.toBean(activity, AppPointActivityDetailRespVO.class); - // 设置 product 信息 - respVO.setProducts(BeanUtils.toBean(products, AppPointActivityDetailRespVO.Product.class)); - PointProductDO minProduct = getMinPropertyObj(products, PointProductDO::getPoint); + PointProductDO minProduct = getMinObject(products, PointProductDO::getPoint); assert minProduct != null; - respVO.setPoint(minProduct.getPoint()).setPrice(minProduct.getPrice()); + AppPointActivityDetailRespVO respVO = BeanUtils.toBean(activity, AppPointActivityDetailRespVO.class) + .setProducts(BeanUtils.toBean(products, AppPointActivityDetailRespVO.Product.class)) + .setPoint(minProduct.getPoint()).setPrice(minProduct.getPrice()); return success(respVO); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/vo/AppPointActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/vo/AppPointActivityDetailRespVO.java index 9153d68b6..2e02f107a 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/vo/AppPointActivityDetailRespVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/vo/AppPointActivityDetailRespVO.java @@ -30,7 +30,7 @@ public class AppPointActivityDetailRespVO { @Schema(description = "商品信息数组", requiredMode = Schema.RequiredMode.REQUIRED) private List products; - //======================= 显示所需兑换积分最少的 sku 信息 ======================= + //======================= 显示所需兑换积分最少的 SKU 信息 ======================= @Schema(description = "兑换积分", requiredMode = Schema.RequiredMode.REQUIRED) private Integer point; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java index b2b8bca98..5e436d959 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java @@ -116,7 +116,7 @@ public interface TradeOrderQueryService { * @param activityId 活动编号 * @return 秒杀商品数量 */ - int getActivityProductCount(Long userId, Long activityId); + int getSeckillProductCount(Long userId, Long activityId); // =================== Order Item =================== diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java index 04cd1b6ff..b105e93ea 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java @@ -174,7 +174,7 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { } @Override - public int getActivityProductCount(Long userId, Long activityId) { + public int getSeckillProductCount(Long userId, Long activityId) { // 获得订单列表 List orders = tradeOrderMapper.selectListByUserIdAndSeckillActivityId(userId, activityId); orders.removeIf(order -> TradeOrderStatusEnum.isCanceled(order.getStatus())); // 过滤掉【已取消】的订单 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImpl.java index 560056a56..72102a6d3 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImpl.java @@ -69,7 +69,8 @@ public class TradePriceServiceImpl implements TradePriceService { .buildCalculateResp(calculateReqBO, spuList, skuList); priceCalculators.forEach(calculator -> calculator.calculate(calculateReqBO, calculateRespBO)); // 2.2 如果最终支付金额小于等于 0,则抛出业务异常 - if (calculateReqBO.getPointActivityId() == null && calculateRespBO.getPrice().getPayPrice() <= 0) { + if (calculateReqBO.getPointActivityId() == null // 积分订单,允许支付金额为 0 + && calculateRespBO.getPrice().getPayPrice() <= 0) { log.error("[calculatePrice][价格计算不正确,请求 calculateReqDTO({}),结果 priceCalculate({})]", calculateReqBO, calculateRespBO); throw exception(PRICE_CALCULATE_PAY_PRICE_ILLEGAL); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointActivityPriceCalculator.java index 158eaa3d9..4670cf9de 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointActivityPriceCalculator.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointActivityPriceCalculator.java @@ -84,7 +84,7 @@ public class TradePointActivityPriceCalculator implements TradePriceCalculator { // 1. 校验是否可以参与积分商城活动 PointValidateJoinRespDTO pointValidateJoinRespDTO = pointActivityApi.validateJoinPointActivity(activityId, skuId, count); // 2. 校验总限购数量,目前只有 trade 有具体下单的数据,需要交给 trade 价格计算使用 - int activityProductCount = tradeOrderQueryService.getActivityProductCount(userId, activityId); + int activityProductCount = tradeOrderQueryService.getSeckillProductCount(userId, activityId); if (activityProductCount + count > pointValidateJoinRespDTO.getCount()) { throw exception(PRICE_CALCULATE_POINT_TOTAL_LIMIT_COUNT); } 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 e1b4ba194..90ae4fb25 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 @@ -60,7 +60,7 @@ public class TradeSeckillActivityPriceCalculator implements TradePriceCalculator // 1. 校验是否可以参与秒杀 SeckillValidateJoinRespDTO seckillActivity = seckillActivityApi.validateJoinSeckill(activityId, skuId, count); // 2. 校验总限购数量,目前只有 trade 有具体下单的数据,需要交给 trade 价格计算使用 - int seckillProductCount = tradeOrderQueryService.getActivityProductCount(userId, activityId); + int seckillProductCount = tradeOrderQueryService.getSeckillProductCount(userId, activityId); if (seckillProductCount + count > seckillActivity.getTotalLimitCount()) { throw exception(PRICE_CALCULATE_SECKILL_TOTAL_LIMIT_COUNT); }