新增字段 已发放数量 giftNum
已发放数量 问题
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package com.czg.service.market.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import com.czg.market.dto.MkShopConsumerCouponDTO;
|
||||
import com.czg.market.entity.MkShopConsumerCoupon;
|
||||
import com.czg.market.entity.ShopCoupon;
|
||||
import com.czg.market.service.MkCouponGiftService;
|
||||
import com.czg.market.service.MkShopConsumerCouponService;
|
||||
import com.czg.service.market.mapper.MkShopConsumerCouponMapper;
|
||||
@@ -28,7 +30,7 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
|
||||
private MkCouponGiftService couponGiftService;
|
||||
|
||||
@Override
|
||||
public Page<MkShopConsumerCouponDTO> getConsumerCouponPage(MkShopConsumerCouponDTO param) {
|
||||
public Page<MkShopConsumerCouponDTO> getConsumerCouponPage(MkShopConsumerCouponDTO param) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq(MkShopConsumerCoupon::getShopId, param.getShopId())
|
||||
.orderBy(MkShopConsumerCoupon::getCreateTime).desc();
|
||||
@@ -61,6 +63,28 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateConsumerCouponById(MkShopConsumerCouponDTO param) {
|
||||
MkShopConsumerCoupon consumerCoupon = getById(param.getId());
|
||||
if (consumerCoupon.getGiveNum() == -10086) {
|
||||
if (param.getGiveNum() == -10086) {
|
||||
param.setLeftNum(-10086);
|
||||
} else {
|
||||
if (param.getGiveNum() < consumerCoupon.getGiftNum()) {
|
||||
throw new ValidateException("修改失败 总发放数量必须大于已发放数量");
|
||||
} else {
|
||||
param.setLeftNum(param.getGiveNum() - consumerCoupon.getGiftNum());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (param.getGiveNum() == -10086) {
|
||||
param.setLeftNum(-10086);
|
||||
} else {
|
||||
if (param.getGiveNum() < consumerCoupon.getGiftNum()) {
|
||||
throw new ValidateException("修改失败 总发放数量必须大于已发放数量");
|
||||
} else {
|
||||
param.setLeftNum(param.getGiveNum() - consumerCoupon.getGiftNum());
|
||||
}
|
||||
}
|
||||
}
|
||||
updateById(BeanUtil.toBean(param, MkShopConsumerCoupon.class), true);
|
||||
//更新优惠券信息/数量
|
||||
couponGiftService.addCouponGift(param.getId(), "消费赠券", 3, param.getCouponGiftList());
|
||||
|
||||
@@ -51,12 +51,24 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
||||
|
||||
@Override
|
||||
public void updateCouponById(ShopCouponDTO param) {
|
||||
if (param.getGiveNum() != null && param.getGiveNum() != -10086) {
|
||||
ShopCoupon tbShopCoupon = getById(param.getId());
|
||||
if (param.getGiveNum() < tbShopCoupon.getGiveNum()) {
|
||||
throw new ValidateException("修改失败 发放数量不可减少");
|
||||
} else {
|
||||
param.setLeftNum(tbShopCoupon.getLeftNum() + tbShopCoupon.getGiveNum() - param.getGiveNum());
|
||||
ShopCoupon tbShopCoupon = getById(param.getId());
|
||||
if (tbShopCoupon.getGiveNum() == -10086) {
|
||||
if (param.getGiveNum() != -10086) {
|
||||
if (param.getGiveNum() < tbShopCoupon.getGiftNum()) {
|
||||
throw new ValidateException("修改失败 总发放数量必须大于已发放数量");
|
||||
}else {
|
||||
param.setLeftNum(param.getGiveNum() - tbShopCoupon.getGiftNum());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(param.getGiveNum()== -10086){
|
||||
param.setLeftNum(-10086);
|
||||
}else {
|
||||
if (param.getGiveNum() < tbShopCoupon.getGiftNum()) {
|
||||
throw new ValidateException("修改失败 总发放数量必须大于已发放数量");
|
||||
}else {
|
||||
param.setLeftNum(param.getGiveNum() - tbShopCoupon.getGiftNum());
|
||||
}
|
||||
}
|
||||
}
|
||||
ShopCoupon coupon = BeanUtil.toBean(param, ShopCoupon.class);
|
||||
|
||||
Reference in New Issue
Block a user