瀏覽代碼

xwh增加商品导入会批量修改库存按钮

xwh 4 年之前
父節點
當前提交
f2ee30d46a

+ 28 - 0
kmall-admin/src/main/java/com/kmall/admin/controller/GoodsController.java

@@ -277,6 +277,34 @@ public class GoodsController {
         //上传文件
         return R.ok();
     }
+
+
+
+    /**
+     * 上传文件(修改库存版)
+     */
+    @RequestMapping("/uploadByCover")
+    @ResponseBody
+    public R uploadByCover(@RequestParam("file") MultipartFile file) {
+        List<GoodsDto> goodsDtoList = new ArrayList<>();//商品信息
+        try {
+            Map<String, Object> beans = new HashMap<String, Object>();
+            beans.put("GoodsDtoList", goodsDtoList);
+            if (file.isEmpty()) {
+                return R.error("文件不能为空!");
+            }
+            excelUtil.readExcel(JxlsXmlTemplateName.GOODS_DTO_LIST, beans, file.getInputStream());
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.error("导入失败!");
+        }
+        goodsService.uploadExcelByCover(goodsDtoList,Integer.parseInt(Dict.exportDataType.item_1.getItem()));
+        //上传文件
+        return R.ok();
+    }
+
+
+
     /**
      * 上传文件
      */

+ 31 - 0
kmall-admin/src/main/java/com/kmall/admin/controller/ProductStoreRelaController.java

@@ -296,6 +296,37 @@ public class ProductStoreRelaController {
         return R.ok("导入成功!");
     }
 
+
+
+    /**
+     * 上传文件(修改库存版)
+     */
+    @RequestMapping("/productStoreRelaUploadByCover")
+    @ResponseBody
+    public R storeUploadByCover(@RequestParam("file") MultipartFile file) {
+        List<StoreGoodsDto> StoreGoodsDtoList = new ArrayList<>();//信息
+        try {
+            StoreGoodsDto storeGoodsDto = new StoreGoodsDto();
+            Map<String, Object> beans = new HashMap<String, Object>();
+            beans.put("StoreGoodsDto", storeGoodsDto);
+            beans.put("StoreGoodsDtoList", StoreGoodsDtoList);
+            if (file.isEmpty()) {
+                return R.error("文件不能为空!");
+            }
+            excelUtil.readExcel(JxlsXmlTemplateName.STORE_GOODS_DTO_LIST, beans, file.getInputStream());
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.error("导入失败!");
+        }
+        productStoreRelaService.uploadExcelByCover(StoreGoodsDtoList);
+        //上传文件
+        return R.ok("导入成功!");
+    }
+
+
+
+
+
     /**
      * 门店商品导出
      * @param params

+ 9 - 0
kmall-admin/src/main/java/com/kmall/admin/service/GoodsService.java

@@ -125,6 +125,15 @@ public interface GoodsService {
      */
     int uploadExcel(List<GoodsDto> goodsEntityList,int exportDataType);
 
+
+    /**
+     * 导入商品(修改库存版)
+     *
+     * @param goodsEntityList
+     * @return
+     */
+    int uploadExcelByCover(List<GoodsDto> goodsEntityList,int exportDataType);
+
     /**
      * 条形码查询商品详情
      * @param prodBarcode 条形码

+ 9 - 0
kmall-admin/src/main/java/com/kmall/admin/service/ProductStoreRelaService.java

@@ -118,6 +118,15 @@ public interface ProductStoreRelaService {
      */
     int uploadExcel(List<StoreGoodsDto> storeGoodsDtoList);
 
