傅行帆 5 лет назад
Родитель
Сommit
615b2adf1d

+ 97
- 0
src/main/java/com/huiju/estateagents/controller/TaChannelController.java Просмотреть файл

@@ -1,10 +1,15 @@
1 1
 package com.huiju.estateagents.controller;
2 2
 
3
+import com.alibaba.excel.EasyExcel;
4
+import com.alibaba.excel.ExcelWriter;
5
+import com.alibaba.excel.write.metadata.WriteSheet;
3 6
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 8
 import com.huiju.estateagents.base.BaseController;
6 9
 import com.huiju.estateagents.base.ResponseBean;
7 10
 import com.huiju.estateagents.entity.TaChannel;
11
+import com.huiju.estateagents.excel.ActivityStatistics.*;
12
+import com.huiju.estateagents.excel.handler.CustomCellWriteHandler;
8 13
 import com.huiju.estateagents.mapper.TaChannelMapper;
9 14
 import com.huiju.estateagents.service.ITaPersonService;
10 15
 import com.huiju.estateagents.service.TaChannelService;
@@ -19,6 +24,8 @@ import org.springframework.format.annotation.DateTimeFormat;
19 24
 import org.springframework.web.bind.annotation.*;
20 25
 
21 26
 import javax.servlet.http.HttpServletRequest;
27
+import javax.servlet.http.HttpServletResponse;
28
+import java.io.IOException;
22 29
 import java.time.LocalDate;
23 30
 import java.util.HashMap;
24 31
 import java.util.List;
@@ -308,4 +315,94 @@ public class TaChannelController extends BaseController {
308 315
                                         HttpServletRequest request) {
309 316
         return taChannelService.getPersonNumList(pageNum, pageSize, getOrgId(request), channelId, targetId, targetType, buildingId);
310 317
     }
318
+
319
+    /**
320
+     * 渠道引进客户统计导出
321
+     * @return
322
+     */
323
+    @GetMapping(value = "/admin/channel/introductionListExport")
324
+    public void getChannelIntroductionListExport(@RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
325
+                                                         @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate endDate,
326
+                                                         @RequestParam(value = "channelType", required = false)String channelType,
327
+                                                         @RequestParam(value = "buildingId", required = false)String buildingId,
328
+                                                         @RequestParam(value = "channelId") Integer channelId,
329
+                                                         HttpServletRequest request, HttpServletResponse response) throws IOException {
330
+        response.setContentType("application/octet-stream");
331
+        response.setCharacterEncoding("utf-8");
332
+        response.setHeader("Content-disposition", "attachment;filename=引进注册用户.xlsx");
333
+        ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), TsChannelDaily.class).registerWriteHandler(new CustomCellWriteHandler()).build();
334
+        // 设置 sheet, 同一个sheet只需要设置一次
335
+        WriteSheet writeSheet = EasyExcel.writerSheet("引进注册用户").build();
336
+        List<TsChannelDaily> data = taChannelService.getChannelIntroductionListExport(getOrgId(request), startDate, endDate, channelType, buildingId, channelId);
337
+        excelWriter.write(data, writeSheet);
338
+        // finish 会帮忙关闭流
339
+        excelWriter.finish();
340
+    }
341
+
342
+    /**
343
+     * 渠道注册用户列表导出
344
+     * @return
345
+     */
346
+    @GetMapping(value = "/admin/channel/introduction/newuserListExport")
347
+    public void getNewuserListExport(@RequestParam(value = "targetId", required = false) String targetId,
348
+                                       @RequestParam(value = "targetType", required = false) String targetType,
349
+                                       @RequestParam(value = "buildingId", required = false) String buildingId,
350
+                                       @RequestParam(value = "channelId", required = false) Integer channelId,
351
+                                       HttpServletRequest request,HttpServletResponse response) throws IOException {
352
+        response.setContentType("application/octet-stream");
353
+        response.setCharacterEncoding("utf-8");
354
+        response.setHeader("Content-disposition", "attachment;filename=注册用户.xlsx");
355
+        ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), ChannelAddRegistNum.class).registerWriteHandler(new CustomCellWriteHandler()).build();
356
+        // 设置 sheet, 同一个sheet只需要设置一次
357
+        WriteSheet writeSheet = EasyExcel.writerSheet("注册用户").build();
358
+        List<ChannelAddRegistNum> data =  taChannelService.getNewuserListExport(getOrgId(request), channelId, targetId, targetType, buildingId);
359
+        excelWriter.write(data, writeSheet);
360
+        // finish 会帮忙关闭流
361
+        excelWriter.finish();
362
+    }
363
+
364
+    /**
365
+     * 渠道访问次数列表导出
366
+     * @return
367
+     */
368
+    @GetMapping(value = "/admin/channel/introduction/visitNumListExport")
369
+    public void getVisitNumListExport(@RequestParam(value = "targetId", required = false) String targetId,
370
+                                        @RequestParam(value = "targetType", required = false) String targetType,
371
+                                        @RequestParam(value = "buildingId", required = false) String buildingId,
372
+                                        @RequestParam(value = "channelId", required = false) Integer channelId,
373
+                                        HttpServletRequest request,HttpServletResponse response) throws IOException {
374
+        response.setContentType("application/octet-stream");
375
+        response.setCharacterEncoding("utf-8");
376
+        response.setHeader("Content-disposition", "attachment;filename=访问次数.xlsx");
377
+        ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), ChannelVisitNum.class).registerWriteHandler(new CustomCellWriteHandler()).build();
378
+        // 设置 sheet, 同一个sheet只需要设置一次
379
+        WriteSheet writeSheet = EasyExcel.writerSheet("访问次数").build();
380
+        List<ChannelVisitNum> data = taChannelService.getVisitNumListExport(getOrgId(request), channelId, targetId, targetType, buildingId);
381
+        excelWriter.write(data, writeSheet);
382
+        // finish 会帮忙关闭流
383
+        excelWriter.finish();
384
+    }
385
+
386
+
387
+    /**
388
+     * 渠道访问人数列表导出
389
+     * @return
390
+     */
391
+    @GetMapping(value = "/admin/channel/introduction/personNumListExport")
392
+    public void getPersonNumListExport(@RequestParam(value = "targetId", required = false) String targetId,
393
+                                         @RequestParam(value = "targetType", required = false) String targetType,
394
+                                         @RequestParam(value = "buildingId", required = false) String buildingId,
395
+                                         @RequestParam(value = "channelId", required = false) Integer channelId,
396
+                                         HttpServletRequest request,HttpServletResponse response) throws IOException {
397
+        response.setContentType("application/octet-stream");
398
+        response.setCharacterEncoding("utf-8");
399
+        response.setHeader("Content-disposition", "attachment;filename=访问人数.xlsx");
400
+        ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), ChannelVisitPersonNum.class).registerWriteHandler(new CustomCellWriteHandler()).build();
401
+        // 设置 sheet, 同一个sheet只需要设置一次
402
+        WriteSheet writeSheet = EasyExcel.writerSheet("访问人数").build();
403
+        List<ChannelVisitPersonNum> data = taChannelService.getPersonNumListExport(getOrgId(request), channelId, targetId, targetType, buildingId);
404
+        excelWriter.write(data, writeSheet);
405
+        // finish 会帮忙关闭流
406
+        excelWriter.finish();
407
+    }
311 408
 }

+ 35
- 35
src/main/java/com/huiju/estateagents/excel/ActivityStatistics/ChannelVisitNum.java Просмотреть файл

@@ -34,46 +34,46 @@ public class ChannelVisitNum {
34 34
     @ExcelProperty(value = "归属地", index = 3)
35 35
     private String province;
36 36
 
37
-    /**
38
-     * 来源渠道
39
-     */
40
-    @ColumnWidth(15)
41
-    @ExcelProperty(value = "来源渠道", index = 4)
42
-    private String personFrom;
43
-
44
-    /**
45
-     * 置业顾问
46
-     */
47
-    @ColumnWidth(15)
48
-    @ExcelProperty(value = "置业顾问", index = 5)
49
-    private String realtyConsultant;
50
-
51
-    /**
52
-     * 置业顾问电话
53
-     */
54
-    @ColumnWidth(15)
55
-    @ExcelProperty(value = "置业顾问电话", index = 6)
56
-    private String realtyConsultantPhone;
57
-
58
-    /**
59
-     * 分享者
60
-     */
61
-    @ColumnWidth(15)
62
-    @ExcelProperty(value = "分享者", index = 7)
63
-    private String sharePersonName;
64
-
65
-    /**
66
-     * 分享者电话
67
-     */
68
-    @ColumnWidth(15)
69
-    @ExcelProperty(value = "分享者电话", index = 8)
70
-    private String sharePersonPhone;
37
+//    /**
38
+//     * 来源渠道
39
+//     */
40
+//    @ColumnWidth(15)
41
+//    @ExcelProperty(value = "来源渠道", index = 4)
42
+//    private String personFrom;
43
+//
44
+//    /**
45
+//     * 置业顾问
46
+//     */
47
+//    @ColumnWidth(15)
48
+//    @ExcelProperty(value = "置业顾问", index = 5)
49
+//    private String realtyConsultant;
50
+//
51
+//    /**
52
+//     * 置业顾问电话
53
+//     */
54
+//    @ColumnWidth(15)
55
+//    @ExcelProperty(value = "置业顾问电话", index = 6)
56
+//    private String realtyConsultantPhone;
57
+//
58
+//    /**
59
+//     * 分享者
60
+//     */
61
+//    @ColumnWidth(15)
62
+//    @ExcelProperty(value = "分享者", index = 7)
63
+//    private String sharePersonName;
64
+//
65
+//    /**
66
+//     * 分享者电话
67
+//     */
68
+//    @ColumnWidth(15)
69
+//    @ExcelProperty(value = "分享者电话", index = 8)
70
+//    private String sharePersonPhone;
71 71
 
72 72
     /**
73 73
      * 访问时间
74 74
      */
75 75
     @ColumnWidth(15)
76
-    @ExcelProperty(value = "访问时间", index = 9)
76
+    @ExcelProperty(value = "访问时间", index = 4)
77 77
     private String visitDate;
78 78
 
79 79
 }

+ 28
- 28
src/main/java/com/huiju/estateagents/excel/ActivityStatistics/ChannelVisitPersonNum.java Просмотреть файл

@@ -34,33 +34,33 @@ public class ChannelVisitPersonNum {
34 34
     @ExcelProperty(value = "归属地", index = 3)
35 35
     private String province;
36 36
 
37
-    /**
38
-     * 来源渠道
39
-     */
40
-    @ColumnWidth(15)
41
-    @ExcelProperty(value = "来源渠道", index = 4)
42
-    private String personFrom;
43
-
44
-    /**
45
-     * 置业顾问
46
-     */
47
-    @ColumnWidth(15)
48
-    @ExcelProperty(value = "置业顾问", index = 5)
49
-    private String realtyConsultant;
50
-
51
-    /**
52
-     * 置业顾问电话
53
-     */
54
-    @ColumnWidth(15)
55
-    @ExcelProperty(value = "置业顾问电话", index = 6)
56
-    private String realtyConsultantPhone;
57
-
58
-    /**
59
-     * 推广人
60
-     */
61
-    @ColumnWidth(15)
62
-    @ExcelProperty(value = "推广人", index = 7)
63
-    private String sharePersonName;
37
+//    /**
38
+//     * 来源渠道
39
+//     */
40
+//    @ColumnWidth(15)
41
+//    @ExcelProperty(value = "来源渠道", index = 4)
42
+//    private String personFrom;
43
+//
44
+//    /**
45
+//     * 置业顾问
46
+//     */
47
+//    @ColumnWidth(15)
48
+//    @ExcelProperty(value = "置业顾问", index = 5)
49
+//    private String realtyConsultant;
50
+//
51
+//    /**
52
+//     * 置业顾问电话
53
+//     */
54
+//    @ColumnWidth(15)
55
+//    @ExcelProperty(value = "置业顾问电话", index = 6)
56
+//    private String realtyConsultantPhone;
57
+//
58
+//    /**
59
+//     * 推广人
60
+//     */
61
+//    @ColumnWidth(15)
62
+//    @ExcelProperty(value = "推广人", index = 7)
63
+//    private String sharePersonName;
64 64
 //    /**
65 65
 //     * 分享者
66 66
 //     */
@@ -79,7 +79,7 @@ public class ChannelVisitPersonNum {
79 79
      * 访问次数
80 80
      */
81 81
     @ColumnWidth(15)
82
-    @ExcelProperty(value = "访问次数", index = 8)
82
+    @ExcelProperty(value = "访问次数", index = 4)
83 83
     private String visitNum;
84 84
 
85 85
 

+ 51
- 0
src/main/java/com/huiju/estateagents/excel/ActivityStatistics/TsChannelDaily.java Просмотреть файл

@@ -0,0 +1,51 @@
1
+package com.huiju.estateagents.excel.ActivityStatistics;
2
+
3
+import com.alibaba.excel.annotation.ExcelProperty;
4
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
5
+import lombok.Data;
6
+
7
+@Data
8
+public class TsChannelDaily {
9
+    /**
10
+     * 类型
11
+     */
12
+    @ColumnWidth(15)
13
+    @ExcelProperty(value = "类型", index = 0)
14
+    private String targetType;
15
+
16
+    /**
17
+     * 内容
18
+     */
19
+    @ColumnWidth(15)
20
+    @ExcelProperty(value = "内容", index = 1)
21
+    private String targetName;
22
+
23
+    /**
24
+     * 关联项目
25
+     */
26
+    @ColumnWidth(15)
27
+    @ExcelProperty(value = "关联项目", index = 2)
28
+    private String buildingName;
29
+
30
+    /**
31
+     * 新增注册用户
32
+     */
33
+    @ColumnWidth(15)
34
+    @ExcelProperty(value = "新增注册用户", index = 3)
35
+    private Integer newCustomers;
36
+
37
+    /**
38
+     * 访问人数
39
+     */
40
+    @ColumnWidth(15)
41
+    @ExcelProperty(value = "访问人数", index = 4)
42
+    private Integer visitPersons;
43
+
44
+    /**
45
+     * 访问次数
46
+     */
47
+    @ColumnWidth(15)
48
+    @ExcelProperty(value = "访问次数", index = 5)
49
+    private Integer visitNum;
50
+
51
+}

+ 9
- 0
src/main/java/com/huiju/estateagents/mapper/TaChannelMapper.java Просмотреть файл

@@ -7,6 +7,7 @@ import com.huiju.estateagents.entity.TsActivityDaily;
7 7
 import com.huiju.estateagents.excel.ActivityStatistics.ChannelAddRegistNum;
8 8
 import com.huiju.estateagents.excel.ActivityStatistics.ChannelVisitNum;
9 9
 import com.huiju.estateagents.excel.ActivityStatistics.ChannelVisitPersonNum;
10
+import com.huiju.estateagents.excel.ActivityStatistics.TsChannelDaily;
10 11
 import org.apache.ibatis.annotations.Mapper;
11 12
 import org.apache.ibatis.annotations.Param;
12 13
 
@@ -62,4 +63,12 @@ public interface TaChannelMapper extends BaseMapper<TaChannel> {
62 63
     IPage<ChannelVisitNum> getChannelVisitNumList(IPage<ChannelVisitNum> iPage,@Param("orgId") Integer orgId,@Param("channelId") Integer channelId,@Param("targetId") String targetId,@Param("targetType") String targetType,@Param("buildingId") String buildingId);
63 64
 
64 65
     IPage<ChannelVisitPersonNum> getChannelPersonNumList(IPage<ChannelVisitPersonNum> iPage,@Param("orgId") Integer orgId,@Param("channelId") Integer channelId,@Param("targetId") String targetId,@Param("targetType") String targetType,@Param("buildingId") String buildingId);
66
+
67
+    List<TsChannelDaily> getChannelIntroductionListExport(@Param("orgId") Integer orgId,@Param("startDate") LocalDate startDate,@Param("endDate") LocalDate endDate,@Param("channelType") String channelType,@Param("buildingId") String buildingId,@Param("channelId") Integer channelId);
68
+
69
+    List<ChannelAddRegistNum> getChannelNewuserListExport( @Param("orgId") Integer orgId, @Param("channelId") Integer channelId, @Param("activityId") String activityId, @Param("activityType") String activityType, @Param("buildingId") String buildingId);
70
+
71
+    List<ChannelVisitNum> getChannelVisitNumListExport(@Param("orgId") Integer orgId,@Param("channelId") Integer channelId,@Param("targetId") String targetId,@Param("targetType") String targetType,@Param("buildingId") String buildingId);
72
+
73
+    List<ChannelVisitPersonNum> getChannelPersonNumListExport(@Param("orgId") Integer orgId,@Param("channelId") Integer channelId,@Param("targetId") String targetId,@Param("targetType") String targetType,@Param("buildingId") String buildingId);
65 74
 }

+ 51
- 0
src/main/java/com/huiju/estateagents/service/TaChannelService.java Просмотреть файл

@@ -1,9 +1,15 @@
1 1
 package com.huiju.estateagents.service;
2
+
2 3
 import com.baomidou.mybatisplus.extension.service.IService;
3 4
 import com.huiju.estateagents.base.ResponseBean;
4 5
 import com.huiju.estateagents.entity.TaChannel;
6
+import com.huiju.estateagents.excel.ActivityStatistics.ChannelAddRegistNum;
7
+import com.huiju.estateagents.excel.ActivityStatistics.ChannelVisitNum;
8
+import com.huiju.estateagents.excel.ActivityStatistics.ChannelVisitPersonNum;
9
+import com.huiju.estateagents.excel.ActivityStatistics.TsChannelDaily;
5 10
 
6 11
 import java.time.LocalDate;
12
+import java.util.List;
7 13
 
8 14
 /**
9 15
  * <p>
@@ -66,4 +72,49 @@ public interface TaChannelService extends IService<TaChannel> {
66 72
      * @return
67 73
      */
68 74
     ResponseBean getPersonNumList(Integer pageNum, Integer pageSize, Integer orgId, Integer channelId, String targetId, String targetType, String buildingId);
75
+
76
+    /**
77
+     * 导出
78
+     * @param orgId
79
+     * @param startDate
80
+     * @param endDate
81
+     * @param channelType
82
+     * @param buildingId
83
+     * @param channelId
84
+     * @return
85
+     */
86
+    List<TsChannelDaily> getChannelIntroductionListExport(Integer orgId, LocalDate startDate, LocalDate endDate, String channelType, String buildingId, Integer channelId);
87
+
88
+    /**
89
+     * 导出
90
+     * @param orgId
91
+     * @param channelId
92
+     * @param targetId
93
+     * @param targetType
94
+     * @param buildingId
95
+     * @return
96
+     */
97
+    List<ChannelAddRegistNum> getNewuserListExport(Integer orgId, Integer channelId, String targetId, String targetType, String buildingId);
98
+
99
+    /**
100
+     * 导出
101
+     * @param orgId
102
+     * @param channelId
103
+     * @param targetId
104
+     * @param targetType
105
+     * @param buildingId
106
+     * @return
107
+     */
108
+    List<ChannelVisitNum> getVisitNumListExport(Integer orgId, Integer channelId, String targetId, String targetType, String buildingId);
109
+
110
+    /**
111
+     * 导出
112
+     * @param orgId
113
+     * @param channelId
114
+     * @param targetId
115
+     * @param targetType
116
+     * @param buildingId
117
+     * @return
118
+     */
119
+    List<ChannelVisitPersonNum> getPersonNumListExport(Integer orgId, Integer channelId, String targetId, String targetType, String buildingId);
69 120
 }

+ 63
- 4
src/main/java/com/huiju/estateagents/service/impl/TaChannelServiceImpl.java Просмотреть файл

@@ -6,16 +6,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6 6
 import com.huiju.estateagents.base.ResponseBean;
7 7
 import com.huiju.estateagents.entity.TaChannel;
8 8
 import com.huiju.estateagents.entity.TsActivityDaily;
9
-import com.huiju.estateagents.excel.ActivityStatistics.ChannelAddRegistNum;
10
-import com.huiju.estateagents.excel.ActivityStatistics.ChannelVisitNum;
11
-import com.huiju.estateagents.excel.ActivityStatistics.ChannelVisitPersonNum;
12
-import com.huiju.estateagents.excel.ActivityStatistics.VisitPersonNum;
9
+import com.huiju.estateagents.excel.ActivityStatistics.*;
13 10
 import com.huiju.estateagents.mapper.TaChannelMapper;
14 11
 import com.huiju.estateagents.service.TaChannelService;
15 12
 import org.springframework.beans.factory.annotation.Autowired;
16 13
 import org.springframework.stereotype.Service;
17 14
 
18 15
 import java.time.LocalDate;
16
+import java.util.List;
19 17
 
20 18
 /**
21 19
  * <p>
@@ -106,4 +104,65 @@ public class TaChannelServiceImpl extends ServiceImpl<TaChannelMapper, TaChannel
106 104
         IPage<ChannelVisitPersonNum> data = taChannelMapper.getChannelPersonNumList(iPage, orgId, channelId, targetId, targetType, buildingId);
107 105
         return ResponseBean.success(data);
108 106
     }
107
+
108
+    /**
109
+     * 导出
110
+     *
111
+     * @param orgId
112
+     * @param startDate
113
+     * @param endDate
114
+     * @param channelType
115
+     * @param buildingId
116
+     * @param channelId
117
+     * @return
118
+     */
119
+    @Override
120
+    public List<TsChannelDaily> getChannelIntroductionListExport(Integer orgId, LocalDate startDate, LocalDate endDate, String channelType, String buildingId, Integer channelId) {
121
+        return taChannelMapper.getChannelIntroductionListExport(orgId,startDate,endDate,channelType,buildingId, channelId);
122
+    }
123
+
124
+    /**
125
+     * 导出
126
+     *
127
+     * @param orgId
128
+     * @param channelId
129
+     * @param targetId
130
+     * @param targetType
131
+     * @param buildingId
132
+     * @return
133
+     */
134
+    @Override
135
+    public List<ChannelAddRegistNum> getNewuserListExport(Integer orgId, Integer channelId, String targetId, String targetType, String buildingId) {
136
+        return taChannelMapper.getChannelNewuserListExport(orgId, channelId, targetId,targetType, buildingId);
137
+    }
138
+
139
+    /**
140
+     * 导出
141
+     *
142
+     * @param orgId
143
+     * @param channelId
144
+     * @param targetId
145
+     * @param targetType
146
+     * @param buildingId
147
+     * @return
148
+     */
149
+    @Override
150
+    public List<ChannelVisitNum> getVisitNumListExport(Integer orgId, Integer channelId, String targetId, String targetType, String buildingId) {
151
+        return taChannelMapper.getChannelVisitNumListExport(orgId, channelId, targetId, targetType, buildingId);
152
+    }
153
+
154
+    /**
155
+     * 导出
156
+     *
157
+     * @param orgId
158
+     * @param channelId
159
+     * @param targetId
160
+     * @param targetType
161
+     * @param buildingId
162
+     * @return
163
+     */
164
+    @Override
165
+    public List<ChannelVisitPersonNum> getPersonNumListExport(Integer orgId, Integer channelId, String targetId, String targetType, String buildingId) {
166
+        return taChannelMapper.getChannelPersonNumListExport(orgId, channelId, targetId, targetType, buildingId);
167
+    }
109 168
 }

+ 156
- 0
src/main/resources/mapper/TaChannelMapper.xml Просмотреть файл

@@ -222,5 +222,161 @@
222 222
         group by t.person_id
223 223
         order by t.create_date desc
224 224
     </select>
225
+    <select id="getChannelIntroductionListExport"
226
+            resultType="com.huiju.estateagents.excel.ActivityStatistics.TsChannelDaily">
227
+        SELECT
228
+        *
229
+        FROM
230
+        ts_channel_daily
231
+        WHERE
232
+        channel_id = #{channelId}
233
+        AND org_id = #{orgId}
234
+        <if test="startDate != null and endDate != null">
235
+            AND statis_date BETWEEN #{startDate} AND #{endDate}
236
+        </if>
237
+        <if test="channelType != null and channelType != ''">
238
+            and target_type = #{channelType}
239
+        </if>
240
+        <if test="buildingId != null and buildingId != ''">
241
+            and building_id = #{buildingId}
242
+        </if>
243
+    </select>
244
+    <select id="getChannelNewuserListExport"
245
+            resultType="com.huiju.estateagents.excel.ActivityStatistics.ChannelAddRegistNum">
246
+        SELECT
247
+        a.nickname, a.phone,
248
+        if(a.gender = '1', '男', if(a.gender = '2', '女','未知') ) as gender,
249
+        a.province,
250
+        t.create_date
251
+        FROM ta_customer_from t
252
+        left join ta_person a on t.person_id = a.person_id
253
+        <!--        left join ta_person_from_record b on a.person_id = b.person_id and b.org_id = #{orgId} and b.is_first_time =1-->
254
+        <!--        left join td_wx_dict b1 on b.scene_id = b1.scene_id-->
255
+        <!--        left join ta_recommend_customer c on c.person_id = t.person_id and c.realty_consultant is not null-->
256
+        <!--        LEFT JOIN ta_user d ON c.realty_consultant = d.user_id-->
257
+        <!--        LEFT JOIN ta_person e ON t.share_person_id = e.person_id-->
258
+        WHERE t.org_id = #{orgId}
259
+        and t.is_org_first = 1
260
+        <!--        and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d' ) and t.create_date &lt;= DATE_FORMAT(#{endDate},-->
261
+        <!--        '%Y-%m-%d' )-->
262
+        <if test="activityId != null and activityId != ''">
263
+            and t.target_id = #{activityId}
264
+        </if>
265
+        <if test="activityType != null and activityType != ''">
266
+            and t.target_type = #{activityType}
267
+        </if>
268
+        <if test="buildingId != null and buildingId != ''">
269
+            and t.building_id = #{buildingId}
270
+        </if>
271
+        <if test="channelId != null and channelId != ''">
272
+            and t.channel_id = #{channelId}
273
+        </if>
274
+        group by t.person_id order by t.create_date desc
275
+    </select>
276
+    <select id="getChannelVisitNumListExport"
277
+            resultType="com.huiju.estateagents.excel.ActivityStatistics.ChannelVisitNum">
278
+        select
279
+        a.nickname, a.phone,
280
+        if(a.gender = '1', '男', if(a.gender = '2', '女','未知') ) as gender,
281
+        a.province,
282
+        b1.scene_alias as personFrom,
283
+        GROUP_CONCAT(d.user_name) as realtyConsultant,
284
+        GROUP_CONCAT(d.phone) as realtyConsultantPhone,
285
+        e.nickname as sharePersonName,
286
+        e.phone as sharePersonPhone,
287
+        t.visit_time as visitDate
288
+        From (
289
+        SELECT
290
+        t.person_id, t.visit_time, t.share_person_id
291
+        FROM
292
+        ta_person_visit_record t
293
+        WHERE
294
+        t.`event` = 'detail'
295
+        AND t.event_type IN (
296
+        'activity',
297
+        'help',
298
+        'group',
299
+        'h5'
300
+        )
301
+        <if test="targetId != null and targetId != ''">
302
+            and t.target_id = #{targetId}
303
+        </if>
304
+        <if test="targetType != null and targetType != ''">
305
+            and (case when #{targetType} = 'activity' then t.target_type = 'dynamic' when #{targetType} = 'h5' then t.event_type = 'h5' else t.target_type = #{targetType}
306
+            end)
307
+        </if>
308
+        <if test="channelId != null and channelId != ''">
309
+            and t.channel_id = #{channelId}
310
+        </if>
311
+        <if test="buildingId != null and buildingId != ''">
312
+            and t.building_id = #{buildingId}
313
+        </if>
314
+        AND t.org_id = #{orgId}
315
+        <!--        AND t.visit_time >= DATE_FORMAT(#{startDate}, '%Y-%m-%d')-->
316
+        <!--        AND t.visit_time &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')-->
317
+        ) t
318
+        left join ta_person a on t.person_id = a.person_id
319
+        left join ta_person_from_record b on a.person_id = b.person_id and b.org_id = #{orgId}
320
+        left join td_wx_dict b1 on b.scene_id = b1.scene_id
321
+        LEFT JOIN ta_recommend_customer c on c.person_id = t.person_id
322
+        left join ta_user d on c.realty_consultant = d.user_id
323
+        left join ta_person e on t.share_person_id = e.person_id
324
+        group by t.visit_time
325
+        order by t.visit_time desc
326
+    </select>
327
+    <select id="getChannelPersonNumListExport"
328
+            resultType="com.huiju.estateagents.excel.ActivityStatistics.ChannelVisitPersonNum">
329
+        select
330
+        a.nickname, a.phone,
331
+        if(a.gender = '1', '男', if(a.gender = '2', '女','未知') ) as gender,
332
+        a.province,
333
+        b1.scene_alias as personFrom,
334
+        GROUP_CONCAT(d.user_name) as realtyConsultant,
335
+        GROUP_CONCAT(d.phone) as realtyConsultantPhone,
336
+        t.create_date as visitDate,
337
+        e.nickName as sharePersonName,
338
+        t.visitNum
339
+        from (
340
+        SELECT
341
+        t.visit_time AS create_date,
342
+        t.person_id,
343
+        count(*) as visitNum
344
+        FROM
345
+        ta_person_visit_record t
346
+        WHERE
347
+        t.`event` = 'detail'
348
+        AND t.event_type IN (
349
+        'activity',
350
+        'help',
351
+        'group',
352
+        'h5'
353
+        )
354
+        AND t.org_id = #{orgId}
355
+        <!--        AND t.visit_time >= DATE_FORMAT(#{startDate}, '%Y-%m-%d')-->
356
+        <!--        AND t.visit_time &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')-->
357
+        <if test="targetId != null and targetId != ''">
358
+            and t.target_id = #{targetId}
359
+        </if>
360
+        <if test="targetType != null and targetType != ''">
361
+            and (case when #{targetType} = 'activity' then t.target_type = 'dynamic' when #{targetType} = 'h5' then t.event_type = 'h5' else t.target_type = #{targetType}
362
+            end)
363
+        </if>
364
+        <if test="buildingId != null and buildingId != ''">
365
+            and t.building_id = #{buildingId}
366
+        </if>
367
+        <if test="channelId != null and channelId != ''">
368
+            and t.channel_id = #{channelId}
369
+        </if>
370
+        GROUP BY
371
+        t.person_id ) as t
372
+        left join ta_person a on t.person_id = a.person_id
373
+        left join ta_person_from_record b on a.person_id = b.person_id and b.org_id = #{orgId} and b.is_first_time = 1
374
+        left join td_wx_dict b1 on b.scene_id = b1.scene_id
375
+        LEFT JOIN ta_recommend_customer c on c.person_id = t.person_id
376
+        left join ta_user d on c.realty_consultant = d.user_id
377
+        LEFT JOIN ta_person e ON e.person_id = b.share_person_id
378
+        group by t.person_id
379
+        order by t.create_date desc
380
+    </select>
225 381
 
226 382
 </mapper>