promotion: 订单使用品类券时,根据品类过滤可用商品

This commit is contained in:
owen 2023-09-02 10:05:56 +08:00
parent 8bbaaf1ce9
commit 71efa0ed6f

View File

@ -103,6 +103,9 @@ public class TradeCouponPriceCalculator implements TradePriceCalculator {
if (PromotionProductScopeEnum.SPU.getScope().equals(coupon.getProductScope())) { if (PromotionProductScopeEnum.SPU.getScope().equals(coupon.getProductScope())) {
matchPredicate = matchPredicate // 额外加如下条件 matchPredicate = matchPredicate // 额外加如下条件
.and(orderItem -> coupon.getProductScopeValues().contains(orderItem.getSpuId())); .and(orderItem -> coupon.getProductScopeValues().contains(orderItem.getSpuId()));
} else if (PromotionProductScopeEnum.CATEGORY.getScope().equals(coupon.getProductScope())) {
matchPredicate = matchPredicate // 额外加如下条件
.and(orderItem -> coupon.getProductScopeValues().contains(orderItem.getCategoryId()));
} }
return filterList(result.getItems(), matchPredicate); return filterList(result.getItems(), matchPredicate);
} }