+
+    /**
+     * 批量导入(修改库存版)
+     *
+     * @param storeGoodsDtoList
+     * @return
+     */
+    int uploadExcelByCover(List<StoreGoodsDto> storeGoodsDtoList);
+
     /**
      * 根据条件参数查询出要导出的列表
      * @param params 条件参数

+ 282 - 0
kmall-admin/src/main/java/com/kmall/admin/service/impl/GoodsServiceImpl.java

@@ -1098,6 +1098,288 @@ public class GoodsServiceImpl implements GoodsService {
     }
 
     @Override
+    @Transactional
+    public int uploadExcelByCover(List<GoodsDto> goodsEntityList, int exportDataType) {
+        SysUserEntity user = ShiroUtils.getUserEntity();
+        String merchSn = user.getMerchSn();
+        boolean isFail = false;
+        List<String> failSameSkuList = new ArrayList<>(), failHotGoodsSnList = new ArrayList<>(),
+                failSuppGoodsSnList = new ArrayList<>(),
+                failUnitGoodsSnList = new ArrayList<>(), failNationGoodsSnList = new ArrayList<>(),
+                failTypeGoodsSnList = new ArrayList<>(), failMerchGoodsSnList = new ArrayList<>(),
+                failMerchUserGoodsSnList = new ArrayList<>();
+//        List<String> failGoodsSnList = new ArrayList<>();
+        List<String> failGoodsTypeList = new ArrayList<>();
+        if (goodsEntityList != null && goodsEntityList.size() > 0) {
+            for (int i = 0; i < goodsEntityList.size(); i++) {
+                GoodsDto goodsDto = goodsEntityList.get(i);
+                GoodsEntity goodsEntity = new GoodsEntity();
+                Map<String, Object> valideDate = MapBeanUtil.fromObject(goodsDto);
+                ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
+                builder.put("goodsSn", "商品编码");
+                builder.put("thirdPartyMerchCode", "第三方商户代码");
+                builder.put("goodsBizType", "货品业务类型");
+                builder.put("name", "商品名称");
+                builder.put("isOnSaleStr", "上架");
+                builder.put("goodsUnit", "商品单位");
+                builder.put("isHotStr", "热销");
+                builder.put("prodBarcode", "产品条码");
+                builder.put("supplierName", "供应商");
+                builder.put("goodsNumber", "商品总库存");
+                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())){
+                    if(!(Dict.orderBizType.item_02.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())
+                            || Dict.orderBizType.item_10.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())
+                            || Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType()))){
+                        isFail = true;
+                        failTypeGoodsSnList.add(goodsDto.getSku());
+                    }
+                }
+                ThirdMerchantBizEntity thirdMerchantBizEntity = thirdMerchantBizDao.getThirdMerchangByCode(goodsDto.getThirdPartyMerchCode());
+                if(thirdMerchantBizEntity != null){
+                    goodsEntity.setMerchSn(thirdMerchantBizEntity.getMerchSn());
+                    goodsEntity.setThirdPartyMerchCode(thirdMerchantBizEntity.getThirdPartyMerchCode());
+
+                    if(!user.getRoleType().equalsIgnoreCase(Dict.roleType.item_1.getItem())) {
+                        if (!merchSn.equalsIgnoreCase(thirdMerchantBizEntity.getMerchSn())) {
+                            isFail = true;
+                            failMerchUserGoodsSnList.add(goodsDto.getGoodsSn());
+                        }
+                    }
+                }else{//商户不存在
+                    isFail = true;
+                    failMerchGoodsSnList.add(goodsDto.getGoodsSn());
+                }
+
+                //校验商品信息是否已存在
+                Map<String, Object> map = new HashMap<>();
+                map.put("isSame", "true");
+                map.put("sku", goodsDto.getSku());
+                map.put("goodsSn", goodsDto.getGoodsSn());
+                map.put("goodsBizType", goodsDto.getGoodsBizType());
+//                List<GoodsEntity> list = querySame(map);
+//                if (list != null && list.size() != 0) {
+//                    isFail = true;
+//                    if(goodsDto.getSku()!=null) {
+//                        failSameSkuList.add(goodsDto.getSku());
+//                    }
+//                    failGoodsSnList.add(goodsDto.getGoodsSn());
+//                    failGoodsTypeList.add(goodsDto.getGoodsBizType());
+//                }
+                //校验产品条码是否存在
+                goodsEntity.setProdBarcode(goodsDto.getProdBarcode());
+                //热销商品校验
+                if (Dict.orderBizType.item_02.getItem().equals(goodsDto.getGoodsBizType())
+                        || Dict.orderBizType.item_10.getItem().equals(goodsDto.getGoodsBizType())) {
+                    if(goodsDto.getIsHotStr().equalsIgnoreCase("1")){
+                        isFail = true;
+                        failHotGoodsSnList.add(goodsDto.getGoodsSn());
+                    }
+                }
+                if(thirdMerchantBizEntity != null) {
+                    SupplierEntity supplierEntity = supplierDao.queryObjectByName(goodsDto.getSupplierName(), thirdMerchantBizEntity.getMerchSn(),thirdMerchantBizEntity.getThirdPartyMerchCode());
+                    if (supplierEntity == null) {
+                        //导入没有查到供货商,执行新增
+                        MerchEntity merchEntity = merchDao.findByMerchSn(thirdMerchantBizEntity.getMerchSn());
+                        if(null == merchEntity || !StringUtils.isNotEmpty(goodsDto.getSupplierFlag())){
+                            isFail = true;
+                            failSuppGoodsSnList.add(goodsDto.getGoodsSn());
+                        }
+
+                        supplierEntity = new SupplierEntity();
+                        supplierEntity.setLevelMerchSn(merchEntity.getMerchSn());
+                        supplierEntity.setLevelMerchFlag(merchEntity.getMerchShortName());
+                        supplierEntity.setThirdPartyMerchCode(thirdMerchantBizEntity.getThirdPartyMerchCode());
+                        supplierEntity.setChildSupplierName(goodsDto.getSupplierName());
+                        supplierEntity.setChildSupplierFlag(goodsDto.getSupplierFlag());
+                        supplierEntity.setIsShow("0");
+
+                        supplierDao.save(supplierEntity);
+                        goodsEntity.setSupplierId(supplierEntity.getId());
+                    } else {
+                        goodsEntity.setSupplierId(supplierEntity.getId());
+                    }
+                }
+                if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
+                    SysCusUnitCodeEntity sysCusUnitCodeEntity = sysCusUnitCodeDao.queryObjectByName(goodsDto.getUnitName());
+                    if (sysCusUnitCodeEntity == null) {
+                        isFail = true;
+                        failUnitGoodsSnList.add(goodsDto.getGoodsSn());
+                    } else {
+                        goodsEntity.setUnitCode(sysCusUnitCodeEntity.getCode());
+                    }
+                    //原产国
+                    SysCusNationCodeEntity sysCusNationCodeEntity = sysCusNationCodeDao.queryObjectByName(goodsDto.getOriCntName());
+                    if (sysCusNationCodeEntity == null) {
+                        isFail = true;
+                        failNationGoodsSnList.add(goodsDto.getGoodsSn());
+                    } else {
+                        goodsEntity.setOriCntCode(sysCusNationCodeEntity.getCode());
+                    }
+
+                    if(goodsDto.getGoodsRate().indexOf("%") != -1){
+                        goodsDto.setGoodsRate(goodsDto.getGoodsRate().substring(0, goodsDto.getGoodsRate().indexOf("%")));
+                    }
+
+                    goodsEntity.setGoodsRate(BigDecimal.valueOf(Double.valueOf(goodsDto.getGoodsRate())).divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP));
+                }
+
+                goodsEntity.setIsOnSale(Integer.parseInt(goodsDto.getIsOnSaleStr()));
+                goodsEntity.setIsHot(Integer.parseInt(goodsDto.getIsHotStr()));
+                goodsEntity.setGoodsSn(goodsDto.getGoodsSn());
+                goodsEntity.setSku(goodsDto.getSku());
+                goodsEntity.setName(goodsDto.getName());
+                goodsEntity.setGoodsUnit(goodsDto.getGoodsUnit());
+                goodsEntity.setGoodsBizType(goodsDto.getGoodsBizType());
+                goodsEntity.setBrand(goodsDto.getBrand());
+                goodsEntity.setCusDeclEle(goodsDto.getCusDeclEle());
+                goodsEntity.setCusGoodsCode(goodsDto.getCusGoodsCode());
+                goodsEntity.setCusRecCode(goodsDto.getCusRecCode());
+                goodsEntity.setCiqProdModel(goodsDto.getCiqProdModel());
+                goodsEntity.setIsDelete(Integer.parseInt(Dict.isDelete.item_0.getItem()));
+                goodsEntity.setIsNew(0);
+                goodsEntity.setUpdateUserId(user.getUserId());
+                goodsEntity.setAddTime(new Date());
+                goodsEntity.setCreateTime(new Date());
+                goodsEntity.setUpdateTime(new Date());
+                goodsEntity.setModTime(new Date());
+                goodsEntity.setGoodsNumber(Integer.parseInt(goodsDto.getGoodsNumber()));
+
+                if(!isFail){
+                    GoodsEntity goods = goodsDao.queryObjectBySn(goodsDto.getGoodsSn());
+                    if(goods!=null) {// 修改商品
+                        goodsEntity.setId(goods.getId());
+                        goodsEntity.setVideoUrl(goods.getVideoUrl());
+                        goodsEntity.setListPicUrl(goods.getListPicUrl());
+                        goodsEntity.setPrimaryPicUrl(goods.getPrimaryPicUrl());
+                        goodsDao.update(goodsEntity);
+                    }else{
+                        goodsDao.save(goodsEntity);
+                    }
+                    // 修改产品
+                    ProductEntity product = productDao.queryObjectByGoodsIdAndStoreId(String.valueOf(goodsEntity.getId()), "");
+
+                    GoodsSpecificationEntity goodsSpecification = new GoodsSpecificationEntity();
+                    // 普通货物暂不添加商品规格
+                    if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
+                        // 添加商品规格
+                        GoodsSpecificationEntity specificationEntity = goodsSpecificationDao.queryByGoodsId(goodsEntity.getId());
+                        if(specificationEntity == null) {
+                            goodsSpecification.setGoodsId(goodsEntity.getId());
+                            goodsSpecification.setValue(goodsEntity.getCiqProdModel());
+                            goodsSpecification.setSpecificationId(1);
+                            goodsSpecificationDao.save(goodsSpecification);
+                        }else {
+                            goodsSpecification.setValue(goodsDto.getCiqProdModel());
+                            goodsSpecification.setId(specificationEntity.getId());
+                            goodsSpecificationDao.update(goodsSpecification);
+                        }
+                        if(product == null){
+                            product = new ProductEntity();
+                            product.setGoodsSn(goodsDto.getGoodsSn());
+                            product.setGoodsId(goodsEntity.getId());
+                            product.setGoodsDefault(0);
+                            product.setGoodsNumber(goodsEntity.getGoodsNumber());
+                            product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
+                            product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
+                            productDao.save(product);
+                        }else{
+                            product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
+                            product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
+                            productDao.update(product);
+                        }
+                    }
+                }
+            }
+            ExportExceptionDataEntity exportExceptionDataEntity = new ExportExceptionDataEntity();
+            exportExceptionDataEntity.setCreaterSn(user.getUserId().toString());
+            exportExceptionDataEntity.setUserId(user.getUserId().intValue());
+            exportExceptionDataEntity.setCreateTime(new Date());
+            exportExceptionDataEntity.setModTime(new Date());
+            exportExceptionDataEntity.setMerchSn(merchSn);
+            exportExceptionDataEntity.setStoreId(user.getStoreId());
+            if(exportDataType == 1) {
+                exportExceptionDataEntity.setExportDataType(Dict.exportDataType.item_1.getItem());
+            }else{
+                exportExceptionDataEntity.setExportDataType(Dict.exportDataType.item_2.getItem());
+            }
+
+            if(failMerchUserGoodsSnList != null && failMerchUserGoodsSnList.size() > 0){
+                exportExceptionDataEntity.setExportExceptionData("不能操作除了登录用户以外商户的商品,当前商户编号为【"+merchSn+"】,请检查商品编码【"+failMerchUserGoodsSnList+"】的商品信息");
+                goodsUtils.save(exportExceptionDataEntity);
+                throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
+            }
+            if(failMerchGoodsSnList != null && failMerchGoodsSnList.size() > 0){
+                exportExceptionDataEntity.setExportExceptionData("第三方商户代码不存在,请在商城配置》第三方商户管理中维护,请检查商品编码【"+failMerchGoodsSnList+"】的商品信息,请先维护再继续操作!");
+                goodsUtils.save(exportExceptionDataEntity);
+                throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
+            }
+//            if(failGoodsSnList != null && failGoodsSnList.size() > 0){
+//                if(failSameSkuList.size()>0) {
+//                    exportExceptionDataEntity.setExportExceptionData("不能有重复的商品编码、sku信息!请检查商品编码【" + failGoodsSnList + "】,业务类型【" +
+//                            failGoodsTypeList + "】,SKU【" + failSameSkuList + "】的商品信息");
+//                    goodsUtils.save(exportExceptionDataEntity);
+//                    throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
+//                }else{
+//                    exportExceptionDataEntity.setExportExceptionData("不能有重复的商品编码、sku信息!请检查商品编码【" + failGoodsSnList + "】,业务类型【" +
+//                            failGoodsTypeList + "】的商品信息");
+//                    goodsUtils.save(exportExceptionDataEntity);
+//                    throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
+//                }
+//            }
+            if(failTypeGoodsSnList != null && failTypeGoodsSnList.size() > 0){
+                exportExceptionDataEntity.setExportExceptionData("货品业务类型只能是【00保税备货、02保税补货、10保税展示】!请检查商品编码【"+failTypeGoodsSnList+"】的商品信息");
+                goodsUtils.save(exportExceptionDataEntity);
+                throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
+            }
+            if(failHotGoodsSnList != null && failHotGoodsSnList.size() > 0){
+                exportExceptionDataEntity.setExportExceptionData("请检查业务类型为【保税补货或保税展示】的商品,商品编码【"+failHotGoodsSnList+"】的商品不能设置为热销!");
+                goodsUtils.save(exportExceptionDataEntity);
+                throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
+            }
+            if(failSuppGoodsSnList != null && failSuppGoodsSnList.size() > 0){
+                exportExceptionDataEntity.setExportExceptionData("供应商信息请在商城配置》商品供应商中维护,供应商与商户信息对应,请检查该商品商户信息下的供应商是否维护,不存在的商品编码【" + failSuppGoodsSnList + "】");
+                goodsUtils.save(exportExceptionDataEntity);
+                throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
+            }
+            if(failUnitGoodsSnList != null && failUnitGoodsSnList.size() > 0){
+                exportExceptionDataEntity.setExportExceptionData("计算单位信息请在商城配置》计算单位中维护,不存在的商品编码【" + failUnitGoodsSnList + "】");
+                goodsUtils.save(exportExceptionDataEntity);
+                throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
+            }
+            if(failNationGoodsSnList != null && failNationGoodsSnList.size() > 0){
+                exportExceptionDataEntity.setExportExceptionData("原产国信息请在商城配置》原产国中维护,不存在的商品编码【" + failNationGoodsSnList + "】");
+                goodsUtils.save(exportExceptionDataEntity);
+                throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
+            }
+        }else{
+            throw new RRException("导入数据为空,或者检查商品编码数据是否为空");
+        }
+        return 1;
+    }
+
+    @Override
     public GoodsDetailsDto queryGoodsDetailsByProdBarcode(String prodBarcode, String storeId) {
         return goodsDao.queryGoodsDetailsByProdBarcode(prodBarcode,storeId);
     }

+ 68 - 4
kmall-admin/src/main/java/com/kmall/admin/service/impl/ProductStoreRelaServiceImpl.java

@@ -20,10 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * Service实现类
@@ -915,6 +912,73 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
         return 1;
     }
 
+    @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);
+                ProductStoreRelaEntity storeRelaEntity = new ProductStoreRelaEntity();
+                StoreEntity store = storeDao.queryObjectByName(storeGoodsDto.getStoreName().trim());
+
+                storeRelaEntity.setStoreId(store.getId());
+                GoodsEntity goodsEntity = goodsDao.queryObjectBySn(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());
+                }
+
+                storeRelaEntity.setBrandId(brandEntity.getId());
+                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);
+                }else{
+                    storeRelaEntity.setId(productStoreRelaEntity.getId());
+                    update(storeRelaEntity);
+                }
+            }
+        }else{
+            throw new RRException("导入数据为空,或者检查数据是否为空");
+        }
+        return 1;
+    }
+
     private BrandEntity initSaveBrandEntity(String brandName, String merchSn, Integer categroyId) {
         BrandEntity brandEntity = new BrandEntity();
         brandEntity.setName(brandName);

+ 7 - 0
kmall-admin/src/main/webapp/WEB-INF/page/shop/goods.html

@@ -152,6 +152,13 @@
                     </Upload>
                 </i-col>
                 #end
+                <i-col style="display: inline-grid;">
+                    <Upload :show-upload-list="false" :on-success="uploadExcelSuccess" :on-error="uploadExcelError" :on-format-error="uploadExcelFormatError"
+                            :format="['xls','xlsx']"
+                            action="../goods/uploadByCover">
+                        <i-button type="ghost" icon="ios-cloud-upload-outline">商品导入(修改库存)</i-button>
+                    </Upload>
+                </i-col>
                 #if($shiro.hasPermission("goods:generalGoodsUpload"))
                 <i-col style="display: inline-grid;">
                     <Upload :show-upload-list="false" :on-success="uploadExcelSuccess" :on-error="uploadExcelError" :on-format-error="uploadExcelFormatError"

+ 7 - 0
kmall-admin/src/main/webapp/WEB-INF/page/shop/storeProductStock.html

@@ -137,6 +137,13 @@
                     </Upload>
                 </i-col>
                 #end
+                <i-col style="display: inline-grid;">
+                    <Upload :show-upload-list="false" :on-success="uploadExcelSuccess" :on-format-error="uploadExcelFormatError"
+                            :format="['xls','xlsx']"
+                            action="../productstorerela/productStoreRelaUploadByCover">
+                        <i-button type="ghost" icon="ios-cloud-upload-outline">门店商品导入(修改库存)</i-button>
+                    </Upload>
+                </i-col>
                 #if($shiro.hasPermission("productstorerela:down"))
                 &nbsp;&nbsp;&nbsp;<a href="../statics/file/store_goods_export_yyyy_mm_dd_v1.0.0.xls">门店商品模板下载</a>&nbsp;&nbsp;&nbsp;&nbsp;
                 #end