Przeglądaj źródła

商品上架必须库存大于零

yzc 2 lat temu
rodzic
commit
cebc3fef1e

+ 3 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java

@@ -670,6 +670,9 @@ public class KwpGoodsService {
         if (Objects.equals(GoodsStatusEnum.PUT_ON_SHELVES.getCode(), goods.getStatus())) {
             throw new BusinessException("上架操作仅针对“已下架”“草稿”状态的单据!");
         }
+        if (goods.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
+            throw new BusinessException("商品上架必须库存大于零!");
+        }
         if (Objects.equals(GoodsStatusEnum.SAVED.getCode(), goods.getStatus())) {
             UpdateGoodsParam updateParam = BeanUtils.copyProperties(goods, UpdateGoodsParam.class);
             updateParam.setAttributes(BeanUtils.copyToList(kwpGoodsAttributeService.getByGoodsId(id), GoodsAttributes.class));