|
@@ -959,16 +959,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());
|
|
|
- }
|
|
|
+// 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);
|
|
|
}
|
|
|
|
|
@@ -1054,17 +1054,37 @@ 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.queryObjectBySnNew(storeGoodsDto.getGoodsSn());
|
|
|
if (goodsEntity != null) {
|
|
@@ -1072,52 +1092,45 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
|
}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("导入数据为空,或者检查数据是否为空");
|
|
|
}
|