diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java index c082e190f..4a95cb1fa 100644 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java @@ -1,11 +1,11 @@ package cn.iocoder.yudao.module.promotion.enums.common; -import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.core.IntArrayValuable; import lombok.AllArgsConstructor; import lombok.Getter; import java.util.Arrays; +import java.util.Objects; /** * 营销的商品范围枚举 @@ -37,15 +37,15 @@ public enum PromotionProductScopeEnum implements IntArrayValuable { } public static boolean isAll(Integer scope) { - return ObjUtil.equal(scope, ALL.scope); + return Objects.equals(scope, ALL.scope); } public static boolean isSpu(Integer scope) { - return ObjUtil.equal(scope, SPU.scope); + return Objects.equals(scope, SPU.scope); } public static boolean isCategory(Integer scope) { - return ObjUtil.equal(scope, CATEGORY.scope); + return Objects.equals(scope, CATEGORY.scope); } } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java index fe15c0f71..fae7fa54d 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java @@ -53,6 +53,7 @@ public class AppActivityController { private DiscountActivityService discountActivityService; @Resource private RewardActivityService rewardActivityService; + @Resource private ProductSpuApi productSpuApi; @@ -91,7 +92,7 @@ public class AppActivityController { // 4. 限时折扣活动 getDiscountActivities(spuIds, now, activityList); // 5. 满减送活动 - getRewardActivities(spuIds, now, activityList); + getRewardActivityList(spuIds, now, activityList); return activityList; } @@ -148,23 +149,9 @@ public class AppActivityController { item.getName(), productMap.get(item.getId()), item.getStartTime(), item.getEndTime()))); } - private static void buildAppActivityRespVO(RewardActivityDO rewardActivity, Collection spuIds, - List activityList) { - for (Long spuId : spuIds) { - // 校验商品是否已经加入过活动 - if (anyMatch(activityList, appActivity -> ObjUtil.equal(appActivity.getId(), rewardActivity.getId()) && - ObjUtil.equal(appActivity.getSpuId(), spuId))) { - continue; - } - activityList.add(new AppActivityRespVO(rewardActivity.getId(), - PromotionTypeEnum.REWARD_ACTIVITY.getType(), rewardActivity.getName(), spuId, - rewardActivity.getStartTime(), rewardActivity.getEndTime())); - } - } - - private void getRewardActivities(Collection spuIds, LocalDateTime now, List activityList) { + private void getRewardActivityList(Collection spuIds, LocalDateTime now, List activityList) { // 1.1 获得所有的活动 - List rewardActivityList = rewardActivityService.getRewardActivityByStatusAndDateTimeLt( + List rewardActivityList = rewardActivityService.getRewardActivityListByStatusAndDateTimeLt( CommonStatusEnum.ENABLE.getStatus(), now); if (CollUtil.isEmpty(rewardActivityList)) { return; @@ -196,4 +183,18 @@ public class AppActivityController { } } + private static void buildAppActivityRespVO(RewardActivityDO rewardActivity, Collection spuIds, + List activityList) { + for (Long spuId : spuIds) { + // 校验商品是否已经加入过活动 + if (anyMatch(activityList, appActivity -> ObjUtil.equal(appActivity.getId(), rewardActivity.getId()) && + ObjUtil.equal(appActivity.getSpuId(), spuId))) { + continue; + } + activityList.add(new AppActivityRespVO(rewardActivity.getId(), + PromotionTypeEnum.REWARD_ACTIVITY.getType(), rewardActivity.getName(), spuId, + rewardActivity.getStartTime(), rewardActivity.getEndTime())); + } + } + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java index 1d4b978e9..27cc86c33 100755 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java @@ -79,6 +79,6 @@ public interface RewardActivityService { * @param dateTime 当前日期时间 * @return 满减送活动列表 */ - List getRewardActivityByStatusAndDateTimeLt(Integer status, LocalDateTime dateTime); + List getRewardActivityListByStatusAndDateTimeLt(Integer status, LocalDateTime dateTime); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java index a6a865eab..1ad0ae48f 100755 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java @@ -165,7 +165,7 @@ public class RewardActivityServiceImpl implements RewardActivityService { } @Override - public List getRewardActivityByStatusAndDateTimeLt(Integer status, LocalDateTime dateTime) { + public List getRewardActivityListByStatusAndDateTimeLt(Integer status, LocalDateTime dateTime) { return rewardActivityMapper.selectListByStatusAndDateTimeLt(status, dateTime); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java index b38decc17..d03826924 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java @@ -186,15 +186,14 @@ public interface TradeOrderUpdateService { */ void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId); - // TODO 芋艿:拼团取消,不调这个接口哈; - + // TODO @puhui999:不传递枚举哈。因为 rpc 不好支持。 /** * 取消支付订单 * * @param userId 用户编号 * @param orderId 订单编号 - * @param cancelTypeEnum 取消类型 + * @param cancelType 取消类型 */ - void cancelPaidOrder(Long userId, Long orderId, TradeOrderCancelTypeEnum cancelTypeEnum); + void cancelPaidOrder(Long userId, Long orderId, TradeOrderCancelTypeEnum cancelType); } 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 36195c117..3eda99411 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 @@ -858,7 +858,8 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { @Override @Transactional(rollbackFor = Exception.class) - public void cancelPaidOrder(Long userId, Long orderId, TradeOrderCancelTypeEnum cancelTypeEnum) { + public void cancelPaidOrder(Long userId, Long orderId, TradeOrderCancelTypeEnum cancelType) { + // TODO @puhui999:这里校验下 cancelType 只允许拼团关闭; // 1.1 检验订单存在 TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId); if (order == null) { @@ -875,13 +876,13 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { } // 2.1 取消订单 - cancelOrder0(order, cancelTypeEnum); + cancelOrder0(order, cancelType); // 2.2 创建退款单 payRefundApi.createRefund(new PayRefundCreateReqDTO() .setAppKey(tradeOrderProperties.getPayAppKey()).setUserIp(getClientIP()) // 支付应用 .setMerchantOrderId(String.valueOf(order.getId())) // 支付单号 .setMerchantRefundId(String.valueOf(order.getId())) - .setReason(cancelTypeEnum.getName()).setPrice(order.getPayPrice()));// 价格信息 + .setReason(cancelType.getName()).setPrice(order.getPayPrice()));// 价格信息 } /** diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculator.java index 0c25dcb30..490c2aea7 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculator.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculator.java @@ -52,7 +52,7 @@ public class TradeRewardActivityPriceCalculator implements TradePriceCalculator private void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result, RewardActivityMatchRespDTO rewardActivity) { // 1.1 获得满减送的订单项(商品)列表 - List orderItems = filterMatchCouponOrderItems(result, rewardActivity); + List orderItems = filterMatchActivityOrderItems(result, rewardActivity); if (CollUtil.isEmpty(orderItems)) { return; } @@ -93,8 +93,9 @@ public class TradeRewardActivityPriceCalculator implements TradePriceCalculator * @param rewardActivity 满减送活动 * @return 订单项(商品)列表 */ - private List filterMatchCouponOrderItems(TradePriceCalculateRespBO result, - RewardActivityMatchRespDTO rewardActivity) { + private List filterMatchActivityOrderItems(TradePriceCalculateRespBO result, + RewardActivityMatchRespDTO rewardActivity) { + // TODO @puhui999:是不是得根据类型过滤哈 return filterList(result.getItems(), orderItem -> CollUtil.contains(rewardActivity.getProductScopeValues(), orderItem.getSpuId())); }