Browse Source

用户行为优化1.0.5

huangzhiguo 1 year ago
parent
commit
da9d108c79

+ 2 - 0
src/main/java/com/caimei/modules/user/dao/NewCmClubDao.java

@@ -106,5 +106,7 @@ public interface NewCmClubDao extends CrudDao<NewCmClub> {
 
     List<ActiveClub> getTouristClubInfo(ActiveClub activeClub);
 
+    List<TouristDataExcel> getTouristExcel(ActiveClub activeClub);
+
     List<CmBehaviorInfo> getBehaviorInfo(CmBehaviorInfo behaviorInfo);
 }

+ 1 - 1
src/main/java/com/caimei/modules/user/entity/ActiveClub.java

@@ -45,7 +45,7 @@ public class ActiveClub  extends DataEntity<ActiveClub> {
     private String classify;  // 机构二级分类
     private String addTime;  // 注册时间
     private String svipUserFlag;  // vip类别
-    private String activeStatus;     // 活跃状态 0:活跃、1:不活跃
+    private String activeStatus;     // 活跃状态 0:活跃、1:不活跃、 2 咨询游客
     private String activeState;     // 活跃状态
     private String customerValues;   // 客户价值
     private String registerTime;    // 注册时间

+ 53 - 0
src/main/java/com/caimei/modules/user/entity/TouristDataExcel.java

@@ -0,0 +1,53 @@
+package com.caimei.modules.user.entity;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+
+/**
+ * Description
+ *
+ * @author : hzg
+ * @date : 2024/2/20
+ */
+public class TouristDataExcel {
+
+    @ExcelProperty(value = "咨询人", index = 0)
+    private String questionMan;
+    @ExcelProperty(value = "手机号/微信号", index = 1)
+    private String mobileOrWeChat;
+    @ExcelProperty(value = "协销联系人名称", index = 2)
+    private String spLinkMan;
+    @ExcelProperty(value = "潜在客户添加时间", index = 3)
+    private String visAddTime;
+
+    public String getQuestionMan() {
+        return questionMan;
+    }
+
+    public void setQuestionMan(String questionMan) {
+        this.questionMan = questionMan;
+    }
+
+    public String getMobileOrWeChat() {
+        return mobileOrWeChat;
+    }
+
+    public void setMobileOrWeChat(String mobileOrWeChat) {
+        this.mobileOrWeChat = mobileOrWeChat;
+    }
+
+    public String getSpLinkMan() {
+        return spLinkMan;
+    }
+
+    public void setSpLinkMan(String spLinkMan) {
+        this.spLinkMan = spLinkMan;
+    }
+
+    public String getVisAddTime() {
+        return visAddTime;
+    }
+
+    public void setVisAddTime(String visAddTime) {
+        this.visAddTime = visAddTime;
+    }
+}

+ 22 - 0
src/main/java/com/caimei/modules/user/service/NewCmClubService.java

@@ -379,6 +379,11 @@ public class NewCmClubService extends CrudService<NewCmClubDao, NewCmClub> {
         return page;
     }
 
+    /**
+     * 机构活跃导出
+     * @param activeClub
+     * @return
+     */
     public List<ActiveClubExcel> exportClubActive(ActiveClub activeClub) {
         List<ActiveClubExcel> clubActiveExcel = newCmClubDao.getExportActiveClubInfo(activeClub);
         clubActiveExcel.forEach( club -> {
@@ -417,6 +422,23 @@ public class NewCmClubService extends CrudService<NewCmClubDao, NewCmClub> {
         return clubActiveExcel;
     }
 
+    /**
+     * 咨询游客导出
+     * @param activeClub
+     * @return
+     */
+    public List<TouristDataExcel> exportTourist(ActiveClub activeClub) {
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Calendar instance = Calendar.getInstance();
+        instance.setTime(new Date());
+        instance.add(Calendar.MONTH, -6);
+        Date time = instance.getTime();
+        String format = dateFormat.format(time);
+        activeClub.setVisAddTime(format);
+        List<TouristDataExcel> touristExcel = newCmClubDao.getTouristExcel(activeClub);
+        return touristExcel;
+    }
+
     public List<easyExcel> exportExcel(ClubStatistics statistics) {
         List<easyExcel> statisticsList = newCmClubDao.findExcelList(statistics);
         List<easyExcel> easyExcels = setExData(statisticsList, statistics);

+ 12 - 6
src/main/java/com/caimei/modules/user/web/newUser/AgencyController.java

@@ -2042,20 +2042,26 @@ public class AgencyController extends BaseController {
 
     @RequestMapping("/exportClubActiveInfo")
     public void exportClubActiveInfo(ActiveClub activeClub, HttpServletRequest request, HttpServletResponse response , RedirectAttributes redirectAttributes) {
-        String name = "客户活跃情况";
+        String name = StringUtils.isBlank(activeClub.getActiveStatus()) ? "客户活跃情况" : ("2".equals(activeClub.getActiveStatus()) ? "咨询游客" : "客户活跃情况");
         try {
 
-            List<ActiveClubExcel> clubActive = newCmClubService.exportClubActive(activeClub);
             response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
             response.setCharacterEncoding("utf-8");
             // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
             String fileName = URLEncoder.encode(name, "UTF-8").replaceAll("\\+", "%20");
             response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
-            // 这里需要设置不关闭流
-            EasyExcel.write(response.getOutputStream(), ActiveClubExcel.class).autoCloseStream(Boolean.FALSE).sheet("客户活跃情况")
-                    .doWrite(clubActive);
+            if (!"2".equals(activeClub.getActiveStatus())) {
+                // 活跃、不活跃用户
+                List<ActiveClubExcel> clubActive = newCmClubService.exportClubActive(activeClub);
+                // 这里需要设置不关闭流
+                EasyExcel.write(response.getOutputStream(), ActiveClubExcel.class).autoCloseStream(Boolean.FALSE).sheet("客户活跃情况").doWrite(clubActive);
+            } else {
+                // 咨询游客
+                List<TouristDataExcel> touristExcels = newCmClubService.exportTourist(activeClub);
+                EasyExcel.write(response.getOutputStream(), TouristDataExcel.class).autoCloseStream(Boolean.FALSE).sheet("咨询游客").doWrite(touristExcels);
+            }
         } catch (Exception e) {
-            addMessage(redirectAttributes, "机构活跃数据导出失败", e.getMessage());
+            addMessage(redirectAttributes, "数据导出失败", e.getMessage());
             e.printStackTrace();
         }
     }

+ 26 - 0
src/main/resources/mappings/modules/user/NewCmClubMapper.xml

@@ -1716,6 +1716,32 @@
         </if>
     </select>
 
+    <select id="getTouristExcel" resultType="com.caimei.modules.user.entity.TouristDataExcel">
+        SELECT
+        cvr.id,
+        cvr.serviceProviderId as spId,
+        s.linkMan as spLinkMan,
+        cvr.questionMan,
+        cvr.addTime as visAddTime
+        FROM cm_visitor_remarks cvr
+        LEFT JOIN serviceprovider s ON s.serviceProviderID = cvr.serviceProviderId
+        <where>
+            cvr.clubId IS NULL OR cvr.clubId = '' and cvr.addTime <![CDATA[ >= ]]> #{visAddTime}
+            <if test="recentlyStartTime != null and recentlyStartTime != ''">
+                AND cvr.addTime <![CDATA[ >= ]]> #{recentlyStartTime}
+            </if>
+            <if test="recentlyEndTime != null and recentlyEndTime != ''">
+                AND cvr.addTime <![CDATA[ <= ]]> #{recentlyEndTime}
+            </if>
+        </where>
+        <if test="orderByType == null or orderByType == 1">
+            ORDER BY cvr.addTime DESC
+        </if>
+        <if test="orderByType == 2">
+            ORDER BY cvr.addTime asc
+        </if>
+    </select>
+
     <select id="getBehaviorInfo" resultType="com.caimei.modules.user.entity.CmBehaviorInfo">
         SELECT
             cbi.id,