浏览代码

Merge branch 'master' of zhh/kmall-haikong into master

lhm 3 年之前
父节点
当前提交
f9725c168d

+ 20 - 8
kmall-admin/src/main/java/com/kmall/admin/controller/BrandController.java

@@ -17,6 +17,8 @@ import com.kmall.common.utils.excel.ExcelExport;
 import com.kmall.common.utils.excel.ExcelUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -31,19 +33,21 @@ import java.util.*;
  * @author Scott
  * @email
  * @date 2017-08-19 17:59:15
+ *
+ * @author zhuhh
+ * @date 2021-12-9 15:57:53
  */
 @RestController
 @RequestMapping("brand")
 public class BrandController {
+    private static final Logger logger = LoggerFactory.getLogger(BrandController.class);
+
     @Autowired
     private BrandService brandService;
 
     @Autowired
     private ExcelUtil excelUtil;
 
-    @Autowired
-    private CategoryService categoryService;
-
     /**
      * 查看列表
      */
@@ -223,11 +227,14 @@ public class BrandController {
 
     /**
      * 导入品牌
+     *
+     * @author zhuhh
+     * @date 2021-12-9 15:59:33
      */
     @RequestMapping("/upload")
     @ResponseBody
     public R upload(@RequestParam("file") MultipartFile file) {
-        List<BrandEntity> brandEntityList = new ArrayList<>();//信息
+        List<BrandEntity> brandEntityList = new ArrayList<>();
         try {
             BrandEntity brandEntity = new BrandEntity();
             Map<String, Object> beans = new HashMap<String, Object>();
@@ -238,16 +245,21 @@ public class BrandController {
             }
             excelUtil.readExcel(JxlsXmlTemplateName.BRAND_DTO_LIST, beans, file.getInputStream());
         } catch (Exception e) {
-            e.printStackTrace();
-            return R.error("导入失败!");
+            logger.error("读取文件失败!", e);
+            return R.error("读取文件失败!");
         }
         try {
+            if (brandEntityList == null || brandEntityList.size() == 0) {
+                logger.error("读取数据为空!");
+                return R.error("读取数据为空!");
+            }
+
             brandService.uploadExcel(brandEntityList);
         } catch (Exception e) {
-            e.printStackTrace();
+            logger.error("保存数据失败!", e);
             return R.error(e.getMessage());
         }
-        //上传文件
+        // 上传文件
         return R.ok("导入成功!");
     }
 

+ 39 - 45
kmall-admin/src/main/java/com/kmall/admin/service/impl/BrandServiceImpl.java

@@ -12,6 +12,7 @@ import com.kmall.common.utils.RRException;
 import com.kmall.common.utils.ValidatorUtil;
 import com.kmall.manager.manager.express.sf.ServiceException;
 import com.kmall.manager.manager.redis.JedisUtil;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -235,55 +236,48 @@ public class BrandServiceImpl implements BrandService {
     @Override
     @Transactional
     public void uploadExcel(List<BrandEntity> brandEntityList) {
-        if (brandEntityList != null && brandEntityList.size() > 0) {
-            for (int i = 0; i < brandEntityList.size(); i++) {
-                BrandEntity brandEntity = brandEntityList.get(i);
-                Integer brandId = brandEntity.getId();
-                Integer isShow = brandEntity.getIsShow();
-                Integer isNew = brandEntity.getIsNew();
-                // 品牌唯一标识符正则校验
-                String uniqueIdentifier = brandEntity.getUniqueIdentifier();
-
-                if (isShow.intValue() != 0 && isShow.intValue() != 1 && isNew.intValue() != 0 && isNew != 1) {
-                    throw new ServiceException("第" + (i + 1) + "行的是否显示或者是否新品牌只可填(0:否 1:是)");
-                }
+        for (int i = 0; i < brandEntityList.size(); i++) {
+            BrandEntity brandEntity = brandEntityList.get(i);
+            String name = brandEntity.getName();
+            Integer isShow = brandEntity.getIsShow();
+            Integer isNew = brandEntity.getIsNew();
+            // 品牌唯一标识符正则校验
+            String uniqueIdentifier = brandEntity.getUniqueIdentifier();
+
+            if (isShow.intValue() != 0 && isShow.intValue() != 1 && isNew.intValue() != 0 && isNew != 1) {
+                throw new ServiceException("第" + (i + 1) + "行的是否显示或者是否新品牌只可填(0:否 1:是)");
+            }
 
+            if (StringUtils.isNotBlank(uniqueIdentifier)) {
+                String regex = "(^[0-9a-zA-Z_&]{1,10}$)";
+                if (!Pattern.matches(regex, uniqueIdentifier)) {
+                    throw new RuntimeException("请输入正确的品牌唯一简码,有问题的简码:" + uniqueIdentifier);
+                }
+            }
 
+            // 数据库查询是否存在对应名字的对象
+            BrandEntity isExist = brandDao.queryByName(name);
 
-                // 如果是0就添加数据
-                if (brandId.intValue() == 0) {
-
-
-                    String regex = "(^[0-9a-zA-Z_&]{1,10}$)";
-                    if(!Pattern.matches(regex,uniqueIdentifier)){
-                        throw new RuntimeException("请输入正确的品牌唯一简码,有问题的简码:"+uniqueIdentifier);
-                    }
-
-                    // 如果是正确的,根据唯一简码查询该简码是否存在
-                    BrandEntity queryBrandEntity = brandDao.queryByUniqueIdentifier(uniqueIdentifier);
-
-                    if (Objects.nonNull(queryBrandEntity)){
-                        throw new ServiceException("第" + (i + 1) + "行的该品牌:【" + queryBrandEntity.getName() + "】已存在!");
-                    }
-                    BrandEntity insertBrandEntity = new BrandEntity();
-                    insertBrandEntity.setName(brandEntity.getName());
-                    insertBrandEntity.setSimpleDesc(brandEntity.getSimpleDesc());
-                    insertBrandEntity.setUniqueIdentifier(uniqueIdentifier);
-                    insertBrandEntity.setIsShow(isShow);
-                    insertBrandEntity.setIsNew(isNew);
-                    this.save(insertBrandEntity);
-                } else {
-                    String regex = "(^[0-9a-zA-Z_&]{1,10}$)";
-                    if(!Pattern.matches(regex,uniqueIdentifier)){
-                        throw new RuntimeException("请输入正确的品牌唯一简码,有问题的简码:"+uniqueIdentifier);
-                    }
-                    BrandEntity updateBrandEntity = brandDao.queryObject(brandId);
-                    if (Objects.isNull(updateBrandEntity)) {
-                        throw new ServiceException("第" + (i + 1) + "行的该品牌编号:【" + brandId + "】不存在!");
-                    }
-                    BeanUtils.copyProperties(brandEntity,updateBrandEntity);
-                    this.update(updateBrandEntity);
+            // 不存在则添加
+            if (isExist == null) {
+                // 如果是正确的,根据唯一简码查询该简码是否存在
+                BrandEntity queryBrandEntity = brandDao.queryByUniqueIdentifier(uniqueIdentifier);
+                if (Objects.nonNull(queryBrandEntity)) {
+                    throw new ServiceException("第" + (i + 1) + "行的该品牌:【" + queryBrandEntity.getName() + "】已存在!");
                 }
+
+                BrandEntity insertBrandEntity = new BrandEntity();
+                insertBrandEntity.setName(brandEntity.getName());
+                insertBrandEntity.setSimpleDesc(brandEntity.getSimpleDesc());
+                insertBrandEntity.setUniqueIdentifier(uniqueIdentifier);
+                insertBrandEntity.setIsShow(isShow);
+                insertBrandEntity.setIsNew(isNew);
+                this.save(insertBrandEntity);
+
+            } else {
+                // 存在则修改
+                BeanUtils.copyProperties(brandEntity, isExist);
+                this.update(isExist);
             }
         }
     }

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

@@ -1147,22 +1147,22 @@ public class GoodsServiceImpl implements GoodsService {
                     // 查询数据库中是否有一级分类
                     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()+"";
-
-                    }
+                    // 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));
@@ -1196,22 +1196,22 @@ public class GoodsServiceImpl implements GoodsService {
                 // 查询数据库中是否有一级分类
                 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()+"";
-
-                }
+                // 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));

+ 5 - 6
kmall-admin/src/main/resources/XmlTemplate/BrandDtoList.xml

@@ -5,12 +5,11 @@
         <loop startRow="1" endRow="1" items="BrandEntityList" var="BrandEntity"
               varType="com.kmall.admin.entity.BrandEntity">
             <section startRow="1" endRow="1">
-                <mapping row="1" col="0">BrandEntity.id</mapping>
-                <mapping row="1" col="1">BrandEntity.name</mapping>
-                <mapping row="1" col="2">BrandEntity.uniqueIdentifier</mapping>
-                <mapping row="1" col="3">BrandEntity.simpleDesc</mapping>
-                <mapping row="1" col="4">BrandEntity.isShow</mapping>
-                <mapping row="1" col="5">BrandEntity.isNew</mapping>
+                <mapping row="1" col="0">BrandEntity.name</mapping>
+                <mapping row="1" col="1">BrandEntity.uniqueIdentifier</mapping>
+                <mapping row="1" col="2">BrandEntity.simpleDesc</mapping>
+                <mapping row="1" col="3">BrandEntity.isShow</mapping>
+                <mapping row="1" col="4">BrandEntity.isNew</mapping>
             </section>
             <loopbreakcondition>
                 <rowcheck offset="0">

+ 6 - 0
kmall-admin/src/main/resources/mybatis/mapper/shop/AddressInfoDao.xml

@@ -105,6 +105,12 @@
 		<if test="storeId != null and storeId.trim() != ''">
 			AND adi.store_id LIKE concat('%',#{storeId},'%')
 		</if>
+		<if test="expressName != null and expressName.trim() != ''">
+			AND ecs.express_name LIKE concat('%',#{expressName},'%')
+		</if>
+		<if test="storeName != null and storeName.trim() != ''">
+			AND ms.store_name LIKE concat('%',#{storeName},'%')
+		</if>
         <choose>
             <when test="sidx != null and sidx.trim() != ''">
                 order by ${sidx} ${order}

+ 6 - 0
kmall-admin/src/main/webapp/WEB-INF/page/shop/addressinfo.html

@@ -12,6 +12,12 @@
                 <i-col span="4">
                     <i-input v-model="q.storeId" @on-enter="query" placeholder="门店id"/>
                 </i-col>
+                <i-col span="4">
+                    <i-input v-model="q.storeName" @on-enter="query" placeholder="门店名称"/>
+                </i-col>
+                <i-col span="4">
+                    <i-input v-model="q.expressName" @on-enter="query" placeholder="快递名称"/>
+                </i-col>
                 <i-button @click="query">查询</i-button>
                 <i-button @click="reloadSearch">重置</i-button>
             </div>

+ 7 - 3
kmall-admin/src/main/webapp/js/shop/addressinfo.js

@@ -70,7 +70,9 @@ let vm = new Vue({
 			],*/
 		},
 		q: {
-			storeId: ''
+			storeId: '',
+			expressName: '',
+			storeName: ''
 		}
 	},
 	methods: {
@@ -222,7 +224,9 @@ let vm = new Vue({
 		},
         reloadSearch: function() {
             vm.q = {
-				storeId: ''
+				storeId: '',
+				expressName: '',
+				storeName: ''
             }
             vm.reload();
 		},
@@ -231,7 +235,7 @@ let vm = new Vue({
 			vm.status='';
             let page = $("#jqGrid").jqGrid('getGridParam', 'page');
 			$("#jqGrid").jqGrid('setGridParam', {
-                postData: {'storeId': vm.q.storeId},
+                postData: {'storeId': vm.q.storeId, 'expressName': vm.q.expressName, 'storeName': vm.q.storeName},
                 page: page
             }).trigger("reloadGrid");
             vm.handleReset('formValidate');

+ 2 - 4
kmall-admin/src/main/webapp/js/shop/category.js

@@ -411,24 +411,22 @@ var vm = new Vue({
             } else {
                 alert(data.msg);
             }
-            setTimeout(exportMsg, 100);
         },
         uploadExcelError: function () {
             alert('上传出现异常,请重试!');
-            setTimeout(exportMsg, 100);
         },
         uploadExcelProgress: function (event, file, fileList) {
-            exportMsg = this.$Message.loading({
+            const exportMsg = this.$Message.loading({
                 content: 'Loading...',
                 duration: 0
             });
+            setTimeout(exportMsg, 100);
         },
         uploadExcelFormatError: function (file) {
             this.$Notice.warning({
                 title: '文件格式不正确',
                 desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。'
             });
-            setTimeout(exportMsg, 100);
         }
         // 上传方法结束----
     },

+ 24 - 9
kmall-admin/src/main/webapp/js/shop/merch.js

@@ -53,22 +53,37 @@ let vm = new Vue({
 	data: {
         showList: true,
         title: null,
-		merch: {merchSn:'',merchName:'',merchShortName:'',sortOrder:'',isShow:1},
-		ruleValidate: {
+        merch: {merchSn:'',merchName:'',merchShortName:'',sortOrder:'',isShow:1},
+        ruleValidate: {
             merchSn: [
-				{required: true, message: '商户编号不能为空', trigger: 'blur'}
-			],
+                {required: true, message: '商户编号不能为空', trigger: 'blur'},
+                {max: 32, message: '商户编号长度不能超过32', trigger: 'blur'}
+            ],
             merchName: [
-                {required: true, message: '商户名称不能为空', trigger: 'blur'}
+                {required: true, message: '商户名称不能为空', trigger: 'blur'},
+                {max: 32, message: '商户名称长度不能超过32', trigger: 'blur'}
             ],
             merchShortName: [
-                {required: true, message: '商户简称不能为空', trigger: 'blur'}
+                {required: true, message: '商户简称不能为空', trigger: 'blur'},
+                {max: 10, message: '商户简称长度不能超过10', trigger: 'blur'}
+            ],
+            sortOrder: [
+                {
+                    type: 'integer', message: '排序只能输入正整数,最大不超过9999', trigger: 'blur', min: 0, max: 9999,
+                    transform(value) {
+                        return Number(value);
+                    }
+                },
+                {pattern: /^[1-9]\d*$/, message: '排序只能输入正整数', trigger: 'blur'}
+            ],
+            remark: [
+                {max: 32, message: '备注长度不能超过32', trigger: 'blur'}
             ]
-		},
-		q: {
+        },
+        q: {
             merchName: '',
             merchSn: ''
-		}
+        }
 	},
 	methods: {
 		query: function () {

+ 2 - 9
kmall-admin/src/main/webapp/js/shop/supplier.js

@@ -193,29 +193,22 @@ let vm = new Vue({
             } else {
                 alert(data.msg);
             }
-            setTimeout(exportMsg, 100);
         },
         uploadExcelError: function () {
             alert('上传出现异常,请重试!');
-            setTimeout(exportMsg, 100);
         },
         uploadExcelProgress: function (event, file, fileList) {
-            console.log("上传中")
-            console.log(event)
-            console.log(file)
-            console.log(fileList)
-            console.log("上传中")
-            exportMsg = this.$Message.loading({
+		    const exportMsg = this.$Message.loading({
                 content: 'Loading...',
                 duration: 0
             });
+            setTimeout(exportMsg, 100);
         },
         uploadExcelFormatError: function (file) {
             this.$Notice.warning({
                 title: '文件格式不正确',
                 desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。'
             });
-            setTimeout(exportMsg, 100);
         }
         // 上传方法结束----
 	}

+ 2 - 9
kmall-admin/src/main/webapp/js/shop/syscusnationcode.js

@@ -182,29 +182,22 @@ let vm = new Vue({
             } else {
                 alert(data.msg);
             }
-            setTimeout(exportMsg, 100);
         },
         uploadExcelError: function () {
             alert('上传出现异常,请重试!');
-            setTimeout(exportMsg, 100);
         },
         uploadExcelProgress: function (event, file, fileList) {
-            console.log("上传中")
-            console.log(event)
-            console.log(file)
-            console.log(fileList)
-            console.log("上传中")
-            exportMsg = this.$Message.loading({
+            const exportMsg = this.$Message.loading({
                 content: 'Loading...',
                 duration: 0
             });
+            setTimeout(exportMsg, 100);
         },
         uploadExcelFormatError: function (file) {
             this.$Notice.warning({
                 title: '文件格式不正确',
                 desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。'
             });
-            setTimeout(exportMsg, 100);
         }
         // 上传方法结束----
 	}

+ 2 - 9
kmall-admin/src/main/webapp/js/shop/syscusunitcode.js

@@ -176,29 +176,22 @@ let vm = new Vue({
             } else {
                 alert(data.msg);
             }
-            setTimeout(exportMsg, 100);
         },
         uploadExcelError: function () {
             alert('上传出现异常,请重试!');
-            setTimeout(exportMsg, 100);
         },
         uploadExcelProgress: function (event, file, fileList) {
-            console.log("上传中")
-            console.log(event)
-            console.log(file)
-            console.log(fileList)
-            console.log("上传中")
-            exportMsg = this.$Message.loading({
+            const exportMsg = this.$Message.loading({
                 content: 'Loading...',
                 duration: 0
             });
+            setTimeout(exportMsg, 100);
         },
         uploadExcelFormatError: function (file) {
             this.$Notice.warning({
                 title: '文件格式不正确',
                 desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。'
             });
-            setTimeout(exportMsg, 100);
         }
         // 上传方法结束----
 	}

+ 7 - 1
kmall-admin/src/main/webapp/js/shop/thirdmerchantbiz.js

@@ -98,7 +98,13 @@ let vm = new Vue({
 		ruleValidate: {
 			name: [
 				{required: true, message: '名称不能为空', trigger: 'blur'}
-			]
+			],
+            thirdPartyMerchCode: [
+                {max: 32, message: '第三方商户代码长度不能超过32', trigger: 'blur'}
+            ],
+            thirdPartyMerchName: [
+                {max: 64, message: '第三方商户名称长度不能超过64', trigger: 'blur'}
+            ]
 		},
 		q: {
 		    name: ''

二进制
kmall-admin/src/main/webapp/statics/file/brand_export_yyyy_mm_dd_v1.0.0.xls