From eef9e7ff69acf4f048611a7ccb4fde4d22cdbe41 Mon Sep 17 00:00:00 2001 From: wyn <1074145239@qq.com> Date: Tue, 23 Jun 2026 15:41:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=81=E4=BC=98=E6=83=A0=E5=88=B8=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=8F=AA=E6=9C=89=E6=8C=87=E5=AE=9Avip=E6=89=8D?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/common/entity/CouponEntity.java | 3 ++ .../service/impl/CouponServiceImpl.java | 28 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/peanut/modules/common/entity/CouponEntity.java b/src/main/java/com/peanut/modules/common/entity/CouponEntity.java index b3c8694..485594b 100644 --- a/src/main/java/com/peanut/modules/common/entity/CouponEntity.java +++ b/src/main/java/com/peanut/modules/common/entity/CouponEntity.java @@ -62,6 +62,9 @@ public class CouponEntity { //使用门槛 private Integer useLevel; + //限定VIP类型,逗号分隔,如1,11,5,51;用户开通其中任意VIP可现金券直接换积分 + private String userVipIds; + private Date createTime; @TableLogic diff --git a/src/main/java/com/peanut/modules/common/service/impl/CouponServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/CouponServiceImpl.java index 10bd914..cfa73bd 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/CouponServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/CouponServiceImpl.java @@ -271,6 +271,15 @@ public class CouponServiceImpl extends ServiceImpl impl return set; } + private boolean matchUserVipIds(String userVipIds, List userVipList) { + Set allowedVipTypes = Arrays.stream(userVipIds.split(",")) + .map(String::trim) + .filter(StringUtils::isNotEmpty) + .map(Integer::parseInt) + .collect(Collectors.toSet()); + return userVipList.stream().anyMatch(userVip -> allowedVipTypes.contains(userVip.getType())); + } + public void getCourseMedicalIds(int courseMedicalId,List list){ CourseMedicine courseMedicine = courseMedicineDao.selectById(courseMedicalId); if (courseMedicine.getIsLast()==1){ @@ -380,7 +389,7 @@ public class CouponServiceImpl extends ServiceImpl impl List> buyOrderProducts = couponToProductDao.selectJoinMaps(wrapper); for (Map map : buyOrderProducts) { ShopProduct shopProduct = shopProductDao.selectById(map.get("product_id").toString()); - //预售书+赠送现金券:VIP用户将券额转为积分;仅产品id=2023时需为妇幼生殖vip(type=10) + //预售书+赠送现金券:VIP用户将券额转为积分;配置user_vip_ids时按限定VIP匹配,不匹配不送券 if ("03".equals(shopProduct.getGoodsType())){ MyUserEntity userEntity = userDao.selectById(order.getUserId()); List userVipList = userVipDao.selectList(new LambdaQueryWrapper() @@ -389,8 +398,21 @@ public class CouponServiceImpl extends ServiceImpl impl int productId = Integer.parseInt(map.get("product_id").toString()); int couponId = Integer.parseInt(map.get("coupon_id").toString()); CouponEntity couponEntity = couponDao.selectById(couponId); - boolean isFyszVip = userVipList.stream().anyMatch(userVip -> Integer.valueOf(10).equals(userVip.getType())); - boolean couponToJf = couponEntity.getCouponType() == 0 && (productId == 2023 ? isFyszVip : userVipList.size() > 0); + boolean shouldGrantCoupon = true; + boolean couponToJf = false; + if (StringUtils.isNotEmpty(couponEntity.getUserVipIds())) { + if (!matchUserVipIds(couponEntity.getUserVipIds(), userVipList)) { + shouldGrantCoupon = false; + } else { + couponToJf = couponEntity.getCouponType() == 0; + } + } else { + boolean isFyszVip = userVipList.stream().anyMatch(userVip -> Integer.valueOf(10).equals(userVip.getType())); + couponToJf = couponEntity.getCouponType() == 0 && (productId == 2023 ? isFyszVip : userVipList.size() > 0); + } + if (!shouldGrantCoupon) { + continue; + } if (couponToJf){ BigDecimal jf = BigDecimal.ZERO; for (int i=0;i