ソースを参照

门店商品绑定商户

zhang 6 年 前
コミット
8d0ac0f578

+ 15 - 4
kmall-admin/src/main/java/com/kmall/admin/controller/ProductStoreRelaController.java

@@ -37,9 +37,11 @@ public class ProductStoreRelaController {
     @ResponseBody
     public R list(@RequestParam Map<String, Object> params) {
         SysUserEntity user = ShiroUtils.getUserEntity();
-        if(user != null) {
-            if (user.getRoleType().equalsIgnoreCase("2")) {
+        if (user != null) {
+            if ("2".equals(user.getRoleType())) {
                 params.put("storeId", user.getStoreId());
+            } else if ("3".equals(user.getRoleType())) {
+                params.put("merchSn", user.getMerchSn());
             }
         }
         //查询列表数据
@@ -83,8 +85,8 @@ public class ProductStoreRelaController {
     @RequiresPermissions("productstorerela:update")
     @ResponseBody
     public R update(@RequestBody ProductStoreRelaEntity productStoreRela) {
-        if (null == productStoreRela.getProductId() || null == productStoreRela.getGoodsId()
-                || null == productStoreRela.getStoreId()) {
+        if (null == productStoreRela.getProductId() || null == productStoreRela.getGoodsId() ||
+            null == productStoreRela.getStoreId()) {
             return R.error("信息不全,保存失败");
         }
         productStoreRelaService.update(productStoreRela);
@@ -110,6 +112,15 @@ public class ProductStoreRelaController {
     @ResponseBody
     public R queryAll(@RequestParam Map<String, Object> params) {
 
+        SysUserEntity user = ShiroUtils.getUserEntity();
+        if (user != null) {
+            if (user.getRoleType().equalsIgnoreCase("2")) {
+                params.put("id", user.getStoreId());
+            } else if (user.getRoleType().equalsIgnoreCase("3")) {
+                params.put("merchSn", user.getMerchSn());
+            }
+        }
+
         List<ProductStoreRelaEntity> list = productStoreRelaService.queryList(params);
 
         return R.ok().put("list", list);

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

@@ -107,6 +107,15 @@ public class StoreController {
     @ResponseBody
     public R queryAll(@RequestParam Map<String, Object> params) {
 
+        SysUserEntity user = ShiroUtils.getUserEntity();
+        if (user != null) {
+            if ("2".equals(user.getRoleType())) {
+                params.put("id", user.getStoreId());
+            } else if ("3".equals(user.getRoleType())) {
+                params.put("merchSn", user.getMerchSn());
+            }
+        }
+
         List<StoreEntity> list = storeService.queryList(params);
 
         return R.ok().put("list", list);

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

@@ -81,6 +81,16 @@ public class ProductStoreRelaEntity implements Serializable {
 
     private String listPicUrl;
 
+    private String merchSn;
+
+    public String getMerchSn() {
+        return merchSn;
+    }
+
+    public void setMerchSn(String merchSn) {
+        this.merchSn = merchSn;
+    }
+
     public String getListPicUrl() {
         return listPicUrl;
     }

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

@@ -203,6 +203,9 @@
         select count(*) from mall_goods 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>

+ 25 - 2
kmall-admin/src/main/resources/mybatis/mapper/ProductStoreRelaDao.xml

@@ -6,6 +6,7 @@
     <resultMap type="com.kmall.admin.entity.ProductStoreRelaEntity" id="productStoreRelaMap">
         <result property="id" column="id"/>
         <result property="storeId" column="store_id"/>
+        <result property="merchSn" column="merch_sn"/>
         <result property="productId" column="product_id"/>
         <result property="stockNum" column="stock_num"/>
         <result property="goodsId" column="goods_id"/>
@@ -34,6 +35,7 @@
 		SELECT
             a.`id`,
             a.`store_id`,
+            a.`merch_sn`,
             a.`product_id`,
             a.`stock_num`,
             a.`goods_id`,
@@ -68,6 +70,7 @@
         select
         a.`id`,
         a.`store_id`,
+        a.`merch_sn`,
         a.`product_id`,
         a.`stock_num`,
         a.`goods_id`,
@@ -93,6 +96,7 @@
         select
         a.`id`,
         a.`store_id`,
+        a.`merch_sn`,
         a.`product_id`,
         a.`stock_num`,
         a.`goods_id`,
@@ -113,6 +117,12 @@
         LEFT JOIN mall_category cg ON b.category_id = cg.id
         left join mall_store s on a.store_id = s.id
         WHERE 1=1 and b.is_delete = 0
+        <if test="storeId != null and storeId != '' ">
+            AND a.store_id = #{storeId}
+        </if>
+        <if test="merchSn != null and merchSn.trim() != '' ">
+            AND a.merch_sn = #{merchSn}
+        </if>
         <if test="goodsId != null">
             AND a.goods_id = #{goodsId}
         </if>
@@ -151,6 +161,7 @@
         select
         a.`id`,
         a.`store_id`,
+        a.`merch_sn`,
         a.`product_id`,
         a.`stock_num`,
         a.`goods_id`,
@@ -173,9 +184,12 @@
         <if test="goodsId != null">
             AND b.id = #{goodsId}
         </if>
-        <if test="storeId != null">
+        <if test="storeId != null and storeId != '' ">
             AND a.store_id = #{storeId}
         </if>
+        <if test="merchSn != null and merchSn.trim() != '' ">
+            AND a.merch_sn = #{merchSn}
+        </if>
         <if test="id != null">
             AND a.id != #{id}
         </if>
@@ -200,6 +214,12 @@
         LEFT JOIN mall_category cg ON b.category_id = cg.id
         left join mall_store s on a.store_id = s.id
         WHERE 1=1 and b.is_delete = 0
+        <if test="storeId != null and storeId != '' ">
+            AND a.store_id = #{storeId}
+        </if>
+        <if test="merchSn != null and merchSn.trim() != '' ">
+            AND a.merch_sn = #{merchSn}
+        </if>
         <if test="goodsId != null">
             AND a.goods_id = #{goodsId}
         </if>
@@ -227,6 +247,7 @@
             keyProperty="id">
 		insert into mall_product_store_rela(
 			`store_id`,
+			`merch_sn`,
 			`product_id`,
 			`stock_num`,
 			`goods_id`,
@@ -255,7 +276,8 @@
         </if>
         )
 		values(
-			#{storeId},
+            #{storeId},
+			#{merchSn},
 			#{productId},
 			#{stockNum},
 			#{goodsId},
@@ -289,6 +311,7 @@
         update mall_product_store_rela
         <set>
             <if test="storeId != null">`store_id` = #{storeId},</if>
+            <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
             <if test="productId != null">`product_id` = #{productId},</if>
             <if test="stockNum != null">`stock_num` = #{stockNum},</if>
             <if test="goodsId != null">`goods_id` = #{goodsId},</if>