浏览代码

用户行为记录

huangzhiguo 2 年之前
父节点
当前提交
8df12d1f06

+ 5 - 0
pom.xml

@@ -77,6 +77,11 @@
             <artifactId>spring-security-test</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>com.caimei</groupId>
+            <artifactId>caimei-common</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+        </dependency>
     </dependencies>
 
     <profiles>

+ 58 - 0
src/main/java/com/caimei365/manager/controller/caimei/user/CmBehaviorRecordApi.java

@@ -0,0 +1,58 @@
+package com.caimei365.manager.controller.caimei.user;
+
+import com.caimei365.manager.entity.PaginationVo;
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.CmBehaviorRecord;
+import com.caimei365.manager.service.caimei.user.CmBehaviorRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/15
+ */
+@RestController
+@RequestMapping("/user/behavior")
+public class CmBehaviorRecordApi {
+
+    @Autowired private CmBehaviorRecordService recordService;
+
+    /**
+     * 用户行为记录列表数据
+     * @param cmBehaviorRecord 参数
+     * @return 返回
+     */
+    @GetMapping("/record/list")
+    public ResponseJson<PaginationVo<CmBehaviorRecord>> list(CmBehaviorRecord cmBehaviorRecord,
+                                                             @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                             @RequestParam(value = "pageSize",defaultValue = "20") int pageSize) {
+
+        return recordService.list(cmBehaviorRecord, pageNum, pageSize);
+    }
+
+    /**
+     * 查看详情
+     * @param cmBehaviorRecord 参数
+     * @param pageNum 页码
+     * @param pageSize 页面数据数
+     * @return 返回
+     */
+    @GetMapping("/record/recordList")
+    public ResponseJson<PaginationVo<CmBehaviorRecord>> recordList (CmBehaviorRecord cmBehaviorRecord,
+                                                                    @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                    @RequestParam(value = "pageSize",defaultValue = "20")int pageSize) {
+        return recordService.recordList(cmBehaviorRecord, pageNum, pageSize);
+    }
+
+    /**
+     * 标签库数据
+     * @return 返回
+     */
+    @GetMapping("/searchList")
+    public ResponseJson searchList () {
+
+        return recordService.searchList();
+    }
+}

+ 157 - 0
src/main/java/com/caimei365/manager/controller/caimei/user/CmShopLabelApi.java

@@ -0,0 +1,157 @@
+package com.caimei365.manager.controller.caimei.user;
+
+import com.caimei.utils.StringUtil;
+import com.caimei.utils.StringUtils;
+import com.caimei365.manager.entity.PaginationVo;
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.CmShop;
+import com.caimei365.manager.entity.caimei.CmShopLabel;
+import com.caimei365.manager.entity.caimei.CmShopRelevance;
+import com.caimei365.manager.service.caimei.user.CmShopLabelService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/15
+ */
+@RestController
+@RequestMapping("/user/shopLabel")
+public class CmShopLabelApi {
+
+    @Autowired private CmShopLabelService shopLabelService;
+
+    /**
+     * 关联标签供应商列表
+     * @param cmShopRelevance 搜索条件
+     * @param pageNum 页码
+     * @param pageSize 页面数据数
+     * @return 返回
+     */
+    @GetMapping("/shopRelevanceList")
+    public ResponseJson<PaginationVo<CmShopRelevance>> shopRelevanceList(CmShopRelevance cmShopRelevance,
+                                                                         @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                         @RequestParam(value = "pageSize",defaultValue = "20") int pageSize) {
+        return shopLabelService.pageList(cmShopRelevance,pageNum,pageSize);
+    }
+
+    /**
+     * 供应商列表
+     * @param shopId 供应商id
+     * @param name 供应商名称
+     * @param pageNum 页码
+     * @param pageSize 页面数据数
+     * @return 返回
+     */
+    @GetMapping("/shopList")
+    public ResponseJson<PaginationVo<CmShop>> shopList(Integer shopId, String name,
+                                                       @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                       @RequestParam(value = "pageSize",defaultValue = "20") int pageSize) {
+        return shopLabelService.shopList(shopId,name,pageNum,pageSize);
+    }
+
+    /**
+     * 添加供应商
+     * @param shopId 供应商id
+     * @return 返回
+     */
+    @GetMapping("/insertShopRelevance")
+    public ResponseJson insertShopRelevance(Integer shopId) {
+        if (shopId == null) {
+            return ResponseJson.error("供应商Id不能为空",null);
+        }
+        return shopLabelService.insertShopRelevance(shopId);
+    }
+
+    /**
+     * 删除关联标签的供应商
+     * @param relevanceId 供应商id
+     * @return 返回
+     */
+    @GetMapping("/delShopById")
+    public ResponseJson delShopRelevanceById(Integer relevanceId) {
+        if (relevanceId == null) {
+            return ResponseJson.error("供应商Id不能为空",null);
+        }
+        return shopLabelService.delShopRelevanceById(relevanceId);
+    }
+
+    /**
+     * 供应商关联标签列表
+     * @param relevanceId 供应商id
+     * @param keyword 标签名
+     * @param pageNum 页码
+     * @param pageSize 页面数据数
+     * @return 返回
+     */
+    @GetMapping("/shopLabelList")
+    public  ResponseJson<PaginationVo<CmShopLabel>> shopLabelList (Integer relevanceId, String keyword,
+                                                                   @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                   @RequestParam(value = "pageSize",defaultValue = "20") int pageSize) {
+        if (relevanceId == null) {
+            ResponseJson.error("供应商Id不能为空",null);
+        }
+        return shopLabelService.shopLabelList(relevanceId,keyword,pageNum,pageSize);
+    }
+
+    /**
+     * 标签列表
+     * @param keyword 标签名
+     * @param pageNum 页码
+     * @param pageSize 页面数据数
+     * @return 返回
+     */
+    @GetMapping("/labelList")
+    public ResponseJson<PaginationVo<CmShopLabel>> labelList(String keyword,
+                                                             @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                             @RequestParam(value = "pageSize",defaultValue = "20") int pageSize) {
+
+        return shopLabelService.labelList(keyword, pageNum, pageSize);
+    }
+
+    /**
+     * 关联标签
+     * @param relevanceId 供应商id
+     * @param keywordIds 标签id或id集合
+     * @return 返回
+     */
+    @GetMapping("/insertLabel")
+    public ResponseJson insertLabel(Integer relevanceId, String keywordIds) {
+        if (relevanceId == null) {
+            return  ResponseJson.error("关联供应商Id不能为空", null);
+        }
+        if (!StringUtils.isNotBlank(keywordIds)) {
+            return ResponseJson.error("标签Id不能为空",null);
+        }
+        return shopLabelService.insertLabel(relevanceId, keywordIds);
+    }
+
+    /**
+     * 添加标签到标签库
+     * @param keyword 标签
+     * @return 返回
+     */
+    @GetMapping("/insertSearch")
+    public ResponseJson insertSearch(String keyword) {
+        if (!StringUtils.isNotBlank(keyword)) {
+            return  ResponseJson.error("标签不能为空", null);
+        }
+        return shopLabelService.insertSearch(keyword);
+    }
+
+    /**
+     * 删除供应商关联标签
+     * @param labelIds id或id集合
+     * @return 返回
+     */
+    @GetMapping("/delShopLabelList")
+    public ResponseJson upShopLabelList(String labelIds) {
+
+        if (!StringUtils.isNoneBlank(labelIds)) {
+            return ResponseJson.error("Id不能为空",null);
+        }
+        return shopLabelService.upShopLabelList(labelIds);
+    }
+}

