|
@@ -207,8 +207,8 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
// 修改产品
|
|
|
if(product == null){
|
|
|
product = new ProductEntity();
|
|
|
- product.setGoodsSn(goodsEntity.getGoodsSn());
|
|
|
- product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
|
|
|
+ product.setGoodsSn(goodsEntity.getGoodsSn().trim());
|
|
|
+ product.setGoodsSpecificationNameValue(goodsSpecification.getValue().trim());
|
|
|
product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
|
|
|
product.setGoodsId(goodsEntity.getId());
|
|
|
product.setGoodsNumber(goodsEntity.getGoodsNumber());
|
|
@@ -216,7 +216,7 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
productDao.save(product);
|
|
|
}else{
|
|
|
product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
|
|
|
- product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
|
|
|
+ product.setGoodsSpecificationNameValue(goodsSpecification.getValue().trim());
|
|
|
productDao.update(product);
|
|
|
}
|
|
|
}
|
|
@@ -263,7 +263,7 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
productStoreRela.setAttributeCategory(categoryDao.queryObject(productStoreRela.getCategoryId()).getParentId());
|
|
|
productStoreRela.setProductId(product.getId());
|
|
|
productStoreRela.setGoodsBizType(goodsEntity.getGoodsBizType());
|
|
|
- productStoreRela.setSku(goodsEntity.getSku());
|
|
|
+ productStoreRela.setSku(goodsEntity.getSku().trim());
|
|
|
productStoreRela.setCreaterSn(user.getUserId().toString());
|
|
|
productStoreRela.setCreateTime(new Date());
|
|
|
productStoreRela.setModerSn(user.getUserId().toString());
|
|
@@ -906,7 +906,7 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
StoreEntity store = storeDao.queryObjectByName(storeGoodsDto.getStoreName().trim());
|
|
|
storeRelaEntity.setExitRegionNumber(storeGoodsDto.getExitRegionNumber());
|
|
|
storeRelaEntity.setStoreId(store.getId());
|
|
|
- GoodsEntity goodsEntity = goodsDao.queryObjectBySn(storeGoodsDto.getGoodsSn());
|
|
|
+ GoodsEntity goodsEntity = goodsDao.queryObjectBySnNew(storeGoodsDto.getGoodsSn());
|
|
|
if (goodsEntity != null) {
|
|
|
storeRelaEntity.setGoodsId(goodsEntity.getId());
|
|
|
}else{
|
|
@@ -916,10 +916,10 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
// 获取分类id
|
|
|
String firstLevelName = storeGoodsDto.getCategoryName();
|
|
|
String secondLevelName = storeGoodsDto.getAttributeCategory();
|
|
|
- Map<String, String> categoryCache = JedisUtil.getMap(secondLevelName);
|
|
|
- if(categoryCache != null){
|
|
|
- String categoryId = categoryCache.get("categoryId");
|
|
|
- String level = categoryCache.get("level");
|
|
|
+ CategoryEntity categoryNew = categoryDao.queryByName(secondLevelName);
|
|
|
+ if(categoryNew != null){
|
|
|
+ String categoryId = categoryNew.getId().toString();
|
|
|
+ String level = categoryNew.getLevel();
|
|
|
|
|
|
String firstLevelCategoryId = "";
|
|
|
String secondLevelCategoryId = "";
|
|
@@ -929,36 +929,37 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
if (category == null) {
|
|
|
|
|
|
// 查询数据库中是否有一级分类
|
|
|
- CategoryEntity firstCategory = categoryDao.queryByName(firstLevelName);
|
|
|
- if(firstCategory == null){
|
|
|
- // 一级分类不存在
|
|
|
- // 新增一级分类
|
|
|
- CategoryEntity firstCategoryEntity = initCategory(firstLevelName, 0, Dict.Level.item_L1);
|
|
|
- categoryDao.save(firstCategoryEntity);
|
|
|
- // 新增二级分类
|
|
|
- CategoryEntity secondCategoryEntity = initCategory(secondLevelName, firstCategoryEntity.getId(), Dict.Level.item_L2);
|
|
|
- categoryDao.save(secondCategoryEntity);
|
|
|
- categoryId = secondCategoryEntity.getId()+"";
|
|
|
-
|
|
|
- firstLevelCategoryId = firstCategoryEntity.getId() + "";
|
|
|
- secondLevelCategoryId = secondCategoryEntity.getId()+"";
|
|
|
- }else{
|
|
|
- // 新增二级分类
|
|
|
- CategoryEntity saveCategoryEntity = initCategory(secondLevelName, firstCategory.getId(), Dict.Level.item_L2);
|
|
|
- categoryDao.save(saveCategoryEntity);
|
|
|
- firstLevelCategoryId = firstCategory.getId() + "";
|
|
|
- secondLevelCategoryId = saveCategoryEntity.getId()+"";
|
|
|
-
|
|
|
- }
|
|
|
- // 存储一级分类
|
|
|
- set2Redis(firstLevelName, firstLevelCategoryId, Dict.Level.item_L1);
|
|
|
- // 存储二级分类
|
|
|
- set2Redis(secondLevelName, secondLevelCategoryId, Dict.Level.item_L2);
|
|
|
-
|
|
|
- // 设置一级、二级分类id
|
|
|
-
|
|
|
- storeRelaEntity.setAttributeCategory(Integer.parseInt(firstLevelCategoryId));
|
|
|
- storeRelaEntity.setCategoryId(Integer.parseInt(secondLevelCategoryId));
|
|
|
+// CategoryEntity firstCategory = categoryDao.queryByName(firstLevelName);
|
|
|
+// if(firstCategory == null){
|
|
|
+// // 一级分类不存在
|
|
|
+// // 新增一级分类
|
|
|
+// CategoryEntity firstCategoryEntity = initCategory(firstLevelName, 0, Dict.Level.item_L1);
|
|
|
+// categoryDao.save(firstCategoryEntity);
|
|
|
+// // 新增二级分类
|
|
|
+// CategoryEntity secondCategoryEntity = initCategory(secondLevelName, firstCategoryEntity.getId(), Dict.Level.item_L2);
|
|
|
+// categoryDao.save(secondCategoryEntity);
|
|
|
+// categoryId = secondCategoryEntity.getId()+"";
|
|
|
+//
|
|
|
+// firstLevelCategoryId = firstCategoryEntity.getId() + "";
|
|
|
+// secondLevelCategoryId = secondCategoryEntity.getId()+"";
|
|
|
+// }else{
|
|
|
+// // 新增二级分类
|
|
|
+// CategoryEntity saveCategoryEntity = initCategory(secondLevelName, firstCategory.getId(), Dict.Level.item_L2);
|
|
|
+// categoryDao.save(saveCategoryEntity);
|
|
|
+// firstLevelCategoryId = firstCategory.getId() + "";
|
|
|
+// secondLevelCategoryId = saveCategoryEntity.getId()+"";
|
|
|
+//
|
|
|
+// }
|
|
|
+// // 存储一级分类
|
|
|
+// set2Redis(firstLevelName, firstLevelCategoryId, Dict.Level.item_L1);
|
|
|
+// // 存储二级分类
|
|
|
+// set2Redis(secondLevelName, secondLevelCategoryId, Dict.Level.item_L2);
|
|
|
+//
|
|
|
+// // 设置一级、二级分类id
|
|
|
+//
|
|
|
+// storeRelaEntity.setAttributeCategory(Integer.parseInt(firstLevelCategoryId));
|
|
|
+// storeRelaEntity.setCategoryId(Integer.parseInt(secondLevelCategoryId));
|
|
|
+ throw new RuntimeException("该分类不是一级或二级分类,请检查,对应条码是:"+ storeGoodsDto.getGoodsSn()+",分类名称为:"+ storeGoodsDto.getAttributeCategory());
|
|
|
|
|
|
}else if(category != null && Dict.Level.item_L2.getItem().equals(category.getLevel())){
|
|
|
// 缓存中没有,数据库中有,直接存入数据库中查询到的数据
|
|
@@ -978,12 +979,12 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
throw new RuntimeException("该分类不是二级分类,请检查,对应sku是:"+ storeGoodsDto.getGoodsSn()+",分类名称为:"+ storeGoodsDto.getAttributeCategory());
|
|
|
}
|
|
|
}else if(Dict.Level.item_L2.getItem().equals(level)){
|
|
|
- // 二级分类id在缓存中有,直接存入商品
|
|
|
- Map<String, String> firstCategoryCache = JedisUtil.getMap(firstLevelName);
|
|
|
- storeRelaEntity.setAttributeCategory(Integer.parseInt(firstCategoryCache.get("categoryId")));
|
|
|
+
|
|
|
+ CategoryEntity firstCategory = categoryDao.queryByName(firstLevelName);
|
|
|
+ storeRelaEntity.setAttributeCategory(firstCategory.getId());
|
|
|
storeRelaEntity.setCategoryId(Integer.parseInt(categoryId));
|
|
|
}else {
|
|
|
- throw new RuntimeException("该分类不是二级分类,请检查,对应sku是:"+ storeGoodsDto.getGoodsSn()+",分类名称为:"+ storeGoodsDto.getAttributeCategory());
|
|
|
+ throw new RuntimeException("该分类不是一级或二级分类,请检查,对应sku是:"+ storeGoodsDto.getGoodsSn()+",分类名称为:"+ storeGoodsDto.getAttributeCategory());
|
|
|
}
|
|
|
}else {
|
|
|
String firstLevelCategoryId = "";
|
|
@@ -993,33 +994,35 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
|
|
|
|
|
|
// 查询数据库中是否有一级分类
|
|
|
- CategoryEntity firstCategory = categoryDao.queryByName(firstLevelName);
|
|
|
- if(firstCategory == null){
|
|
|
- // 一级分类不存在
|
|
|
- // 新增一级分类
|
|
|
- CategoryEntity firstCategoryEntity = initCategory(firstLevelName, 0, Dict.Level.item_L1);
|
|
|
- categoryDao.save(firstCategoryEntity);
|
|
|
- // 新增二级分类
|
|
|
- CategoryEntity secondCategoryEntity = initCategory(secondLevelName, firstCategoryEntity.getId(), Dict.Level.item_L2);
|
|
|
- categoryDao.save(secondCategoryEntity);
|
|
|
- firstLevelCategoryId = firstCategoryEntity.getId() + "";
|
|
|
- secondLevelCategoryId = secondCategoryEntity.getId()+"";
|
|
|
- }else{
|
|
|
- // 新增二级分类
|
|
|
- CategoryEntity saveCategoryEntity = initCategory(secondLevelName, firstCategory.getId(), Dict.Level.item_L2);
|
|
|
- categoryDao.save(saveCategoryEntity);
|
|
|
- firstLevelCategoryId = firstCategory.getId() + "";
|
|
|
- secondLevelCategoryId = saveCategoryEntity.getId()+"";
|
|
|
-
|
|
|
- }
|
|
|
- // 存储一级分类
|
|
|
- set2Redis(firstLevelName, firstLevelCategoryId, Dict.Level.item_L1);
|
|
|
- // 存储二级分类
|
|
|
- set2Redis(secondLevelName, secondLevelCategoryId, Dict.Level.item_L2);
|
|
|
+// CategoryEntity firstCategory = categoryDao.queryByName(firstLevelName);
|
|
|
+// if(firstCategory == null){
|
|
|
+// // 一级分类不存在
|
|
|
+// // 新增一级分类
|
|
|
+// CategoryEntity firstCategoryEntity = initCategory(firstLevelName, 0, Dict.Level.item_L1);
|
|
|
+// categoryDao.save(firstCategoryEntity);
|
|
|
+// // 新增二级分类
|
|
|
+// CategoryEntity secondCategoryEntity = initCategory(secondLevelName, firstCategoryEntity.getId(), Dict.Level.item_L2);
|
|
|
+// categoryDao.save(secondCategoryEntity);
|
|
|
+// firstLevelCategoryId = firstCategoryEntity.getId() + "";
|
|
|
+// secondLevelCategoryId = secondCategoryEntity.getId()+"";
|
|
|
+// }else{
|
|
|
+// // 新增二级分类
|
|
|
+// CategoryEntity saveCategoryEntity = initCategory(secondLevelName, firstCategory.getId(), Dict.Level.item_L2);
|
|
|
+// categoryDao.save(saveCategoryEntity);
|
|
|
+// firstLevelCategoryId = firstCategory.getId() + "";
|
|
|
+// secondLevelCategoryId = saveCategoryEntity.getId()+"";
|
|
|
+//
|
|
|
+// }
|
|
|
+// // 存储一级分类
|
|
|
+// set2Redis(firstLevelName, firstLevelCategoryId, Dict.Level.item_L1);
|
|
|
+// // 存储二级分类
|
|
|
+// set2Redis(secondLevelName, secondLevelCategoryId, Dict.Level.item_L2);
|
|
|
+//
|
|
|
+// // 设置一级、二级分类id
|
|
|
+// storeRelaEntity.setAttributeCategory(Integer.parseInt(firstLevelCategoryId));
|
|
|
+// storeRelaEntity.setCategoryId(Integer.parseInt(secondLevelCategoryId));
|
|
|
+ throw new RuntimeException("该分类不是一级或二级分类,请检查,对应sku是:"+ storeGoodsDto.getGoodsSn()+",分类名称为:"+ storeGoodsDto.getAttributeCategory());
|
|
|
|
|
|
- // 设置一级、二级分类id
|
|
|
- storeRelaEntity.setAttributeCategory(Integer.parseInt(firstLevelCategoryId));
|
|
|
- storeRelaEntity.setCategoryId(Integer.parseInt(secondLevelCategoryId));
|
|
|
|
|
|
}else if(category != null && Dict.Level.item_L2.getItem().equals(category.getLevel())){
|
|
|
// 缓存中没有,数据库中有,直接存入数据库中查询到的数据
|
|
@@ -1149,7 +1152,7 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
StoreEntity store = storeDao.queryObjectByName(storeGoodsDto.getStoreName().trim());
|
|
|
|
|
|
storeRelaEntity.setStoreId(store.getId());
|
|
|
- GoodsEntity goodsEntity = goodsDao.queryObjectBySn(storeGoodsDto.getGoodsSn());
|
|
|
+ GoodsEntity goodsEntity = goodsDao.queryObjectBySnNew(storeGoodsDto.getGoodsSn());
|
|
|
if (goodsEntity != null) {
|
|
|
storeRelaEntity.setGoodsId(goodsEntity.getId());
|
|
|
}else{
|