Browse Source

管理员维护增加商户绑定

zhang 6 years ago
parent
commit
b865ff4879

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

@@ -3,6 +3,7 @@ package com.kmall.admin.service.impl;
 import com.kmall.admin.dao.MerchDao;
 import com.kmall.admin.entity.MerchEntity;
 import com.kmall.admin.service.MerchService;
+import com.kmall.common.utils.RRException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -39,11 +40,19 @@ public class MerchServiceImpl
 
     @Override
     public int save(MerchEntity merch) {
+        MerchEntity tempMerch = merchDao.findByMerchSn(merch.getMerchSn());
+        if(tempMerch != null){
+            throw new RRException("商户编号已经存在");
+        }
         return merchDao.save(merch);
     }
 
     @Override
     public int update(MerchEntity merch) {
+        MerchEntity tempMerch = merchDao.findByMerchSn(merch.getMerchSn());
+        if(tempMerch != null && tempMerch.getId() != merch.getId()){
+            throw new RRException("商户编号已经存在");
+        }
         return merchDao.update(merch);
     }
 

+ 6 - 0
kmall-admin/src/main/webapp/WEB-INF/page/sys/user.html

@@ -55,6 +55,7 @@
                 <Radio-group v-model="user.roleType">
                     <Radio label="1">操作员</Radio>
                     <Radio label="2">店员</Radio>
+                    <Radio label="3">商户管理员</Radio>
                 </Radio-group>
             </Form-item>
             <Form-item label="门店" prop="storeId">
@@ -62,6 +63,11 @@
                     <i-option v-for="store in storeList" :value="store.id" :key="store.id">{{store.storeName}}</i-option>
                 </i-select>
             </Form-item>
+            <Form-item label="商户" prop="merchSn">
+                <i-select v-model="user.merchSn" filterable placeholder="商户" label-in-value>
+                    <i-option v-for="merch in merchList" :value="merch.merchSn" :key="merch.merchSn">{{merch.merchName}}</i-option>
+                </i-select>
+            </Form-item>
             <Form-item label="状态" prop="status">
                 <Radio-group v-model="user.status">
                     <Radio label="0">

+ 11 - 2
kmall-admin/src/main/webapp/js/sys/user.js

@@ -88,7 +88,8 @@ var vm = new Vue({
                 {required: true, message: '手机号不能为空', trigger: 'blur'}
             ]*/
         },
-        storeList: []
+        storeList: [],
+        merchList: []
     },
     methods: {
         query: function () {
@@ -98,18 +99,25 @@ var vm = new Vue({
             vm.showList = false;
             vm.title = "新增(默认密码:111111)";
             vm.roleList = {};
-            vm.user = {status: 1, roleIdList: [], deptId: '', deptName: '', storeId: '', roleType: 2};
+            vm.user = {status: 1, roleIdList: [], deptId: '', deptName: '', storeId: '', roleType: 2,merchSn:''};
             vm.storeList = [];
+            vm.merchList = [];
             //获取角色信息
             this.getRoleList();
             // vm.getDept();
             vm.getStoreList();
+            vm.getMerchList();
         },
         getStoreList: function() {
             $.get("../store/queryAll", function (r) {
                 vm.storeList = r.list;
             });
         },
+        getMerchList: function() {
+            $.get("../merch/queryAll", function (r) {
+                vm.merchList = r.list;
+            });
+        },
         getDept: function () {
             //加载部门树
             $.get("../sys/dept/list", function (r) {
@@ -135,6 +143,7 @@ var vm = new Vue({
                 //获取角色信息
                 vm.getStoreList();
                 vm.getRoleList();
+                vm.getMerchList();
                 // vm.getDept();
             });
 

+ 12 - 1
kmall-common/src/main/java/com/kmall/common/entity/SysUserEntity.java

@@ -17,7 +17,8 @@ import java.util.Set;
  * @email
  * @date 2016年9月18日 上午9:28:55
  */
-public class SysUserEntity implements Serializable {
+public class SysUserEntity
+        implements Serializable {
     private static final long serialVersionUID = 1L;
 
     /**
@@ -79,6 +80,8 @@ public class SysUserEntity implements Serializable {
 
     private Integer storeId;
 
+    private String merchSn;
+
     private String roleType;
 
     private Set<String> permsSet;
@@ -189,6 +192,14 @@ public class SysUserEntity implements Serializable {
         this.storeId = storeId;
     }
 
+    public String getMerchSn() {
+        return merchSn;
+    }
+
+    public void setMerchSn(String merchSn) {
+        this.merchSn = merchSn;
+    }
+
     public String getRoleType() {
         return roleType;
     }

+ 6 - 2
kmall-common/src/main/java/com/kmall/common/service/impl/SysUserServiceImpl.java

@@ -83,8 +83,10 @@ public class SysUserServiceImpl implements SysUserService {
         if (Integer.valueOf(r.get("code").toString()) != 0) {
             throw new RRException(r.get("msg").toString());
         } else {
-            if (!"1".equals(user.getRoleType())) {
+            if ("2".equals(user.getRoleType())) {
                 builder.put("storeId", "门店");
+            }else if ("3".equals(user.getRoleType())) {
+                builder.put("merchSn", "商户");
             }
             r = ValidatorUtil.isEmpty(builder.build(), valideDate);
             if (Integer.valueOf(r.get("code").toString()) != 0) {
@@ -127,8 +129,10 @@ public class SysUserServiceImpl implements SysUserService {
         if (Integer.valueOf(r.get("code").toString()) != 0) {
             throw new RRException(r.get("msg").toString());
         } else {
-            if (!"1".equals(user.getRoleType())) {
+            if ("2".equals(user.getRoleType())) {
                 builder.put("storeId", "门店");
+            }else if ("3".equals(user.getRoleType())) {
+                builder.put("merchSn", "商户");
             }
             r = ValidatorUtil.isEmpty(builder.build(), valideDate);
             if (Integer.valueOf(r.get("code").toString()) != 0) {

+ 3 - 0
kmall-common/src/main/resources/mybatis/mapper/SysUserDao.xml

@@ -86,6 +86,7 @@
 			`create_user_id`,
 			`dept_id`,
 			`store_id`,
+			`merch_sn`,
 			`role_type`,
 			`create_time`
 		)
@@ -100,6 +101,7 @@
 			#{createUserId},
 			#{deptId},
 			#{storeId},
+			#{merchSn},
 			#{roleType},
 			#{createTime}
 		)
@@ -114,6 +116,7 @@
 			<if test="status != null">`status` = #{status}, </if>
 			<if test="deptId != null">`dept_id` = #{deptId}, </if>
 			<if test="storeId != null">`store_id` = #{storeId}, </if>
+			<if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
 			<if test="roleType != null">`role_type` = #{roleType}, </if>
 		</set>
 		where user_id = #{userId}