+ 49 - 0
src/main/java/com/caimei365/manager/dao/user/CmBehaviorRecordDao.java

@@ -0,0 +1,49 @@
+package com.caimei365.manager.dao.user;
+
+import com.caimei365.manager.entity.caimei.CmBehaviorRecord;
+import com.caimei365.manager.entity.caimei.RetuenEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/15
+ */
+@Mapper
+public interface CmBehaviorRecordDao {
+
+    /**
+     * 昨日数据
+     * @param cmBehaviorRecord 参数
+     * @return 返回
+     */
+    List<CmBehaviorRecord> findList(CmBehaviorRecord cmBehaviorRecord);
+
+    /**
+     * 今日数据
+     * @param cmBehaviorRecord 参数
+     * @return 返回
+     */
+    List<CmBehaviorRecord> findListToday(CmBehaviorRecord cmBehaviorRecord);
+
+    /**
+     * 访问来源
+     * @return 返回
+     */
+    List<CmBehaviorRecord> selRegion();
+    /**
+     * 查询单条详情
+     * @param cmBehaviorRecord 参数
+     * @return 返回
+     */
+    List<CmBehaviorRecord> recordList(CmBehaviorRecord cmBehaviorRecord);
+
+    /**
+     * 标签库
+     * @return 返回
+     */
+    List<RetuenEntity> searchList();
+}

+ 83 - 0
src/main/java/com/caimei365/manager/dao/user/CmShopLabelDao.java

@@ -0,0 +1,83 @@
+package com.caimei365.manager.dao.user;
+
+import com.caimei365.manager.entity.caimei.CmShop;
+import com.caimei365.manager.entity.caimei.CmShopLabel;
+import com.caimei365.manager.entity.caimei.CmShopRelevance;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/15
+ */
+@Mapper
+public interface CmShopLabelDao {
+
+    /**
+     * 关联标签供应商列表
+     * @param cmShopRelevance 搜索条件
+     * @return 返回
+     */
+    List<CmShopRelevance> shopRelevanceList(CmShopRelevance cmShopRelevance);
+
+    /**
+     * 供应商列表
+     * @param shopId  供应商id
+     * @param shopName 供应商名称
+     * @return 返回
+     */
+    List<CmShop> shopList(@Param("shopId") Integer shopId, @Param("name") String shopName);
+
+    /**
+     * 添加供应商
+     * @param cmShopRelevance 供应商信息
+     */
+    void insertShopRelevance(CmShopRelevance cmShopRelevance);
+    /**
+     * 删除关联标签供应商
+     * @param relevanceId 供应商id
+     */
+    void upShopRelevance(@Param("id") Integer relevanceId);
+
+    /**
+     * 删除标签
+     * @param relevanceId 供应商id
+     */
+    void upShopLabel(@Param("relevanceId") Integer relevanceId);
+
+    /**
+     * 供应商标签列表
+     * @param relevanceId 供应商id
+     * @param keyword 标签名
+     * @return 返回
+     */
+    List<CmShopLabel> shopLabelList(@Param("relevanceId") Integer relevanceId, @Param("keyword") String keyword);
+
+    /**
+     * 标签列表
+     * @param keyword 标签名
+     * @return 返回
+     */
+    List<CmShopLabel> labelList(@Param("keyword") String keyword);
+
+    /**
+     * 关联标签
+     * @param cmShopLabel 标签信息
+     */
+    void insertLabel(CmShopLabel cmShopLabel);
+
+    /**
+     * 添加标签到标签库
+     * @param keyword 标签
+     */
+    void insertSearch(String  keyword);
+    /**
+     * 删除关联标签
+     * @param ids 标签id或id集合
+     */
+    void upShopLabelList(List<Integer> ids);
+}

