!193 增加批发商品不能参加促销活动的限制 修复批发商品购买数量限制

Merge pull request !193 from OceansDeep/feature/pg
This commit is contained in:
OceansDeep 2022-06-16 08:47:21 +00:00 committed by Gitee
commit 2e4c6f4284
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 39 additions and 1 deletions

View File

@ -253,6 +253,7 @@ public enum ResultCode {
*/
PROMOTION_GOODS_NOT_EXIT(40000, "当前促销商品不存在!"),
PROMOTION_GOODS_QUANTITY_NOT_EXIT(40020, "当前促销商品库存不足!"),
PROMOTION_GOODS_DO_NOT_JOIN_WHOLESALE(40050, "批发商品无法参加促销"),
PROMOTION_SAME_ACTIVE_EXIST(40001, "活动时间内已存在同类活动,请选择关闭、删除当前时段的活动"),
PROMOTION_START_TIME_ERROR(40002, "活动起始时间不能小于当前时间"),
PROMOTION_END_TIME_ERROR(40003, "活动结束时间不能小于当前时间"),

View File

@ -419,7 +419,7 @@ public class CartServiceImpl implements CartService {
cartSkuVO.setNum(num);
}
if (cartSkuVO.getNum() > 99) {
if (cartSkuVO.getGoodsSku() != null && !GoodsSalesModeEnum.WHOLESALE.name().equals(cartSkuVO.getGoodsSku().getSalesModel()) && cartSkuVO.getNum() > 99) {
cartSkuVO.setNum(99);
}
}

View File

@ -5,8 +5,11 @@ import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.PromotionTypeEnum;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum;
import cn.lili.modules.goods.entity.vos.GoodsVO;
import cn.lili.modules.goods.service.GoodsService;
import cn.lili.modules.goods.service.GoodsSkuService;
@ -313,6 +316,40 @@ public class PromotionGoodsServiceImpl extends ServiceImpl<PromotionGoodsMapper,
return promotionMap;
}
@Override
public boolean save(PromotionGoods entity) {
this.checkGoodsSku(entity.getSkuId());
return super.save(entity);
}
@Override
public boolean saveBatch(Collection<PromotionGoods> entityList) {
for (PromotionGoods promotionGoods : entityList) {
this.checkGoodsSku(promotionGoods.getSkuId());
}
return super.saveBatch(entityList);
}
@Override
public boolean saveOrUpdateBatch(Collection<PromotionGoods> entityList) {
for (PromotionGoods promotionGoods : entityList) {
this.checkGoodsSku(promotionGoods.getSkuId());
}
return super.saveOrUpdateBatch(entityList);
}
/**
* 检查是否为不能参加促销活动的商品
*
* @param skuId 商品skuId
*/
private void checkGoodsSku(String skuId) {
GoodsSku goodsSku = goodsSkuService.getGoodsSkuByIdFromCache(skuId);
if (goodsSku != null && GoodsSalesModeEnum.WHOLESALE.name().equals(goodsSku.getSalesModel())) {
throw new ServiceException(ResultCode.PROMOTION_GOODS_DO_NOT_JOIN_WHOLESALE, goodsSku.getGoodsName());
}
}
private void setGoodsPromotionInfo(GoodsSku dataSku, Map.Entry<String, Object> promotionInfo) {
JSONObject promotionsObj = JSONUtil.parseObj(promotionInfo.getValue());
PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams();