未使用券 不可用删除

This commit is contained in:
wangw 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" +
" 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" +

View File

@ -157,11 +157,11 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
public boolean delete(Integer[] ids) {
for (Integer id : ids) {
List<TbActivate> 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<TbShopCouponMapper, TbS
Map<Integer, JsonObject> 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());