Selaa lähdekoodia

Merge remote-tracking branch 'origin/developer' into developerB

huangzhiguo 1 vuosi sitten
vanhempi
commit
605f317af2
32 muutettua tiedostoa jossa 1495 lisäystä ja 91 poistoa
  1. 68 0
      src/main/java/com/caimei365/manager/config/GlobalControllerAdvice.java
  2. 241 1
      src/main/java/com/caimei365/manager/config/utils/DateUtil.java
  3. 39 0
      src/main/java/com/caimei365/manager/controller/caimei/HomeApi.java
  4. 90 12
      src/main/java/com/caimei365/manager/controller/caimei/keyword/KeyWordApi.java
  5. 23 0
      src/main/java/com/caimei365/manager/controller/caimei/user/CmBehaviorRecordApi.java
  6. 4 1
      src/main/java/com/caimei365/manager/controller/caimei/user/CustomerApi.java
  7. 47 0
      src/main/java/com/caimei365/manager/dao/HomeDao.java
  8. 59 3
      src/main/java/com/caimei365/manager/dao/KeyWordDao.java
  9. 1 1
      src/main/java/com/caimei365/manager/dao/WeChatDao.java
  10. 14 0
      src/main/java/com/caimei365/manager/dao/user/CmBehaviorRecordDao.java
  11. 5 0
      src/main/java/com/caimei365/manager/entity/caimei/CmBehaviorRecord.java
  12. 56 0
      src/main/java/com/caimei365/manager/entity/caimei/CmKeywordInfo.java
  13. 36 0
      src/main/java/com/caimei365/manager/entity/caimei/CmKeywordSubtag.java
  14. 21 0
      src/main/java/com/caimei365/manager/entity/caimei/CmPageType.java
  15. 11 0
      src/main/java/com/caimei365/manager/entity/caimei/KeyWord.java
  16. 12 0
      src/main/java/com/caimei365/manager/entity/caimei/cmUser/CmShopAdvertisingImage.java
  17. 14 0
      src/main/java/com/caimei365/manager/service/caimei/HomeService.java
  18. 29 4
      src/main/java/com/caimei365/manager/service/caimei/KeyWordService.java
  19. 171 2
      src/main/java/com/caimei365/manager/service/caimei/impl/HomeServiceImpl.java
  20. 111 11
      src/main/java/com/caimei365/manager/service/caimei/impl/KeyWordServiceImpl.java
  21. 62 0
      src/main/java/com/caimei365/manager/service/caimei/listener/LabelListener.java
  22. 14 0
      src/main/java/com/caimei365/manager/service/caimei/user/CmBehaviorRecordService.java
  23. 24 0
      src/main/java/com/caimei365/manager/service/caimei/user/impl/CmBehaviorRecordServiceImpl.java
  24. 1 1
      src/main/java/com/caimei365/manager/service/wechat/impl/WechatMenuServiceImpl.java
  25. 6 3
      src/main/resources/config/beta/application-beta.yml
  26. 4 0
      src/main/resources/config/dev/application-dev.yml
  27. 4 0
      src/main/resources/config/prod/application-prod.yml
  28. 41 4
      src/main/resources/mapper/CmBehaciorRecordDao.xml
  29. 142 3
      src/main/resources/mapper/HomeDao.xml
  30. 143 44
      src/main/resources/mapper/KeyWordDao.xml
  31. 1 1
      src/main/resources/mapper/WeChatDao.xml
  32. 1 0
      src/main/resources/mapper/user/CustomerServiceDao.xml

+ 68 - 0
src/main/java/com/caimei365/manager/config/GlobalControllerAdvice.java

@@ -0,0 +1,68 @@
+package com.caimei365.manager.config;
+
+import cn.hutool.core.date.DateUtil;
+import com.caimei365.manager.entity.ResponseJson;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.web.bind.WebDataBinder;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.InitBinder;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import java.beans.PropertyEditorSupport;
+import java.time.LocalDateTime;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Set;
+
+import static cn.hutool.core.date.DatePattern.NORM_DATETIME_PATTERN;
+import static cn.hutool.core.date.DatePattern.NORM_DATE_PATTERN;
+@Slf4j
+@ControllerAdvice
+public class GlobalControllerAdvice {
+
+    @ResponseBody
+    @ExceptionHandler(value = ConstraintViolationException.class)
+    public ResponseJson ConstraintViolationExceptionHandler(ConstraintViolationException ex) {
+        Set<ConstraintViolation<?>> constraintViolations = ex.getConstraintViolations();
+        Iterator<ConstraintViolation<?>> iterator = constraintViolations.iterator();
+        String msg ="入参错误!";
+        if (iterator.hasNext()) {
+            ConstraintViolation<?> cvl = iterator.next();
+            msg=cvl.getPropertyPath().toString().split("\\.")[1] + " " + cvl.getMessageTemplate();
+        }
+        return ResponseJson.error(msg);
+    }
+
+    @ResponseBody
+    @ExceptionHandler(value = Exception.class)
+    public ResponseJson Exception(HttpServletRequest request, Exception e){
+        log.error("出错了:[\u001B[31m {} \u001B[0m]",e.toString());
+        e.printStackTrace();
+        return ResponseJson.error("操作失败!");
+    }
+
+    @InitBinder
+    public void initBinder(WebDataBinder binder) {
+        binder.registerCustomEditor(LocalDateTime.class, new PropertyEditorSupport() {
+            @Override
+            public void setAsText(String text) {
+                if (StringUtils.isNotBlank(text)) {
+                    setValue(DateUtil.parseLocalDateTime(text));
+                }
+            }
+        });
+        binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
+            @Override
+            public void setAsText(String text) {
+                if (StringUtils.isNotBlank(text)) {
+                    setValue(DateUtil.parse(text, NORM_DATETIME_PATTERN, NORM_DATE_PATTERN));
+                }
+            }
+        });
+    }
+}

+ 241 - 1
src/main/java/com/caimei365/manager/config/utils/DateUtil.java

@@ -1,11 +1,17 @@
 package com.caimei365.manager.config.utils;
 
+import org.apache.commons.lang3.time.DateFormatUtils;
+
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
 
