ct пре 1 недеља
родитељ
комит
86f73bf811

+ 4 - 3
fs-admin/src/main/java/com/fs/hisStore/FsStoreProductScrmController.java

@@ -7,6 +7,7 @@ import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.hisStore.param.FormatAttrParam;
 import com.fs.hisStore.vo.FsStoreProductAttrValueVO;
 import com.fs.hisStore.vo.FsStoreProductExportVO;
 import com.fs.hisStore.vo.FsStoreProductListVO;
@@ -68,7 +69,7 @@ public class FsStoreProductScrmController extends BaseController
     /**
      * 查询商品列表
      */
-    @PreAuthorize("@ss.hasPermi('store:storeProduct:list')")
+//    @PreAuthorize("@ss.hasPermi('store:storeProduct:list')")
     @GetMapping("/list")
     public TableDataInfo list(FsStoreProductScrm fsStoreProduct)
     {
@@ -158,8 +159,8 @@ public class FsStoreProductScrmController extends BaseController
 
     @ApiOperation(value = "生成属性")
     @PostMapping(value = "/genFormatAttr/{productId}")
-    public ResponseEntity genFormatAttr(@PathVariable Long productId, @RequestBody String jsonStr){
-        return new ResponseEntity<>(fsStoreProductService.getFormatAttr(productId,jsonStr), HttpStatus.OK);
+    public ResponseEntity genFormatAttr(@PathVariable Long productId,@RequestBody FormatAttrParam param){
+        return new ResponseEntity<>(fsStoreProductService.getFormatAttr(productId,param.getAttrs(),param.getStores()), HttpStatus.OK);
     }
 
 

+ 1 - 1
fs-company/src/main/java/com/fs/hisStore/controller/FsStoreProductScrmController.java

@@ -37,7 +37,7 @@ public class FsStoreProductScrmController extends BaseController
     /**
      * 查询商品列表
      */
-    @PreAuthorize("@ss.hasPermi('store:storeProduct:list')")
+//    @PreAuthorize("@ss.hasPermi('store:storeProduct:list')")
     @GetMapping("/list")
     public TableDataInfo list(FsStoreProductScrm fsStoreProduct)
     {

+ 12 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreProductAttrValueScrm.java

@@ -25,6 +25,18 @@ public class FsStoreProductAttrValueScrm extends BaseEntity
     @Excel(name = "商品ID")
     private Long productId;
 
+    public Long getStoreId() {
+        return storeId;
+    }
+
+    public void setStoreId(Long storeId) {
+        this.storeId = storeId;
+    }
+
+    /** 门店ID */
+    @Excel(name = "门店ID")
+    private Long storeId;
+
     /** 商品属性索引值 (attr_value|attr_value[|....]) */
     @Excel(name = "商品属性索引值 (attr_value|attr_value[|....])")
     private String sku;

+ 2 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreProductScrm.java

@@ -24,6 +24,8 @@ public class FsStoreProductScrm extends BaseEntity
     /** 商品id */
     private Long productId;
 
+    private String storeId;
+
     /** 商品图片 */
     @Excel(name = "商品图片")
     private String image;

+ 2 - 2
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreScrmMapper.java

@@ -80,7 +80,7 @@ public interface FsStoreScrmMapper
             + "</script>")
     List<FsStoreScrmVO> selectFsStoreListByIds(@Param("storeIds") List<Integer> storeIds);
 
-//    @Select("select store_id ,store_name,bus_no,bus_name  from fs_store ")
-    @Select("select store_id ,store_name  from fs_store_scrm ")
+    @Select("select store_id ,store_name,bus_no,bus_name  from fs_store_scrm ")
+//    @Select("select store_id ,store_name  from fs_store_scrm ")
     List<FsStoreScrmVO> selectFsAllStoreList();
 }

+ 11 - 0
fs-service/src/main/java/com/fs/hisStore/param/FormatAttrParam.java

@@ -0,0 +1,11 @@
+package com.fs.hisStore.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class FormatAttrParam implements Serializable {
+    private String attrs;
+    private Long[] stores;
+}

+ 4 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreProductAddEditParam.java

@@ -4,6 +4,7 @@ import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
 import com.fs.hisStore.dto.ProductArrtDTO;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.List;
@@ -21,6 +22,9 @@ public class FsStoreProductAddEditParam implements Serializable
     /** 商品id */
     private Long productId;
 
+    @NotNull(message = "店铺不能为空")
+    private String storeId;
+
     /** 商品图片 */
     private String image;
 

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreProductScrmService.java

@@ -70,7 +70,7 @@ public interface IFsStoreProductScrmService
 
     List<FsStoreProductListVO> selectFsStoreProductBarCodeListVO(FsStoreProductScrm fsStoreProduct);
 
-    Map<String,Object> getFormatAttr(Long productId, String jsonStr);
+    Map<String,Object> getFormatAttr(Long productId, String jsonStr,Long[] stores);
 
 
     R addOrEdit(FsStoreProductAddEditParam fsStoreProduct);

+ 44 - 43
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java

@@ -9,6 +9,7 @@ import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.BeanCopyUtils;
 import com.fs.common.core.domain.R;
@@ -172,17 +173,16 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
     }
 
     @Override