+ 197 - 0
src/main/java/com/caimei365/manager/entity/caimei/CmBehaviorRecord.java

@@ -0,0 +1,197 @@
+package com.caimei365.manager.entity.caimei;
+
+import lombok.Data;
+import lombok.Value;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/15
+ */
+@Data
+public class CmBehaviorRecord {
+    private Integer recordId;
+    /**
+     * 访问人IP地址
+     */
+    private String ip;
+    /**
+     * ip对应地区地址
+     */
+    private String region;
+    /**
+     * 访问来源
+     */
+    private String accessSource;
+    /**
+     * 访问客户端
+     */
+    private String accessClient;
+    /**
+     *  用户id、0为游客
+     */
+    private Integer userId;
+    /**
+     * 页面路径
+     */
+    private String pagePath;
+    /**
+     * 页面类型
+     */
+    private String pageType;
+    /**
+     * 页面标签
+     */
+    private String pageLabel;
+    /**
+     * 商品图片
+     */
+    private String productImage;
+    /**
+     * 商品ID
+     */
+    private Integer productId;
+    /**
+     * 商品名称
+     */
+    private String productName;
+    /**
+     * 访问时间
+     */
+    private String accessTime;
+    /**
+     * 访问时长
+     */
+    private String accessDuration;
+    /**
+     * 访问日期
+     */
+    private String accessDate;
+    private String consultName;
+    private String consultMobile;
+    /**
+     * 最后访问时间
+     */
+    private String lastAccessTime;
+    /**
+     * 是否是roos页面行为 1:用户行为、2:roos行为统计
+     */
+    private String behaviorType;
+    private Integer count;
+
+    /**
+     * 公司类型
+     */
+    private String companyType;
+    /**
+     * 公司名称
+     */
+    private String corporateName;
+    /**
+     *  联系人
+     */
+    private String contacts;
+    /**
+     * 手机号码
+     */
+    private String phoneNumber;
+
+    private Integer number;
+    /**
+     * 访问页面总数
+     */
+    private Integer numbers;
+    /**
+     * 公司类型
+     */
+    private String userIdentity;
+
+    /**
+     * 机构ID
+     */
+    private Integer clubId;
+    /**
+     * 机构公司名称
+     */
+    private String name;
+    /**
+     * 机构简称
+     */
+    private String cSname;
+    /**
+     * 机构联系人
+     */
+    private String linkMan;
+    /**
+     * 联系手机
+     */
+    private String contractMobile;
+    /**
+     * 用户名
+     */
+    private String userName;
+    /**
+     * 注册IP
+     */
+    private String registerIP;
+    /**
+     * 注册时间
+     */
+    private String registerTime;
+    /**
+     * 供应商公司名称
+     */
+    private String sname;
+    /**
+     * 供应商联系人
+     */
+    private String slinkMan;
+    /**
+     * 联系手机
+     */
+    private String scontractMobile;
+    /**
+     * 协销名称
+     */
+    private String spName;
+    /**
+     * 开始时间
+     */
+    private String startTime;
+    /**
+     * 结束时间
+     */
+    private String endTime;
+    /**
+     * 供应商ID
+     */
+    private Integer shopId;
+    /**
+     * 页面类型下拉
+     */
+    private String pageTypes;
+    /**
+     * 是否为今日数据 0今日数据 1往日数据
+     */
+    private Integer todayType;
+    /**
+     * 关联供应商
+     */
+    private String relevanceShop;
+    /**
+     * 标签
+     */
+    private String label;
+    /**
+     * 注册时间
+     */
+    private String addTime;
+    /**
+     * 页面查询条件
+     */
+    private List<String> labels;
+}

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

