Ver código fonte

所有商品绑定商户

zhang 6 anos atrás
pai
commit
db6832407b

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

@@ -45,6 +45,12 @@ public class GoodsController {
     @RequestMapping("/list")
     @RequiresPermissions("goods:list")
     public R list(@RequestParam Map<String, Object> params) {
+
+        SysUserEntity user = ShiroUtils.getUserEntity();
+        //判断是否是店员和商户
+        if ("2".equals(user.getRoleType()) || "3".equals(user.getRoleType())) {
+            params.put("merchSn", user.getMerchSn());
+        }
         //查询列表数据
         Query query = new Query(params);
 

+ 9 - 0
kmall-admin/src/main/java/com/kmall/admin/controller/MerchController.java

@@ -5,9 +5,11 @@ import java.util.Map;
 
 import com.kmall.admin.entity.MerchEntity;
 import com.kmall.admin.service.MerchService;
+import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.PageUtils;
 import com.kmall.common.utils.Query;
 import com.kmall.common.utils.R;
+import com.kmall.common.utils.ShiroUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -99,6 +101,13 @@ public class MerchController {
     @ResponseBody
     public R queryAll(@RequestParam Map<String, Object> params) {
 
+        SysUserEntity user = ShiroUtils.getUserEntity();
+
+        //判断是否是店员和商户
+        if ("2".equals(user.getRoleType()) || "3".equals(user.getRoleType())) {
+            params.put("roleMerchSn", user.getMerchSn());
+        }
+
         List<MerchEntity> list = merchService.queryList(params);
 
         return R.ok().put("list", list);

+ 10 - 0
kmall-admin/src/main/java/com/kmall/admin/entity/GoodsAttributeEntity.java

@@ -28,6 +28,16 @@ public class GoodsAttributeEntity implements Serializable {
     // 删除标识
     private Integer isDelete = 0;
 
+    private String merchSn;
+
+    public String getMerchSn() {
+        return merchSn;
+    }
+
+    public void setMerchSn(String merchSn) {
+        this.merchSn = merchSn;
+    }
+
     public String getGoodsName() {
         return goodsName;
     }

+ 11 - 0
kmall-admin/src/main/java/com/kmall/admin/entity/GoodsEntity.java

@@ -172,6 +172,17 @@ public class GoodsEntity implements Serializable {
     //品牌
     private String brandName;
 
+    //商户编号
+    private String merchSn;
+
+    public String getMerchSn() {
+        return merchSn;
+    }
+
+    public void setMerchSn(String merchSn) {
+        this.merchSn = merchSn;
+    }
+
     public Integer getStoreId() {
         return storeId;
     }

+ 10 - 0
kmall-admin/src/main/java/com/kmall/admin/entity/GoodsGalleryEntity.java

@@ -37,6 +37,16 @@ public class GoodsGalleryEntity implements Serializable {
     //文件类型:0:图片;1:视频
     private String fileType;
 
+    private String merchSn;
+
+    public String getMerchSn() {
+        return merchSn;
+    }
+
+    public void setMerchSn(String merchSn) {
+        this.merchSn = merchSn;
+    }
+
     public String getFileType() {
         return fileType;
     }

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

@@ -96,6 +96,7 @@ public class GoodsServiceImpl implements GoodsService {
     public int save(GoodsEntity goods) {
         Map<String, Object> valideDate = MapBeanUtil.fromObject(goods);
         ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
+        builder.put("merchSn", "商户");
         builder.put("attributeCategory", "商品分类");
         builder.put("categoryId", "商品二级分类");
         builder.put("goodsSn", "商品编码");
@@ -178,6 +179,7 @@ public class GoodsServiceImpl implements GoodsService {
         // 添加商品轮播图
         for (int i=0;i<galleryEntityList.size();i++) {
             GoodsGalleryEntity galleryEntity =galleryEntityList.get(i);
+            galleryEntity.setMerchSn(goods.getMerchSn());
             galleryEntity.setGoodsId(id);
             galleryEntity.setSortOrder((i+1));
             galleryEntity.setFileType("0");//图片
@@ -185,6 +187,7 @@ public class GoodsServiceImpl implements GoodsService {
         }
         if(org.apache.commons.lang.StringUtils.isNotEmpty(goods.getVideoUrl())){
             GoodsGalleryEntity galleryEntity = new GoodsGalleryEntity();
+            galleryEntity.setMerchSn(goods.getMerchSn());
             galleryEntity.setGoodsId(id);
             galleryEntity.setSortOrder(0);
             galleryEntity.setFileType("1");//视频
@@ -198,6 +201,7 @@ public class GoodsServiceImpl implements GoodsService {
                 if (item.getIsDelete() == 0) {
                     if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNotEmpty(item.getValue())) {
                         item.setGoodsId(id);
+                        item.setMerchSn(goods.getMerchSn());
                         goodsAttributeDao.save(item);
                     } else if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNullOrEmpty(item.getValue())) {
                         throw new RRException("商品属性【" + attributeDao.queryObject(item.getAttributeId()).getName() + "】值不能为空!");
@@ -233,6 +237,7 @@ public class GoodsServiceImpl implements GoodsService {
     public int update(GoodsEntity goods) {
         Map<String, Object> valideDate = MapBeanUtil.fromObject(goods);
         ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
+        builder.put("merchSn", "商户");
         builder.put("attributeCategory", "商品分类");
         builder.put("categoryId", "商品二级分类");
         builder.put("goodsSn", "商品编码");
@@ -325,6 +330,7 @@ public class GoodsServiceImpl implements GoodsService {
         goodsGalleryDao.deleteByGoodsId(goods.getId());
         for (int i=0;i<galleryEntityList.size();i++) {
             GoodsGalleryEntity galleryEntity =galleryEntityList.get(i);
+            galleryEntity.setMerchSn(goods.getMerchSn());
             galleryEntity.setGoodsId(goods.getId());
             galleryEntity.setSortOrder((i+1));
             galleryEntity.setFileType("0");//图片
@@ -332,6 +338,7 @@ public class GoodsServiceImpl implements GoodsService {
         }
         if(org.apache.commons.lang.StringUtils.isNotEmpty(goods.getVideoUrl())){
             GoodsGalleryEntity galleryEntity = new GoodsGalleryEntity();
+            galleryEntity.setMerchSn(goods.getMerchSn());
             galleryEntity.setGoodsId(goods.getId());
             galleryEntity.setSortOrder(0);
             galleryEntity.setFileType("1");//视频
@@ -346,9 +353,11 @@ public class GoodsServiceImpl implements GoodsService {
             for (GoodsAttributeEntity item : attributeEntityList) {
                 if (item.getIsDelete() == 0) {
                      if (item.getId() != null) {
-                        goodsAttributeDao.update(item);
+                         item.setMerchSn(goods.getMerchSn());
+                         goodsAttributeDao.update(item);
                     } else if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNotEmpty(item.getValue())) {
                         item.setGoodsId(goods.getId());
+                        item.setMerchSn(goods.getMerchSn());
                         goodsAttributeDao.save(item);
                     } else if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNullOrEmpty(item.getValue())) {
                         throw new RRException("商品属性【" + attributeDao.queryObject(item.getAttributeId()).getName() + "】值不能为空!");

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

@@ -7,6 +7,7 @@
     <resultMap type="com.kmall.admin.entity.GoodsAttributeEntity" id="goodsAttributeMap">
         <result property="id" column="id"/>
         <result property="goodsId" column="goods_id"/>
+        <result property="merchSn" column="merch_sn"/>
         <result property="attributeId" column="attribute_id"/>
         <result property="value" column="value"/>
     </resultMap>
@@ -15,6 +16,7 @@
         select
         id,
         goods_id,
+        merch_sn,
         attribute_id,
         value
         from mall_goods_attribute
@@ -25,6 +27,7 @@
         select
         mall_goods_attribute.id,
         mall_goods_attribute.goods_id,
+        mall_goods_attribute.merch_sn,
         mall_goods_attribute.attribute_id,
         mall_goods_attribute.value,
         mall_goods.name goods_name,
@@ -66,10 +69,12 @@
     <insert id="save" parameterType="com.kmall.admin.entity.GoodsAttributeEntity" useGeneratedKeys="true" keyProperty="id">
         insert into mall_goods_attribute(
         `goods_id`,
+        `merch_sn`,
         `attribute_id`,
         `value`)
         values(
         #{goodsId},
+        #{merchSn},
         #{attributeId},
         #{value})
     </insert>
@@ -78,6 +83,7 @@
         update mall_goods_attribute
         <set>
             <if test="goodsId != null">`goods_id` = #{goodsId},</if>
+            <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
             <if test="attributeId != null">`attribute_id` = #{attributeId},</if>
             <if test="value != null">`value` = #{value}</if>
         </set>

+ 7 - 0
kmall-admin/src/main/resources/mybatis/mapper/GoodsDao.xml

@@ -5,6 +5,7 @@
 
     <resultMap type="com.kmall.admin.entity.GoodsEntity" id="goodsMap">
         <result property="id" column="id"/>
+        <result property="merchSn" column="merch_sn"/>
         <result property="categoryId" column="category_id"/>
         <result property="goodsSn" column="goods_sn"/>
         <result property="name" column="name"/>
@@ -118,6 +119,9 @@
         WHERE 1=1
         <!--  数据过滤  -->
         ${filterSql}
+        <if test="merchSn != null and merchSn.trim() != ''">
+            AND mall_goods.merch_sn = #{merchSn}
+        </if>
         <if test="goodsSn != null and goodsSn != ''">
             AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
         </if>
@@ -230,6 +234,7 @@
 
     <insert id="save" parameterType="com.kmall.admin.entity.GoodsEntity" useGeneratedKeys="true" keyProperty="id">
         insert into mall_goods(
+            `merch_sn`,
 			`category_id`,
             `supplier_id`,
 			`goods_sn`,
@@ -279,6 +284,7 @@
 			`mod_time`,
 			`tstm`)
 		values(
+			#{merchSn},
 			#{categoryId},
             #{supplierId},
 			#{goodsSn},
@@ -332,6 +338,7 @@
     <update id="update" parameterType="com.kmall.admin.entity.GoodsEntity">
         update mall_goods
         <set>
+            <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
             <if test="categoryId != null">`category_id` = #{categoryId}, </if>
             <if test="supplierId != null">`supplier_id` = #{supplierId}, </if>
             <if test="goodsSn != null">`goods_sn` = #{goodsSn}, </if>

+ 8 - 0
kmall-admin/src/main/resources/mybatis/mapper/GoodsGalleryDao.xml

@@ -5,6 +5,7 @@
 
     <resultMap type="com.kmall.admin.entity.GoodsGalleryEntity" id="goodsGalleryMap">
         <result property="id" column="id"/>
+        <result property="merchSn" column="merch_sn"/>
         <result property="goodsId" column="goods_id"/>
         <result property="imgUrl" column="img_url"/>
         <result property="fileType" column="file_type"/>
@@ -16,6 +17,7 @@
         select
         `id`,
         `goods_id`,
+        `merch_sn`,
         `img_url`,
         `img_desc`,
         `file_type`,
@@ -27,6 +29,7 @@
         select
         `id`,
         `goods_id`,
+        `merch_sn`,
         `img_url`,
         `img_desc`,
         `file_type`,
@@ -38,6 +41,7 @@
         select
         `id`,
         `goods_id`,
+        `merch_sn`,
         `img_url`,
         `img_desc`,
         `file_type`,
@@ -50,6 +54,7 @@
         select
         mall_goods_gallery.id,
         mall_goods_gallery.goods_id,
+        mall_goods_gallery.merch_sn,
         mall_goods_gallery.img_url,
         mall_goods_gallery.file_type,
         mall_goods_gallery.img_desc,
@@ -95,12 +100,14 @@
     <insert id="save" parameterType="com.kmall.admin.entity.GoodsGalleryEntity" useGeneratedKeys="true" keyProperty="id">
         insert into mall_goods_gallery(
         `goods_id`,
+        `merch_sn`,
         `img_url`,
         `file_type`,
         `img_desc`,
         `sort_order`)
         values(
         #{goodsId},
+        #{merchSn},
         #{imgUrl},
         #{fileType},
         #{imgDesc},
@@ -110,6 +117,7 @@
     <update id="update" parameterType="com.kmall.admin.entity.GoodsGalleryEntity">
         update mall_goods_gallery
         <set>
+            <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
             <if test="goodsId != null">`goods_id` = #{goodsId},</if>
             <if test="imgUrl != null">`img_url` = #{imgUrl},</if>
             <if test="fileType != null">`file_type` = #{fileType},</if>

+ 3 - 0
kmall-admin/src/main/resources/mybatis/mapper/MerchDao.xml

@@ -77,6 +77,9 @@
 			`is_show` as `show`
 		from mall_merch
 		WHERE 1=1
+		<if test="roleMerchSn != null and roleMerchSn.trim() != ''">
+			AND merch_sn = #{roleMerchSn}
+		</if>
 		<if test="merchName != null and merchName.trim() != ''">
 			AND merch_name LIKE concat('%',#{merchName},'%')
 		</if>

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

@@ -133,6 +133,11 @@
                     </i-col>
                 </Row>
                 <!--<i-form ref="formValidate" :model="goods" :rules="ruleValidate" :label-width="80">-->
+                    <Form-item label="商户" prop="merchSn">
+                        <i-select v-model="goods.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="categoryId" style="height: 30px;">
                         <!--<i-input v-model="goods.categoryName" @on-click="categoryTree" icon="eye" readonly="readonly" placeholder="商品类型"/>-->
                         <i-select v-model="goods.attributeCategory" placeholder="商品分类" filterable @on-change="changeCategories"

+ 8 - 0
kmall-admin/src/main/webapp/js/shop/goods.js

@@ -139,6 +139,7 @@ var vm = new Vue({
         categoryId: '',
         cusUnitCodeList: [],
         cusNationCodeList: [],
+        merchList: [],
         suppliers: []
     },
     methods: {
@@ -200,6 +201,7 @@ var vm = new Vue({
             vm.getFreights();
             vm.getCusUnitCodeList();
             vm.getCusNationCode();
+            vm.getMerchList();
             vm.showInput = true;
         },
         update: function (event) {
@@ -222,6 +224,7 @@ var vm = new Vue({
             vm.getCusNationCode();
             vm.getFreights();
             vm.getGoodsGallery(id);
+            vm.getMerchList();
             vm.showInput = true;
             if (vm.goods.goodsBizType == '10' || vm.goods.goodsBizType == '02') {
                 vm.showInput = false;
@@ -263,6 +266,11 @@ var vm = new Vue({
                 vm.uploadList = r.list;
             });
         },
+        getMerchList: function() {
+            $.get("../merch/queryAll", function (r) {
+                vm.merchList = r.list;
+            });
+        },
         saveOrUpdate: function (event) {
             var url = vm.goods.id == null ? "../goods/save" : "../goods/update";
             vm.goods.goodsDesc = $('#goodsDesc').editable('getHTML');