-    public Map<String, Object> getFormatAttr(Long productId, String jsonStr) {
-        JSONObject jsonObject = JSON.parseObject(jsonStr);
+    public Map<String, Object> getFormatAttr(Long productId, String jsonStr,Long[] stores) {
+        JSONArray jsonObject = JSON.parseArray(jsonStr);
         Map<String, Object> resultMap = new LinkedHashMap<>(3);
-        if (jsonObject == null || jsonObject.get("attrs") == null || jsonObject.getJSONArray("attrs").isEmpty()) {
+        if (jsonObject == null || jsonObject.isEmpty()) {
             resultMap.put("attr", new ArrayList<>());
             resultMap.put("value", new ArrayList<>());
             resultMap.put("header", new ArrayList<>());
             return resultMap;
         }
-        List<ProductArrtDTO> fromatDetailDTOList = JSON.parseArray(jsonObject.get("attrs").toString(),
-                ProductArrtDTO.class);
+        List<ProductArrtDTO> fromatDetailDTOList = JSON.parseArray(jsonStr, ProductArrtDTO.class);
         DetailVO detailDto = this.attrFormat(fromatDetailDTOList);
         List<Map<String, Object>> headerMapList = null;
         List<Map<String, Object>> valueMapList = new ArrayList<>();
@@ -220,48 +220,51 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                 String key = "value" + (j + 1);
                 valueMap.put(key, detailValues[j]);
             }
-
-            valueMap.put("detail", detail);
-            valueMap.put("sku", "");
-            valueMap.put("image", "");
-            valueMap.put("price", 0);
-            valueMap.put("cost", 0);
-            valueMap.put("otPrice", 0);
-            valueMap.put("stock", 0);
-            valueMap.put("barCode", "");
-            valueMap.put("groupBarCode", "");
-            valueMap.put("agentPrice", 0);
-            valueMap.put("weight", 0);
-            valueMap.put("volume", 0);
-            valueMap.put("brokerage", 0);
-            valueMap.put("brokerageTwo", 0);
-            valueMap.put("brokerageThree", 0);
-            valueMap.put("integral", 0);
             if (productId > 0) {
                 FsStoreProductAttrValueScrm attrValueMap=new FsStoreProductAttrValueScrm();
                 attrValueMap.setProductId(productId);
                 attrValueMap.setSku(sku);
                 List<FsStoreProductAttrValueScrm> values = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueList(attrValueMap);
-                if (values != null&&values.size()==1) {
-                    valueMap.put("id",values.get(0).getId());
-                    valueMap.put("sku",values.get(0).getSku());
-                    valueMap.put("image", values.get(0).getImage());
-                    valueMap.put("price", values.get(0).getPrice());
-                    valueMap.put("cost", values.get(0).getCost());
-                    valueMap.put("otPrice", values.get(0).getOtPrice());
-                    valueMap.put("agentPrice", values.get(0).getAgentPrice());
-                    valueMap.put("stock", values.get(0).getStock());
-                    valueMap.put("barCode", values.get(0).getBarCode());
-                    valueMap.put("groupBarCode", values.get(0).getGroupBarCode());
-                    valueMap.put("weight", values.get(0).getWeight());
-                    valueMap.put("volume", values.get(0).getVolume());
-                    valueMap.put("brokerage", values.get(0).getBrokerage());
-                    valueMap.put("brokerageTwo", values.get(0).getBrokerageTwo());
-                    valueMap.put("brokerageThree", values.get(0).getBrokerageThree());
-                    valueMap.put("integral", values.get(0).getIntegral());
+                for (FsStoreProductAttrValueScrm value : values){
+                    valueMap.put("detail", value.getDetail());
+                    valueMap.put("sku", value.getSku());
+                    valueMap.put("image", value.getImage());
+                    valueMap.put("price", value.getPrice());
+                    valueMap.put("cost", value.getCost());
+                    valueMap.put("otPrice", value.getOtPrice());
+                    valueMap.put("stock", value.getStock());
+                    valueMap.put("barCode", value.getBarCode());
+                    valueMap.put("groupBarCode", value.getGroupBarCode());
+                    valueMap.put("agentPrice", value.getAgentPrice());
+                    valueMap.put("weight", value.getWeight());
+                    valueMap.put("volume", value.getVolume());
+                    valueMap.put("brokerage", value.getBrokerage());
+                    valueMap.put("brokerageTwo", value.getBrokerageTwo());
+                    valueMap.put("brokerageThree", value.getBrokerageThree());
+                    valueMap.put("integral", value.getIntegral());
+                    valueMap.put("storeId", value.getStoreId());
+                    valueMapList.add(ObjectUtil.clone(valueMap));
                 }
+            } else {
+                valueMap.put("detail", detail);
+                valueMap.put("sku", "");
+                valueMap.put("image", "");
+                valueMap.put("price", 0);
+                valueMap.put("cost", 0);
+                valueMap.put("otPrice", 0);
+                valueMap.put("stock", 0);
+                valueMap.put("barCode", "");
+                valueMap.put("groupBarCode", "");
+                valueMap.put("agentPrice", 0);
+                valueMap.put("weight", 0);
+                valueMap.put("volume", 0);
+                valueMap.put("brokerage", 0);
+                valueMap.put("brokerageTwo", 0);
+                valueMap.put("brokerageThree", 0);
+                valueMap.put("integral", 0);
+                valueMap.put("storeId", "");
+                valueMapList.add(ObjectUtil.clone(valueMap));
             }
-            valueMapList.add(ObjectUtil.clone(valueMap));
         }
         this.addHeaderMap(headerMap, headerMapList, align);
         resultMap.put("attr", fromatDetailDTOList);
@@ -293,7 +296,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                         .build();
                 List<ProductArrtDTO> items=new ArrayList<>();
                 items.add(fromatDetailDto);
-                param.getValues().get(0).setSku("默认");
+                param.getValues().forEach(value -> value.setSku("默认"));
                 addProductAttr(product.getProductId(),items,param.getValues());
             } else {
                 addProductAttr(product.getProductId(),param.getItems(),param.getValues());
@@ -345,7 +348,6 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
         Map<String,Object> map = new LinkedHashMap<>();
         map.put("attr",items);
         // map.put("value",values);
-
         for(FsStoreProductAttrValueScrm val: values){
             //更新套餐商品属性ID  获取套餐
             Long id=val.getId();
@@ -364,7 +366,6 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                     }
                 }
             }
