huangzhiguo преди 2 години
родител
ревизия
8e59a0fc92

+ 8 - 0
src/main/java/com/caimei365/commodity/mapper/PageMapper.java

@@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.web.bind.annotation.PostMapping;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -272,6 +273,13 @@ public interface PageMapper {
      */
     ArchivePo getArchiveByArchiveId(Integer archiveId);
 
+    /**
+     * 获取关键词
+     * @param ids
+     * @return
+     */
+    List<String> keyWordList(ArrayList<String> ids);
+
     /**
      * 获取机构类型
      *

+ 4 - 0
src/main/java/com/caimei365/commodity/model/po/ArchivePo.java

@@ -47,4 +47,8 @@ public class ArchivePo implements Serializable {
      * 商品分类:1医美,2生美
      */
     private Integer productClassify;
+    /**
+     * 标签库ids
+     */
+    private String labelIds;
 }

+ 4 - 0
src/main/java/com/caimei365/commodity/model/vo/ArchiveDetailVo.java

@@ -48,4 +48,8 @@ public class ArchiveDetailVo implements Serializable {
      * 商品属性:1产品,2仪器
      */
     private Integer productType;
+    /**
+     * 关联标签库字符串
+     */
+    private String  relatedLabels;
 }

+ 4 - 0
src/main/java/com/caimei365/commodity/model/vo/ProductDetailVo.java

@@ -366,4 +366,8 @@ public class ProductDetailVo implements Serializable {
      * 特殊商品退货须知提示  (取后台帮助中心id1040的数据)
      */
     private String  helpContent;
+    /**
+     * 关联标签库字符串
+     */
+    private String  relatedLabels;
 }

+ 24 - 0
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -24,6 +24,7 @@ import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.RequestBody;
 
 import javax.annotation.Resource;
+import java.net.URLDecoder;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -651,6 +652,12 @@ public class PageServiceImpl implements PageService {
         // 设置售罄标记
         Integer flag = priceMapper.getSaleOutFlag(product.getProductId()) > 0 ? 0 : 1;
         product.setSaleOutFlag(flag);
+        // 关联标签库字符串
+        if (StringUtils.isNotBlank(product.getRelatedLabels())) {
+            String replaceAll = product.getRelatedLabels().replaceAll("##", ",");
+            product.setRelatedLabels(replaceAll);
+        }
+
         return ResponseJson.success(product);
     }
 
@@ -1142,6 +1149,22 @@ public class PageServiceImpl implements PageService {
                 fileArchive.setFileUrl(fileUrl);
             }
         });
+        // 获取标签
+        ArrayList<String> item = new ArrayList();
+        if (StringUtils.isNotBlank(archive.getLabelIds())) {
+            if (archive.getLabelIds().contains(",")) {
+                for (String s : archive.getLabelIds().split(",")) {
+                    item.add(s);
+                }
+            } else {
+                item.add(archive.getLabelIds());
+            }
+        }
+        List<String> keyWordList = pageMapper.keyWordList(item);
+        item.clear();
+        for (String s : keyWordList) {
+            item.add(s);
+        }
         ArchiveDetailVo archiveDetail = new ArchiveDetailVo();
         archiveDetail.setImageArchiveList(imageArchiveList);
         archiveDetail.setVideoArchiveList(videoArchiveList);
@@ -1151,6 +1174,7 @@ public class PageServiceImpl implements PageService {
         archiveDetail.setProductName(archive.getProductName());
         archiveDetail.setProductType(archive.getProductType());
         archiveDetail.setShopName(archive.getShopName());
+        archiveDetail.setRelatedLabels(StringUtils.strip(item.toString(),"[]"));
         return ResponseJson.success(archiveDetail);
     }
 

+ 12 - 3
src/main/resources/mapper/PageMapper.xml

@@ -290,7 +290,8 @@
                p.productName                                                                                   as productName,
                p.qualificationTime                                                                             as qualificationTime,
                p.qualificationLink                                                                             as qualificationLink,
-               p.returnGoodsStutas
+               p.returnGoodsStutas,
+               P.relatedLabels
         from product p
                  left join shop s on s.shopId = p.shopId
         where p.productID = #{productId}
@@ -633,13 +634,21 @@
                cpa.archiveLevel                                             AS "archiveLevel",
                if(cpa.productId is not null, ifnull(p.commodityType, cpa.productType),
                   cpa.productType)                                          AS "productType",
-               cpa.productClassify                                          AS "productClassify"
+               cpa.productClassify                                          AS "productClassify",
+                cpa.labelIds                                                AS "labelIds"
         from cm_product_archive cpa
                  left join product p on cpa.productId = p.productID
                  left join shop s on p.shopID = s.shopID
         where cpa.id = #{archiveId}
     </select>
-
+    <select id="keyWordList" resultType="java.lang.String">
+        select keyword from cm_user_search_frequency
+        where
+        id in
+        <foreach collection="ids" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+    </select>
     <select id="getClubTypeByUserId" resultType="java.lang.Integer">
         select ifnull(firstClubType, 0)
         from club