|
@@ -1,14 +1,11 @@
|
|
|
package com.kmall.admin.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import com.google.common.collect.ImmutableBiMap;
|
|
|
-import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.kmall.admin.dao.*;
|
|
|
import com.kmall.admin.dao.mk.dist.MkDistSellAllocationDao;
|
|
|
import com.kmall.admin.dto.StoreGoodsDto;
|
|
|
import com.kmall.admin.entity.*;
|
|
|
-import com.kmall.admin.entity.kmall2eccs.KtoEccsEntity;
|
|
|
import com.kmall.admin.entity.mk.dist.MkDistSellAllocationEntity;
|
|
|
import com.kmall.admin.fromcomm.entity.SysUserEntity;
|
|
|
import com.kmall.admin.service.BrandService;
|
|
@@ -207,8 +204,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 +213,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 +260,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());
|
|
@@ -902,11 +899,30 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
|
|
|
for (int i = 0; i < storeGoodsDtoList.size(); i++) {
|
|
|
StoreGoodsDto storeGoodsDto = storeGoodsDtoList.get(i);
|
|
|
+
|
|
|
+ Map<String, Object> valideDate = MapBeanUtil.fromObject(storeGoodsDto);
|
|
|
+ ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
|
|
|
+ builder.put("storeName", "门店名称");
|
|
|
+ builder.put("goodsSn", "sku");
|
|
|
+ builder.put("stockNum", "库存");
|
|
|
+ builder.put("categoryName", "一级分类");
|
|
|
+ builder.put("attributeCategory", "二级分类");
|
|
|
+ builder.put("brandName", "品牌");
|
|
|
+ builder.put("uniqueIdentifier", "品牌唯一简码");
|
|
|
+ builder.put("retailPrice", "零售价(税后)");
|
|
|
+ builder.put("marketPrice", "市场价");
|
|
|
+ builder.put("bottomLinePrice", "底线价");
|
|
|
+ builder.put("exitRegionNumber", "出区数");
|
|
|
+ R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
|
|
|
+ if (Integer.valueOf(r.get("code").toString()) != 0) {
|
|
|
+ throw new RRException(r.get("msg").toString());
|
|
|
+ }
|
|
|
+
|
|
|
ProductStoreRelaEntity storeRelaEntity = new ProductStoreRelaEntity();
|
|
|
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().trim());
|
|
|
if (goodsEntity != null) {
|
|
|
storeRelaEntity.setGoodsId(goodsEntity.getId());
|
|
|
}else{
|
|
@@ -914,130 +930,24 @@ 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");
|
|
|
-
|
|
|
- String firstLevelCategoryId = "";
|
|
|
- String secondLevelCategoryId = "";
|
|
|
-
|
|
|
+ String firstLevelName = storeGoodsDto.getCategoryName().trim();
|
|
|
+ String secondLevelName = storeGoodsDto.getAttributeCategory().trim();
|
|
|
+ CategoryEntity categoryNew = categoryDao.queryByName(secondLevelName);
|
|
|
+ if(categoryNew != null){
|
|
|
+ String categoryId = categoryNew.getId().toString();
|
|
|
+ String level = categoryNew.getLevel();
|
|
|
if(categoryId == null){
|
|
|
- CategoryEntity category = categoryDao.queryByName(secondLevelName);
|
|
|
- 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));
|
|
|
-
|
|
|
- }else if(category != null && Dict.Level.item_L2.getItem().equals(category.getLevel())){
|
|
|
- // 缓存中没有,数据库中有,直接存入数据库中查询到的数据
|
|
|
- storeRelaEntity.setCategoryId(category.getId());
|
|
|
- // 将该id存入带缓存中
|
|
|
- CategoryEntity firstCategory = categoryDao.queryByName(firstLevelName);
|
|
|
- // 存储一级分类
|
|
|
- set2Redis(firstLevelName, firstCategory.getId()+"", Dict.Level.item_L1);
|
|
|
- // 存储二级分类
|
|
|
- set2Redis(secondLevelName, category.getId() + "", Dict.Level.item_L2);
|
|
|
-
|
|
|
- // 设置一级、二级分类id
|
|
|
- storeRelaEntity.setAttributeCategory(firstCategory.getId());
|
|
|
- storeRelaEntity.setCategoryId(category.getId());
|
|
|
-
|
|
|
- }else{
|
|
|
- throw new RuntimeException("该分类不是二级分类,请检查,对应sku是:"+ storeGoodsDto.getGoodsSn()+",分类名称为:"+ storeGoodsDto.getAttributeCategory());
|
|
|
- }
|
|
|
+ throw new RuntimeException("该分类不是二级分类,请检查,对应条码是:"+ 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")));
|
|
|
- storeRelaEntity.setCategoryId(Integer.parseInt(categoryId));
|
|
|
- }else {
|
|
|
- throw new RuntimeException("该分类不是二级分类,请检查,对应sku是:"+ storeGoodsDto.getGoodsSn()+",分类名称为:"+ storeGoodsDto.getAttributeCategory());
|
|
|
- }
|
|
|
- }else {
|
|
|
- String firstLevelCategoryId = "";
|
|
|
- String secondLevelCategoryId = "";
|
|
|
- CategoryEntity category = categoryDao.queryByName(secondLevelName);
|
|
|
- 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);
|
|
|
- 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()+"";
|
|
|
-
|
|
|
+ if(firstCategory==null) {
|
|
|
+ throw new RuntimeException("该分类不是一级分类,请检查,对应条码是:" + storeGoodsDto.getGoodsSn() + ",分类名称为:" + firstLevelName);
|
|
|
}
|
|
|
- // 存储一级分类
|
|
|
- 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));
|
|
|
-
|
|
|
- }else if(category != null && Dict.Level.item_L2.getItem().equals(category.getLevel())){
|
|
|
- // 缓存中没有,数据库中有,直接存入数据库中查询到的数据
|
|
|
- // 将该id存入带缓存中
|
|
|
- CategoryEntity firstCategory = categoryDao.queryByName(firstLevelName);
|
|
|
- // 存储一级分类
|
|
|
- set2Redis(firstLevelName, firstCategory.getId()+"", Dict.Level.item_L1);
|
|
|
- // 存储二级分类
|
|
|
- set2Redis(secondLevelName, category.getId() + "", Dict.Level.item_L2);
|
|
|
-
|
|
|
- // 设置一级、二级分类id
|
|
|
storeRelaEntity.setAttributeCategory(firstCategory.getId());
|
|
|
- storeRelaEntity.setCategoryId(category.getId());
|
|
|
-
|
|
|
-
|
|
|
- }else{
|
|
|
- throw new RuntimeException("该分类不是二级分类,请检查,对应sku是:"+ storeGoodsDto.getGoodsSn()+",分类名称为:"+ storeGoodsDto.getAttributeCategory());
|
|
|
+ storeRelaEntity.setCategoryId(Integer.parseInt(categoryId));
|
|
|
}
|
|
|
+ }else {
|
|
|
+ throw new RuntimeException("该分类不是二级分类,请检查,对应条码是:"+ storeGoodsDto.getGoodsSn()+",分类名称为:"+ storeGoodsDto.getAttributeCategory());
|
|
|
}
|
|
|
|
|
|
checkBrand(storeGoodsDto, storeRelaEntity);
|
|
@@ -1045,13 +955,16 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
storeRelaEntity.setRetailPrice(new BigDecimal(storeGoodsDto.getRetailPrice()));
|
|
|
storeRelaEntity.setBottomLinePrice(storeGoodsDto.getBottomLinePrice());
|
|
|
storeRelaEntity.setStockNum(Integer.valueOf(storeGoodsDto.getStockNum()));
|
|
|
-
|
|
|
+// String strCheck = productStoreRelaDao.queryproductStoreByName(storeRelaEntity.getSku(),storeRelaEntity.getStoreId());
|
|
|
+// if(strCheck!=null&&!"".equals(strCheck)){
|
|
|
+// throw new RuntimeException("该商品在当前账号所属门店已存在,请勿重复导入!"+storeRelaEntity.getGoodsSn());
|
|
|
+// }
|
|
|
ProductStoreRelaEntity productStoreRelaEntity = productStoreRelaDao.queryByGoodsIdAndStoreId(storeRelaEntity.getStoreId(), storeRelaEntity.getGoodsId());
|
|
|
if (Objects.isNull(productStoreRelaEntity)) {
|
|
|
((ProductStoreRelaService) AopContext.currentProxy()).save(storeRelaEntity);
|
|
|
}else{
|
|
|
storeRelaEntity.setId(productStoreRelaEntity.getId());
|
|
|
- storeRelaEntity.setStockNum(productStoreRelaEntity.getStockNum()+Integer.valueOf(storeGoodsDto.getStockNum()));
|
|
|
+ storeRelaEntity.setStockNum(productStoreRelaEntity.getStockNum());
|
|
|
((ProductStoreRelaService) AopContext.currentProxy()).update(storeRelaEntity);
|
|
|
}
|
|
|
|
|
@@ -1091,18 +1004,9 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
if (brandId == null) {
|
|
|
Map<String, String> brandCacheData = new HashMap<>();
|
|
|
// 数据库里面查询
|
|
|
- BrandEntity queryBrand = brandService.queryByUniqueIdentifier(uniqueIdentifier);
|
|
|
+ BrandEntity queryBrand = brandService.queryByUniqueIdentifier(uniqueIdentifier.trim());
|
|
|
if (queryBrand == null) {
|
|
|
- BrandEntity brandEntity = new BrandEntity();
|
|
|
- brandEntity.setName(brandName);
|
|
|
- brandEntity.setUniqueIdentifier(uniqueIdentifier);
|
|
|
- brandEntity.setSimpleDesc(brandName);
|
|
|
- brandEntity.setIsShow(1);
|
|
|
- brandEntity.setIsNew(0);
|
|
|
- brandService.save(brandEntity);
|
|
|
- brandCacheData.put("brandId", brandEntity.getId() + "");
|
|
|
- brandCacheData.put("brandName", brandName);
|
|
|
- storeRelaEntity.setBrandId(brandEntity.getId());
|
|
|
+ throw new RuntimeException("该品牌不存在,请检查品牌唯一标识符是否正确:"+uniqueIdentifier);
|
|
|
} else {
|
|
|
brandCacheData.put("brandId", queryBrand.getId() + "");
|
|
|
brandCacheData.put("brandName", queryBrand.getName());
|
|
@@ -1115,18 +1019,9 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
}else{
|
|
|
Map<String, String> brandCacheData = new HashMap<>();
|
|
|
// 数据库里面查询
|
|
|
- BrandEntity queryBrand = brandService.queryByUniqueIdentifier(uniqueIdentifier);
|
|
|
+ BrandEntity queryBrand = brandService.queryByUniqueIdentifier(uniqueIdentifier.trim());
|
|
|
if (queryBrand == null) {
|
|
|
- BrandEntity brandEntity = new BrandEntity();
|
|
|
- brandEntity.setName(brandName);
|
|
|
- brandEntity.setUniqueIdentifier(uniqueIdentifier);
|
|
|
- brandEntity.setSimpleDesc(brandName);
|
|
|
- brandEntity.setIsShow(1);
|
|
|
- brandEntity.setIsNew(0);
|
|
|
- brandService.save(brandEntity);
|
|
|
- brandCacheData.put("brandId", brandEntity.getId() + "");
|
|
|
- brandCacheData.put("brandName", brandName);
|
|
|
- storeRelaEntity.setBrandId(brandEntity.getId());
|
|
|
+ throw new RuntimeException("该品牌不存在,请检查品牌唯一标识符是否正确:"+uniqueIdentifier);
|
|
|
} else {
|
|
|
brandCacheData.put("brandId", queryBrand.getId() + "");
|
|
|
brandCacheData.put("brandName", queryBrand.getName());
|
|
@@ -1137,70 +1032,83 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 这里调用当前bean的save()和update(),事务会失效
|
|
|
+ * 这里调用当前bean的save()和update(),事务会失效,【修改库存】
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public int uploadExcelByCover(List<StoreGoodsDto> storeGoodsDtoList) {
|
|
|
if (storeGoodsDtoList != null && storeGoodsDtoList.size() > 0) {
|
|
|
+
|
|
|
for (int i = 0; i < storeGoodsDtoList.size(); i++) {
|
|
|
StoreGoodsDto storeGoodsDto = storeGoodsDtoList.get(i);
|
|
|
+
|
|
|
+ Map<String, Object> valideDate = MapBeanUtil.fromObject(storeGoodsDto);
|
|
|
+ ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
|
|
|
+ builder.put("storeName", "门店名称");
|
|
|
+ builder.put("goodsSn", "sku");
|
|
|
+ builder.put("stockNum", "库存");
|
|
|
+ builder.put("categoryName", "一级分类");
|
|
|
+ builder.put("attributeCategory", "二级分类");
|
|
|
+ builder.put("brandName", "品牌");
|
|
|
+ builder.put("uniqueIdentifier", "品牌唯一简码");
|
|
|
+ builder.put("retailPrice", "零售价(税后)");
|
|
|
+ builder.put("marketPrice", "市场价");
|
|
|
+ builder.put("bottomLinePrice", "底线价");
|
|
|
+ builder.put("exitRegionNumber", "出区数");
|
|
|
+ R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
|
|
|
+ if (Integer.valueOf(r.get("code").toString()) != 0) {
|
|
|
+ throw new RRException(r.get("msg").toString());
|
|
|
+ }
|
|
|
+
|
|
|
ProductStoreRelaEntity storeRelaEntity = new ProductStoreRelaEntity();
|
|
|
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{
|
|
|
throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]未录入系统");
|
|
|
}
|
|
|
- CategoryEntity parentCategoryEntity = categoryDao.queryObjectByName(storeGoodsDto.getCategoryName(), store.getMerchSn(),0);
|
|
|
- CategoryEntity categoryEntity;//二级分类
|
|
|
- if (parentCategoryEntity != null) {
|
|
|
- categoryEntity = categoryDao.queryObjectByName(storeGoodsDto.getAttributeCategory(), store.getMerchSn(),parentCategoryEntity.getId());
|
|
|
- if (categoryEntity == null) {
|
|
|
- categoryEntity = initSaveCategoryEntity(storeGoodsDto.getAttributeCategory(), store.getMerchSn(), parentCategoryEntity.getId());
|
|
|
- categoryDao.save(categoryEntity);
|
|
|
- categoryEntity = categoryDao.queryObjectByName(storeGoodsDto.getAttributeCategory(), store.getMerchSn(),parentCategoryEntity.getId());
|
|
|
- }
|
|
|
- }else{
|
|
|
-// throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的一级类别输入有误");
|
|
|
- // 如果没有一级分类就自动创建一二级分类
|
|
|
- parentCategoryEntity = initSaveCategoryEntity(storeGoodsDto.getCategoryName(), store.getMerchSn(),0);
|
|
|
- categoryDao.save(parentCategoryEntity);
|
|
|
- // 保存后再查出来
|
|
|
- parentCategoryEntity = categoryDao.queryObjectByName(storeGoodsDto.getCategoryName(), store.getMerchSn(),0);
|
|
|
- categoryEntity = initSaveCategoryEntity(storeGoodsDto.getAttributeCategory(),store.getMerchSn(),parentCategoryEntity.getId());
|
|
|
- categoryDao.save(categoryEntity);
|
|
|
- categoryEntity = categoryDao.queryObjectByName(storeGoodsDto.getAttributeCategory(), store.getMerchSn(),parentCategoryEntity.getId());
|
|
|
- }
|
|
|
-
|
|
|
- storeRelaEntity.setCategoryId(parentCategoryEntity.getId());
|
|
|
- storeRelaEntity.setAttributeCategory(categoryEntity.getId());
|
|
|
|
|
|
- BrandEntity brandEntity = brandDao.queryObjectByName(storeGoodsDto.getBrandName(), store.getMerchSn(),storeRelaEntity.getAttributeCategory());
|
|
|
- if (brandEntity == null) {
|
|
|
- // throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的品牌输入有误");
|
|
|
- brandEntity = initSaveBrandEntity(storeGoodsDto.getBrandName(), store.getMerchSn(),storeRelaEntity.getAttributeCategory());
|
|
|
- brandDao.save(brandEntity);
|
|
|
- brandEntity = brandDao.queryObjectByName(storeGoodsDto.getBrandName(), store.getMerchSn(),storeRelaEntity.getAttributeCategory());
|
|
|
+ // 获取分类id
|
|
|
+ String firstLevelName = storeGoodsDto.getCategoryName().trim();
|
|
|
+ String secondLevelName = storeGoodsDto.getAttributeCategory().trim();
|
|
|
+ CategoryEntity categoryNew = categoryDao.queryByName(secondLevelName);
|
|
|
+ if(categoryNew != null){
|
|
|
+ String categoryId = categoryNew.getId().toString();
|
|
|
+ String level = categoryNew.getLevel();
|
|
|
+ if(categoryId == null){
|
|
|
+ throw new RuntimeException("该分类不是二级分类,请检查,对应条码是:"+ storeGoodsDto.getGoodsSn()+",分类名称为:"+ storeGoodsDto.getAttributeCategory());
|
|
|
+ }else if(Dict.Level.item_L2.getItem().equals(level)){
|
|
|
+ CategoryEntity firstCategory = categoryDao.queryByName(firstLevelName);
|
|
|
+ if(firstCategory==null) {
|
|
|
+ throw new RuntimeException("该分类不是一级分类,请检查,对应条码是:" + storeGoodsDto.getGoodsSn() + ",分类名称为:" + firstLevelName);
|
|
|
+ }
|
|
|
+ storeRelaEntity.setAttributeCategory(firstCategory.getId());
|
|
|
+ storeRelaEntity.setCategoryId(Integer.parseInt(categoryId));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ throw new RuntimeException("该分类不是二级分类,请检查,对应条码是:"+ storeGoodsDto.getGoodsSn()+",分类名称为:"+ storeGoodsDto.getAttributeCategory());
|
|
|
}
|
|
|
|
|
|
- storeRelaEntity.setBrandId(brandEntity.getId());
|
|
|
+ checkBrand(storeGoodsDto, storeRelaEntity);
|
|
|
storeRelaEntity.setMarketPrice(new BigDecimal(storeGoodsDto.getMarketPrice()));
|
|
|
storeRelaEntity.setRetailPrice(new BigDecimal(storeGoodsDto.getRetailPrice()));
|
|
|
storeRelaEntity.setBottomLinePrice(storeGoodsDto.getBottomLinePrice());
|
|
|
storeRelaEntity.setStockNum(Integer.valueOf(storeGoodsDto.getStockNum()));
|
|
|
ProductStoreRelaEntity productStoreRelaEntity = productStoreRelaDao.queryByGoodsIdAndStoreId(storeRelaEntity.getStoreId(), storeRelaEntity.getGoodsId());
|
|
|
if (Objects.isNull(productStoreRelaEntity)) {
|
|
|
- save(storeRelaEntity);
|
|
|
+ throw new RuntimeException("该商品不存在无法修改库存:"+ storeRelaEntity.getGoodsSn());
|
|
|
}else{
|
|
|
storeRelaEntity.setId(productStoreRelaEntity.getId());
|
|
|
storeRelaEntity.setStockNum(productStoreRelaEntity.getStockNum()+Integer.valueOf(storeGoodsDto.getStockNum()));
|
|
|
- update(storeRelaEntity);
|
|
|
+ ((ProductStoreRelaService) AopContext.currentProxy()).update(storeRelaEntity);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}else{
|
|
|
throw new RRException("导入数据为空,或者检查数据是否为空");
|
|
|
}
|