From 2e4ef9a0a53768c2e23685ed44f77c282b3aeedd Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 14 Nov 2024 14:18:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E4=BD=BF=E7=94=A8=E5=88=B8=20?= =?UTF-8?q?=E4=B8=8D=E5=8F=AF=E7=94=A8=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/mybatis/mapper/TbActivateInRecordMapper.java | 2 +- .../mybatis/service/impl/TbShopCouponServiceImpl.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbActivateInRecordMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbActivateInRecordMapper.java index 2b47b89b..ddcc059d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbActivateInRecordMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbActivateInRecordMapper.java @@ -47,7 +47,7 @@ public interface TbActivateInRecordMapper extends BaseMapper @Select("SELECT sum( over_num ) from tb_activate_in_record" + " where coupon_id = #{couponId} " + " and now() < use_end_time group by coupon_id ") - int countNoUseCoupon(@Param("couponId") Integer couponId); + Integer countNoUseCoupon(@Param("couponId") Integer couponId); @Update("update tb_activate_in_record" + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopCouponServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopCouponServiceImpl.java index b2a80ac0..3554e500 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopCouponServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopCouponServiceImpl.java @@ -157,11 +157,11 @@ public class TbShopCouponServiceImpl extends ServiceImpl tbActivates = activateMapper.queActByCouponId(id); - if(CollectionUtil.isNotEmpty(tbActivates)){ + if (CollectionUtil.isNotEmpty(tbActivates)) { throw new BadRequestException("该优惠券已关联活动,请解绑后删除"); } - int i = inRecordMapper.countNoUseCoupon(id); - if (i > 0) { + Integer i = inRecordMapper.countNoUseCoupon(id); + if (i != null && i > 0) { throw new BadRequestException("该优惠券有发放后未使用,无法删除"); } } @@ -254,7 +254,7 @@ public class TbShopCouponServiceImpl extends ServiceImpl coupons = new HashMap<>(); for (TbUserCouponVo tbUserCouponVo : tbUserCouponVos) { if (!coupons.containsKey(tbUserCouponVo.getCouponId())) { - setCouponInfo(coupons, tbUserCouponVo, null, week ,now, formatter); + setCouponInfo(coupons, tbUserCouponVo, null, week, now, formatter); } JsonObject couponJson = coupons.get(tbUserCouponVo.getCouponId()); tbUserCouponVo.setUseRestrictions(couponJson.get("useRestrictions").toString());