未使用券 不可用删除

This commit is contained in:
2024-11-14 14:18:00 +08:00
parent aba8d9b524
commit 2e4ef9a0a5
2 changed files with 5 additions and 5 deletions

View File

@@ -47,7 +47,7 @@ public interface TbActivateInRecordMapper extends BaseMapper<TbActivateInRecord>
@Select("SELECT sum( over_num ) from tb_activate_in_record" + @Select("SELECT sum( over_num ) from tb_activate_in_record" +
" where coupon_id = #{couponId} " + " where coupon_id = #{couponId} " +
" and now() < use_end_time group by coupon_id ") " 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" + @Update("update tb_activate_in_record" +

View File

@@ -160,8 +160,8 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
if (CollectionUtil.isNotEmpty(tbActivates)) { if (CollectionUtil.isNotEmpty(tbActivates)) {
throw new BadRequestException("该优惠券已关联活动,请解绑后删除"); throw new BadRequestException("该优惠券已关联活动,请解绑后删除");
} }
int i = inRecordMapper.countNoUseCoupon(id); Integer i = inRecordMapper.countNoUseCoupon(id);
if (i > 0) { if (i != null && i > 0) {
throw new BadRequestException("该优惠券有发放后未使用,无法删除"); throw new BadRequestException("该优惠券有发放后未使用,无法删除");
} }
} }