-
         }
     }
 

+ 4 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreProductListVO.java

@@ -20,6 +20,10 @@ public class FsStoreProductListVO  implements Serializable
     /** 商品图片 */
     private String image;
 
+    private String storeId;
+
+    private String storeName;
+
     /** 轮播图 */
     private String sliderImage;
 

+ 6 - 1
fs-service/src/main/resources/mapper/hisStore/FsStoreProductAttrValueScrmMapper.xml

@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="FsStoreProductAttrValueScrm" id="FsStoreProductAttrValueResult">
         <result property="id"    column="id"    />
         <result property="productId"    column="product_id"    />
+        <result property="storeId"    column="store_id"    />
         <result property="sku"    column="sku"    />
         <result property="stock"    column="stock"    />
         <result property="sales"    column="sales"    />
@@ -26,13 +27,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectFsStoreProductAttrValueVo">
-        select id, product_id, sku, stock, sales, price, image, cost,agent_price, bar_code,group_bar_code, ot_price, weight, volume, brokerage, brokerage_two,brokerage_three, integral from fs_store_product_attr_value_scrm
+        select id, product_id,store_id, sku, stock, sales, price, image, cost,agent_price, bar_code,group_bar_code, ot_price, weight, volume, brokerage, brokerage_two,brokerage_three, integral from fs_store_product_attr_value_scrm
     </sql>
 
     <select id="selectFsStoreProductAttrValueList" parameterType="FsStoreProductAttrValueScrm" resultMap="FsStoreProductAttrValueResult">
         <include refid="selectFsStoreProductAttrValueVo"/>
         <where>
             <if test="productId != null "> and product_id = #{productId}</if>
+            <if test="storeId != null "> and store_id = #{storeId}</if>
             <if test="sku != null  and sku != ''"> and sku = #{sku}</if>
             <if test="stock != null "> and stock = #{stock}</if>
             <if test="sales != null "> and sales = #{sales}</if>
