|
|
@@ -198,7 +198,7 @@ public class HBGoodsService implements IHBGoodsService {
|
|
|
for (CategoryProdHb categoryProd : categoryProds) {
|
|
|
FrontCategory frontCategory = frontCategoryMapper.selectOne(new LambdaQueryWrapper<FrontCategory>()
|
|
|
.eq(FrontCategory::getCode, categoryProd.getCode()));
|
|
|
- addShopCategory(frontCategory, categoryProd.getProdId(),shopDetail.getShopId(), shopDetail.getHbStationId());
|
|
|
+ addShopCategory(frontCategory, categoryProd.getProdId(), shopDetail.getShopId(), shopDetail.getHbStationId());
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -219,74 +219,91 @@ public class HBGoodsService implements IHBGoodsService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void addShopCategory(FrontCategory frontCategory,Long prodId, Long shopId, String hbShopId) {
|
|
|
+ public void addShopCategory(FrontCategory frontCategory, Long prodId, Long shopId, String hbShopId) {
|
|
|
+ log.info("添加门店分类:{}", frontCategory);
|
|
|
ShopCategory shopCategoryByCode = shopCategoryMapper.selectOne(new LambdaQueryWrapper<ShopCategory>()
|
|
|
.eq(ShopCategory::getCode, frontCategory.getCode())
|
|
|
.eq(ShopCategory::getShopId, shopId)
|
|
|
.eq(ShopCategory::getIsDelete, 0));
|
|
|
|
|
|
- if (shopCategoryByCode != null) {
|
|
|
- log.info("门店分类已存在,无需添加");
|
|
|
- return;
|
|
|
- }
|
|
|
- ShopCategory shopCategory = new ShopCategory();
|
|
|
- shopCategory.setCode(frontCategory.getCode());
|
|
|
- shopCategory.setName(frontCategory.getName());
|
|
|
- if (frontCategory.getParentCode() == null || frontCategory.getParentCode().equals("0")) {
|
|
|
- shopCategory.setPid(0L);
|
|
|
- shopCategory.setParentCode("0");
|
|
|
- } else {
|
|
|
- ShopCategory shopCategoryByCode1 = shopCategoryMapper.selectOne(new LambdaQueryWrapper<ShopCategory>()
|
|
|
- .eq(ShopCategory::getCode, frontCategory.getParentCode())
|
|
|
- .eq(ShopCategory::getShopId, shopId)
|
|
|
- .eq(ShopCategory::getIsDelete, 0));
|
|
|
- if (shopCategoryByCode1 == null) {
|
|
|
- //不存在门店分类父类目添加
|
|
|
- FrontCategory frontCategoryParent = frontCategoryMapper.selectOne(new LambdaQueryWrapper<FrontCategory>()
|
|
|
- .eq(FrontCategory::getCode, frontCategory.getParentCode())
|
|
|
- .eq(FrontCategory::getIsDelete, 0));
|
|
|
- addShopCategory(frontCategoryParent,prodId, shopId, hbShopId);
|
|
|
-
|
|
|
- shopCategoryByCode1 = shopCategoryMapper.selectOne(new LambdaQueryWrapper<ShopCategory>()
|
|
|
+ if (shopCategoryByCode == null) {
|
|
|
+ ShopCategory shopCategory = new ShopCategory();
|
|
|
+ shopCategory.setCode(frontCategory.getCode());
|
|
|
+ shopCategory.setName(frontCategory.getName());
|
|
|
+ if (frontCategory.getParentCode() == null || frontCategory.getParentCode().equals("0")) {
|
|
|
+ shopCategory.setPid(0L);
|
|
|
+ shopCategory.setParentCode("0");
|
|
|
+ } else {
|
|
|
+ ShopCategory shopCategoryByCode1 = shopCategoryMapper.selectOne(new LambdaQueryWrapper<ShopCategory>()
|
|
|
.eq(ShopCategory::getCode, frontCategory.getParentCode())
|
|
|
.eq(ShopCategory::getShopId, shopId)
|
|
|
.eq(ShopCategory::getIsDelete, 0));
|
|
|
+ if (shopCategoryByCode1 == null) {
|
|
|
+ //不存在门店分类父类目添加
|
|
|
+ FrontCategory frontCategoryParent = frontCategoryMapper.selectOne(new LambdaQueryWrapper<FrontCategory>()
|
|
|
+ .eq(FrontCategory::getCode, frontCategory.getParentCode())
|
|
|
+ .eq(FrontCategory::getIsDelete, 0));
|
|
|
+ addShopCategory(frontCategoryParent, prodId, shopId, hbShopId);
|
|
|
+
|
|
|
+ shopCategoryByCode1 = shopCategoryMapper.selectOne(new LambdaQueryWrapper<ShopCategory>()
|
|
|
+ .eq(ShopCategory::getCode, frontCategory.getParentCode())
|
|
|
+ .eq(ShopCategory::getShopId, shopId)
|
|
|
+ .eq(ShopCategory::getIsDelete, 0));
|
|
|
+ }
|
|
|
+ shopCategory.setPid(shopCategoryByCode1.getId());
|
|
|
+ shopCategory.setParentCode(shopCategoryByCode1.getCode());
|
|
|
}
|
|
|
- shopCategory.setPid(shopCategoryByCode1.getId());
|
|
|
- shopCategory.setParentCode(shopCategoryByCode1.getCode());
|
|
|
- }
|
|
|
-
|
|
|
- shopCategory.setShopId(shopId);
|
|
|
- shopCategory.setHbShopId(hbShopId);
|
|
|
- shopCategory.setLabel(frontCategory.getLabel());
|
|
|
- shopCategory.setIcon(frontCategory.getIcon());
|
|
|
- shopCategory.setPic(frontCategory.getPic());
|
|
|
- shopCategory.setLevel(frontCategory.getLevel());
|
|
|
- shopCategory.setIsDelete(0);
|
|
|
- shopCategory.setOperateUser("admin");
|
|
|
- shopCategory.setNum(frontCategory.getNum());
|
|
|
- shopCategory.setIsLeaves(frontCategory.getIsLeaves());
|
|
|
|
|
|
- shopCategoryMapper.insert(shopCategory);
|
|
|
+ shopCategory.setShopId(shopId);
|
|
|
+ shopCategory.setHbShopId(hbShopId);
|
|
|
+ shopCategory.setLabel(frontCategory.getLabel());
|
|
|
+ shopCategory.setIcon(frontCategory.getIcon());
|
|
|
+ shopCategory.setPic(frontCategory.getPic());
|
|
|
+ shopCategory.setLevel(frontCategory.getLevel());
|
|
|
+ shopCategory.setIsDelete(0);
|
|
|
+ shopCategory.setOperateUser("admin");
|
|
|
+ shopCategory.setNum(frontCategory.getNum());
|
|
|
+ shopCategory.setIsLeaves(frontCategory.getIsLeaves());
|
|
|
+ shopCategory.setRecTime(new Date());
|
|
|
+
|
|
|
+ shopCategoryMapper.insert(shopCategory);
|
|
|
+ log.info("门店分类添加成功:{}", shopCategory);
|
|
|
+ //二级添加门店-分类绑定商品管理
|
|
|
+ addCategoryProd(prodId, shopCategory);
|
|
|
+ } else {
|
|
|
+ log.info("门店分类已存在,无需添加");
|
|
|
+ //二级添加门店-分类绑定商品管理
|
|
|
+ addCategoryProd(prodId, shopCategoryByCode);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //二级添加门店-分类管理
|
|
|
+ /**
|
|
|
+ * 添加门店-分类绑定商品管理
|
|
|
+ *
|
|
|
+ * @param prodId 商品id
|
|
|
+ * @param shopCategory 门店分类
|
|
|
+ */
|
|
|
+ private void addCategoryProd(Long prodId, ShopCategory shopCategory) {
|
|
|
+ log.info("添加门店-分类绑定商品管理");
|
|
|
if (shopCategory.getLevel() == 2) {
|
|
|
- Integer count = categoryProdMapper.selectCount(new LambdaQueryWrapper<CategoryProd>()
|
|
|
- .eq(CategoryProd::getCode, shopCategory.getCode())
|
|
|
+ Integer count = categoryProdMapper.selectCount(new LambdaQueryWrapper<CategoryProd>()
|
|
|
.eq(CategoryProd::getIsDelete, 0)
|
|
|
+ .eq(CategoryProd::getCode, shopCategory.getCode())
|
|
|
+ .eq(CategoryProd::getProdId, prodId)
|
|
|
.eq(CategoryProd::getShopId, shopCategory.getShopId()));
|
|
|
|
|
|
- if (count == 0){
|
|
|
- CategoryProd categoryProd = new CategoryProd();
|
|
|
- categoryProd.setProdId(prodId);
|
|
|
- categoryProd.setCategoryId(shopCategory.getId());
|
|
|
- categoryProd.setCode(shopCategory.getCode());
|
|
|
- categoryProd.setShopId(shopCategory.getShopId());
|
|
|
- categoryProd.setIsDelete(0);
|
|
|
- categoryProd.setCreateTime(new Date());
|
|
|
-
|
|
|
- categoryProdMapper.insert(categoryProd);
|
|
|
- }
|
|
|
+ if (count == 0) {
|
|
|
+ CategoryProd categoryProd = new CategoryProd();
|
|
|
+ categoryProd.setProdId(prodId);
|
|
|
+ categoryProd.setCategoryId(shopCategory.getId());
|
|
|
+ categoryProd.setCode(shopCategory.getCode());
|
|
|
+ categoryProd.setShopId(shopCategory.getShopId());
|
|
|
+ categoryProd.setIsDelete(0);
|
|
|
+ categoryProd.setCreateTime(new Date());
|
|
|
+
|
|
|
+ categoryProdMapper.insert(categoryProd);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -380,6 +397,7 @@ public class HBGoodsService implements IHBGoodsService {
|
|
|
shopSkuInfo.setRecTime(new Date());
|
|
|
shopSkuInfo.setUpdateTime(new Date());
|
|
|
shopSkuMapper.insert(shopSkuInfo);
|
|
|
+
|
|
|
log.info("库存添加成功");
|
|
|
} else {
|
|
|
shopSku.setSpuId(sku.getProdId());
|
|
|
@@ -624,13 +642,13 @@ public class HBGoodsService implements IHBGoodsService {
|
|
|
if (StringUtils.isEmpty(ztFrontCategoryCodeLevel)) {
|
|
|
ztFrontCategoryCodeLevel = jsonObject.getString("ztFrontCategoryCode");
|
|
|
}
|
|
|
- addCategoryProd(spuId, ztFrontCategoryCodeLevel);
|
|
|
+ addCategoryProdHb(spuId, ztFrontCategoryCodeLevel);
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void addCategoryProd(Long spuId, String ztFrontCategoryCodeLevel) {
|
|
|
+ private void addCategoryProdHb(Long spuId, String ztFrontCategoryCodeLevel) {
|
|
|
CategoryProdHb categoryProd = new CategoryProdHb();
|
|
|
categoryProd.setCode(ztFrontCategoryCodeLevel);
|
|
|
categoryProd.setProdId(spuId);
|