|
@@ -88,8 +88,6 @@ public class GoodsManagerImpl extends BaseServiceImpl<GoodsMapper, GoodsDO> impl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
for (int i = 1; i <= bean.size(); i++) {
|
|
|
bean.get(i-1).setSort(bean.get(i-1).getId()+100000000*i);
|
|
|
}
|
|
@@ -110,6 +108,9 @@ public class GoodsManagerImpl extends BaseServiceImpl<GoodsMapper, GoodsDO> impl
|
|
|
BeanUtil.copyProperties(goodsDTO, goodsDO);
|
|
|
//先删除sku在新增
|
|
|
productManager.remove(new LambdaQueryWrapper<ProductDO>().eq(ProductDO::getGoodsId, goodsDTO.getId()));
|
|
|
+ //再删除库存列表在新增
|
|
|
+ productStockManager.remove(new LambdaQueryWrapper<ProductStockDO>().eq(ProductStockDO::getGoodsId,goodsDTO.getId()));
|
|
|
+
|
|
|
List<ProductDO> bean = BeanUtils.toBean(goodsDTO.getProductList(), ProductDO.class);
|
|
|
// 保存相册
|
|
|
goodsGalleryMapper.delete(new LambdaQueryWrapper<GoodsGalleryDO>().eq(GoodsGalleryDO::getGoodsId,goodsDTO.getId()));
|
|
@@ -126,6 +127,10 @@ public class GoodsManagerImpl extends BaseServiceImpl<GoodsMapper, GoodsDO> impl
|
|
|
for (int i = 1; i <= bean.size(); i++) {
|
|
|
bean.get(i-1).setSort(bean.get(i-1).getId()+100000000*i);
|
|
|
}
|
|
|
+
|
|
|
+ //初始化库存
|
|
|
+ productStockManager.intStock(bean,goodsDO);
|
|
|
+
|
|
|
productManager.updateBatchById(bean);
|
|
|
}
|
|
|
|
|
@@ -205,13 +210,14 @@ public class GoodsManagerImpl extends BaseServiceImpl<GoodsMapper, GoodsDO> impl
|
|
|
throw new ServiceException("请先下架商品");
|
|
|
}
|
|
|
long count = productStockManager.count(new LambdaQueryWrapper<ProductStockDO>()
|
|
|
- .eq(ProductStockDO::getGoodsId, id).ge(ProductStockDO::getActualStock,0));
|
|
|
+ .eq(ProductStockDO::getGoodsId, id).gt(ProductStockDO::getActualStock,0));
|
|
|
if (count>0){
|
|
|
throw new ServiceException("该商品在各大仓库还有库存,请先清空库存再删除");
|
|
|
}
|
|
|
removeById(id);
|
|
|
//先删除sku在新增
|
|
|
productManager.remove(new LambdaQueryWrapper<ProductDO>().eq(ProductDO::getGoodsId, id));
|
|
|
+ productStockManager.remove(new LambdaQueryWrapper<ProductStockDO>().eq(ProductStockDO::getGoodsId,id));
|
|
|
|
|
|
}
|
|
|
|