|
@@ -149,12 +149,12 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
}
|
|
}
|
|
|
|
|
|
//商品配置校验
|
|
//商品配置校验
|
|
- if(!StringUtils.isNotEmpty(goodsEntity.getListPicUrl())){
|
|
|
|
- throw new RRException("该商品列表图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品列表图信息,再来操作门店商品数据");
|
|
|
|
- }
|
|
|
|
- if(!StringUtils.isNotEmpty(goodsEntity.getPrimaryPicUrl())){
|
|
|
|
- throw new RRException("该商品主图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品主图信息,再来操作门店商品数据");
|
|
|
|
- }
|
|
|
|
|
|
+// if(!StringUtils.isNotEmpty(goodsEntity.getListPicUrl())){
|
|
|
|
+// throw new RRException("该商品列表图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品列表图信息,再来操作门店商品数据");
|
|
|
|
+// }
|
|
|
|
+// if(!StringUtils.isNotEmpty(goodsEntity.getPrimaryPicUrl())){
|
|
|
|
+// throw new RRException("该商品主图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品主图信息,再来操作门店商品数据");
|
|
|
|
+// }
|
|
// List<GoodsGalleryEntity> galleryEntityList = goodsGalleryDao.queryObjectByGoodId(goodsEntity.getId());
|
|
// List<GoodsGalleryEntity> galleryEntityList = goodsGalleryDao.queryObjectByGoodId(goodsEntity.getId());
|
|
// if (galleryEntityList == null || galleryEntityList.size() <= 0) {
|
|
// if (galleryEntityList == null || galleryEntityList.size() <= 0) {
|
|
// throw new RRException("该商品轮播图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品详情轮播图信息,再来操作门店商品数据");
|
|
// throw new RRException("该商品轮播图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品详情轮播图信息,再来操作门店商品数据");
|
|
@@ -851,24 +851,38 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]未录入系统");
|
|
throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]未录入系统");
|
|
}
|
|
}
|
|
CategoryEntity parentCategoryEntity = categoryDao.queryObjectByName(storeGoodsDto.getCategoryName(), store.getMerchSn(),0);
|
|
CategoryEntity parentCategoryEntity = categoryDao.queryObjectByName(storeGoodsDto.getCategoryName(), store.getMerchSn(),0);
|
|
|
|
+ CategoryEntity categoryEntity;//二级分类
|
|
if (parentCategoryEntity != null) {
|
|
if (parentCategoryEntity != null) {
|
|
- storeRelaEntity.setCategoryId(parentCategoryEntity.getId());
|
|
|
|
- CategoryEntity categoryEntity = categoryDao.queryObjectByName(storeGoodsDto.getAttributeCategory(), store.getMerchSn(),parentCategoryEntity.getId());
|
|
|
|
- if (categoryEntity != null) {
|
|
|
|
- storeRelaEntity.setAttributeCategory(categoryEntity.getId());
|
|
|
|
- }else{
|
|
|
|
- throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的二级类别输入有误");
|
|
|
|
|
|
+ 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{
|
|
}else{
|
|
- throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的一级类别输入有误");
|
|
|
|
|
|
+// 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());
|
|
BrandEntity brandEntity = brandDao.queryObjectByName(storeGoodsDto.getBrandName(), store.getMerchSn(),storeRelaEntity.getAttributeCategory());
|
|
- if (brandEntity != null) {
|
|
|
|
- storeRelaEntity.setBrandId(brandEntity.getId());
|
|
|
|
- }else{
|
|
|
|
- throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的品牌输入有误");
|
|
|
|
|
|
+ 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());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ storeRelaEntity.setBrandId(brandEntity.getId());
|
|
/*FreightEntity freightEntity = freightDao.queryFreightByFreightNameAndStoreId(storeGoodsDto.getFreightName(), store.getId());
|
|
/*FreightEntity freightEntity = freightDao.queryFreightByFreightNameAndStoreId(storeGoodsDto.getFreightName(), store.getId());
|
|
if (freightEntity != null) {
|
|
if (freightEntity != null) {
|
|
storeRelaEntity.setFreightId(freightEntity.getId());
|
|
storeRelaEntity.setFreightId(freightEntity.getId());
|
|
@@ -876,9 +890,9 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的运费模板输入有误");
|
|
throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的运费模板输入有误");
|
|
}*/
|
|
}*/
|
|
// 如果底线价大于零售价
|
|
// 如果底线价大于零售价
|
|
- if (new BigDecimal(storeGoodsDto.getBottomLinePrice()).compareTo(new BigDecimal(storeGoodsDto.getRetailPrice())) == 1) {
|
|
|
|
- throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的底线价不可以大于零售价");
|
|
|
|
- }
|
|
|
|
|
|
+// if (new BigDecimal(storeGoodsDto.getBottomLinePrice()).compareTo(new BigDecimal(storeGoodsDto.getRetailPrice())) == 1) {
|
|
|
|
+// throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的底线价不可以大于零售价");
|
|
|
|
+// }
|
|
// 查询批次号是否存在
|
|
// 查询批次号是否存在
|
|
// GoodsBatchEntity goodsBatchEntity = goodsBatchDao.queryByBatchSnAndSku(storeGoodsDto.getBatchSn(), goodsEntity.getSku());
|
|
// GoodsBatchEntity goodsBatchEntity = goodsBatchDao.queryByBatchSnAndSku(storeGoodsDto.getBatchSn(), goodsEntity.getSku());
|
|
// if (goodsBatchEntity!=null){
|
|
// if (goodsBatchEntity!=null){
|
|
@@ -901,5 +915,42 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private BrandEntity initSaveBrandEntity(String brandName, String merchSn, Integer categroyId) {
|
|
|
|
+ BrandEntity brandEntity = new BrandEntity();
|
|
|
|
+ brandEntity.setName(brandName);
|
|
|
|
+ brandEntity.setMerchSn(merchSn);
|
|
|
|
+ brandEntity.setCategoryId(categroyId);
|
|
|
|
+ brandEntity.setSimpleDesc(brandName);
|
|
|
|
+ brandEntity.setIsShow(1);
|
|
|
|
+ brandEntity.setIsNew(0);
|
|
|
|
+ // 图片随便填
|
|
|
|
+ brandEntity.setListPicUrl("http://120.76.26.84:80/group1/M00/00/58/rBJEdV-X_ReANxuzAABXBxj7KoY326.jpg");
|
|
|
|
+ brandEntity.setPicUrl("http://120.76.26.84:80/group1/M00/00/58/rBJEdV-X_ReANxuzAABXBxj7KoY326.jpg");
|
|
|
|
+ brandEntity.setAppListPicUrl("http://120.76.26.84:80/group1/M00/00/58/rBJEdV-X_ReANxuzAABXBxj7KoY326.jpg");
|
|
|
|
+ brandEntity.setNewPicUrl("http://120.76.26.84:80/group1/M00/00/58/rBJEdV-X_ReANxuzAABXBxj7KoY326.jpg");
|
|
|
|
+ return brandEntity;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private CategoryEntity initSaveCategoryEntity(String categoryName, String merchSn, Integer parentId){
|
|
|
|
+ CategoryEntity saveCategoryEntity = new CategoryEntity();
|
|
|
|
+ saveCategoryEntity.setName(categoryName);
|
|
|
|
+ saveCategoryEntity.setParentId(parentId);
|
|
|
|
+ saveCategoryEntity.setIsShow(1);
|
|
|
|
+ saveCategoryEntity.setFrontDesc(categoryName);
|
|
|
|
+ saveCategoryEntity.setMerchSn(merchSn);
|
|
|
|
+ // 如果是一级分类
|
|
|
|
+ if (parentId.intValue()==0){
|
|
|
|
+ saveCategoryEntity.setLevel("L1");
|
|
|
|
+ }else{
|
|
|
|
+ saveCategoryEntity.setLevel("L2");
|
|
|
|
+ }
|
|
|
|
+ saveCategoryEntity.setType(0);
|
|
|
|
+ // 给个默认图片即可
|
|
|
|
+ saveCategoryEntity.setIconUrl("http://120.76.26.84:80/group1/M00/00/54/rBJEdV9hfU2AVyZHAAAK_hSw3F0952.png");
|
|
|
|
+ saveCategoryEntity.setWapBannerUrl("http://120.76.26.84:80/group1/M00/00/54/rBJEdV9hfU2AVyZHAAAK_hSw3F0952.png");
|
|
|
|
+ return saveCategoryEntity;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|