Selaa lähdekoodia

用户行为今日数据,供应商关联

huangzhiguo 2 vuotta sitten
vanhempi
commit
417347104f

+ 4 - 3
src/main/java/com/caimei365/manager/controller/caimei/user/CmShopLabelApi.java

@@ -46,7 +46,7 @@ public class CmShopLabelApi {
      * @return 返回
      */
     @GetMapping("/shopList")
-    public ResponseJson<PaginationVo<CmShop>> shopList(Integer shopId, String name,
+    public ResponseJson<PaginationVo<CmShop>> shopList(String shopId, String name,
                                                        @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                        @RequestParam(value = "pageSize",defaultValue = "20") int pageSize) {
         return shopLabelService.shopList(shopId,name,pageNum,pageSize);
@@ -98,17 +98,18 @@ public class CmShopLabelApi {
 
     /**
      * 标签列表
+     * @param shopId 供应商Id
      * @param keyword 标签名
      * @param pageNum 页码
      * @param pageSize 页面数据数
      * @return 返回
      */
     @GetMapping("/labelList")
-    public ResponseJson<PaginationVo<CmShopLabel>> labelList(String keyword,
+    public ResponseJson<PaginationVo<CmShopLabel>> labelList(String shopId, String keyword,
                                                              @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                              @RequestParam(value = "pageSize",defaultValue = "20") int pageSize) {
 
-        return shopLabelService.labelList(keyword, pageNum, pageSize);
+        return shopLabelService.labelList(shopId, keyword, pageNum, pageSize);
     }
 
     /**

+ 8 - 2
src/main/java/com/caimei365/manager/dao/user/CmShopLabelDao.java

@@ -30,7 +30,7 @@ public interface CmShopLabelDao {
      * @param shopName 供应商名称
      * @return 返回
      */
-    List<CmShop> shopList(@Param("shopId") Integer shopId, @Param("name") String shopName);
+    List<CmShop> shopList(@Param("shopId") String shopId, @Param("name") String shopName);
 
     /**
      * 添加供应商
@@ -59,11 +59,17 @@ public interface CmShopLabelDao {
 
     /**
      * 标签列表
+     * @param shopId 供应商Id
      * @param keyword 标签名
      * @return 返回
      */
-    List<CmShopLabel> labelList(@Param("keyword") String keyword);
+    List<CmShopLabel> labelList(@Param("shopId") String shopId ,@Param("keyword") String keyword);
 
+    /**
+     * 标签库数据
+     * @return 返回
+     */
+    List<CmShopLabel> labelListAll();
     /**
      * 关联标签
      * @param cmShopLabel 标签信息

+ 4 - 0
src/main/java/com/caimei365/manager/entity/caimei/CmShopLabel.java

@@ -49,4 +49,8 @@ public class CmShopLabel {
      */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date addTime;
+    /**
+     * 标签库数据来源(1:手动添加;2:用户关键词统计;3:导入)
+     */
+    private Integer fromSearch;
 }

+ 2 - 2
src/main/java/com/caimei365/manager/service/caimei/user/CmShopLabelService.java

@@ -31,7 +31,7 @@ public interface CmShopLabelService {
      * @param pageSize 页面数据数
      * @return 返回
      */
-    ResponseJson<PaginationVo<CmShop>> shopList(Integer shopId, String name, Integer pageNum, Integer pageSize);
+    ResponseJson<PaginationVo<CmShop>> shopList(String shopId, String name, Integer pageNum, Integer pageSize);
 
     /**
      * 添加供应商
@@ -64,7 +64,7 @@ public interface CmShopLabelService {
      * @param pageSize 页面数据数
      * @return 返回
      */
-    ResponseJson<PaginationVo<CmShopLabel>> labelList(String keyword, Integer pageNum, Integer pageSize);
+    ResponseJson<PaginationVo<CmShopLabel>> labelList(String shopId, String keyword, Integer pageNum, Integer pageSize);
 
     /**
      * 关联标签

+ 14 - 6
src/main/java/com/caimei365/manager/service/caimei/user/impl/CmBehaviorRecordServiceImpl.java

@@ -42,6 +42,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
     public ResponseJson<PaginationVo<CmBehaviorRecord>> list(CmBehaviorRecord cmBehaviorRecord,Integer pageNum, Integer pageSize) {
         List<CmBehaviorRecord> list = null;
         List<String> labels = new ArrayList<>();
+        String behaviorType = "";
         if (StringUtils.isNotBlank(cmBehaviorRecord.getLabel())) {
             if (cmBehaviorRecord.getLabel().contains(",")) {
                 String[] split = cmBehaviorRecord.getLabel().split(",");
@@ -53,6 +54,11 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
             }
         }
         cmBehaviorRecord.setLabels(labels);
+        //"深圳艾斯佰丽生物科技有限公司".equals(cmBehaviorRecord.getSpName())
+        if ("小九九专用测试公司".equals(cmBehaviorRecord.getRelevanceShop()) || "小九九专用测试公司".equals(cmBehaviorRecord.getCorporateName())) {
+            behaviorType = "2";
+        }
+        cmBehaviorRecord.setBehaviorType(behaviorType);
         PageHelper.startPage(pageNum, pageSize);
         if (cmBehaviorRecord.getTodayType() == 0) {
             list = cmBehaviorRecordDao.findListToday(cmBehaviorRecord);
@@ -154,13 +160,15 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
             }
             // 供应商显示
             if (shopNameList.size() > 0) {
-                shopNameList.forEach(sn -> {
-                    String shopName = "";
-                    if (r.getRecordId().equals(sn.getRecordId())) {
-                        shopName += sn.getName();
+                String shopName = "";
+                for(CmBehaviorRecord record :shopNameList) {
+
+                    if (r.getRecordId().equals(record.getRecordId())) {
+                        shopName += record.getName();
                     }
-                    r.setRelevanceShop(shopName);
-                });
+
+                }
+                r.setRelevanceShop(shopName);
             }
         });
         PageHelper.startPage(pageNum, pageSize);

+ 14 - 7
src/main/java/com/caimei365/manager/service/caimei/user/impl/CmShopLabelServiceImpl.java

@@ -36,8 +36,8 @@ public class CmShopLabelServiceImpl implements CmShopLabelService {
      */
     @Override
     public ResponseJson<PaginationVo<CmShopRelevance>> pageList(CmShopRelevance cmShopRelevance, Integer pageNum, Integer pageSize) {
-        List<CmShopRelevance> relevanceList = cmShopLabelDao.shopRelevanceList(cmShopRelevance);
         PageHelper.startPage(pageNum,pageSize);
+        List<CmShopRelevance> relevanceList = cmShopLabelDao.shopRelevanceList(cmShopRelevance);
         PaginationVo<CmShopRelevance> pageList = new PaginationVo<>(relevanceList);
         return ResponseJson.success(pageList);
     }
@@ -52,9 +52,10 @@ public class CmShopLabelServiceImpl implements CmShopLabelService {
      * @return 返回
      */
     @Override
-    public ResponseJson<PaginationVo<CmShop>> shopList(Integer shopId, String name, Integer pageNum, Integer pageSize) {
-        List<CmShop> shopList = cmShopLabelDao.shopList(shopId, name);
+    public ResponseJson<PaginationVo<CmShop>> shopList(String shopId, String name, Integer pageNum, Integer pageSize) {
         PageHelper.startPage(pageNum, pageSize);
+        List<CmShop> shopList = cmShopLabelDao.shopList(shopId, name);
+
         PaginationVo<CmShop> pageList = new PaginationVo<>(shopList);
         return ResponseJson.success(pageList);
     }
@@ -103,8 +104,8 @@ public class CmShopLabelServiceImpl implements CmShopLabelService {
      */
     @Override
     public ResponseJson<PaginationVo<CmShopLabel>> shopLabelList(Integer relevanceId, String keyword, Integer pageNum, Integer pageSize) {
-        List<CmShopLabel> labelList = cmShopLabelDao.shopLabelList(relevanceId, keyword);
         PageHelper.startPage(pageNum,pageSize);
+        List<CmShopLabel> labelList = cmShopLabelDao.shopLabelList(relevanceId, keyword);
         PaginationVo<CmShopLabel> pageList = new PaginationVo<>(labelList);
         return ResponseJson.success(pageList);
     }
@@ -118,9 +119,9 @@ public class CmShopLabelServiceImpl implements CmShopLabelService {
      * @return 返回
      */
     @Override
-    public ResponseJson<PaginationVo<CmShopLabel>> labelList(String keyword, Integer pageNum, Integer pageSize) {
-        List<CmShopLabel> labelList = cmShopLabelDao.labelList(keyword);
+    public ResponseJson<PaginationVo<CmShopLabel>> labelList(String shopId, String keyword, Integer pageNum, Integer pageSize) {
         PageHelper.startPage(pageNum,pageSize);
+        List<CmShopLabel> labelList = cmShopLabelDao.labelList(shopId, keyword);
         PaginationVo<CmShopLabel> pageList = new PaginationVo<>(labelList);
         return ResponseJson.success(pageList);
     }
@@ -161,10 +162,16 @@ public class CmShopLabelServiceImpl implements CmShopLabelService {
      * 添加标签到标签库
      *
      * @param keyword 标签
-     * @return
+     * @return 返回
      */
     @Override
     public ResponseJson insertSearch(String keyword) {
+        List<CmShopLabel> labelList = cmShopLabelDao.labelListAll();
+        for (CmShopLabel shopLabel : labelList) {
+            if (shopLabel.getKeyword().equals(keyword) ) {
+                return ResponseJson.error("不能重复添加标签",null);
+            }
+        }
         cmShopLabelDao.insertSearch(keyword);
         return ResponseJson.success("添加成功", null);
     }

+ 5 - 0
src/main/resources/mapper/CmBehaciorRecordDao.xml

@@ -32,6 +32,7 @@
         accessDate,
         accessClient,
         region,
+        relevanceShop,
         addTime
         FROM cm_behavior_record_index
         <where>
@@ -59,6 +60,9 @@
             </if>
             <if test="relevanceShop != null and relevanceShop != ''">
                 AND relevanceShop like concat('%',#{relevanceShop},'%')
+                <if test="behaviorType == 2">
+                    or behaviorType = #{behaviorType}
+                </if>
             </if>
             <if test="labels != null and labels.size > 0">
                 AND
@@ -93,6 +97,7 @@
         region,
         relevanceShop,
         label,
+        relevanceShop,
         addTime
         FROM cm_behavior_record_today
         <where>

+ 18 - 7
src/main/resources/mapper/CmShopLabelDao.xml

@@ -8,10 +8,10 @@
         <where>
             csr.delFlag = 0
             <if test="shopName != null and shopName != ''">
-                and s.name = #{shopName}
+                and s.name like concat('%',#{shopName},'%')
             </if>
             <if test="linkMan != null and linkMan != ''">
-                and s.linkMan = #{linkMan}
+                and s.linkMan like concat('%',#{linkMan},'%')
             </if>
             <if test="contractMobile != null and contractMobile != ''">
                 and s.contractMobile = #{contractMobile}
@@ -47,7 +47,7 @@
         where relevanceId = #{relevanceId}
     </update>
     <select id="shopLabelList" resultType="com.caimei365.manager.entity.caimei.CmShopLabel">
-        SELECT csl.*, cusf.keyword, cusf.frequency, cusf.searchTime
+        SELECT csl.*, cusf.keyword, cusf.frequency, cusf.searchTime, cusf.fromSearch
         FROM cm_shop_label csl
         LEFT JOIN cm_user_search_frequency cusf ON csl.keywordId = cusf.id
         <where>
@@ -67,20 +67,31 @@
             addTime
         from cm_user_search_frequency
         <where>
-            delStatus = 1 and id NOT IN ( SELECT keywordId FROM cm_shop_label where delFlag = 0)
+            trueStatus = 1 and delStatus = 1 and id NOT IN
+            ( SELECT csl.keywordId FROM cm_shop_label csl
+                LEFT JOIN cm_shop_relevance csr ON csl.relevanceId = csr.id WHERE csr.shopID = #{shopId} AND csl.delFlag = 0)
             <if test="keyword != null and keyword != ''">
                 and keyword like concat('%',#{keyword},'%')
             </if>
         </where>
-        order by searchTime desc
+        order by frequency desc, addTime
+    </select>
+    <select id="labelListAll" resultType="com.caimei365.manager.entity.caimei.CmShopLabel">
+        select
+            id,
+            keyword,
+            frequency,
+            searchTime,
+            addTime
+        from cm_user_search_frequency
     </select>
     <insert id="insertLabel">
         INSERT INTO cm_shop_label(relevanceId, keywordId, pickTime, delFlag)
         VALUES (#{relevanceId}, #{keywordId}, #{pickTime}, '0')
     </insert>
     <insert id="insertSearch">
-        INSERT INTO cm_user_search_frequency(fromSearch, keyword, frequency, trueStatus, delStatus, linkageFrequency, searchTime, recommendStatus, recommendFlag,addTime)
-        VALUES (1, #{keyword}, 1, 1, 1, 0, now(), 0, 0, now())
+        INSERT INTO cm_user_search_frequency(fromSearch, keyword, frequency, trueStatus, delStatus, linkageFrequency, recommendStatus, recommendFlag, addTime)
+        VALUES (1, #{keyword}, 0, 1, 1, 0, 0, 0, now())
     </insert>
     <update id="upShopLabelList">
         update cm_shop_label