@@ -60,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         insert into fs_store_product_attr_value_scrm
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="productId != null">product_id,</if>
+            <if test="storeId != null">store_id,</if>
             <if test="sku != null and sku != ''">sku,</if>
             <if test="stock != null">stock,</if>
             <if test="sales != null">sales,</if>
@@ -79,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="productId != null">#{productId},</if>
+            <if test="storeId != null">#{storeId},</if>
             <if test="sku != null and sku != ''">#{sku},</if>
             <if test="stock != null">#{stock},</if>
             <if test="sales != null">#{sales},</if>
@@ -102,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         update fs_store_product_attr_value_scrm
         <trim prefix="SET" suffixOverrides=",">
             <if test="productId != null">product_id = #{productId},</if>
+            <if test="storeId != null">store_id = #{storeId},</if>
             <if test="sku != null and sku != ''">sku = #{sku},</if>
             <if test="stock != null">stock = #{stock},</if>
             <if test="sales != null">sales = #{sales},</if>

+ 7 - 3
fs-service/src/main/resources/mapper/hisStore/FsStoreProductScrmMapper.xml

@@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <resultMap type="FsStoreProductScrm" id="FsStoreProductResult">
         <result property="productId"    column="product_id"    />
+        <result property="storeId"    column="store_id"    />
         <result property="image"    column="image"    />
         <result property="video"    column="video"    />
         <result property="sliderImage"    column="slider_image"    />
@@ -52,12 +53,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectFsStoreProductVo">
-        select product_id, image,video, slider_image, product_name, product_info, keyword, bar_code, cate_id, price, vip_price, ot_price, postage, unit_name, sort, sales, stock, is_show, is_hot, is_benefit, is_best, is_new, description, create_time, update_time, is_postage, is_del, give_integral, cost, is_good, browse, code_path, temp_id, spec_type, is_integral, integral, product_type, prescribe_code, prescribe_spec, prescribe_factory, prescribe_name,is_display,tui_cate_id,company_ids from fs_store_product_scrm
+        select product_id,store_id, image,video, slider_image, product_name, product_info, keyword, bar_code, cate_id, price, vip_price, ot_price, postage, unit_name, sort, sales, stock, is_show, is_hot, is_benefit, is_best, is_new, description, create_time, update_time, is_postage, is_del, give_integral, cost, is_good, browse, code_path, temp_id, spec_type, is_integral, integral, product_type, prescribe_code, prescribe_spec, prescribe_factory, prescribe_name,is_display,tui_cate_id,company_ids from fs_store_product_scrm
     </sql>
 
     <select id="selectFsStoreProductList" parameterType="FsStoreProductScrm" resultMap="FsStoreProductResult">
         <include refid="selectFsStoreProductVo"/>
-        <where>
+        where is_del = 0
+            <if test="storeId != null "> and store_id = #{storeId}</if>
             <if test="image != null  and image != ''"> and image = #{image}</if>
             <if test="sliderImage != null  and sliderImage != ''"> and slider_image = #{sliderImage}</if>
             <if test="productName != null  and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
@@ -98,7 +100,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="prescribeName != null  and prescribeName != ''"> and prescribe_name like concat('%', #{prescribeName}, '%')</if>
             <if test="isDisplay != null "> and is_display = #{isDisplay}</if>
 
-        </where>
     </select>
 
     <select id="selectFsStoreProductById" parameterType="Long" resultMap="FsStoreProductResult">
@@ -120,6 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <insert id="insertFsStoreProduct" parameterType="FsStoreProductScrm" useGeneratedKeys="true" keyProperty="productId">
         insert into fs_store_product_scrm
         <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="storeId != null">store_id,</if>
             <if test="image != null and image != ''">image,</if>
             <if test="video != null and video != ''">video,</if>
             <if test="sliderImage != null and sliderImage != ''">slider_image,</if>
@@ -165,6 +167,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyIds != null and companyIds != ''">company_ids,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="storeId != null">#{storeId},</if>
             <if test="image != null and image != ''">#{image},</if>
             <if test="video != null and video != ''">#{video},</if>
             <if test="sliderImage != null and sliderImage != ''">#{sliderImage},</if>
@@ -214,6 +217,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="updateFsStoreProduct" parameterType="FsStoreProductScrm">
         update fs_store_product_scrm
         <trim prefix="SET" suffixOverrides=",">
+            <if test="storeId != null">store_id = #{storeId},</if>
             <if test="image != null and image != ''">image = #{image},</if>
             <if test="video != null and video != ''">video = #{video},</if>
             <if test="sliderImage != null and sliderImage != ''">slider_image = #{sliderImage},</if>