-public class DateUtil {
+public class DateUtil extends org.apache.commons.lang3.time.DateUtils {
+    private static String[] parsePatterns = {
+            "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
+            "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
+            "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
     private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
     private static Calendar calendar = Calendar.getInstance();
 
@@ -52,6 +58,240 @@ public class DateUtil {
         return format;
     }
 
+
+    /**
+     * 得到当前日期字符串 格式(yyyy-MM-dd)
+     */
+    public static String getDate() {
+        return getDate("yyyy-MM-dd");
+    }
+
+    /**
+     * 得到当前日期字符串 格式(yyyy-MM-dd) pattern可以为:"yyyy-MM-dd" "HH:mm:ss" "E"
+     */
+    public static String getDate(String pattern) {
+        return DateFormatUtils.format(new Date(), pattern);
+    }
+
+    /**
+     * 得到当前日期字符串 格式(yyyy-MM-dd) pattern可以为:"yyyy-MM-dd" "HH:mm:ss" "E"
+     */
+    public static String setDate(Date date, String pattern) {
+        if (date == null) {
+            return "";
+        }
+        return DateFormatUtils.format(date, pattern);
+    }
+    /**
+     * 得到当前日期字符串 格式(yyyy-MM-dd) pattern可以为:"yyyy-MM-dd" "HH:mm:ss" "E"
+     */
+    public static Date setFormatDate(String dateString, String pattern) {
+        Date date = null;
+        try {
+            date = new SimpleDateFormat(pattern).parse(dateString);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return date;
+    }
+
+    /**
+     * 得到日期字符串 默认格式(yyyy-MM-dd) pattern可以为:"yyyy-MM-dd" "HH:mm:ss" "E"
+     */
+    public static String formatDate(Date date, Object... pattern) {
+        String formatDate = null;
+        if (pattern != null && pattern.length > 0) {
+            formatDate = DateFormatUtils.format(date, pattern[0].toString());
+        } else {
+            formatDate = DateFormatUtils.format(date, "yyyy-MM-dd");
+        }
+        return formatDate;
+    }
+
+
+    /**
+     * 得到日期时间字符串,转换格式(yyyy-MM-dd HH:mm:ss)
+     */
+    public static String formatDateTime(Date date) {
+        return formatDate(date, "yyyy-MM-dd HH:mm:ss");
+    }
+
+
+    /**
+     * 得到当前时间字符串 格式(HH:mm:ss)
+     */
+    public static String getTime() {
+        return formatDate(new Date(), "HH:mm:ss");
+    }
+
+    /**
+     * 得到当前日期和时间字符串 格式(yyyy-MM-dd HH:mm:ss)
+     */
+    public static String getDateTime() {
+        return formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
+    }
+
+    /**
+     * 得到当前年份字符串 格式(yyyy)
+     */
+    public static String getYear() {
+        return formatDate(new Date(), "yyyy");
+    }
+
+    /**
+     * 得到当前月份字符串 格式(MM)
+     */
+    public static String getMonth() {
+        return formatDate(new Date(), "MM");
+    }
+
+    /**
+     * 得到当天字符串 格式(dd)
+     */
+    public static String getDay() {
+        return formatDate(new Date(), "dd");
+    }
+
+    /**
+     * 得到当前星期字符串 格式(E)星期几
+     */
+    public static String getWeek() {
+        return formatDate(new Date(), "E");
+    }
+
+    /**
+     * 日期型字符串转化为日期 格式
+     * { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm",
+     * "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm",
+     * "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm" }
+     */
+    public static Date parseDate(Object str) {
+        if (str == null) {
+            return null;
+        }
+        try {
+            return parseDate(str.toString(), parsePatterns);
+        } catch (ParseException e) {
+            return null;
+        }
+    }
+
+    /**
+     * 获取过去的天数
+     *
+     * @param date
+     * @return
+     */
+    public static long pastDays(Date date) {
+        long t = new Date().getTime() - date.getTime();
+        return t / (24 * 60 * 60 * 1000);
+    }
+
+    /**
+     * 获取过去的小时
+     *
+     * @param date
+     * @return
+     */
+    public static long pastHour(Date date) {
+        long t = new Date().getTime() - date.getTime();
+        return t / (60 * 60 * 1000);
+    }
+
+    /**
+     * 获取过去的分钟
+     *
+     * @param date
+     * @return
+     */
+    public static long pastMinutes(Date date) {
+        long t = new Date().getTime() - date.getTime();
+        return t / (60 * 1000);
+    }
+
+    /**
+     * 转换为时间(天,时:分:秒.毫秒)
+     *
+     * @param timeMillis
+     * @return
+     */
+    public static String formatDateTime(long timeMillis) {
+        long day = timeMillis / (24 * 60 * 60 * 1000);
+        long hour = (timeMillis / (60 * 60 * 1000) - day * 24);
+        long min = ((timeMillis / (60 * 1000)) - day * 24 * 60 - hour * 60);
+        long s = (timeMillis / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
+        long sss = (timeMillis - day * 24 * 60 * 60 * 1000 - hour * 60 * 60 * 1000 - min * 60 * 1000 - s * 1000);
+        return (day > 0 ? day + "," : "") + hour + ":" + min + ":" + s + "." + sss;
+    }
+
+    /**
+     * 获取两个日期之间的天数
+     *
+     * @param before
+     * @param after
+     * @return
+     */
+    public static double getDistanceOfTwoDate(Date before, Date after) {
+        long beforeTime = before.getTime();
+        long afterTime = after.getTime();
+        return (afterTime - beforeTime) / (1000 * 60 * 60 * 24);
+    }
+
+    /**
+     * @param nowTime   当前时间
+     * @param startTime 开始时间
+     * @param endTime   结束时间
+     * @return
+     * @author sunran   判断当前时间在时间区间内
+     */
+    public static boolean isEffectiveDate(Date nowTime, Date startTime, Date endTime) {
+        if (nowTime.getTime() == startTime.getTime()
+                || nowTime.getTime() == endTime.getTime()) {
+            return true;
+        }
+
+        Calendar date = Calendar.getInstance();
+        date.setTime(nowTime);
+
+        Calendar begin = Calendar.getInstance();
+        begin.setTime(startTime);
+
+        Calendar end = Calendar.getInstance();
+        end.setTime(endTime);
+
+        if (date.after(begin) && date.before(end)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+    /**
+     * 获取当天00:00:00的时间戳
+     *
+     * @return 时间戳
+     */
+    public static Date getStartTime(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        return calendar.getTime();
+    }
+
+    /**
+     * 获取当天23:59:59的时间戳
+     *
+     * @return 时间戳
+     */
+    public static Date getEndTime(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        return calendar.getTime();
+    }
 //    public static void main(String[] args) throws ParseException {
 //        String month = "2020-02";
 //        System.out.println(getMinDateMonth(month));

+ 39 - 0
src/main/java/com/caimei365/manager/controller/caimei/HomeApi.java

@@ -1,12 +1,17 @@
 package com.caimei365.manager.controller.caimei;
 
+import cn.hutool.core.date.DateTime;
+import com.caimei365.manager.config.utils.DateUtil;
 import com.caimei365.manager.entity.ResponseJson;
 import com.caimei365.manager.service.caimei.HomeService;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import javax.validation.constraints.NotNull;
+import java.util.Date;
 import java.util.Map;
 
 /**
@@ -15,6 +20,7 @@ import java.util.Map;
  * @author : Charles
  * @date : 2022/3/23
  */
+@Validated
 @RestController
 @RequestMapping("/home")
 public class HomeApi {
@@ -28,4 +34,37 @@ public class HomeApi {
     public ResponseJson<Map<String, Object>> getDashboardData() {
         return homeService.getDashboardData();
     }
+
+    /**
+     * 机构统计
+     */
+    @GetMapping("/getClubCount")
+    public ResponseJson<Map<String, Object>> getClubCount(Date startCreateTime, Date endCreateTime) {
+        if (null != endCreateTime) {
+            endCreateTime = DateUtil.getEndTime(endCreateTime);
+        }
+        return homeService.getClubCount(startCreateTime, endCreateTime);
+    }
+
+    /**
+     * 机构趋势
+     */
+    @GetMapping("/getClubTrend")
+    public ResponseJson<Map<String, Object>> getClubTrend(Date startCreateTime, Date endCreateTime) {
+        if (null != endCreateTime) {
+            endCreateTime = DateUtil.getEndTime(endCreateTime);
+        }
+        return homeService.getClubTrend(startCreateTime, endCreateTime);
+    }
+
+    /**
+     * 访问统计
+     */
+    @GetMapping("/getAccessRecordCount")
+    public ResponseJson<Map<String, Object>> getAccessRecordCount(Date startCreateTime, Date endCreateTime) {
+        if (null != endCreateTime) {
+            endCreateTime = DateUtil.getEndTime(endCreateTime);
+        }
+        return homeService.getAccessRecordCount(startCreateTime, endCreateTime);
+    }
 }

+ 90 - 12
src/main/java/com/caimei365/manager/controller/caimei/keyword/KeyWordApi.java

@@ -1,13 +1,16 @@
 package com.caimei365.manager.controller.caimei.keyword;
 
 import com.alibaba.excel.EasyExcel;
+import com.caimei365.manager.dao.KeyWordDao;
 import com.caimei365.manager.entity.PaginationVo;
 import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.CmKeywordInfo;
 import com.caimei365.manager.entity.caimei.CmPriorKeyword;
 import com.caimei365.manager.entity.caimei.KeyWord;
 import com.caimei365.manager.entity.caimei.cmUser.ServiceProviderModel;
 import com.caimei365.manager.service.caimei.KeyWordService;
 import com.caimei365.manager.service.caimei.listener.KeywordListener;
+import com.caimei365.manager.service.caimei.listener.LabelListener;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -16,6 +19,7 @@ import javax.annotation.Resource;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -32,6 +36,9 @@ public class KeyWordApi {
     @Resource
     private KeywordListener keywordListener;
 
+    @Resource
+    private LabelListener labelListener;
+
     /**
      * 关键词列表
      * keyword 关键词
@@ -142,32 +149,103 @@ public class KeyWordApi {
     public ResponseJson<List<ServiceProviderModel>> getServiceList() { return keyWordService.getServiceList(); }
 
     /**
-     * 静态标签列表
+     * 动态/静态标签列表
+     * dynamicStatus 动态静态标记 0:动态标签;1:静态标签
+     * parentLabel 父标签标记  父标签 0 否 1 是
      * keyword 关键词
      * beginTime  自定义时间查询起始时间
      * endTime    自定义时间查询终止时间
-     * labelStatus  标签库状态 0未添加 1已添加 传1即是标签列表
      * fromSearch 标签库数据来源(1:手动添加;2:用户关键词统计;3:导入 4:协销填写)
+     * serviceProviderId 协销id
      */
     @GetMapping("/statekeyword/list")
-    public ResponseJson<PaginationVo<KeyWord>> getStateKeyWordList(String keyword, String beginTime, String endTime,
-                                                                   Integer fromSearch,  Integer serviceProviderId,
-                                                              @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                                              @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
-        return keyWordService.getStateKeyWordList(keyword, fromSearch, beginTime, endTime, serviceProviderId, pageNum, pageSize);
+    public ResponseJson<PaginationVo<CmKeywordInfo>> getStateKeyWordList(Integer dynamicStatus, Integer parentLabel,
+                                                                         String keyword, String beginTime, String endTime,
+                                                                         Integer fromSearch, Integer serviceProviderId,
+                                                                         @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                         @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+        if (null == dynamicStatus) {
+            return ResponseJson.error(-1, "类型不能为空", null);
+        }
+        return keyWordService.getStateKeyWordList(dynamicStatus, parentLabel, keyword, fromSearch, beginTime, endTime, serviceProviderId, pageNum, pageSize);
     }
 
     /**
-     * 保存静态标签
+     * 动态标签编辑回显
+     * @param id
+     * @return
+     */
+    @GetMapping("/editKeyword")
+    public ResponseJson<CmKeywordInfo> editKeyword(Integer id) {
+        if (null == id) {
+            return  ResponseJson.error(-1, "id不能为空", null);
+        }
+        return keyWordService.editKeyword(id);
+    }
+
+    /**
+     * 获取子标签
      * @param keyword
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    @GetMapping("/getSubtagKeyword")
+    public ResponseJson<PaginationVo<CmKeywordInfo>> getSubtagKeyword(String keyword,
+                                                                      @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                      @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+
+        return keyWordService.getSubtagKeyword(keyword, pageNum, pageSize);
+    }
+
+    /**
+     * 保存 动态/静态标签
+     * @param cmKeywordInfo
      * @return
      */
-    @GetMapping("/saveLabelByState")
-    public ResponseJson saveLabelByState(String keyword) {
-        if (StringUtils.isBlank(keyword)) {
+    @PostMapping("/saveLabelByState")
+    public ResponseJson saveLabelByState(@RequestBody CmKeywordInfo cmKeywordInfo) {
+        if (null == cmKeywordInfo) {
+            return ResponseJson.error(-1, "参数错误", null);
+        }
+        if (StringUtils.isBlank(cmKeywordInfo.getKeyword())) {
             return ResponseJson.error(-1, "标签不能为空", null);
         }
-        return keyWordService.insertLabelByState(keyword);
+        if (null == cmKeywordInfo.getDynamicStatus()) {
+            return ResponseJson.error(-1, "标签归属类型不能为空", null);
+        }
+        return keyWordService.insertKeywordInfo(cmKeywordInfo);
+    }
+
+    /**
+     * 删除动态/静态标签
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping("/delete/TrendsLabel")
+    public ResponseJson delTrendsLabel(String id) {
+        if (StringUtils.isBlank(id)) {
+            return ResponseJson.error(-1, "id不能为空", null);
+        }
+        return keyWordService.deleteTrendsLabel(id);
+    }
+
+    /**
+     * 导入动态标签
+     *
+     * @param keywordFile
+     * @return
+     */
+    @PostMapping("/import/keywordLabel")
+    public ResponseJson doKeywordImport(MultipartFile keywordFile) {
+        try {
+            InputStream inputStream = keywordFile.getInputStream();
+            EasyExcel.read(inputStream, CmKeywordInfo.class, labelListener).sheet().doRead();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return ResponseJson.success();
     }
 
     /**

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

@@ -7,6 +7,7 @@ import com.alibaba.excel.write.metadata.WriteSheet;
 import com.caimei365.manager.entity.PaginationVo;
 import com.caimei365.manager.entity.ResponseJson;
 import com.caimei365.manager.entity.caimei.CmBehaviorRecord;
+import com.caimei365.manager.entity.caimei.CmPageType;
 import com.caimei365.manager.service.caimei.user.CmBehaviorRecordService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -29,6 +30,28 @@ public class CmBehaviorRecordApi {
 
     @Autowired private CmBehaviorRecordService recordService;
 
+    /**
+     * 获取父标签
+     * @param keyword
+     * @return
+     */
+    @GetMapping("/getKeyword")
+    public ResponseJson getKeyword(String keyword) {
+
+        return recordService.getKeyword(keyword);
+    }
+
+    /**
+     * 获取页面类型
+     * @param pageLabels
+     * @return
+     */
+    @GetMapping("/getPageType")
+    public ResponseJson<List<CmPageType>> getPageType(String pageLabels) {
+
+        return recordService.getPageType(pageLabels);
+    }
+
     /**
      * 用户行为记录列表数据
      * @param cmBehaviorRecord 参数

+ 4 - 1
src/main/java/com/caimei365/manager/controller/caimei/user/CustomerApi.java

@@ -2,6 +2,7 @@ package com.caimei365.manager.controller.caimei.user;
 
 import com.caimei365.manager.config.security.ConstantKey;
 import com.caimei365.manager.config.security.JwtService;
+import com.caimei365.manager.config.utils.DateUtil;
 import com.caimei365.manager.entity.PaginationVo;
 import com.caimei365.manager.entity.ResponseJson;
 import com.caimei365.manager.entity.caimei.CmShop;
@@ -359,7 +360,9 @@ public class CustomerApi {
     public ResponseJson<PaginationVo<CmShopAdvertisingImage>> getShopAdvertisingImage(CmShopAdvertisingImage cmShopAdvertisingImage,
                                                                                       @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                                                       @RequestParam(value = "pageSize",defaultValue = "20") int pageSize) {
-
+        if (null != cmShopAdvertisingImage.getEndPvCreateTime()) {
+            cmShopAdvertisingImage.setEndPvCreateTime(DateUtil.getEndTime(cmShopAdvertisingImage.getEndPvCreateTime()));
+        }
         return customerService.getShopAdvertisingImage(cmShopAdvertisingImage, pageNum, pageSize);
     }
 

+ 47 - 0
src/main/java/com/caimei365/manager/dao/HomeDao.java

@@ -1,6 +1,11 @@
 package com.caimei365.manager.dao;
 
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -18,12 +23,54 @@ public interface HomeDao {
      * 统计采美商品数量
      */
     int countAllProducts();
+
     /**
      * 统计采美订单数量
      */
     int countAllOrders();
+
     /**
      * 统计采美订单总额
      */
     int countAllOrderMoney();
+
+
+    /**
+     * 机构统计
+     */
+    int countClub(@Param("userIdentity") Integer userIdentity, @Param("startCreateTime") Date startCreateTime, @Param("endCreateTime") Date endCreateTime);
+    /**
+     * 机构活跃度统计
+     */
+    int countClubActivity( @Param("startCreateTime") Date startCreateTime, @Param("endCreateTime") Date endCreateTime);
+    /**
+     * 机构订单趋势
+     */
+    int countClubOrder(@Param("userIdentity") Integer userIdentity, @Param("startCreateTime") Date startCreateTime, @Param("endCreateTime") Date endCreateTime);
+    /**
+     * 机构咨询统计
+     */
+    int countClubRemarks(@Param("startCreateTime") Date startCreateTime, @Param("endCreateTime") Date endCreateTime);
+    /**
+     * 游客咨询统计
+     */
+    int countClubVisitorRemarks(@Param("startCreateTime") Date startCreateTime, @Param("endCreateTime") Date endCreateTime);
+    /**
+     * 访问统计
+     */
+    int countRecord(@Param("userId") Integer userId, @Param("userIdentity") Integer userIdentity, @Param("startCreateTime") Date startCreateTime, @Param("endCreateTime") Date endCreateTime);
+    /**
+     *
+     * 热门商品
+     */
+    List<Map<String, String>> countProductSalesRecord(@Param("startCreateTime") Date startCreateTime, @Param("endCreateTime") Date endCreateTime);
+    /**
+     *
+     * 热门品牌
+     */
+    List<Map<String, String>>  countBrandProductSalesRecord(@Param("startCreateTime") Date startCreateTime, @Param("endCreateTime") Date endCreateTime);
+    /**
+     * 热门搜索词
+     */
+    List<String> countKeyword(@Param("startCreateTime") Date startCreateTime, @Param("endCreateTime") Date endCreateTime);
 }

+ 59 - 3
src/main/java/com/caimei365/manager/dao/KeyWordDao.java

@@ -1,11 +1,14 @@
 package com.caimei365.manager.dao;
 
+import com.caimei365.manager.entity.caimei.CmKeywordInfo;
+import com.caimei365.manager.entity.caimei.CmKeywordSubtag;
 import com.caimei365.manager.entity.caimei.CmPriorKeyword;
 import com.caimei365.manager.entity.caimei.KeyWord;
 import com.caimei365.manager.entity.caimei.cmUser.ServiceProviderModel;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -28,6 +31,13 @@ public interface KeyWordDao {
 
     Integer findKeywordExist(String keyword);
 
+    /**
+     * 是否已存在
+     * @param keyword
+     * @return
+     */
+    Integer getKeywordByName(String keyword);
+
     Map<String, String> findLinkageStatus(String id);
 
     void updateDelFlag(String id);
@@ -42,6 +52,8 @@ public interface KeyWordDao {
 
     /**
      * 静态标签列表
+     * @param dynamicStatus
+     * @param parentLabel
      * @param keyword
      * @param fromSearch
      * @param beginTime
@@ -49,14 +61,58 @@ public interface KeyWordDao {
      * @param serviceProviderId
      * @return
      */
-    List<KeyWord> getStateKeyWordList(String keyword, Integer fromSearch, String beginTime, String endTime, Integer serviceProviderId);
+    List<CmKeywordInfo> getStateKeyWordList(Integer dynamicStatus, Integer parentLabel, String keyword, Integer fromSearch, String beginTime, String endTime, Integer serviceProviderId);
+
+    /**
+     * 动态标签编辑
+     * @param id
+     * @return
+     */
+    CmKeywordInfo getkeywordById(@Param("id") Integer id);
+
+    /**
+     * 动态标签子标签集合
+     * @param id
+     * @return
+     */
+    List<CmKeywordSubtag> getkeywordSubtag(@Param("id") Integer id);
 
     /**
-     * 插入静态标签
+     * 获取所有子标签
      * @param keyword
+     * @return
+     */
+    List<CmKeywordInfo> getKeyword(@Param("keyword") String keyword);
+
+    /**
+     * 插入 动态/静态标签
+     * @param cmKeywordInfo
      */
-    void insertLabelByState(String keyword);
+    void insertKeywordInfo(CmKeywordInfo cmKeywordInfo);
 
+    /**
+     * 修改标签数据
+     * @param cmKeywordInfo
+     */
+    void updateKeyword(CmKeywordInfo cmKeywordInfo);
+
+    /**
+     * 添加子标签与父标签的关联
+     * @param subtag
+     */
+    void insertKeywordSubtag(CmKeywordSubtag subtag);
+
+    /**
+     * 删除与父标签的关联
+     * @param keywordId
+     * @param ids
+     */
+    void updateKeywordSubtag(@Param("keywordId") Integer keywordId, @Param("ids") List<Integer> ids);
+    /**
+     * 删除动态/静态标签
+     * @param id
+     */
+    void updateKeywordInfo(@Param("id") String id);
     /**
      * 优先展示标签
      * @param keyword

+ 1 - 1
src/main/java/com/caimei365/manager/dao/WeChatDao.java

@@ -39,7 +39,7 @@ public interface WeChatDao {
      * 根据父级Id统计同级别菜单数量
      * @param parentId 父级ID
      */
-    Integer countChildByParentId(Integer parentId);
+    Integer countChildByParentId(Integer parentId,String wxType);
 
     /**
      * 获取微信公众号菜单列表

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

@@ -1,6 +1,7 @@
 package com.caimei365.manager.dao.user;
 
 import com.caimei365.manager.entity.caimei.CmBehaviorRecord;
+import com.caimei365.manager.entity.caimei.CmPageType;
 import com.caimei365.manager.entity.caimei.RetuenEntity;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -15,6 +16,19 @@ import java.util.List;
  */
 @Mapper
 public interface CmBehaviorRecordDao {
+    /**
+     * 获取父标签
+     * @param keyword
+     * @return
+     */
+    List<RetuenEntity> getkeyword(@Param("keyword") String keyword);
+
+    /**
+     * 页面标签
+     * @param pageLabels
+     * @return
+     */
+    List<CmPageType> getPageType(@Param("pageLabels") String pageLabels);
 
     /**
      * 昨日数据

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

@@ -249,4 +249,9 @@ public class CmBehaviorRecord {
      */
     @ExcelIgnore
     private Integer exportType;
+    /**
+     * 父标签查询
+     */
+    @ExcelIgnore
+    private String pageLabels;
 }

+ 56 - 0
src/main/java/com/caimei365/manager/entity/caimei/CmKeywordInfo.java

@@ -0,0 +1,56 @@
+package com.caimei365.manager.entity.caimei;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : hzg
+ * @date : 2023/11/28
+ */
+@Data
+public class CmKeywordInfo {
+
+    private Integer id;
+    /**
+     * 标签库数据来源(1:手动添加;4:协销填写)
+     */
+    private Integer fromSearch;
+    /**
+     * 协销Id 当 fromSearch 为 4的时候有值
+     */
+    private Integer serviceProviderId;
+    /**
+     * 标签
+     */
+    @ExcelProperty("标签名")
+    private String keyword;
+    /**
+     * 子标签
+     */
+    private List<CmKeywordSubtag> subtag;
+    /**
+     * 0:动态标签;1:静态标签
+     */
+    private Integer dynamicStatus;
+    /**
+     * 父标签 0 否 1 是
+     */
+    private Integer parentLabel;
+    /**
+     * 添加时间
+     */
+    private Date addTime;
+    /**
+     * 联动搜索状态:0未启用,1已启用
+     */
+    private Integer linkageStatus;
+    /**
+     * 0:已删除;1未删除
+     */
+    private Integer delFlag;
+}

+ 36 - 0
src/main/java/com/caimei365/manager/entity/caimei/CmKeywordSubtag.java

@@ -0,0 +1,36 @@
+package com.caimei365.manager.entity.caimei;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : hzg
+ * @date : 2023/11/29
+ */
+@Data
+public class CmKeywordSubtag {
+    private Integer id;
+    /**
+     * 父标签id
+     */
+    private Integer keywordId;
+    /**
+     * 子标签Id
+     */
+    private Integer subtagId;
+    /**
+     * 子标签名
+     */
+    private String keyword;
+    /**
+     * 添加时间
+     */
+    private String addTime;
+    /**
+     * 删除标记 0 未删除 1 已删除
+     */
+    private Integer delFlag;
+}

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

@@ -0,0 +1,21 @@
+package com.caimei365.manager.entity.caimei;
+
+import lombok.Data;
+
+/**
+ * Description
+ *
+ * @author : hzg
+ * @date : 2023/12/1
+ */
+@Data
+public class CmPageType {
+    /**
+     * id
+     */
+    private Integer id;
+    /**
+     * 页面类型
+     */
+    private String pageType;
+}

+ 11 - 0
src/main/java/com/caimei365/manager/entity/caimei/KeyWord.java

@@ -2,6 +2,7 @@ package com.caimei365.manager.entity.caimei;
 
 import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.ExcelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.experimental.Accessors;
 import org.springframework.format.annotation.DateTimeFormat;
@@ -76,4 +77,14 @@ public class KeyWord implements Serializable {
      * shi发支持选择
      */
     private Boolean flag;
+
+    //点击量统计
+    /** 开始点击量时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date startPvCreateTime;
+    /** 结束点击量时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date endPvCreateTime;
+    /** 点击量 */
+    private Integer pv;
 }

+ 12 - 0
src/main/java/com/caimei365/manager/entity/caimei/cmUser/CmShopAdvertisingImage.java

@@ -1,8 +1,10 @@
 package com.caimei365.manager.entity.caimei.cmUser;
 
 import com.caimei365.manager.entity.caimei.CmShop;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -50,6 +52,16 @@ public class CmShopAdvertisingImage {
      * 删除标记:0未删除,1已删除
      */
     private Integer delFlag;
+
+    //点击量统计
+    /** 开始点击量时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date startPvCreateTime;
+    /** 结束点击量时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date endPvCreateTime;
+    /** 点击量 */
+    private Integer pv;
     /**
      * 供应商信息
      */

+ 14 - 0
src/main/java/com/caimei365/manager/service/caimei/HomeService.java

@@ -1,7 +1,9 @@
 package com.caimei365.manager.service.caimei;
 
 import com.caimei365.manager.entity.ResponseJson;
+import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.Map;
 
 /**
@@ -15,4 +17,16 @@ public interface HomeService {
      * 仪表盘数据
      */
     ResponseJson<Map<String, Object>> getDashboardData();
+    /**
+     * 机构统计
+     */
+    ResponseJson<Map<String, Object>> getClubCount(Date startCreateTime, Date endCreateTime);
+    /**
+     * 机构趋势
+     */
+    ResponseJson<Map<String, Object>> getClubTrend(Date startCreateTime, Date endCreateTime);
+    /**
+     * 访问统计
+     */
+    ResponseJson<Map<String, Object>> getAccessRecordCount(Date startCreateTime, Date endCreateTime);
 }

+ 29 - 4
src/main/java/com/caimei365/manager/service/caimei/KeyWordService.java

@@ -2,11 +2,13 @@ package com.caimei365.manager.service.caimei;
 
 import com.caimei365.manager.entity.PaginationVo;
 import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.CmKeywordInfo;
 import com.caimei365.manager.entity.caimei.CmPriorKeyword;
 import com.caimei365.manager.entity.caimei.KeyWord;
 import com.caimei365.manager.entity.caimei.cmUser.ServiceProviderModel;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author zzj
@@ -33,7 +35,9 @@ public interface KeyWordService {
     ResponseJson<List<ServiceProviderModel>> getServiceList();
 
     /**
-     * 静态标签列表
+     * 动态/静态标签列表
+     * @param dynamicStatus
+     * @param parentLabel
      * @param keyword
      * @param fromSearch
      * @param beginTime
@@ -42,15 +46,36 @@ public interface KeyWordService {
      * @param pageSize
      * @return
      */
-    ResponseJson<PaginationVo<KeyWord>> getStateKeyWordList(String keyword, Integer fromSearch, String beginTime, String endTime, Integer serviceProviderId, int pageNum, int pageSize);
+    ResponseJson<PaginationVo<CmKeywordInfo>> getStateKeyWordList(Integer dynamicStatus, Integer parentLabel, String keyword, Integer fromSearch, String beginTime, String endTime, Integer serviceProviderId, int pageNum, int pageSize);
 
     /**
-     * 插入静态标签
+     * 动态标签编辑回显
+     * @param id
+     * @return
+     */
+    ResponseJson<CmKeywordInfo> editKeyword(Integer id);
+
+    /**
+     * 选择子标签
      * @param keyword
+     * @param pageNum
+     * @param pageSize
      * @return
      */
-    ResponseJson insertLabelByState(String keyword);
+    ResponseJson<PaginationVo<CmKeywordInfo>> getSubtagKeyword(String keyword,  int pageNum, int pageSize);
+    /**
+     * 保存 动态/静态标签
+     * @param cmKeywordInfo
+     * @return
+     */
+    ResponseJson insertKeywordInfo(CmKeywordInfo cmKeywordInfo);
 
+    /**
+     * 删除动态标签
+     * @param id
+     * @return
+     */
+    ResponseJson deleteTrendsLabel(String id);
     /**
      * 优先展示标签列表
      * @param keyword

+ 171 - 2
src/main/java/com/caimei365/manager/service/caimei/impl/HomeServiceImpl.java

@@ -1,5 +1,7 @@
 package com.caimei365.manager.service.caimei.impl;
 
+import com.caimei.utils.AppUtils;
+import com.caimei365.manager.config.utils.DateUtil;
 import com.caimei365.manager.dao.HomeDao;
 import com.caimei365.manager.entity.ResponseJson;
 import com.caimei365.manager.service.caimei.HomeService;
@@ -7,8 +9,8 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.Map;
+import javax.xml.crypto.Data;
+import java.util.*;
 
 /**
  * Description
@@ -21,6 +23,8 @@ import java.util.Map;
 public class HomeServiceImpl implements HomeService {
     @Resource
     private HomeDao homeDao;
+
+
     /**
      * 仪表盘数据
      */
@@ -41,4 +45,169 @@ public class HomeServiceImpl implements HomeService {
         data.put("money", money);
         return ResponseJson.success(data);
     }
+
+    @Override
+    public ResponseJson<Map<String, Object>> getClubCount(Date startCreateTime, Date endCreateTime) {
+        int count = homeDao.countClub(null, startCreateTime, endCreateTime);
+        //机构统计
+        Map<String, Object> dataClub = new LinkedHashMap<>(5);
+        dataClub.put("个人机构", homeDao.countClub(1, startCreateTime, endCreateTime));
+        dataClub.put("医美机构", homeDao.countClub(2, startCreateTime, endCreateTime));
+        dataClub.put("生美机构", homeDao.countClub(3, startCreateTime, endCreateTime));
+        dataClub.put("项目公司", homeDao.countClub(4, startCreateTime, endCreateTime));
+        dataClub.put("其他", homeDao.countClub(-1, startCreateTime, endCreateTime));
+
+        Map<String, Object> mapclubCount = new HashMap<>(3);
+        mapclubCount.put("name", "机构统计");
+        mapclubCount.put("count", count);
+        mapclubCount.put("data", dataClub);
+
+        // 机构活跃度统计
+        Map<String, Object> clubActivity = new LinkedHashMap<>(2);
+        int countClubActivity = homeDao.countClubActivity(startCreateTime, endCreateTime);
+        clubActivity.put("活跃机构", countClubActivity);
+        clubActivity.put("不活跃机构",count-countClubActivity);
+
+        Map<String, Object> mapclubActivityCount = new HashMap<>(3);
+        mapclubActivityCount.put("name", "机构活跃度统计");
+        mapclubActivityCount.put("count", count);
+        mapclubActivityCount.put("data", clubActivity);
+
+        //封装数据
+        Map<String, Object> data = new HashMap<>(2);
+        data.put("clubCount", mapclubCount);
+        data.put("clubActivityCount", mapclubActivityCount);
+        return ResponseJson.success(data);
+    }
+
+    @Override
+    public ResponseJson<Map<String, Object>> getClubTrend(Date startCreateTime, Date endCreateTime) {
+        List<Map<String, Object>> mapCreateTimeList = setCreateTime(startCreateTime, endCreateTime);
+        //机构新增趋势
+        Map<String, Object> dataClub = new LinkedHashMap<>(5);
+        dataClub.put("个人机构", setClubTrend(1,1,mapCreateTimeList));
+        dataClub.put("医美机构", setClubTrend(1,2,mapCreateTimeList));
+        dataClub.put("生美机构", setClubTrend(1,3,mapCreateTimeList));
+        dataClub.put("项目公司", setClubTrend(1,4,mapCreateTimeList));
+        dataClub.put("其他", setClubTrend(1,-1,mapCreateTimeList));
+
+        Map<String, Object> mapclubCount = new HashMap<>(3);
+        mapclubCount.put("name", "机构新增趋势");
+        mapclubCount.put("count", homeDao.countClub(null, startCreateTime, endCreateTime));
+        mapclubCount.put("data", dataClub);
+
+
+        // 机构订单趋势
+        Map<String, Object> clubOrder = new LinkedHashMap<>(5);
+        clubOrder.put("个人机构", setClubTrend(2,1,mapCreateTimeList));
+        clubOrder.put("医美机构", setClubTrend(2,2,mapCreateTimeList));
+        clubOrder.put("生美机构", setClubTrend(2,3,mapCreateTimeList));
+        clubOrder.put("项目公司", setClubTrend(2,4,mapCreateTimeList));
+        clubOrder.put("其他", setClubTrend(2,-1,mapCreateTimeList));
+
+        Map<String, Object> mapclubOrder = new HashMap<>(3);
+        mapclubOrder.put("name", "机构订单趋势");
+        mapclubOrder.put("count", homeDao.countClubOrder(null, startCreateTime, endCreateTime));
+        mapclubOrder.put("data", clubOrder);
+
+        //封装数据
+        Map<String, Object> data = new HashMap<>(2);
+        data.put("clubCount", mapclubCount);
+        data.put("clubOrder", mapclubOrder);
+        return ResponseJson.success(data);
+    }
+
+    @Override
+    public ResponseJson<Map<String, Object>> getAccessRecordCount(Date startCreateTime, Date endCreateTime) {
+        // 咨询统计
+        int clubRemarks = homeDao.countClubRemarks(startCreateTime, endCreateTime);
+        int clubVisitorRemarks = homeDao.countClubVisitorRemarks(startCreateTime, endCreateTime);
+        Map<String, Object> countClubRemarks = new LinkedHashMap<>(2);
+        countClubRemarks.put("机构咨询", clubRemarks);
+        countClubRemarks.put("游客咨询", clubVisitorRemarks);
+
+        Map<String, Object> mapRemarks = new HashMap<>(3);
+        mapRemarks.put("name", "咨询统计");
+        mapRemarks.put("count", (clubRemarks + clubVisitorRemarks));
+        mapRemarks.put("data", countClubRemarks);
+
+        //访问统计
+        Map<String, Object> countRecord = new LinkedHashMap<>(7);
+        countRecord.put("个人机构", homeDao.countRecord(null, 1, startCreateTime, endCreateTime));
+        countRecord.put("医美机构", homeDao.countRecord(null, 2, startCreateTime, endCreateTime));
+        countRecord.put("生美机构", homeDao.countRecord(null, 3, startCreateTime, endCreateTime));
+        countRecord.put("项目公司", homeDao.countRecord(null, 4, startCreateTime, endCreateTime));
+        countRecord.put("其他", homeDao.countRecord(null, -1, startCreateTime, endCreateTime));
+        countRecord.put("游客", homeDao.countRecord(0, null, startCreateTime, endCreateTime));
+        countRecord.put("供应商", homeDao.countRecord(null, 5, startCreateTime, endCreateTime));
+
+        Map<String, Object> mapRecord = new HashMap<>(3);
+        mapRecord.put("name", "访问统计");
+        mapRecord.put("count", homeDao.countRecord(null, null, startCreateTime, endCreateTime));
+        mapRecord.put("data", countRecord);
+
+        // 热门品牌
+        List<Map<String, String>> mapBrandProductSalesRecord = homeDao.countBrandProductSalesRecord(startCreateTime, endCreateTime);
+        // 热门商品
+        List<Map<String, String>> mapProductSalesRecord = homeDao.countProductSalesRecord(startCreateTime, endCreateTime);
+        mapProductSalesRecord.forEach(s->{
+            s.put("image",AppUtils.getImageURL("product",s.get("image"), 0, "https://www.caimei365.com/"));
+        });
+        // 热门搜索词
+        List<String> mapKeyword = homeDao.countKeyword(startCreateTime, endCreateTime);
+
+        //封装数据
+        Map<String, Object> data = new HashMap<>(5);
+        data.put("record", mapRecord);
+        data.put("remarks", mapRemarks);
+        data.put("brandProductSalesRecords", mapBrandProductSalesRecord);
+        data.put("productSalesRecords", mapProductSalesRecord);
+        data.put("keywords", mapKeyword);
+        return ResponseJson.success(data);
+    }
+
+    public List<Map<String, Object>> setCreateTime(Date startCreateTime, Date endCreateTime) {
+        List<Map<String, Object>> list = new ArrayList<>();
+        // Calendar获取日期字符串
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(startCreateTime);
+        int ofTwoDate = (int) DateUtil.getDistanceOfTwoDate(startCreateTime, endCreateTime);
+        int ofTwoMonth = (int) ofTwoDate / 30;
+        int dates, cycle, count;
+        if (ofTwoMonth > 1) {
+            dates = ofTwoMonth;
+            cycle = Calendar.MONTH;
+            count = 1;
+        } else if (ofTwoMonth == 1 && ofTwoDate > 7) {
+            dates = 4;
+            cycle = Calendar.DATE;
+            count = 7;
+        } else {
+            dates = 7;
+            cycle = Calendar.DATE;
+            count = 1;
+        }
+        for (int i = 0; i < dates; i++) {
+            Map<String, Object> mapCreateTime = new HashMap<>(2);
+            mapCreateTime.put("startCreateTime", calendar.getTime());
+            calendar.add(cycle, count);
+            mapCreateTime.put("endCreateTime",calendar.getTime());
+            list.add(mapCreateTime);
+        }
+        return list;
+    }
+
+    public List<Map<String, Object>> setClubTrend(Integer type,Integer userType, List<Map<String, Object>> mapCreateTimeList) {
+        List<Map<String, Object>> list = new ArrayList<>();
+        Date startCreateTime, endCreateTime;
+        for (Map<String, Object> map : mapCreateTimeList) {
+            Map<String, Object> mapClubTrend = new HashMap<>(2);
+            startCreateTime = (Date) map.get("startCreateTime");
+            endCreateTime =(Date) map.get("endCreateTime");
+            mapClubTrend.put("time", DateUtil.setDate(startCreateTime,"yyyy/MM/dd"));
+            mapClubTrend.put("num", type==1?homeDao.countClub(userType, startCreateTime, endCreateTime):homeDao.countClubOrder(userType, startCreateTime, endCreateTime));
+            list.add(mapClubTrend);
+        }
+        return list;
+    }
 }

+ 111 - 11
src/main/java/com/caimei365/manager/service/caimei/impl/KeyWordServiceImpl.java

@@ -5,6 +5,8 @@ import com.caimei.utils.StringUtils;
 import com.caimei365.manager.dao.KeyWordDao;
 import com.caimei365.manager.entity.PaginationVo;
 import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.CmKeywordInfo;
+import com.caimei365.manager.entity.caimei.CmKeywordSubtag;
 import com.caimei365.manager.entity.caimei.CmPriorKeyword;
 import com.caimei365.manager.entity.caimei.KeyWord;
 import com.caimei365.manager.entity.caimei.cmUser.ServiceProviderModel;
@@ -17,6 +19,8 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -174,7 +178,9 @@ public class KeyWordServiceImpl implements KeyWordService {
     }
 
     /**
-     * 静态标签列表
+     * 动态/静态标签列表
+     * @param dynamicStatus
+     * @param parentLabel
      * @param keyword
      * @param fromSearch
      * @param beginTime
@@ -185,28 +191,122 @@ public class KeyWordServiceImpl implements KeyWordService {
      * @return
      */
     @Override
-    public ResponseJson<PaginationVo<KeyWord>> getStateKeyWordList(String keyword, Integer fromSearch, String beginTime, String endTime, Integer serviceProviderId, int pageNum, int pageSize) {
+    public ResponseJson<PaginationVo<CmKeywordInfo>> getStateKeyWordList(Integer dynamicStatus, Integer parentLabel, String keyword, Integer fromSearch, String beginTime, String endTime, Integer serviceProviderId, int pageNum, int pageSize) {
         PageHelper.startPage(pageNum, pageSize);
-        List<KeyWord> keyWords = keyWordDao.getStateKeyWordList(keyword, fromSearch, beginTime, endTime, serviceProviderId);
-        PaginationVo<KeyWord> pageData = new PaginationVo<>(keyWords);
+        List<CmKeywordInfo> keyWords = keyWordDao.getStateKeyWordList(dynamicStatus, parentLabel, keyword, fromSearch, beginTime, endTime, serviceProviderId);
+        PaginationVo<CmKeywordInfo> pageData = new PaginationVo<>(keyWords);
         return ResponseJson.success(pageData);
     }
 
     /**
-     * 插入静态标签
+     * 动态标签编辑回显
+     *
+     * @param id
+     * @return
+     */
+    @Override
+    public ResponseJson<CmKeywordInfo> editKeyword(Integer id) {
+        // 标签数据
+        CmKeywordInfo cmKeywordInfo = keyWordDao.getkeywordById(id);
+        if (null != cmKeywordInfo) {
+            // 前端要求默认 【】
+            cmKeywordInfo.setSubtag(new ArrayList<>());
+            // 若为父标签,获取子标签返回
+            if (1 == cmKeywordInfo.getParentLabel()) {
+                List<CmKeywordSubtag> cmKeywordSubtags = keyWordDao.getkeywordSubtag(id);
+                cmKeywordInfo.setSubtag(null == cmKeywordSubtags ? new ArrayList<>() : cmKeywordSubtags);
+            }
+        } else {
+            return ResponseJson.error(-1, "标签数据异常", null);
+        }
+        return ResponseJson.success(cmKeywordInfo);
+    }
+
+    /**
+     * 选择子标签
      *
      * @param keyword
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    @Override
+    public ResponseJson<PaginationVo<CmKeywordInfo>> getSubtagKeyword(String keyword, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<CmKeywordInfo> keywordList = keyWordDao.getKeyword(keyword);
+        PaginationVo<CmKeywordInfo> page = new PaginationVo<>(keywordList);
+        return ResponseJson.success(page);
+    }
+
+    /**
+     * 保存 动态/静态标签
+     *
+     * @param cmKeywordInfo
      * @return
      */
     @Override
-    public ResponseJson insertLabelByState(String keyword) {
-        Integer keywordExist = keyWordDao.findKeywordExist(keyword);
-        if (null == keywordExist) {
-            keyWordDao.insertLabelByState(keyword);
-            return ResponseJson.success();
+    public ResponseJson insertKeywordInfo(CmKeywordInfo cmKeywordInfo) {
+        List<Integer> ids = new ArrayList<>();
+        if (null == cmKeywordInfo.getId()) {
+            // 添加
+            Integer key = keyWordDao.getKeywordByName(cmKeywordInfo.getKeyword());
+            // 添加标签
+            if (null == key) {
+                keyWordDao.insertKeywordInfo(cmKeywordInfo);
+            } else {
+                return ResponseJson.error(-1, "标签已存在", null);
+            }
         } else {
-            return ResponseJson.error(-1, "关键词已存在", null);
+            // 修改
+            keyWordDao.updateKeyword(cmKeywordInfo);
+        }
+        // 有子标签时将子标签与父标签关联
+        if (null != cmKeywordInfo.getSubtag() && cmKeywordInfo.getSubtag().size() > 0) {
+            for (CmKeywordSubtag subtag : cmKeywordInfo.getSubtag()) {
+                if (null == subtag.getId()) {
+                    return ResponseJson.error(-1, "子标签id不能为空", null);
+                }
+                subtag.setKeywordId(cmKeywordInfo.getId());
+                subtag.setSubtagId(subtag.getSubtagId());
+                keyWordDao.insertKeywordSubtag(subtag);
+                ids.add(subtag.getId());
+            }
+            log.info("ids==="+ids);
+            if (null != ids && ids.size() >0) {
+                // 删除与父标签关联
+                keyWordDao.updateKeywordSubtag(cmKeywordInfo.getId(), ids);
+            }
+        }
+        return ResponseJson.success();
+    }
+
+    /**
+     * 删除动态标签
+     *
+     * @param id
+     * @return
+     */
+    @Override
+    public ResponseJson deleteTrendsLabel(String id) {
+        if (id.contains(",")) {
+            String[] split = id.split(",");
+            for (String s : split) {
+                // 删除动态/静态标签
+                keyWordDao.updateKeywordInfo(s);
+                // 删除有限展示标签
+                keyWordDao.delPriorKeywordById(Integer.parseInt(s));
+                // 删除子标签
+                keyWordDao.updateKeywordSubtag(Integer.parseInt(s), new ArrayList<>());
+            }
+        } else {
+            // 删除动态/静态标签
+            keyWordDao.updateKeywordInfo(id);
+            // 删除有限展示标签
+            keyWordDao.delPriorKeywordById(Integer.parseInt(id));
+            // 删除子标签
+            keyWordDao.updateKeywordSubtag(Integer.parseInt(id), new ArrayList<>());
         }
+        return ResponseJson.success();
     }
 
     /**

+ 62 - 0
src/main/java/com/caimei365/manager/service/caimei/listener/LabelListener.java

@@ -0,0 +1,62 @@
+package com.caimei365.manager.service.caimei.listener;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.alibaba.fastjson.JSON;
+import com.caimei365.manager.dao.KeyWordDao;
+import com.caimei365.manager.entity.caimei.CmKeywordInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : hzg
+ * @date : 2023/11/28
+ */
+@Slf4j
+@Service
+public class LabelListener extends AnalysisEventListener<CmKeywordInfo> {
+
+    @Resource
+    private KeyWordDao keyWordDao;
+
+    /**
+     * 批处理阈值
+     */
+    private static final int BATCH_COUNT = 20;
+
+    List<CmKeywordInfo> list = new ArrayList<>(BATCH_COUNT);
+
+    @Override
+    public void invoke(CmKeywordInfo data, AnalysisContext analysisContext) {
+        log.info("解析一条数据====" + JSON.toJSONString(data));
+        list.add(data);
+        if (list.size() >= BATCH_COUNT) {
+            save(list);
+            list.clear();
+        }
+    }
+
+    @Override
+    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+        save(list);
+        log.info("数据解析完成");
+    }
+
+    public void save(List<CmKeywordInfo> infoList) {
+        infoList.forEach(info -> {
+            Integer keywordId = keyWordDao.getKeywordByName(info.getKeyword());
+            if (null == keywordId) {
+                info.setDynamicStatus(0);
+                info.setParentLabel(0);
+                keyWordDao.insertKeywordInfo(info);
+            }
+        });
+    }
+}

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

@@ -3,6 +3,7 @@ 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 com.caimei365.manager.entity.caimei.CmPageType;
 
 import java.util.List;
 
@@ -13,6 +14,19 @@ import java.util.List;
  * @date : 2023/3/15
  */
 public interface CmBehaviorRecordService {
+    /**
+     * 获取父标签
+     * @param keyword
+     * @return
+     */
+    ResponseJson getKeyword(String keyword);
+
+    /**
+     * 获取页面标签
+     * @param pageLabels
+     * @return
+     */
+    ResponseJson<List<CmPageType>> getPageType(String pageLabels);
     /**
      * 用户行为列表
      * @param cmBehaviorRecord

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

@@ -6,6 +6,7 @@ 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.entity.caimei.CmPageType;
 import com.caimei365.manager.service.caimei.user.CmBehaviorRecordService;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
@@ -31,6 +32,29 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
     @Resource
     private CmBehaviorRecordDao cmBehaviorRecordDao;
 
+    /**
+     * 获取父标签
+     *
+     * @param keyword
+     * @return
+     */
+    @Override
+    public ResponseJson getKeyword(String keyword) {
+        return ResponseJson.success(cmBehaviorRecordDao.getkeyword(keyword));
+    }
+
+    /**
+     * 获取页面标签
+     *
+     * @param pageLabels
+     * @return
+     */
+    @Override
+    public ResponseJson<List<CmPageType>> getPageType(String pageLabels) {
+        return ResponseJson.success(cmBehaviorRecordDao.getPageType(pageLabels));
+    }
+
+
     /**
      * 用户行为列表
      * @param cmBehaviorRecord

+ 1 - 1
src/main/java/com/caimei365/manager/service/wechat/impl/WechatMenuServiceImpl.java

@@ -153,7 +153,7 @@ public class WechatMenuServiceImpl implements WechatMenuService {
         }
         menu.setWxType(parentMenu.getWxType());
         // 根据父级Id统计同级别菜单数量
-        Integer count = weChatDao.countChildByParentId(menu.getParentId());
+        Integer count = weChatDao.countChildByParentId(menu.getParentId(),menu.getWxType());
         // 一级菜单
         if (menu.getParentId() == 1 || menu.getParentId() == 2) {
             if (count >= 3) {

+ 6 - 3
src/main/resources/config/beta/application-beta.yml

@@ -66,9 +66,12 @@ wechat:
     appid: wx0938e78f38bc203d
     secret: a3b417fc249a964ad0df2813a1f19102
   hehe:
-    id: gh_7890123
-    appid: wx7890123
-    secret: abc7890123
+#    id: gh_7890123
+#    appid: wx7890123
+#    secret: abc7890123
+    id: gh_4d0a30254952
+    appid: wx778caddd81b66a2f
+    secret: eb5987c766198f45d7f2c489b5fd5100
   caimei-old:
     id: gh_123456
     appid: wx123456

+ 4 - 0
src/main/resources/config/dev/application-dev.yml

@@ -83,3 +83,7 @@ fdfs:
     height: 150
   tracker-list:            #TrackerList参数,支持多个
     - 192.168.2.100:22122
+
+mybatis:
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

+ 4 - 0
src/main/resources/config/prod/application-prod.yml

@@ -68,6 +68,10 @@ wechat:
     appid: wx91c4152b60ca91a3
     secret: a563dd2c07c9c815a4e697c8b6cb73dc
   hehe:
+    id: gh_4d0a30254952
+    appid: wx778caddd81b66a2f
+    secret: eb5987c766198f45d7f2c489b5fd5100
+  hehe-old:
     id: gh_eecada09617d
     appid: wxd81864ddacc0ed25
     secret: 7873323db2984c75556f8d04e76d1f02

+ 41 - 4
src/main/resources/mapper/CmBehaciorRecordDao.xml

@@ -12,6 +12,31 @@
         b.accessTime,
         b.accessDate
     </sql>
+
+    <select id="getkeyword" resultType="com.caimei365.manager.entity.caimei.RetuenEntity">
+        select
+            id,
+            keyword as value
+        from cm_keyword_info
+        where parentLabel = 1
+        and delFlag = 1
+        <if test="keyword != null and keyword != ''">
+            and keyword like concat('%',#{keyword},'%')
+        </if>
+    </select>
+
+    <select id="getPageType" resultType="com.caimei365.manager.entity.caimei.CmPageType">
+        select
+            id,
+            pageType
+        from cm_page_type
+        <where>
+            <if test="pageLabels != null and pageLabels != ''">
+                pageType like concat('%',#{pageLabels},'%')
+            </if>
+        </where>
+    </select>
+
     <select id="findList" resultType="com.caimei365.manager.entity.caimei.CmBehaviorRecord">
         SELECT
         IP as ip,
@@ -42,7 +67,7 @@
                 AND IP = #{ip}
             </if>
             <if test="corporateName != null and corporateName != ''">
-                AND corporateName like concat('%',#{corporateName},'%')
+                AND (corporateName like concat('%',#{corporateName},'%') or contacts like concat('%',#{corporateName},'%'))
             </if>
             <if test="companyType != null and companyType != ''">
                 AND companyType = #{companyType}
@@ -51,7 +76,7 @@
                 AND accessClient =#{accessClient}
             </if>
             <if test="contacts != null and contacts != ''">
-                AND contacts = #{contacts}
+                AND (corporateName like concat('%',#{contacts},'%') or contacts like concat('%',#{contacts},'%'))
             </if>
             <if test="phoneNumber != null and phoneNumber != ''">
                 AND phoneNumber = #{phoneNumber}
@@ -72,6 +97,12 @@
                     label like concat('%',#{label},'%')
                 </foreach>
             </if>
+            <if test="pageLabels != null and pageLabels != ''">
+                AND pageLabels like concat('%', #{pageLabels}, '%')
+            </if>
+                <if test="pageTypes != null and pageTypes != ''">
+                AND pageTypes like concat('%', #{pageTypes}, '%')
+            </if>
             <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                 AND accessDate between #{startTime} and #{endTime}
             </if>
@@ -109,7 +140,7 @@
                 AND IP = #{ip}
             </if>
             <if test="corporateName != null and corporateName != ''">
-                AND corporateName like concat('%',#{corporateName},'%')
+                AND (corporateName like concat('%',#{corporateName},'%') or contacts like concat('%',#{corporateName},'%'))
             </if>
             <if test="companyType != null and companyType != ''">
                 AND companyType = #{companyType}
@@ -118,7 +149,7 @@
                 AND accessClient =#{accessClient}
             </if>
             <if test="contacts != null and contacts != ''">
-                AND contacts = #{contacts}
+                AND (corporateName like concat('%',#{contacts},'%') or contacts like concat('%',#{contacts},'%'))
             </if>
             <if test="phoneNumber != null and phoneNumber != ''">
                 AND phoneNumber = #{phoneNumber}
@@ -135,6 +166,12 @@
                     label like concat('%',#{label},'%')
                 </foreach>
             </if>
+            <if test="pageLabels != null and pageLabels != ''">
+                AND pageLabels like concat('%', #{pageLabels}, '%')
+            </if>
+            <if test="pageTypes != null and pageTypes != ''">
+                AND pageTypes like concat('%', #{pageTypes}, '%')
+            </if>
             <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                 AND accessDate between #{startTime} and #{endTime}
             </if>

+ 142 - 3
src/main/resources/mapper/HomeDao.xml

@@ -5,12 +5,151 @@
         SELECT IFNULL(COUNT(*), 0) FROM user
     </select>
     <select id="countAllProducts" resultType="java.lang.Integer">
-        SELECT IFNULL(COUNT(*), 0) FROM product p left join cm_organize_product_info copi ON copi.productId = p.productId WHERE copi.validFlag != '0'
+        SELECT IFNULL(COUNT(*), 0)
+        FROM product p
+                 left join cm_organize_product_info copi ON copi.productId = p.productId
+        WHERE copi.validFlag != '0'
     </select>
     <select id="countAllOrders" resultType="java.lang.Integer">
-        SELECT IFNULL(COUNT(*), 0) FROM cm_order WHERE delFlag != '0'
+        SELECT IFNULL(COUNT(*), 0)
+        FROM cm_order
+        WHERE delFlag != '0'
     </select>
     <select id="countAllOrderMoney" resultType="java.lang.Integer">
-        SELECT SUM(IFNULL(payTotalFee, 0)) FROM cm_order WHERE delFlag != '0'
+        SELECT SUM(IFNULL(payTotalFee, 0))
+        FROM cm_order
+        WHERE delFlag != '0'
     </select>
+
+
+    <select id="countClub" resultType="java.lang.Integer">
+        SELECT IFNULL(COUNT(*), 0)
+        FROM club c
+        LEFT JOIN user u ON u.userID = c.userID
+        WHERE 1=1 and u.userIdentity!=8
+        <if test="userIdentity != null and userIdentity !=-1">
+            and c.firstClubType=#{userIdentity}
+        </if>
+        <if test="userIdentity != null and userIdentity ==-1">
+            and (c.firstClubType not in(1,2,3,4) or c.firstClubType is null)
+        </if>
+        <if test="startCreateTime != null ">AND str_to_date(u.registerTime, '%Y-%m-%d') >= #{startCreateTime}</if>
+        <if test="endCreateTime != null ">AND str_to_date(u.registerTime, '%Y-%m-%d') <![CDATA[ <= ]]> #{endCreateTime}</if>
+    </select>
+
+    <select id="countClubActivity" resultType="java.lang.Integer">
+        SELECT IFNULL(COUNT(*), 0)
+        FROM club c
+        LEFT JOIN user u ON u.userID = c.userID
+        WHERE 1=1 and u.userIdentity!=8
+        <if test="startCreateTime != null ">AND str_to_date(u.registerTime, '%Y-%m-%d') >= #{startCreateTime}</if>
+        <if test="endCreateTime != null ">AND str_to_date(u.registerTime, '%Y-%m-%d') <![CDATA[ <= ]]> #{endCreateTime}</if>
+        and (u.loginTime is not null
+        or c.userID  in(SELECT DISTINCT co.userID FROM cm_order co
+        WHERE 1=1
+        <if test="startCreateTime != null ">AND co.orderTime >= #{startCreateTime}</if>
+        <if test="endCreateTime != null ">AND co.orderTime <![CDATA[ <= ]]> #{endCreateTime}</if>)
+        or c.clubId  in(SELECT DISTINCT ccr.clubId FROM cm_club_remarks ccr
+        WHERE 1=1
+        <if test="startCreateTime != null ">AND ccr.addTime >= #{startCreateTime}</if>
+        <if test="endCreateTime != null ">AND ccr.addTime <![CDATA[ <= ]]> #{endCreateTime}</if>
+        ))
+    </select>
+
+    <select id="countClubOrder" resultType="java.lang.Integer">
+        SELECT IFNULL(COUNT(*), 0)
+        FROM cm_order co
+        LEFT JOIN user u ON u.userID = co.userID
+        LEFT JOIN club c ON c.userID = u.userID
+        WHERE 1=1
+        <if test="userIdentity != null and userIdentity !=-1">
+            and c.firstClubType=#{userIdentity}
+        </if>
+        <if test="userIdentity != null and userIdentity ==-1">
+            and (c.firstClubType not in(1,2,3,4) or c.firstClubType is null)
+        </if>
+        <if test="startCreateTime != null ">AND co.orderTime >= #{startCreateTime}</if>
+        <if test="endCreateTime != null ">AND co.orderTime <![CDATA[ <= ]]> #{endCreateTime}</if>
+    </select>
+
+    <select id="countClubRemarks" resultType="java.lang.Integer">
+        SELECT IFNULL(COUNT(*), 0)
+        FROM cm_club_remarks ccr
+        WHERE 1=1
+        <if test="startCreateTime != null ">AND ccr.addTime >= #{startCreateTime}</if>
+        <if test="endCreateTime != null ">AND ccr.addTime <![CDATA[ <= ]]> #{endCreateTime}</if>
+    </select>
+
+    <select id="countClubVisitorRemarks" resultType="java.lang.Integer">
+        SELECT IFNULL(COUNT(*), 0)
+        FROM cm_visitor_remarks cvr
+        WHERE 1=1
+        <if test="startCreateTime != null ">AND cvr.addTime >= #{startCreateTime}</if>
+        <if test="endCreateTime != null ">AND cvr.addTime <![CDATA[ <= ]]> #{endCreateTime}</if>
+    </select>
+
+    <select id="countRecord" resultType="java.lang.Integer">
+        SELECT IFNULL(COUNT(*), 0)
+        FROM cm_behavior_record_index cbri
+        LEFT JOIN user u ON u.userID = cbri.userID
+        LEFT JOIN club c ON c.userID = u.userID
+        WHERE 1=1
+        <if test="userId != null ">
+            and cbri.userID=#{userId}
+        </if>
+        <if test="userIdentity != null and userIdentity !=-1">
+            <if test="userIdentity == 5">
+                and u.userIdentity=3
+            </if>
+            <if test="userIdentity != 5">
+                and c.firstClubType=#{userIdentity}
+            </if>
+        </if>
+        <if test="userIdentity != null and userIdentity ==-1">
+            and (c.firstClubType not in(1,2,3,4) or c.firstClubType is null)
+        </if>
+        <if test="startCreateTime != null ">AND cbri.accessTime >= #{startCreateTime}</if>
+        <if test="endCreateTime != null ">AND cbri.accessTime <![CDATA[ <= ]]> #{endCreateTime}</if>
+    </select>
+
+    <select id="countProductSalesRecord" resultType="java.util.HashMap">
+        SELECT
+        p.mainImage as image,
+        p.name
+        FROM cm_product_sales_record cpsr
+        LEFT JOIN product p ON p.productID = cpsr.productID
+        WHERE 1=1
+        <if test="startCreateTime != null ">AND cpsr.saleTime >= #{startCreateTime}</if>
+        <if test="endCreateTime != null ">AND cpsr.saleTime <![CDATA[ <= ]]> #{endCreateTime}</if>
+        group by cpsr.productID
+        order by sum(cpsr.sales) desc
+        limit 0,10
+    </select>
+
+    <select id="countBrandProductSalesRecord" resultType="java.util.HashMap">
+        SELECT
+        cb.logo  as image,
+        cb.name
+        FROM cm_product_sales_record cpsr
+        LEFT JOIN product p ON p.productID = cpsr.productID
+        LEFT JOIN cm_brand  cb ON cb.id = p.brandID
+        WHERE 1=1 and cb.name is not null
+        <if test="startCreateTime != null ">AND cpsr.saleTime >= #{startCreateTime}</if>
+        <if test="endCreateTime != null ">AND cpsr.saleTime <![CDATA[ <= ]]> #{endCreateTime}</if>
+        group by p.brandID
+        order by sum(cpsr.sales) desc
+        limit 0,10
+    </select>
+
+    <select id="countKeyword" resultType="String">
+        SELECT
+        cusf.keyword
+        FROM cm_user_search_frequency cusf
+        WHERE 1=1
+        <if test="startCreateTime != null ">AND cusf.searchTime >= #{startCreateTime}</if>
+        <if test="endCreateTime != null ">AND cusf.searchTime <![CDATA[ <= ]]> #{endCreateTime}</if>
+        order by cusf.frequency desc
+        limit 0,10
+    </select>
+
 </mapper>

+ 143 - 44
src/main/resources/mapper/KeyWordDao.xml

@@ -54,12 +54,13 @@
         SELECT cusf.id AS id, cusf.frequency, cusf.keyword as keyword, cusf.addTime, cusf.linkageStatus,
         cusf.searchTime as searchTime,cusf.trueStatus as labelStatus,cusf.fromSearch as fromSearch,
         cusf.dynamicStatus, s.linkMan as name
+        ,IFNULL((select sum(c.pv) from cm_praise_statistics c where  c.delFlag = 0 and c.type = 6 and cusf.id = c.authorId  <if test="beginTime != null and beginTime !=''">AND c.createTime >= #{beginTime} </if><if test="endTime != null and endTime !=''">AND c.createTime <![CDATA[ <= ]]> #{endTime} </if>), 0) as pv
         FROM cm_user_search_frequency cusf
         left join serviceprovider s on cusf.serviceProviderId = s.serviceProviderID
         WHERE cusf.delStatus = 1
-        <if test="beginTime !=null and beginTime !=''">
-            AND (cusf.searchTime BETWEEN #{beginTime} AND #{endTime} or cusf.searchTime IS NULL)
-        </if>
+<!--        <if test="beginTime !=null and beginTime !=''">-->
+<!--            AND (cusf.searchTime BETWEEN #{beginTime} AND #{endTime} or cusf.searchTime IS NULL)-->
+<!--        </if>-->
         <if test="keyword !=null and keyword !=''">
             AND cusf.keyword LIKE CONCAT('%',#{keyword},'%')
         </if>
@@ -129,6 +130,14 @@
         limit 1
     </select>
 
+    <select id="getKeywordByName" resultType="java.lang.Integer">
+        select id
+        from cm_keyword_info
+        where keyword = #{keyword}
+          and delFlag = 1
+        limit 1
+    </select>
+
     <select id="getServiceList" resultType="com.caimei365.manager.entity.caimei.cmUser.ServiceProviderModel">
         SELECT
             ser.serviceProviderID AS serviceProviderId,
@@ -139,70 +148,160 @@
         order by ser.addTime asc
     </select>
 
-    <select id="getStateKeyWordList" resultType="com.caimei365.manager.entity.caimei.KeyWord">
-        SELECT cusf.id AS id, cusf.frequency, cusf.keyword as keyword, cusf.addTime,
-        cusf.searchTime as searchTime,cusf.trueStatus as labelStatus,cusf.fromSearch as fromSearch,
-        cusf.serviceProviderId, cusf.dynamicStatus, s.linkMan as name
-        FROM cm_user_search_frequency cusf
-        left join serviceprovider s on cusf.serviceProviderId = s.serviceProviderID
-        WHERE cusf.delStatus = 1 AND cusf.dynamicStatus = 1
-        <if test="beginTime !=null and beginTime !=''">
-            AND (cusf.searchTime BETWEEN #{beginTime} AND #{endTime} or cusf.searchTime IS NULL)
-        </if>
-        <if test="keyword !=null and keyword !=''">
-            AND cusf.keyword LIKE CONCAT('%',#{keyword},'%')
-        </if>
-        <if test="fromSearch != null">
-            AND cusf.fromSearch = #{fromSearch}
-        </if>
-        <if test="serviceProviderId != null">
-            AND cusf.serviceProviderID = #{serviceProviderId}
-        </if>
-        ORDER BY cusf.addTime DESC
+    <select id="getStateKeyWordList" resultType="com.caimei365.manager.entity.caimei.CmKeywordInfo">
+        SELECT cki.id AS id,
+        cki.keyword AS keyword,
+        cki.fromSearch AS fromSearch,
+        cki.serviceProviderId,
+        cki.dynamicStatus,
+        cki.parentLabel,
+        cki.addTime,
+        s.linkMan AS NAME
+        FROM cm_keyword_info cki
+        LEFT JOIN serviceprovider s ON cki.serviceProviderId = s.serviceProviderID
+        <where>
+            cki.delFlag = 1
+            <if test="dynamicStatus != null">
+               AND cki.dynamicStatus = #{dynamicStatus}
+            </if>
+            <if test="parentLabel != null">
+                AND cki.parentLabel = #{parentLabel}
+            </if>
+            <if test="beginTime !=null and beginTime !=''">
+                AND (cki.addTime BETWEEN #{beginTime} AND #{endTime} or cki.addTime IS NULL)
+            </if>
+            <if test="keyword !=null and keyword !=''">
+                AND cki.keyword LIKE CONCAT('%',#{keyword},'%')
+            </if>
+            <if test="fromSearch != null">
+                AND cki.fromSearch = #{fromSearch}
+            </if>
+            <if test="serviceProviderId != null">
+                AND cki.serviceProviderId = #{serviceProviderId}
+            </if>
+        </where>
+        ORDER BY cki.addTime DESC
     </select>
 
-    <insert id="insertLabelByState">
-        insert into cm_user_search_frequency(fromSearch, keyword, frequency, trueStatus, dynamicStatus, addTime)
-        values (1, #{keyword}, 0, 0, 1, now())
+    <select id="getkeywordById" resultType="com.caimei365.manager.entity.caimei.CmKeywordInfo">
+        SELECT
+            id AS id,
+            keyword AS keyword,
+            ifnull(parentLabel, 0) as parentLabel,
+            fromSearch AS fromSearch,
+            serviceProviderId,
+            dynamicStatus,
+            addTime
+        FROM cm_keyword_info
+        where delFlag = 1 and id = #{id}
+    </select>
+
+    <select id="getkeywordSubtag" resultType="com.caimei365.manager.entity.caimei.CmKeywordSubtag">
+        SELECT
+            cks.id AS id,
+            cki.keyword AS keyword,
+            cks.addTime
+        FROM cm_keyword_subtag cks
+        left join cm_keyword_info cki on cks.subtagId = cki.id
+        where cki.delFlag = 1 and cks.delFlag = 0 and cks.keywordId = #{id}
+    </select>
+
+    <select id="getKeyword" resultType="com.caimei365.manager.entity.caimei.CmKeywordInfo">
+        SELECT
+            id AS id,
+            keyword AS keyword,
+            parentLabel,
+            fromSearch AS fromSearch,
+            serviceProviderId,
+            dynamicStatus,
+            addTime
+        FROM cm_keyword_info
+        <where>
+            delFlag = 1 and parentLabel = 0
+            <if test="keyword != null and keyword != ''">
+                and keyword like concat ('%', #{keyword} , '%')
+            </if>
+        </where>
+        order by addTime desc
+    </select>
+
+    <insert id="insertKeywordInfo" keyProperty="id" keyColumn="id" useGeneratedKeys="true">
+        insert into cm_keyword_info(fromSearch, keyword, dynamicStatus, parentLabel, addTime, linkageStatus, delFlag)
+        values (1, #{keyword}, #{dynamicStatus}, #{parentLabel}, now(), 0, 1)
     </insert>
 
+    <update id="updateKeyword">
+        update cm_keyword_info
+        set keyword = #{keyword},
+            parentLabel = #{parentLabel}
+        where id = #{id}
+    </update>
+
+    <insert id="insertKeywordSubtag" keyProperty="subtagId" keyColumn="id" useGeneratedKeys="true">
+        insert into cm_keyword_subtag(keywordId, subtagId, addTime, delFlag)
+        values (#{keywordId}, #{subtagId}, now(), 0)
+    </insert>
+
+    <update id="updateKeywordSubtag">
+        update cm_keyword_subtag
+        set delFlag = 1
+        where keywordId = #{keywordId}
+          <if test="ids.size()>0">
+            and subtagId not in
+            <foreach collection="ids" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+          </if>
+    </update>
+
+    <update id="updateKeywordInfo">
+        update cm_keyword_info
+        set delFlag = 0
+        where id = #{id}
+    </update>
+
     <select id="getPriorKeywordList" resultType="com.caimei365.manager.entity.caimei.CmPriorKeyword">
         select
-            cpk.id, cpk.searchId AS searchId ,cusf.fromSearch as fromSearch, cusf.keyword as keyword, cusf.dynamicStatus,
-            cusf.serviceProviderId, cpk.addTime, s.linkMan as name
+            cpk.id, cpk.searchId AS searchId ,cki.fromSearch as fromSearch, cki.keyword as keyword, cki.dynamicStatus,
+            cki.serviceProviderId, cpk.addTime, s.linkMan as name
         from cm_prior_keyword cpk
-        left join cm_user_search_frequency cusf on cpk.searchId = cusf.id
-        left join serviceprovider s on cusf.serviceProviderId = s.serviceProviderID
-        WHERE cpk.delFlag = 0 AND cusf.delStatus = 1
+        left join cm_keyword_info cki on cpk.searchId = cki.id
+        left join serviceprovider s on cki.serviceProviderId = s.serviceProviderID
+        WHERE cpk.delFlag = 0 AND cki.delFlag = 1
         <if test="keyword !=null and keyword !=''">
-            AND cusf.keyword LIKE CONCAT('%',#{keyword},'%')
+            AND cki.keyword LIKE CONCAT('%',#{keyword},'%')
         </if>
         <if test="fromSearch != null">
-            AND cusf.fromSearch = #{fromSearch}
+            AND cki.fromSearch = #{fromSearch}
         </if>
         <if test="dynamicStatus != null">
-            AND cusf.dynamicStatus = #{dynamicStatus}
+            AND cki.dynamicStatus = #{dynamicStatus}
         </if>
         order by cpk.addTime desc
     </select>
 
     <select id="getPickKeyword" resultType="com.caimei365.manager.entity.caimei.KeyWord">
-        SELECT cusf.id AS id, cusf.frequency, cusf.keyword as keyword, cusf.addTime,
-        cusf.searchTime as searchTime,cusf.trueStatus as labelStatus,cusf.fromSearch as fromSearch,
-        cusf.serviceProviderId, cusf.dynamicStatus, s.linkMan as name
-        FROM cm_user_search_frequency cusf
-        left join serviceprovider s on cusf.serviceProviderId = s.serviceProviderID
-        WHERE cusf.delStatus = 1
+        SELECT
+               cki.id AS id,
+               cki.keyword as keyword,
+               cki.addTime,
+               cki.fromSearch as fromSearch,
+               cki.serviceProviderId,
+               cki.dynamicStatus,
+               s.linkMan as name
+        FROM cm_keyword_info cki
+        left join serviceprovider s on cki.serviceProviderId = s.serviceProviderID
+        WHERE cki.delFlag = 1
         <if test="keyword !=null and keyword !=''">
-            AND cusf.keyword LIKE CONCAT('%',#{keyword},'%')
+            AND cki.keyword LIKE CONCAT('%',#{keyword},'%')
         </if>
         <if test="fromSearch != null">
-            AND cusf.fromSearch = #{fromSearch}
+            AND cki.fromSearch = #{fromSearch}
         </if>
         <if test="dynamicStatus != null">
-            AND cusf.dynamicStatus = #{dynamicStatus}
+            AND cki.dynamicStatus = #{dynamicStatus}
         </if>
-        ORDER BY cusf.addTime DESC
+        ORDER BY cki.addTime DESC
     </select>
 
     <select id="getPriorCount" resultType="java.lang.Integer">

+ 1 - 1
src/main/resources/mapper/WeChatDao.xml

@@ -14,7 +14,7 @@
         FROM wechat_menu a WHERE a.id = #{id}
     </select>
     <select id="countChildByParentId" resultType="java.lang.Integer">
-        SELECT IFNULL(COUNT(*),0) FROM wechat_menu WHERE parent_id = #{parentId}
+        SELECT IFNULL(COUNT(*),0) FROM wechat_menu WHERE parent_id = #{parentId} and wx_type= #{wxType}
     </select>
     <update id="updateWechatMenu">
         UPDATE wechat_menu SET parent_id = #{parentId}, parent_ids = #{parentIds}, name = #{name}, sort = #{sort},

+ 1 - 0
src/main/resources/mapper/user/CustomerServiceDao.xml

@@ -266,6 +266,7 @@
             csa.addTime,
             csa.status,
             csa.delFlag
+            ,IFNULL((select sum(c.pv) from cm_praise_statistics c where  c.delFlag = 0 and c.type = 5 and csa.id = c.authorId  <if test="startPvCreateTime != null ">AND c.createTime >= #{startPvCreateTime} </if><if test="endPvCreateTime != null ">AND c.createTime <![CDATA[ <= ]]> #{endPvCreateTime} </if>), 0) as pv
             from cm_shop_advertisingImage csa
             left join shop s on s.shopId = csa.shopId
             <where>