@@ -0,0 +1,52 @@
+package com.caimei365.manager.entity.caimei;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/15
+ */
+@Data
+public class CmShopLabel {
+
+    private Integer id;
+    /**
+     * 关联供应商关联Id
+     */
+    private Integer relevanceId;
+    /**
+     * 标签Id
+     */
+    private Integer keywordId;
+    /**
+     * 标签
+     */
+    private String keyword;
+    /**
+     * 搜索次数
+     */
+    private Integer frequency;
+    /**
+     * 最近搜索时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:SS")
+    private Date searchTime;
+    /**
+     * 选择标签时间
+     */
+    private String pickTime;
+    /**
+     * 是否删除
+     */
+    private String delFlag;
+    /**
+     * 添加时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date addTime;
+}

+ 40 - 0
src/main/java/com/caimei365/manager/entity/caimei/CmShopRelevance.java

@@ -0,0 +1,40 @@
+package com.caimei365.manager.entity.caimei;
+
+import lombok.Data;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/15
+ */
+@Data
+public class CmShopRelevance {
+
+    private Integer id;
+    /**
+     * 供应商Id
+     */
+    private Integer shopId;
+    /**
+     * 供应商名称
+     */
+    private String shopName;
+    /**
+     * 联系人
+     */
+    private String linkMan;
+    /**
+     * 手机号
+     */
+    private String contractMobile;
+    /**
+     * 添加时间
+     */
+    private String addTime;
+    /**
+     * 删除标记
+     */
+    private String delFlag;
+
+}

+ 21 - 0
src/main/java/com/caimei365/manager/entity/caimei/RetuenEntity.java

@@ -0,0 +1,21 @@
+package com.caimei365.manager.entity.caimei;
+
+import lombok.Data;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/16
+ */
+@Data
+public class RetuenEntity {
+    /**
+     * key
+     */
+    private String id;
+    /**
+     * value
+     */
+    private String value;
+}

+ 39 - 0
src/main/java/com/caimei365/manager/service/caimei/user/CmBehaviorRecordService.java

@@ -0,0 +1,39 @@
+package com.caimei365.manager.service.caimei.user;
+
+import com.caimei365.manager.entity.PaginationVo;
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.CmBehaviorRecord;
+
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/15
+ */
+public interface CmBehaviorRecordService {
+    /**
+     * 用户行为列表
+     * @param cmBehaviorRecord
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    ResponseJson<PaginationVo<CmBehaviorRecord>> list(CmBehaviorRecord cmBehaviorRecord,Integer pageNum, Integer pageSize);
+
+    /**
+     * 查看详情
+     * @param cmBehaviorRecord
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    ResponseJson<PaginationVo<CmBehaviorRecord>> recordList(CmBehaviorRecord cmBehaviorRecord,Integer pageNum, Integer pageSize);
+
+    /**
+     * 标签库数据
+     * @return 返回
+     */
+    ResponseJson searchList();
+}

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

@@ -0,0 +1,89 @@
+package com.caimei365.manager.service.caimei.user;
+
+import com.caimei365.manager.entity.PaginationVo;
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.CmShop;
+import com.caimei365.manager.entity.caimei.CmShopLabel;
+import com.caimei365.manager.entity.caimei.CmShopRelevance;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/15
+ */
+public interface CmShopLabelService {
+
+    /**
+     * 关联标签供应商列表
+     *  @param cmShopRelevance 搜索条件
+     *  @param pageNum 页码
+     *  @param pageSize 页面数据数
+     *  @return 返回
+     */
+    ResponseJson<PaginationVo<CmShopRelevance>> pageList(CmShopRelevance cmShopRelevance, Integer pageNum, Integer pageSize);
+
+    /**
+     * 供应商列表
+     * @param shopId 供应商id
+     * @param name 供应商名称
+     * @param pageNum 页码
+     * @param pageSize 页面数据数
+     * @return 返回
+     */
+    ResponseJson<PaginationVo<CmShop>> shopList(Integer shopId, String name, Integer pageNum, Integer pageSize);
+
+    /**
+     * 添加供应商
+     * @param shopId 供应商id
+     * @return 返回
+     */
+    ResponseJson insertShopRelevance(Integer shopId);
+
+    /**
+     * 删除关联标签的供应商
+     * @param relevanceId 供应商id
+     * @return 返回
+     */
+    ResponseJson delShopRelevanceById(Integer relevanceId);
+
+    /**
+     * 供应商关联标签列表
+     * @param relevanceId 供应商id
+     * @param keyword 标签名
+     * @param pageNum 页码
+     * @param pageSize 页面数据数
+     * @return 返回
+     */
+    ResponseJson<PaginationVo<CmShopLabel>> shopLabelList(Integer relevanceId, String keyword, Integer pageNum, Integer pageSize);
+
+    /**
+     * 标签列表
+     * @param keyword 标签名
+     * @param pageNum 页码
+     * @param pageSize 页面数据数
+     * @return 返回
+     */
+    ResponseJson<PaginationVo<CmShopLabel>> labelList(String keyword, Integer pageNum, Integer pageSize);
+
+    /**
+     * 关联标签
+     * @param relevanceId 供应商id
+     * @param keywordIds 标签id或id集合
+     * @return 返回
+     */
+    ResponseJson insertLabel(Integer relevanceId, String keywordIds);
+
+    /**
+     * 添加标签到标签库
+     * @param keyword 标签
+     * @return 返回
+     */
+    ResponseJson insertSearch(String keyword);
+    /**
+     * 删除供应商关联标签
+     * @param labelIds id或id集合
+     * @return 返回
+     */
+    ResponseJson upShopLabelList(String labelIds);
+}

+ 167 - 0
src/main/java/com/caimei365/manager/service/caimei/user/impl/CmBehaviorRecordServiceImpl.java

@@ -0,0 +1,167 @@
+package com.caimei365.manager.service.caimei.user.impl;
+
+import com.caimei.utils.AppUtils;
+import com.caimei.utils.StringUtils;
+import com.caimei365.manager.dao.user.CmBehaviorRecordDao;
+import com.caimei365.manager.entity.PaginationVo;
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.CmBehaviorRecord;
+import com.caimei365.manager.service.caimei.user.CmBehaviorRecordService;
+import com.github.pagehelper.PageHelper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/15
+ */
+@Slf4j
+@Service
+public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
+
+    @Resource
+    private CmBehaviorRecordDao cmBehaviorRecordDao;
+
+    /**
+     * 用户行为列表
+     * @param cmBehaviorRecord
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    @Override
+    public ResponseJson<PaginationVo<CmBehaviorRecord>> list(CmBehaviorRecord cmBehaviorRecord,Integer pageNum, Integer pageSize) {
+        List<CmBehaviorRecord> list = null;
+        List<String> labels = new ArrayList<>();
+        if (StringUtils.isNotBlank(cmBehaviorRecord.getLabel())) {
+            if (cmBehaviorRecord.getLabel().contains(",")) {
+                String[] split = cmBehaviorRecord.getLabel().split(",");
+                for (String str : split) {
+                    labels.add(str);
+                }
+            } else {
+                labels.add(cmBehaviorRecord.getLabel());
+            }
+        }
+        cmBehaviorRecord.setLabels(labels);
+        PageHelper.startPage(pageNum, pageSize);
+        if (cmBehaviorRecord.getTodayType() == 0) {
+            list = cmBehaviorRecordDao.findListToday(cmBehaviorRecord);
+        } else {
+            list = cmBehaviorRecordDao.findList(cmBehaviorRecord);
+        }
+        // 总时长
+        for (CmBehaviorRecord record : list) {
+            String time = calculationTime(record.getAccessDuration());
+            record.setAccessDuration(time);
+        }
+        PaginationVo<CmBehaviorRecord> pageData = new PaginationVo<>(list);
+        return ResponseJson.success(pageData);
+    }
+
+    /**
+     * 查看详情
+     * @param cmBehaviorRecord
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    @Override
+    public ResponseJson<PaginationVo<CmBehaviorRecord>> recordList(CmBehaviorRecord cmBehaviorRecord, Integer pageNum, Integer pageSize) {
+        // 详情
+        List<CmBehaviorRecord> recordList = cmBehaviorRecordDao.recordList(cmBehaviorRecord);
+        // 访问来源
+        List<CmBehaviorRecord> reginList = cmBehaviorRecordDao.selRegion();
+        // 计算访问时长,填入信息
+        recordList.forEach(r -> {
+            r.setProductImage(AppUtils.getImageURL("product", r.getProductImage(), 0, ""));
+            String time = calculationTime(r.getAccessDuration());
+            r.setAccessDuration(time);
+            String decode = null;
+            try {
+                decode = URLDecoder.decode(r.getPagePath(),"UTF-8");
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            r.setPagePath(decode);
+
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+            String s = null;
+            try {
+                s = simpleDateFormat.format(simpleDateFormat.parse(r.getAccessTime()));
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+            for (CmBehaviorRecord record : reginList) {
+                String format = null;
+                try {
+                    format = simpleDateFormat.format(simpleDateFormat.parse(record.getAccessTime()));
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+                if (r.getIp().equals(record.getIp()) && r.getPageType().equals(record.getPageType()) && format.equals(s)) {
+                    record.setAccessSource(record.getAccessSource());
+                }
+            }
+        });
+        PageHelper.startPage(pageNum, pageSize);
+        PaginationVo<CmBehaviorRecord> pageData = new PaginationVo<>(recordList);
+        return ResponseJson.success(pageData);
+    }
+
+    /**
+     * 标签库数据
+     *
+     * @return 返回
+     */
+    @Override
+    public ResponseJson searchList() {
+
+        return ResponseJson.success(cmBehaviorRecordDao.searchList());
+    }
+
+    /**
+     * 时间计算
+     * @param recordTime
+     * @return
+     */
+    public String calculationTime(String recordTime){
+        double doc = Double.parseDouble(recordTime);
+        int num = (int)doc;
+        //小时
+        int HH = 0;
+        // 分钟
+        int mm = 0;
+        //秒
+        int ss = 0;
+        int item = num / 1000;
+        if ((item / 60) >0) {
+            mm = item / 60;
+            ss = item % 60;
+        } else {
+            ss = item;
+        }
+        if ((mm / 60) >0) {
+            HH = mm / 60;
+            mm = mm % 60;
+        }
+        String  str= HH+":"+mm+":"+ss;
+        SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+        Date parse = null;
+        try {
+            parse = dateFormat.parse(str);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return dateFormat.format(parse);
+    }
+}

+ 192 - 0
src/main/java/com/caimei365/manager/service/caimei/user/impl/CmShopLabelServiceImpl.java

@@ -0,0 +1,192 @@
+package com.caimei365.manager.service.caimei.user.impl;
+
+import com.caimei.utils.StringUtils;
+import com.caimei365.manager.dao.user.CmShopLabelDao;
+import com.caimei365.manager.entity.PaginationVo;
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.CmShop;
+import com.caimei365.manager.entity.caimei.CmShopLabel;
+import com.caimei365.manager.entity.caimei.CmShopRelevance;
+import com.caimei365.manager.service.caimei.user.CmShopLabelService;
+import com.github.pagehelper.PageHelper;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/15
+ */
+@Service
+public class CmShopLabelServiceImpl implements CmShopLabelService {
+    @Resource private CmShopLabelDao cmShopLabelDao;
+
+    /**
+     * 关联标签供应商列表
+     *  @param cmShopRelevance 搜索条件
+     *  @param pageNum 页码
+     *  @param pageSize 页面数据数
+     *  @return 返回
+     */
+    @Override
+    public ResponseJson<PaginationVo<CmShopRelevance>> pageList(CmShopRelevance cmShopRelevance, Integer pageNum, Integer pageSize) {
+        List<CmShopRelevance> relevanceList = cmShopLabelDao.shopRelevanceList(cmShopRelevance);
+        PageHelper.startPage(pageNum,pageSize);
+        PaginationVo<CmShopRelevance> pageList = new PaginationVo<>(relevanceList);
+        return ResponseJson.success(pageList);
+    }
+
+    /**
+     * 供应商列表
+     *
+     * @param shopId 供应商id
+     * @param name 供应商名称
+     * @param pageNum 页码
+     * @param pageSize 页面数据数
+     * @return 返回
+     */
+    @Override
+    public ResponseJson<PaginationVo<CmShop>> shopList(Integer shopId, String name, Integer pageNum, Integer pageSize) {
+        List<CmShop> shopList = cmShopLabelDao.shopList(shopId, name);
+        PageHelper.startPage(pageNum, pageSize);
+        PaginationVo<CmShop> pageList = new PaginationVo<>(shopList);
+        return ResponseJson.success(pageList);
+    }
+
+    /**
+     * 添加供应商
+     *
+     * @param shopId 供应商id
+     * @return 返回
+     */
+    @Override
+    public ResponseJson insertShopRelevance(Integer shopId) {
+        CmShopRelevance cmShopRelevance = new CmShopRelevance();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        // 初始化数据
+        cmShopRelevance.setAddTime(dateFormat.format(new Date()));
+        cmShopRelevance.setShopId(shopId);
+        // 保存供应商信息
+        cmShopLabelDao.insertShopRelevance(cmShopRelevance);
+        return ResponseJson.success("添加供应商成功");
+    }
+
+    /**
+     * 删除关联标签的供应商
+     *
+     * @param relevanceId 供应商id
+     * @return 返回
+     */
+    @Override
+    public ResponseJson delShopRelevanceById(Integer relevanceId) {
+        // 删除供应商
+        cmShopLabelDao.upShopRelevance(relevanceId);
+        // 删除标签
+        cmShopLabelDao.upShopLabel(relevanceId);
+        return ResponseJson.success("删除供应商完成");
+    }
+
+    /**
+     * 供应商关联标签列表
+     *
+     * @param relevanceId 供应商id
+     * @param keyword 标签名
+     * @param pageNum 页码
+     * @param pageSize 页面数据数
+     * @return 返回
+     */
+    @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);
+        PaginationVo<CmShopLabel> pageList = new PaginationVo<>(labelList);
+        return ResponseJson.success(pageList);
+    }
+
+    /**
+     * 标签列表
+     *
+     * @param keyword 标签名
+     * @param pageNum 页码
+     * @param pageSize 页面数据数
+     * @return 返回
+     */
+    @Override
+    public ResponseJson<PaginationVo<CmShopLabel>> labelList(String keyword, Integer pageNum, Integer pageSize) {
+        List<CmShopLabel> labelList = cmShopLabelDao.labelList(keyword);
+        PageHelper.startPage(pageNum,pageSize);
+        PaginationVo<CmShopLabel> pageList = new PaginationVo<>(labelList);
+        return ResponseJson.success(pageList);
+    }
+
+    /**
+     * 关联标签
+     *
+     * @param relevanceId 供应商id
+     * @param keywordIds 标签id或id集合
+     * @return 返回
+     */
+    @Override
+    public ResponseJson insertLabel(Integer relevanceId, String keywordIds) {
+        List<Integer> list = new ArrayList<>();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        // 多个时进行拆分
+        if (keywordIds.contains(",")) {
+            String[] split = keywordIds.split(",");
+            for (String str : split) {
+                list.add(Integer.parseInt(str));
+            }
+        } else {
+            list.add(Integer.parseInt(keywordIds));
+        }
+        // 关联标签
+        String format = dateFormat.format(new Date());
+        for (Integer i : list) {
+            CmShopLabel cmShopLabel = new CmShopLabel();
+            cmShopLabel.setRelevanceId(relevanceId);
+            cmShopLabel.setKeywordId(i);
+            cmShopLabel.setPickTime(format);
+            cmShopLabelDao.insertLabel(cmShopLabel);
+        }
+        return ResponseJson.success("关联成功", null);
+    }
+
+    /**
+     * 添加标签到标签库
+     *
+     * @param keyword 标签
+     * @return
+     */
+    @Override
+    public ResponseJson insertSearch(String keyword) {
+        cmShopLabelDao.insertSearch(keyword);
+        return ResponseJson.success("添加成功", null);
+    }
+
+    /**
+     * 删除供应商关联标签
+     *
+     * @param labelIds id或id集合
+     * @return 返回
+     */
+    @Override
+    public ResponseJson upShopLabelList(String labelIds) {
+        List<Integer> list = new ArrayList<>();
+        if (labelIds.contains(",")) {
+            String[] split = labelIds.split(",");
+            for (String str : split) {
+                list.add(Integer.parseInt(str));
+            }
+        } else {
+            list.add(Integer.parseInt(labelIds));
+        }
+        cmShopLabelDao.upShopLabelList(list);
+        return ResponseJson.success("删除完成");
+    }
+}

