|
@@ -804,34 +804,29 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
builder.put("thirdPartyMerchCode", "第三方商户代码");
|
|
|
builder.put("goodsBizType", "货品业务类型");
|
|
|
builder.put("name", "商品名称");
|
|
|
+ builder.put("prodBarcode", "产品条码");
|
|
|
+ builder.put("sku", "sku");
|
|
|
builder.put("isOnSaleStr", "上架");
|
|
|
builder.put("goodsUnit", "商品单位");
|
|
|
- builder.put("isHotStr", "热销");
|
|
|
- builder.put("prodBarcode", "产品条码");
|
|
|
-// builder.put("marketPrice", "市场价");
|
|
|
-// builder.put("retailPrice", "零售价");
|
|
|
- builder.put("supplierName", "供应商");
|
|
|
- builder.put("goodsNumber", "商品总库存");
|
|
|
+ builder.put("isHotStr", "是否热销");
|
|
|
+ builder.put("goodsRate", "商品税率");
|
|
|
+ builder.put("brand", "产品品牌");
|
|
|
+ builder.put("uniqueIdentifier", "品牌唯一简码");
|
|
|
+ builder.put("unitName", "计量单位");
|
|
|
+ builder.put("oriCntName", "原产国");
|
|
|
+ builder.put("valueAddedTaxRate", "增值税率");
|
|
|
+ builder.put("goodsNumber", "库存数");
|
|
|
+ builder.put("firstLevel", "一级分类");
|
|
|
+ builder.put("secondLevel", "二级分类");
|
|
|
+ builder.put("warehouseSn", "仓库编码");
|
|
|
+ builder.put("consignorSn", "货主编码");
|
|
|
+ builder.put("warehousSysGoodId", "仓储系统商品ID");
|
|
|
+ builder.put("inventoryType", "库存类型");
|
|
|
+ builder.put("legalUnit1Qty", "第一法定单位数量");
|
|
|
+ builder.put("legalUnit2Qty", "第二法定单位数量");
|
|
|
R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
|
|
|
if (Integer.valueOf(r.get("code").toString()) != 0) {
|
|
|
throw new RRException(r.get("msg").toString());
|
|
|
- } else {
|
|
|
- if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
|
|
|
- // 海关信息,普通货物可不添加
|
|
|
- builder.put("goodsRate", "商品税率");
|
|
|
- builder.put("sku", "SKU");
|
|
|
-// builder.put("brand", "产品品牌");
|
|
|
- builder.put("unitName", "计量单位");
|
|
|
- builder.put("oriCntName", "原产国");
|
|
|
- //builder.put("cusGoodsCode", "海关商品编码");
|
|
|
- //builder.put("ciqProdModel", "国检规格型号");
|
|
|
- //builder.put("cusDeclEle", "海关申报要素");
|
|
|
- //builder.put("cusRecCode", "海关备案编号");
|
|
|
- }
|
|
|
- r = ValidatorUtil.isEmpty(builder.build(), valideDate);
|
|
|
- if (Integer.valueOf(r.get("code").toString()) != 0) {
|
|
|
- throw new RRException(r.get("msg").toString());
|
|
|
- }
|
|
|
}
|
|
|
//业务类型校验
|
|
|
if(!Dict.orderBizType.item_11.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())){
|
|
@@ -895,10 +890,10 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goodsEntity.setSupplierId(supplierEntity.getId());
|
|
|
}
|
|
|
}
|
|
|
- //商品配置校验
|
|
|
- /*
|
|
|
- 先在redis在查询该品牌是否存在,如果存在获取品牌id,如果不存在,先新增该品牌,在将品牌存入到redis中,在获取品牌id
|
|
|
- */
|
|
|
+ GoodsEntity goodsNew = goodsDao.queryObjectBySnNew(goodsDto.getGoodsSn());
|
|
|
+ if(goodsNew!=null){
|
|
|
+ throw new RRException("该商品数据已存在,请勿重复导入:"+goodsNew.getGoodsSn());
|
|
|
+ }
|
|
|
// 获取品牌唯一简码
|
|
|
checkBrand(goodsDto, goodsEntity);
|
|
|
// 获取二级分类id
|
|
@@ -957,7 +952,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goodsEntity.setConsignorSn(goodsDto.getConsignorSn());
|
|
|
goodsEntity.setInventoryType(goodsDto.getInventoryType());
|
|
|
goodsEntity.setDefectiveProductsGrade(goodsDto.getDefectiveProductsGrade());
|
|
|
- goodsEntity.setNetWeight(new BigDecimal(goodsDto.getNetWeight()));
|
|
|
+ //goodsEntity.setNetWeight(new BigDecimal(goodsDto.getNetWeight()));
|
|
|
goodsEntity.setLegalUnit1Qty(new BigDecimal(goodsDto.getLegalUnit1Qty()));
|
|
|
goodsEntity.setLegalUnit2Qty(new BigDecimal(goodsDto.getLegalUnit2Qty()));
|
|
|
if(null!=goodsDto.getImpConsumTaxRate()){
|
|
@@ -1139,105 +1134,26 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
|
|
|
private void checkCategory(GoodsDto goodsDto, GoodsEntity goodsEntity) {
|
|
|
- String secondLevel = goodsDto.getSecondLevel(); // 二级分类名称
|
|
|
- Map<String, String> categoryCache = JedisUtil.getMap(secondLevel);
|
|
|
- if(categoryCache != null){
|
|
|
- String categoryId = categoryCache.get("categoryId");
|
|
|
- String level = categoryCache.get("level");
|
|
|
+ // 二级分类名称
|
|
|
+ String secondLevel = goodsDto.getSecondLevel().trim();
|
|
|
+ String firstLevelName = goodsDto.getFirstLevel().trim();
|
|
|
+ CategoryEntity categoryNew = categoryDao.queryByName(secondLevel);
|
|
|
+ if(categoryNew != null){
|
|
|
+ String categoryId = categoryNew.getId().toString();
|
|
|
+ String level = categoryNew.getLevel();
|
|
|
if(categoryId == null){
|
|
|
- CategoryEntity category = categoryDao.queryByName(secondLevel);
|
|
|
- if (category == null) {
|
|
|
-
|
|
|
- // 将该id存入带缓存中
|
|
|
- Map<String,String> categoryCacheData = new HashMap<>();
|
|
|
- categoryCacheData.put("level",Dict.Level.item_L2.getItem());
|
|
|
-
|
|
|
- // 查询数据库中是否有一级分类
|
|
|
- String firstLevel = goodsDto.getFirstLevel();
|
|
|
- CategoryEntity firstCategory = categoryDao.queryByName(firstLevel);
|
|
|
- // if(firstCategory == null){
|
|
|
- // // 一级分类不存在
|
|
|
- // // 新增一级分类
|
|
|
- // CategoryEntity firstCategoryEntity = initCategory(firstLevel, 0, Dict.Level.item_L1);
|
|
|
- // categoryDao.save(firstCategoryEntity);
|
|
|
- // // 新增二级分类
|
|
|
- // CategoryEntity secondCategoryEntity = initCategory(secondLevel, firstCategoryEntity.getId(), Dict.Level.item_L2);
|
|
|
- // categoryDao.save(secondCategoryEntity);
|
|
|
- // categoryId = secondCategoryEntity.getId()+"";
|
|
|
- // }else{
|
|
|
- // // 新增二级分类
|
|
|
- // CategoryEntity saveCategoryEntity = initCategory(secondLevel, firstCategory.getId(), Dict.Level.item_L2);
|
|
|
- // categoryDao.save(saveCategoryEntity);
|
|
|
- // categoryId = saveCategoryEntity.getId()+"";
|
|
|
- //
|
|
|
- // }
|
|
|
-// categoryCacheData.put("categoryId",categoryId);
|
|
|
-// JedisUtil.setMap(secondLevel,categoryCacheData,0);
|
|
|
-// goodsEntity.setCategoryId(Integer.parseInt(categoryId));
|
|
|
- throw new RuntimeException("该分类不是二级分类,请检查,对应条码是:"+ goodsDto.getSku()+",分类名称为:"+ goodsDto.getSecondLevel());
|
|
|
- }else if(category != null && Dict.Level.item_L2.getItem().equals(category.getLevel())){
|
|
|
- // 缓存中没有,数据库中有,直接存入数据库中查询到的数据
|
|
|
- goodsEntity.setCategoryId(category.getId());
|
|
|
- // 将该id存入带缓存中
|
|
|
- Map<String,String> categoryCacheData = new HashMap<>();
|
|
|
- categoryCacheData.put("level",Dict.Level.item_L2.getItem());
|
|
|
- categoryCacheData.put("categoryId",category.getId()+"");
|
|
|
- JedisUtil.setMap(secondLevel,categoryCacheData,0);
|
|
|
-
|
|
|
- }else{
|
|
|
- throw new RuntimeException("该分类不是二级分类,请检查,对应sku是:"+ goodsDto.getSku()+",分类名称为:"+ goodsDto.getSecondLevel());
|
|
|
- }
|
|
|
+ throw new RuntimeException("该分类不是二级分类,请检查,对应sku是:"+ goodsDto.getSku()+",分类名称为:"+ goodsDto.getSecondLevel());
|
|
|
}else if(Dict.Level.item_L2.getItem().equals(level)){
|
|
|
+ CategoryEntity firstCategory = categoryDao.queryByName(firstLevelName);
|
|
|
+ if(firstCategory==null) {
|
|
|
+ throw new RuntimeException("该分类不是一级分类,请检查,对应sku是:" + goodsDto.getSku() + ",分类名称为:" + firstLevelName);
|
|
|
+ }
|
|
|
+ goodsEntity.setAttributeCategory(firstCategory.getId());
|
|
|
// 二级分类id在缓存中有,直接存入商品
|
|
|
goodsEntity.setCategoryId(Integer.parseInt(categoryId));
|
|
|
- }else {
|
|
|
- throw new RuntimeException("该分类不是二级分类,请检查,对应sku是:"+ goodsDto.getSku()+",分类名称为:"+ goodsDto.getSecondLevel());
|
|
|
}
|
|
|
}else {
|
|
|
- String categoryId = "";
|
|
|
- CategoryEntity category = categoryDao.queryByName(secondLevel);
|
|
|
- if (category == null) {
|
|
|
- // 将该id存入带缓存中
|
|
|
- Map<String,String> categoryCacheData = new HashMap<>();
|
|
|
- categoryCacheData.put("level",Dict.Level.item_L2.getItem());
|
|
|
-
|
|
|
- // 查询数据库中是否有一级分类
|
|
|
- String firstLevel = goodsDto.getFirstLevel();
|
|
|
- CategoryEntity firstCategory = categoryDao.queryByName(firstLevel);
|
|
|
- // if(firstCategory == null){
|
|
|
- // // 一级分类不存在
|
|
|
- // // 新增一级分类
|
|
|
- // CategoryEntity firstCategoryEntity = initCategory(firstLevel, 0, Dict.Level.item_L1);
|
|
|
- // categoryDao.save(firstCategoryEntity);
|
|
|
- // // 新增二级分类
|
|
|
- // CategoryEntity secondCategoryEntity = initCategory(secondLevel, firstCategoryEntity.getId(), Dict.Level.item_L2);
|
|
|
- // categoryDao.save(secondCategoryEntity);
|
|
|
- // categoryId = secondCategoryEntity.getId()+"";
|
|
|
- // }else{
|
|
|
- // // 新增二级分类
|
|
|
- // CategoryEntity saveCategoryEntity = initCategory(secondLevel, firstCategory.getId(), Dict.Level.item_L2);
|
|
|
- // categoryDao.save(saveCategoryEntity);
|
|
|
- // categoryId = saveCategoryEntity.getId()+"";
|
|
|
- //
|
|
|
- // }
|
|
|
-// categoryCacheData.put("categoryId",categoryId);
|
|
|
-// JedisUtil.setMap(secondLevel,categoryCacheData,0);
|
|
|
-// goodsEntity.setCategoryId(Integer.parseInt(categoryId));
|
|
|
- throw new RuntimeException("该分类不是二级分类,请检查,对应条码是:"+ goodsDto.getSku()+",分类名称为:"+ goodsDto.getSecondLevel());
|
|
|
-
|
|
|
-
|
|
|
- }else if(category != null && Dict.Level.item_L2.getItem().equals(category.getLevel())){
|
|
|
- // 缓存中没有,数据库中有,直接存入数据库中查询到的数据
|
|
|
- goodsEntity.setCategoryId(category.getId());
|
|
|
- // 将该id存入带缓存中
|
|
|
- Map<String,String> categoryCacheData = new HashMap<>();
|
|
|
- categoryCacheData.put("level",Dict.Level.item_L2.getItem());
|
|
|
- categoryCacheData.put("categoryId",category.getId()+"");
|
|
|
- JedisUtil.setMap(secondLevel,categoryCacheData,0);
|
|
|
-
|
|
|
- }else{
|
|
|
throw new RuntimeException("该分类不是二级分类,请检查,对应sku是:"+ goodsDto.getSku()+",分类名称为:"+ goodsDto.getSecondLevel());
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|