参数校验
This commit is contained in:
@@ -3,6 +3,7 @@ package com.czg.service.market.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MkCouponGiftDTO;
|
||||
import com.czg.market.dto.MkShopConsumerCouponDTO;
|
||||
import com.czg.market.dto.MkShopCouponGiftDTO;
|
||||
@@ -115,7 +116,7 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
|
||||
@Transactional
|
||||
public void addConsumerCoupon(MkShopConsumerCouponDTO param) {
|
||||
if (CollUtil.isEmpty(param.getCouponGiftList())) {
|
||||
throw new ValidateException("优惠券信息不能为空");
|
||||
throw new CzgException("优惠券信息不能为空");
|
||||
}
|
||||
MkShopConsumerCoupon bean = BeanUtil.toBean(param, MkShopConsumerCoupon.class);
|
||||
save(bean);
|
||||
@@ -132,7 +133,7 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
|
||||
param.setLeftNum(-10086);
|
||||
} else {
|
||||
if (param.getGiveNum() < consumerCoupon.getGiftNum()) {
|
||||
throw new ValidateException("修改失败 总发放数量必须大于已发放数量");
|
||||
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
||||
} else {
|
||||
param.setLeftNum(param.getGiveNum() - consumerCoupon.getGiftNum());
|
||||
}
|
||||
@@ -142,7 +143,7 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
|
||||
param.setLeftNum(-10086);
|
||||
} else {
|
||||
if (param.getGiveNum() < consumerCoupon.getGiftNum()) {
|
||||
throw new ValidateException("修改失败 总发放数量必须大于已发放数量");
|
||||
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
||||
} else {
|
||||
param.setLeftNum(param.getGiveNum() - consumerCoupon.getGiftNum());
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.czg.account.service.ShopUserService;
|
||||
import com.czg.account.vo.ShopInfoCouponVO;
|
||||
import com.czg.account.vo.UserCouponFoodVo;
|
||||
import com.czg.account.vo.UserCouponVo;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MkShopCouponGiftDTO;
|
||||
import com.czg.market.dto.ShopCouponDTO;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
@@ -191,7 +192,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
||||
if (tbShopCoupon.getGiveNum() == -10086) {
|
||||
if (param.getGiveNum() != -10086) {
|
||||
if (param.getGiveNum() < tbShopCoupon.getGiftNum()) {
|
||||
throw new ValidateException("修改失败 总发放数量必须大于已发放数量");
|
||||
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
||||
} else {
|
||||
param.setLeftNum(param.getGiveNum() - tbShopCoupon.getGiftNum());
|
||||
}
|
||||
@@ -201,7 +202,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
||||
param.setLeftNum(-10086);
|
||||
} else {
|
||||
if (param.getGiveNum() < tbShopCoupon.getGiftNum()) {
|
||||
throw new ValidateException("修改失败 总发放数量必须大于已发放数量");
|
||||
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
||||
} else {
|
||||
param.setLeftNum(param.getGiveNum() - tbShopCoupon.getGiftNum());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user