+ 5 - 5
src/main/resources/config/dev/application-dev.yml

@@ -2,12 +2,12 @@ spring:
   #数据源连接--start
   datasource:
     #本地连接数据库
-    url: jdbc:mysql://192.168.2.100:3306/caimei?characterEncoding=UTF8&serverTimezone=Asia/Shanghai
-    username: developer
-    password: 05bZ/OxTB:X+yd%1
-#    url: jdbc:mysql://120.79.25.27:3306/caimei?characterEncoding=UTF8&serverTimezone=Asia/Shanghai
+#    url: jdbc:mysql://192.168.2.100:3306/caimei?characterEncoding=UTF8&serverTimezone=Asia/Shanghai
 #    username: developer
-#    password: J5p3tgOVazNl4ydf
+#    password: 05bZ/OxTB:X+yd%1
+    url: jdbc:mysql://120.79.25.27:3306/caimei?characterEncoding=UTF8&serverTimezone=Asia/Shanghai
+    username: developer
+    password: J5p3tgOVazNl4ydf
     type: com.zaxxer.hikari.HikariDataSource
     hikari:
       minimum-idle: 5

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

@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei365.manager.dao.user.CmBehaviorRecordDao">
+    <sql id="behaviorRecord">
+        b.recordID,
+        b.IP as ip,
+        b.userID as userId,
+        b.pagePath,
+        b.pageType,
+        b.pageLabel,
+        b.productID as productId,
+        b.accessTime,
+        b.accessDate
+    </sql>
+    <select id="findList" resultType="com.caimei365.manager.entity.caimei.CmBehaviorRecord">
+        SELECT
+        IP as ip,
+        userID as userId,
+        clubID as clubId,
+        lastAccessTime,
+        companyType,
+        corporateName,
+        contacts,
+        phoneNumber,
+        spName,
+        number as numbers,
+        consultName,
+        consultMobile,
+        productID,
+        accessTime,
+        accessDuration,
+        accessDate,
+        accessClient,
+        region,
+        addTime
+        FROM cm_behavior_record_index
+        <where>
+            delFlag = 0
+            <if test="ip != null and ip != ''">
+                AND IP = #{ip}
+            </if>
+            <if test="corporateName != null and corporateName != ''">
+                AND corporateName like concat('%',#{corporateName},'%')
+            </if>
+            <if test="companyType != null and companyType != ''">
+                AND companyType = #{companyType}
+            </if>
+            <if test="accessClient != null and accessClient != ''">
+                AND accessClient =#{accessClient}
+            </if>
+            <if test="contacts != null and contacts != ''">
+                AND contacts = #{contacts}
+            </if>
+            <if test="phoneNumber != null and phoneNumber != ''">
+                AND phoneNumber = #{phoneNumber}
+            </if>
+            <if test="spName != null and spName != ''">
+                AND spName = #{spName}
+            </if>
+            <if test="relevanceShop != null and relevanceShop != ''">
+                AND relevanceShop like concat('%',#{relevanceShop},'%')
+            </if>
+            <if test="labels != null and labels.size > 0">
+                AND
+                <foreach collection="labels" open="(" close=")" separator="or" item="label">
+                    label like concat('%',#{label},'%')
+                </foreach>
+            </if>
+            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
+                AND accessDate between #{startTime} and #{endTime}
+            </if>
+        </where>
+        ORDER BY accessTime DESC
+    </select>
+    <select id="findListToday" resultType="com.caimei365.manager.entity.caimei.CmBehaviorRecord">
+        SELECT
+        IP as ip,
+        userID as userId,
+        clubID as clubId,
+        lastAccessTime,
+        companyType,
+        corporateName,
+        contacts,
+        phoneNumber,
+        spName,
+        number as numbers,
+        consultName,
+        consultMobile,
+        accessTime,
+        accessDuration,
+        accessDate,
+        accessClient,
+        region,
+        relevanceShop,
+        label,
+        addTime
+        FROM cm_behavior_record_today
+        <where>
+            <if test="ip != null and ip != ''">
+                AND IP = #{ip}
+            </if>
+            <if test="corporateName != null and corporateName != ''">
+                AND corporateName like concat('%',#{corporateName},'%')
+            </if>
+            <if test="companyType != null and companyType != ''">
+                AND companyType = #{companyType}
+            </if>
+            <if test="accessClient != null and accessClient != ''">
+                AND accessClient =#{accessClient}
+            </if>
+            <if test="contacts != null and contacts != ''">
+                AND contacts = #{contacts}
+            </if>
+            <if test="phoneNumber != null and phoneNumber != ''">
+                AND phoneNumber = #{phoneNumber}
+            </if>
+            <if test="spName != null and spName != ''">
+                AND spName = #{spName}
+            </if>
+            <if test="relevanceShop != null and relevanceShop != ''">
+                AND relevanceShop like concat('%',#{relevanceShop},'%')
+            </if>
+            <if test="labels != null and labels.size > 0">
+                AND
+                <foreach collection="labels" open="(" close=")" separator="or" item="label">
+                    label like concat('%',#{label},'%')
+                </foreach>
+            </if>
+            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
+                AND accessDate between #{startTime} and #{endTime}
+            </if>
+        </where>
+        ORDER BY accessTime DESC
+    </select>
+    <select id="selRegion" resultType="com.caimei365.manager.entity.caimei.CmBehaviorRecord">
+        SELECT * FROM cm_behavior_record_ref
+    </select>
+    <select id="recordList" resultType="com.caimei365.manager.entity.caimei.CmBehaviorRecord">
+        SELECT
+        <include refid="behaviorRecord"/>
+        ,b.accessDuration,
+        b.accessSource,
+        b.accessClient,
+        u.userIdentity,
+        c.name,
+        c.clubId,
+        c.linkMan,
+        c.contractMobile,
+        s.name AS sname,
+        s.linkMan AS slinkMan,
+        s.contractMobile AS sncontractMobile,
+        p.name AS productName,
+        p.mainImage AS productImage,
+        pt.pagetype AS pageTypes
+        FROM cm_behavior_record b
+        LEFT JOIN USER u ON b.userID = u.userID
+        LEFT JOIN club c ON b.userID = c.userID
+        LEFT JOIN shop s ON b.userID = s.userID
+        LEFT JOIN product p ON b.productID = p.productID
+        LEFT JOIN cm_page_type pt ON b.pageType = pt.id
+        <where>
+            b.accessDate = #{accessDate}  AND b.IP != '106.55.202.118' AND b.delFlag = 0
+            <if test="userId != null">
+                AND b.userID = #{userId} AND b.IP = #{ip}
+            </if>
+        </where>
+        ORDER BY accessTime DESC
+    </select>
+    <select id="searchList" resultType="com.caimei365.manager.entity.caimei.RetuenEntity">
+        select id , keyword as value from cm_user_search_frequency where trueStatus = 1
+    </select>
+</mapper>

+ 93 - 0
src/main/resources/mapper/CmShopLabelDao.xml

@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei365.manager.dao.user.CmShopLabelDao">
+    <select id="shopRelevanceList" resultType="com.caimei365.manager.entity.caimei.CmShopRelevance">
+        SELECT csr.*,s.name as shopName,s.linkMan,s.contractMobile
+        FROM cm_shop_relevance csr
+        LEFT JOIN shop s ON csr.shopID = s.shopID
+        <where>
+            csr.delFlag = 0
+            <if test="shopName != null and shopName != ''">
+                and s.name = #{shopName}
+            </if>
+            <if test="linkMan != null and linkMan != ''">
+                and s.linkMan = #{linkMan}
+            </if>
+            <if test="contractMobile != null and contractMobile != ''">
+                and s.contractMobile = #{contractMobile}
+            </if>
+        </where>
+        order by csr.addTime desc
+    </select>
+    <select id="shopList" resultType="com.caimei365.manager.entity.caimei.CmShop">
+        SELECT shopID, name, linkMan, contractMobile FROM shop
+        <where>
+            shopID NOT IN ( SELECT shopID FROM cm_shop_relevance where delFlag = 0)
+            <if test="shopId != null and shopId != ''">
+                and shopID = #{shopId}
+            </if>
+            <if test="name != null and name != ''">
+                and name like concat('%',#{name},'%')
+            </if>
+        </where>
+        order by shopID
+    </select>
+    <insert id="insertShopRelevance">
+        INSERT INTO cm_shop_relevance(shopID, ADDTIME, delFlag)
+        VALUES (#{shopId}, #{addTime}, '0')
+    </insert>
+    <update id="upShopRelevance">
+        update cm_shop_relevance
+        set delFlag = 1
+        where id = #{id}
+    </update>
+    <update id="upShopLabel">
+        update cm_shop_label
+        set delFlag = 1
+        where relevanceId = #{relevanceId}
+    </update>
+    <select id="shopLabelList" resultType="com.caimei365.manager.entity.caimei.CmShopLabel">
+        SELECT csl.*, cusf.keyword, cusf.frequency, cusf.searchTime
+        FROM cm_shop_label csl
+        LEFT JOIN cm_user_search_frequency cusf ON csl.keywordId = cusf.id
+        <where>
+            relevanceId = #{relevanceId} and csl.delFlag = 0
+            <if test="keyword != null and keyword != ''">
+                and cusf.keyword like concat('%',#{keyword},'%')
+            </if>
+        </where>
+        order by csl.pickTime desc,cusf.frequency desc
+    </select>
+    <select id="labelList" resultType="com.caimei365.manager.entity.caimei.CmShopLabel">
+        select
+            id,
+            keyword,
+            frequency,
+            searchTime,
+            addTime
+        from cm_user_search_frequency
+        <where>
+            delStatus = 1 and id NOT IN ( SELECT keywordId FROM cm_shop_label where delFlag = 0)
+            <if test="keyword != null and keyword != ''">
+                and keyword like concat('%',#{keyword},'%')
+            </if>
+        </where>
+        order by searchTime desc
+    </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>
+    <update id="upShopLabelList">
+        update cm_shop_label
+        set delFlag = 1
+        where id in
+        <foreach collection="ids" open="(" separator="," close=")" item="id">
+            #{id}
+        </foreach>
+    </update>
+</mapper>