parent
e6fe3e66c7
commit
0794ac7569
|
|
@ -50,6 +50,7 @@ public class AConsumerCouponController {
|
|||
public CzgResult<Void> addConsumerCoupon(@RequestBody MkShopConsumerCouponDTO param) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
param.setShopId(shopId);
|
||||
param.setLeftNum(param.getGiveNum());
|
||||
mkShopConsumerCouponService.addConsumerCoupon(param);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,11 @@ public class MkShopConsumerCouponDTO implements Serializable {
|
|||
*/
|
||||
private Integer giveNum;
|
||||
|
||||
/**
|
||||
* 已发放数量
|
||||
*/
|
||||
private Integer giftNum;
|
||||
|
||||
/**
|
||||
* 每人领取限量,-10086为不限量
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -140,6 +140,10 @@ public class ShopCouponDTO implements Serializable {
|
|||
* 总发放数量,-10086为不限量
|
||||
*/
|
||||
private Integer giveNum;
|
||||
/**
|
||||
* 已发放数量
|
||||
*/
|
||||
private Integer giftNum;
|
||||
|
||||
/**
|
||||
* 可领取用户:全部/all,新用户一次/new,仅会员/vip
|
||||
|
|
|
|||
|
|
@ -69,6 +69,11 @@ public class MkShopConsumerCoupon implements Serializable {
|
|||
*/
|
||||
private Integer giveNum;
|
||||
|
||||
/**
|
||||
* 已发放数量
|
||||
*/
|
||||
private Integer giftNum;
|
||||
|
||||
/**
|
||||
* 每人领取限量,-10086为不限量
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -134,6 +134,10 @@ public class ShopCoupon implements Serializable {
|
|||
* 总发放数量,-10086为不限量
|
||||
*/
|
||||
private Integer giveNum;
|
||||
/**
|
||||
* 已发放数量
|
||||
*/
|
||||
private Integer giftNum;
|
||||
|
||||
/**
|
||||
* 可领取用户:全部/all,新用户一次/new,仅会员/vip
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue