Ver código fonte

fixed excel商品导入业务处理逻辑完善

fushengqian 6 dias atrás
pai
commit
f544daa60e
28 arquivos alterados com 262 adições e 29 exclusões
  1. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/AdminRoleEnum.java
  2. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/ApplyGoodsEnum.java
  3. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/BalanceSettingEnum.java
  4. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/CouponUseForEnum.java
  5. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/GoodsTypeEnum.java
  6. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/MemberSourceEnum.java
  7. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/OrderSettingEnum.java
  8. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/PointSettingEnum.java
  9. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/PrinterSettingEnum.java
  10. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/QrCodeEnum.java
  11. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/SendWayEnum.java
  12. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/SettingTypeEnum.java
  13. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/SmsSettingEnum.java
  14. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/StaffCategoryEnum.java
  15. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/UserActionEnum.java
  16. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/UserCouponStatusEnum.java
  17. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/UserSettingEnum.java
  18. 1 1
      fuint-application/src/main/java/com/fuint/common/enums/WxMessageEnum.java
  19. 18 0
      fuint-application/src/main/java/com/fuint/common/enums/YesOrNoEnum.java
  20. 11 0
      fuint-application/src/main/java/com/fuint/common/service/CateService.java
  21. 12 2
      fuint-application/src/main/java/com/fuint/common/service/GoodsService.java
  22. 9 0
      fuint-application/src/main/java/com/fuint/common/service/StoreService.java
  23. 27 0
      fuint-application/src/main/java/com/fuint/common/service/impl/CateServiceImpl.java
  24. 130 7
      fuint-application/src/main/java/com/fuint/common/service/impl/GoodsServiceImpl.java
  25. 26 0
      fuint-application/src/main/java/com/fuint/common/service/impl/StoreServiceImpl.java
  26. 2 2
      fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendGoodsController.java
  27. 2 0
      fuint-repository/src/main/java/com/fuint/repository/mapper/MtGoodsMapper.java
  28. 7 0
      fuint-repository/src/main/resources/mapper/MtGoodsMapper.xml

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/AdminRoleEnum.java

@@ -68,7 +68,7 @@ public enum AdminRoleEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (AdminRoleEnum c : AdminRoleEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/ApplyGoodsEnum.java

@@ -48,7 +48,7 @@ public enum ApplyGoodsEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (ApplyGoodsEnum c : ApplyGoodsEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/BalanceSettingEnum.java

@@ -48,7 +48,7 @@ public enum BalanceSettingEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (BalanceSettingEnum c : BalanceSettingEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/CouponUseForEnum.java

@@ -54,7 +54,7 @@ public enum CouponUseForEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (CouponUseForEnum c : CouponUseForEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/GoodsTypeEnum.java

@@ -55,7 +55,7 @@ public enum GoodsTypeEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (GoodsTypeEnum c : GoodsTypeEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/MemberSourceEnum.java

@@ -50,7 +50,7 @@ public enum MemberSourceEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (MemberSourceEnum c : MemberSourceEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/OrderSettingEnum.java

@@ -51,7 +51,7 @@ public enum OrderSettingEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (OrderSettingEnum c : OrderSettingEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/PointSettingEnum.java

@@ -50,7 +50,7 @@ public enum PointSettingEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (PointSettingEnum c : PointSettingEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/PrinterSettingEnum.java

@@ -50,7 +50,7 @@ public enum PrinterSettingEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (PrinterSettingEnum c : PrinterSettingEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/QrCodeEnum.java

@@ -57,7 +57,7 @@ public enum QrCodeEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (QrCodeEnum c : QrCodeEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/SendWayEnum.java

@@ -49,7 +49,7 @@ public enum SendWayEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (SendWayEnum c : SendWayEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/SettingTypeEnum.java

@@ -54,7 +54,7 @@ public enum SettingTypeEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (SettingTypeEnum c : SettingTypeEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/SmsSettingEnum.java

@@ -50,7 +50,7 @@ public enum SmsSettingEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (UserSettingEnum c : UserSettingEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/StaffCategoryEnum.java

@@ -75,7 +75,7 @@ public enum StaffCategoryEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (StaffCategoryEnum c : StaffCategoryEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/UserActionEnum.java

@@ -55,7 +55,7 @@ public enum UserActionEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (UserActionEnum c : UserActionEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/UserCouponStatusEnum.java

@@ -57,7 +57,7 @@ public enum UserCouponStatusEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (UserCouponStatusEnum c : UserCouponStatusEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/UserSettingEnum.java

@@ -52,7 +52,7 @@ public enum UserSettingEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (UserSettingEnum c : UserSettingEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/enums/WxMessageEnum.java

@@ -53,7 +53,7 @@ public enum WxMessageEnum {
     // 普通方法,通过Value获取key
     public static String getKey(String v) {
         for (WxMessageEnum c : WxMessageEnum.values()) {
-            if (c.getValue() == v) {
+            if (c.getValue().equals(v)) {
                 return c.getKey();
             }
         }

+ 18 - 0
fuint-application/src/main/java/com/fuint/common/enums/YesOrNoEnum.java

@@ -36,4 +36,22 @@ public enum YesOrNoEnum {
     public void setValue(String value) {
         this.value = value;
     }
+
+    public static String getKey(String v) {
+        for (YesOrNoEnum c : YesOrNoEnum.values()) {
+            if (c.getValue().equals(v)) {
+                return c.getKey();
+            }
+        }
+        return null;
+    }
+
+    public static String getValue(String k) {
+        for (YesOrNoEnum c : YesOrNoEnum.values()) {
+            if (c.getKey().equals(k)) {
+                return c.getValue();
+            }
+        }
+        return null;
+    }
 }

+ 11 - 0
fuint-application/src/main/java/com/fuint/common/service/CateService.java

@@ -67,4 +67,15 @@ public interface CateService extends IService<MtGoodsCate> {
      * @return
      * */
     List<MtGoodsCate> queryCateListByParams(Map<String, Object> params) throws BusinessCheckException;
+
+    /**
+     * 获取分类ID
+     *
+     * @param merchantId 商户ID
+     * @param storeId 店铺ID
+     * @param name 分类名称
+     * @return
+     * */
+    Integer getGoodsCateId(Integer merchantId, Integer storeId, String name);
+
 }

+ 12 - 2
fuint-application/src/main/java/com/fuint/common/service/GoodsService.java

@@ -1,5 +1,6 @@
 package com.fuint.common.service;
 
+import com.fuint.common.dto.AccountInfo;
 import com.fuint.common.dto.GoodsDto;
 import com.fuint.common.dto.GoodsSpecValueDto;
 import com.fuint.common.dto.GoodsTopDto;
@@ -164,9 +165,18 @@ public interface GoodsService {
      * 导入商品
      *
      * @param file excel文件
-     * @param operator 操作者
+     * @param accountInfo 操作者
      * @param filePath 文件地址
      * */
-    String importGoods(MultipartFile file, String operator, String filePath) throws BusinessCheckException;
+    Boolean importGoods(MultipartFile file, AccountInfo accountInfo, String filePath) throws BusinessCheckException;
+
+    /**
+     * 获取规格ID
+     *
+     * @param goodsId 商品ID
+     * @param specName 规格名称
+     * @param specValue 规格值
+     * */
+    Integer getSpecId(Integer goodsId, String specName, String specValue);
 
 }

+ 9 - 0
fuint-application/src/main/java/com/fuint/common/service/StoreService.java

@@ -105,4 +105,13 @@ public interface StoreService extends IService<MtStore> {
      * */
     String getStoreNames(String storeIds);
 
+    /**
+     * 获取店铺ID
+     *
+     * @param merchantId 商户ID
+     * @param storeNames 店铺名称
+     * @return
+     * */
+    String getStoreIds(Integer merchantId, String storeNames);
+
 }

+ 27 - 0
fuint-application/src/main/java/com/fuint/common/service/impl/CateServiceImpl.java

@@ -261,4 +261,31 @@ public class CateServiceImpl extends ServiceImpl<MtGoodsCateMapper, MtGoodsCate>
         List<MtGoodsCate> dataList = cateMapper.selectList(lambdaQueryWrapper);
         return dataList;
     }
+
+    /**
+     * 获取分类ID
+     *
+     * @param merchantId 商户ID
+     * @param storeId 店铺ID
+     * @param name 分类名称
+     * @return
+     * */
+    @Override
+    public Integer getGoodsCateId(Integer merchantId, Integer storeId, String name) {
+        Integer cate = 0;
+        Map<String, Object> param = new HashMap<>();
+        param.put("status", StatusEnum.ENABLED.getKey());
+        param.put("name", name);
+        if (storeId != null && storeId > 0) {
+            param.put("storeId", storeId);
+        }
+        if (merchantId != null && merchantId > 0) {
+            param.put("merchantId", merchantId);
+        }
+        List<MtGoodsCate> cateList = queryCateListByParams(param);
+        if (cateList != null && cateList.size() > 0) {
+            cate = cateList.get(0).getId();
+        }
+        return cate;
+    }
 }

+ 130 - 7
fuint-application/src/main/java/com/fuint/common/service/impl/GoodsServiceImpl.java

@@ -1,9 +1,11 @@
 package com.fuint.common.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fuint.common.Constants;
+import com.fuint.common.dto.AccountInfo;
 import com.fuint.common.dto.GoodsDto;
 import com.fuint.common.dto.GoodsSpecValueDto;
 import com.fuint.common.dto.GoodsTopDto;
@@ -230,7 +232,7 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
     @OperationServiceLog(description = "保存商品信息")
     public MtGoods saveGoods(MtGoods reqDto, String storeIds) throws BusinessCheckException {
         MtGoods mtGoods = new MtGoods();
-        if (reqDto.getId() > 0) {
+        if (reqDto.getId() != null && reqDto.getId() > 0) {
             mtGoods = queryGoodsById(reqDto.getId());
             reqDto.setMerchantId(mtGoods.getMerchantId());
         }
@@ -836,12 +838,13 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
      * 导入商品
      *
      * @param file excel文件
-     * @param operator 操作者
+     * @param accountInfo 操作者
+     * @return
      * */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    @OperationServiceLog(description = "导入发券列表")
-    public String importGoods(MultipartFile file, String operator, String filePath) throws BusinessCheckException {
+    @OperationServiceLog(description = "导入商品列表")
+    public Boolean importGoods(MultipartFile file, AccountInfo accountInfo, String filePath) throws BusinessCheckException {
         String originalFileName = file.getOriginalFilename();
         boolean isExcel2003 = XlsUtil.isExcel2003(originalFileName);
         boolean isExcel2007 = XlsUtil.isExcel2007(originalFileName);
@@ -851,21 +854,141 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
             throw new BusinessCheckException("文件类型不正确");
         }
 
+        if (accountInfo == null || accountInfo.getMerchantId() == null || accountInfo.getMerchantId() <= 0) {
+            throw new BusinessCheckException("没有操作权限");
+        }
+
+        // 1、录入商品信息
         List<List<String>> goodsList = new ArrayList<>();
+        List<List<String>> skuList = new ArrayList<>();
         try {
             goodsList = XlsUtil.readExcelContent(file.getInputStream(), isExcel2003, 0, 1, null, null, null);
+            skuList = XlsUtil.readExcelContent(file.getInputStream(), isExcel2003, 1, 1, null, null, null);
         } catch (IOException e) {
             logger.error("GoodsServiceImpl->parseExcelContent{}", e);
-            throw new BusinessCheckException("导入失败" + e.getMessage());
+            throw new BusinessCheckException("商品导入失败" + e.getMessage());
         } catch (Exception e) {
             e.printStackTrace();
         }
 
         if (goodsList != null && goodsList.size() > 0) {
-            // empty
+            if (goodsList.size() > 1000) {
+                throw new BusinessCheckException("商品导入失败,单次导入商品数量不能大于1000");
+            }
+            for (int i = 0; i < goodsList.size(); i++) {
+                 List<String> goods = goodsList.get(0);
+                 MtGoods mtGoods = new MtGoods();
+                 mtGoods.setId(0);
+                 mtGoods.setName(goods.get(0));
+                 mtGoods.setType(GoodsTypeEnum.getKey(goods.get(1)));
+                 mtGoods.setGoodsNo(goods.get(2));
+                 mtGoods.setMerchantId(accountInfo.getMerchantId());
+                 mtGoods.setStoreId(accountInfo.getStoreId());
+                 Integer cateId = cateService.getGoodsCateId(accountInfo.getMerchantId(), accountInfo.getStoreId(), goods.get(3));
+                 mtGoods.setCateId(cateId);
+                 mtGoods.setOperator(accountInfo.getAccountName());
+                 String storeIds = storeService.getStoreIds(accountInfo.getMerchantId(), goods.get(4));
+                 String images = goods.get(5);
+                 if (StringUtil.isNotEmpty(images)) {
+                     String[] imgArr = images.split(",");
+                     if (imgArr.length > 0) {
+                         mtGoods.setLogo(imgArr[0]);
+                         String imagesJson = JSONObject.toJSONString(images.split(","));
+                         mtGoods.setImages(imagesJson);
+                     }
+                 }
+                 mtGoods.setSort(Integer.parseInt(goods.get(6)));
+                 mtGoods.setCanUsePoint(YesOrNoEnum.getKey(goods.get(7)));
+                 mtGoods.setIsMemberDiscount(YesOrNoEnum.getKey(goods.get(8)));
+                 if (goods.get(9).equals(YesOrNoEnum.YES.getKey())) {
+                     mtGoods.setIsSingleSpec(YesOrNoEnum.YES.getKey());
+                 } else {
+                     mtGoods.setIsSingleSpec(YesOrNoEnum.NO.getKey());
+                 }
+                 mtGoods.setInitSale(Integer.parseInt(goods.get(10)));
+                 mtGoods.setSalePoint(goods.get(11));
+                 mtGoods.setDescription(goods.get(12));
+                 mtGoods.setPrice(new BigDecimal("0"));
+                 mtGoods.setStock(0);
+                 mtGoods.setStatus(StatusEnum.ENABLED.getKey());
+                 saveGoods(mtGoods, storeIds);
+            }
         }
 
-        return "";
+        // 2、录入规格信息
+        if (skuList != null && skuList.size() > 0) {
+            for (int j = 0; j < skuList.size(); j++) {
+                 List<String> sku = skuList.get(j);
+                 MtGoods mtGoods = mtGoodsMapper.getByGoodsName(accountInfo.getMerchantId(), sku.get(0));
+                 if (mtGoods != null) {
+                     // 单规格
+                     if (mtGoods.getIsSingleSpec().equals(YesOrNoEnum.YES.getKey())) {
+                         mtGoods.setPrice(new BigDecimal(sku.get(4)));
+                         mtGoods.setLinePrice(new BigDecimal(sku.get(5)));
+                         mtGoods.setStock(Integer.parseInt(sku.get(6)));
+                         mtGoods.setWeight(new BigDecimal(sku.get(7)));
+                         mtGoodsMapper.updateById(mtGoods);
+                     }
+                     // 多规格
+                     if (mtGoods.getIsSingleSpec().equals(YesOrNoEnum.NO.getKey())) {
+                         List<String> specIds = new ArrayList<>();
+                         if (StringUtil.isNotEmpty(sku.get(2)) && StringUtil.isNotEmpty(sku.get(3))) {
+                             String[] specNameList = sku.get(2).split(",");
+                             String[] specValueList = sku.get(3).split(",");
+                             if (specNameList.length == specValueList.length) {
+                                 for (int y = 0; y < specNameList.length; y++) {
+                                      Integer specId = getSpecId(mtGoods.getId(), specNameList[y], specValueList[y]);
+                                      specIds.add(specId.toString());
+                                 }
+                             }
+                         }
+                         if (StringUtil.isNotEmpty(sku.get(1))) {
+                             MtGoodsSku mtGoodsSku = new MtGoodsSku();
+                             mtGoodsSku.setSkuNo(sku.get(1));
+                             mtGoodsSku.setGoodsId(mtGoods.getId());
+                             mtGoodsSku.setSpecIds(String.join("-", specIds));
+                             mtGoodsSku.setPrice(new BigDecimal(sku.get(4)));
+                             mtGoodsSku.setLinePrice(new BigDecimal(sku.get(5)));
+                             mtGoodsSku.setStock(Integer.parseInt(sku.get(6)));
+                             mtGoodsSku.setWeight(new BigDecimal(sku.get(7)));
+                             mtGoodsSku.setStatus(StatusEnum.ENABLED.getKey());
+                             mtGoodsSkuMapper.insert(mtGoodsSku);
+                         }
+                     }
+                 }
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 获取规格ID
+     *
+     * @param goodsId 商品ID
+     * @param specName 规格名称
+     * @param specValue 规格值
+     * */
+    @Override
+    public Integer getSpecId(Integer goodsId, String specName, String specValue) {
+        Map<String, Object> params = new HashMap<>();
+        params.put("goods_id", goodsId);
+        params.put("name", specName);
+        params.put("value", specValue);
+        params.put("status", StatusEnum.ENABLED.getKey());
+        Integer specId;
+        List<MtGoodsSpec> specList = mtGoodsSpecMapper.selectByMap(params);
+        if (specList != null && specList.size() > 0) {
+            specId = specList.get(0).getId();
+        } else {
+            MtGoodsSpec mtGoodsSpec = new MtGoodsSpec();
+            mtGoodsSpec.setGoodsId(goodsId);
+            mtGoodsSpec.setName(specName);
+            mtGoodsSpec.setValue(specValue);
+            mtGoodsSpec.setStatus(StatusEnum.ENABLED.getKey());
+            mtGoodsSpecMapper.insert(mtGoodsSpec);
+            specId = mtGoodsSpec.getId();
+        }
+        return specId;
     }
 
 }

+ 26 - 0
fuint-application/src/main/java/com/fuint/common/service/impl/StoreServiceImpl.java

@@ -427,4 +427,30 @@ public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implem
        }
        return String.join(",", storeNames);
     }
+
+    /**
+     * 获取店铺名称
+     *
+     * @param merchantId 商户ID
+     * @param storeNames 店铺名称
+     * @return
+     * */
+    @Override
+    public String getStoreIds(Integer merchantId, String storeNames) {
+        if (StringUtil.isEmpty(storeNames)) {
+            return "";
+        }
+        String[] names = storeNames.split(",");
+        List<String> storeIds = new ArrayList<>();
+        if (names.length > 0) {
+            for (int i = 0; i < names.length; i++) {
+                MtStore mtStore = mtStoreMapper.queryStoreByName(names[i]);
+                if (mtStore != null) {
+                    storeIds.add(mtStore.getId().toString());
+                }
+            }
+        }
+        return String.join(",", storeIds);
+    }
+
 }

+ 2 - 2
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendGoodsController.java

@@ -786,8 +786,8 @@ public class BackendGoodsController extends BaseController {
         MultipartFile file = multipartRequest.getFile("file");
 
         String filePath = goodsService.saveGoodsFile(request, file);
-        String uuid = goodsService.importGoods(file, accountInfo.getAccountName(), filePath);
+        Boolean result = goodsService.importGoods(file, accountInfo, filePath);
 
-        return getSuccessResult(uuid);
+        return getSuccessResult(result);
     }
 }

+ 2 - 0
fuint-repository/src/main/java/com/fuint/repository/mapper/MtGoodsMapper.java

@@ -23,6 +23,8 @@ public interface MtGoodsMapper extends BaseMapper<MtGoods> {
 
     MtGoods getByGoodsNo(@Param("merchantId") Integer merchantId, @Param("goodsNo") String goodsNo);
 
+    MtGoods getByGoodsName(@Param("merchantId") Integer merchantId, @Param("goodsName") String goodsName);
+
     Boolean updateInitSale(@Param("goodsId") Integer goodsId, @Param("saleNum") Integer saleNum);
 
     List<GoodsBean> selectGoodsList(@Param("merchantId") Integer merchantId, @Param("storeId") Integer storeId, @Param("cateId") Integer cateId, @Param("keyword") String keyword);

+ 7 - 0
fuint-repository/src/main/resources/mapper/MtGoodsMapper.xml

@@ -31,6 +31,13 @@
         </if>
     </select>
 
+    <select id="getByGoodsName" resultType="com.fuint.repository.model.MtGoods">
+        select * from mt_goods t where t.NAME = #{goodsName} and t.STATUS = 'A'
+        <if test="merchantId != null and merchantId > 0">
+            AND t.MERCHANT_ID = #{merchantId}
+        </if>
+    </select>
+
     <update id="updateInitSale">
         update mt_goods t set t.INIT_SALE = t.INIT_SALE + #{saleNum} where t.ID = #{goodsId}
     </update>