未使用券 不可用删除
This commit is contained in:
@@ -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" +
|
||||||
|
|||||||
@@ -157,11 +157,11 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
|
|||||||
public boolean delete(Integer[] ids) {
|
public boolean delete(Integer[] ids) {
|
||||||
for (Integer id : ids) {
|
for (Integer id : ids) {
|
||||||
List<TbActivate> tbActivates = activateMapper.queActByCouponId(id);
|
List<TbActivate> tbActivates = activateMapper.queActByCouponId(id);
|
||||||
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("该优惠券有发放后未使用,无法删除");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -254,7 +254,7 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
|
|||||||
Map<Integer, JsonObject> coupons = new HashMap<>();
|
Map<Integer, JsonObject> coupons = new HashMap<>();
|
||||||
for (TbUserCouponVo tbUserCouponVo : tbUserCouponVos) {
|
for (TbUserCouponVo tbUserCouponVo : tbUserCouponVos) {
|
||||||
if (!coupons.containsKey(tbUserCouponVo.getCouponId())) {
|
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());
|
JsonObject couponJson = coupons.get(tbUserCouponVo.getCouponId());
|
||||||
tbUserCouponVo.setUseRestrictions(couponJson.get("useRestrictions").toString());
|
tbUserCouponVo.setUseRestrictions(couponJson.get("useRestrictions").toString());
|
||||||
|
|||||||
Reference in New Issue
Block a user