Преглед на файлове

Merge remote-tracking branch 'origin/dev' into dev

顾绍勇 преди 5 години
родител
ревизия
49bbf2c97a
променени са 19 файла, в които са добавени 644 реда и са изтрити 121 реда
  1. 2
    0
      src/main/java/com/huiju/estateagents/base/BaseController.java
  2. 1
    1
      src/main/java/com/huiju/estateagents/controller/ExtendContentController.java
  3. 35
    18
      src/main/java/com/huiju/estateagents/controller/MiniAppController.java
  4. 97
    0
      src/main/java/com/huiju/estateagents/controller/TaChannelController.java
  5. 5
    0
      src/main/java/com/huiju/estateagents/controller/TaPersonController.java
  6. 3
    0
      src/main/java/com/huiju/estateagents/entity/TaBuilding.java
  7. 9
    0
      src/main/java/com/huiju/estateagents/entity/TaCustomerFrom.java
  8. 10
    0
      src/main/java/com/huiju/estateagents/entity/TaPerson.java
  9. 35
    35
      src/main/java/com/huiju/estateagents/excel/ActivityStatistics/ChannelVisitNum.java
  10. 28
    28
      src/main/java/com/huiju/estateagents/excel/ActivityStatistics/ChannelVisitPersonNum.java
  11. 51
    0
      src/main/java/com/huiju/estateagents/excel/ActivityStatistics/TsChannelDaily.java
  12. 9
    0
      src/main/java/com/huiju/estateagents/mapper/TaChannelMapper.java
  13. 6
    5
      src/main/java/com/huiju/estateagents/service/ITaPersonService.java
  14. 51
    0
      src/main/java/com/huiju/estateagents/service/TaChannelService.java
  15. 15
    1
      src/main/java/com/huiju/estateagents/service/impl/TaBuildingServiceImpl.java
  16. 63
    4
      src/main/java/com/huiju/estateagents/service/impl/TaChannelServiceImpl.java
  17. 46
    17
      src/main/java/com/huiju/estateagents/service/impl/TaPersonServiceImpl.java
  18. 156
    0
      src/main/resources/mapper/TaChannelMapper.xml
  19. 22
    12
      src/main/resources/mapper/statistic/TsPersonFromStatisticMapper.xml

+ 2
- 0
src/main/java/com/huiju/estateagents/base/BaseController.java Целия файл

@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
10 10
 
11 11
 import javax.servlet.http.HttpServletRequest;
12 12
 import java.util.ArrayList;
13
+import java.util.Enumeration;
13 14
 import java.util.List;
14 15
 import java.util.Map;
15 16
 
@@ -140,3 +141,4 @@ public class BaseController {
140 141
         return taPersonBuildingList;
141 142
     }
142 143
 }
144
+

+ 1
- 1
src/main/java/com/huiju/estateagents/controller/ExtendContentController.java Целия файл

@@ -252,7 +252,7 @@ public class ExtendContentController extends BaseController {
252 252
             //一个城市只能有一个开屏广告
253 253
             boolean existFlag = iExtendContentService.advertistExistFlag(extendContent, getOrgId(request));
254 254
             if (!existFlag){
255
-                responseBean.addError("该城市已有开屏广告,请勿再次上架");
255
+                responseBean.addError("该发布位置已有开屏广告,请勿再次上架");
256 256
                 return responseBean;
257 257
             }
258 258
 

+ 35
- 18
src/main/java/com/huiju/estateagents/controller/MiniAppController.java Целия файл

@@ -12,6 +12,7 @@ import com.huiju.estateagents.center.taUser.entity.TaUser;
12 12
 import com.huiju.estateagents.center.taUser.service.ITaUserService;
13 13
 import com.huiju.estateagents.common.CommConstant;
14 14
 import com.huiju.estateagents.common.JWTUtils;
15
+import com.huiju.estateagents.common.StringUtils;
15 16
 import com.huiju.estateagents.drainage.entity.TaDrainage;
16 17
 import com.huiju.estateagents.drainage.service.ITaDrainageService;
17 18
 import com.huiju.estateagents.entity.*;
@@ -22,7 +23,6 @@ import com.huiju.estateagents.service.*;
22 23
 import com.huiju.estateagents.third.service.ITaThirdPartyMiniappConfigService;
23 24
 import me.chanjar.weixin.common.error.WxErrorException;
24 25
 import org.apache.commons.collections.CollectionUtils;
25
-import org.apache.commons.lang3.StringUtils;
26 26
 import org.apache.http.HttpStatus;
27 27
 import org.slf4j.Logger;
28 28
 import org.slf4j.LoggerFactory;
@@ -194,10 +194,10 @@ public class MiniAppController extends BaseController {
194 194
             HttpServletRequest request) {
195 195
         String appid = request.getHeader("appid");
196 196
 
197
-        if (StringUtils.isBlank(code)) {
197
+        if (StringUtils.isEmpty(code)) {
198 198
             return ResponseBean.error("参数 code 不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
199 199
         }
200
-        if (StringUtils.isBlank(appid)) {
200
+        if (StringUtils.isEmpty(appid)) {
201 201
             return ResponseBean.error("Header 参数 appid 不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
202 202
         }
203 203
 
@@ -254,8 +254,8 @@ public class MiniAppController extends BaseController {
254 254
             // 增加积分线程 --- 3.5.23版本授权手机分享者增加积分,单纯分享不增加积分
255 255
 //            ExecutorService threadPool = Executors.newCachedThreadPool();
256 256
 //            threadPool.execute(() -> {
257
-////                if (null != from && from.contains("share") && !com.huiju.estateagents.common.StringUtils.isEmpty(recommender) && count > 0) {
258
-//                if (null != from && from.contains("share") && !com.huiju.estateagents.common.StringUtils.isEmpty(recommender)) {
257
+////                if (null != from && from.contains("share") && !StringUtils.isEmpty(recommender) && count > 0) {
258
+//                if (null != from && from.contains("share") && !StringUtils.isEmpty(recommender)) {
259 259
 //                    // 校验是否点击过此人的分享
260 260
 //                    boolean checkPoint = checkSharePersonFrom(from, taPerson.getPersonId(), targetId, orgId);
261 261
 //                    if (checkPoint) {
@@ -265,7 +265,7 @@ public class MiniAppController extends BaseController {
265 265
 //                }
266 266
 //            });
267 267
 
268
-            if (StringUtils.isNotBlank(from) && StringUtils.isNotBlank(recommender) && StringUtils.isNotBlank(targetId)) {
268
+            if (!StringUtils.isEmpty(from) && !StringUtils.isEmpty(recommender) && !StringUtils.isEmpty(targetId)) {
269 269
                 TaSharePersonFrom taSharePersonFrom = new TaSharePersonFrom();
270 270
                 TaPerson recommenderPerson = taPersonService.getById(recommender);
271 271
                 taSharePersonFrom.setCreateDate(LocalDateTime.now());
@@ -486,7 +486,7 @@ public class MiniAppController extends BaseController {
486 486
     /**
487 487
      * 获取用户绑定手机号信息
488 488
      */
489
-    @PostMapping("/userPhone")
489
+    @PostMapping("Phone")
490 490
     public ResponseBean phone(@RequestBody String paramStr, HttpServletRequest request) {
491 491
         String appid = request.getHeader("appid");
492 492
         JSONObject params = JSONObject.parseObject(paramStr);
@@ -502,19 +502,25 @@ public class MiniAppController extends BaseController {
502 502
         // 楼盘ID
503 503
         String buildingId = params.getString("buildingId");
504 504
         // 场景ID
505
-        String sceneId = params.getString("sceneId");
505
+        String sceneId = StringUtils.ifNull(params.getString("sceneId"), request.getHeader("x-sceneId"));
506 506
         // 访问目标
507
-        String targetType = params.getString("targetType");
507
+        String targetType = StringUtils.ifNull(params.getString("targetType"), request.getHeader("x-targetType"));
508 508
         // 目标ID
509
-        String targetId = params.getString("targetId");
509
+        String targetId = StringUtils.ifNull(params.getString("targetId"), request.getHeader("x-targetId"));
510 510
         // 目标名称
511
-        String targetName = params.getString("targetName");
511
+        String targetName = StringUtils.ifNull(params.getString("targetName"), request.getHeader("x-targetName"));
512 512
         // 推广用户
513
-        String promoter = params.getString("promoter");
513
+        String promoter = StringUtils.ifNull(params.getString("promoter"), request.getHeader("x-recommender"));
514
+        // 置业顾问
515
+        String consultantPersonId = request.getHeader("x-consultant");
516
+        // 渠道ID
517
+        String channelId = params.getString("channelId");
518
+        // 推广码ID
519
+        String qrCodeId = params.getString("qrCodeId");
514 520
 
515 521
         // 解密
516 522
         WxMaPhoneNumberInfo phoneNoInfo = miniAppService.getPhoneNoInfo(sessionKey, encryptedData, iv, appid);
517
-        if (null == phoneNoInfo || com.huiju.estateagents.common.StringUtils.isEmpty(phoneNoInfo.getPhoneNumber())) {
523
+        if (null == phoneNoInfo || StringUtils.isEmpty(phoneNoInfo.getPhoneNumber())) {
518 524
             ResponseBean.error("解析用户手机号码出错", ResponseBean.ERROR_UNAVAILABLE);
519 525
         }
520 526
 
@@ -522,17 +528,28 @@ public class MiniAppController extends BaseController {
522 528
         Integer orgId = getOrgId(request);
523 529
         String phone = phoneNoInfo.getPhoneNumber();
524 530
 
531
+        TaCustomerFrom customerFrom = new TaCustomerFrom();
532
+        customerFrom.setTargetType(targetType);
533
+        customerFrom.setTargetId(targetId);
534
+        customerFrom.setTargetName(targetName);
535
+        customerFrom.setOrgId(orgId);
536
+        customerFrom.setSceneId(sceneId);
537
+        if (!StringUtils.isEmpty(channelId)) {
538
+            customerFrom.setChannelId(Integer.valueOf(channelId));
539
+        }
540
+        if (!StringUtils.isEmpty(qrCodeId)) {
541
+            customerFrom.setQrCodeId(Integer.valueOf(qrCodeId));
542
+        }
543
+
525 544
         try {
526 545
             taPersonService.authPhone(
527 546
                     orgId,
528 547
                     openid,
529 548
                     phone,
530 549
                     buildingId,
531
-                    sceneId,
532
-                    targetType,
533
-                    targetId,
534
-                    targetName,
535
-                    promoter);
550
+                    promoter,
551
+                    consultantPersonId,
552
+                    customerFrom);
536 553
 
537 554
             return ResponseBean.success(phoneNoInfo);
538 555
         } catch (Exception e) {

+ 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
 }

+ 5
- 0
src/main/java/com/huiju/estateagents/controller/TaPersonController.java Целия файл

@@ -783,4 +783,9 @@ public class TaPersonController extends BaseController {
783 783
         return responseBean;
784 784
     }
785 785
 
786
+    @PutMapping("/wx/userInfo/updatePhoto")
787
+    public ResponseBean updateUserPhoto(String photoUrl, HttpServletRequest request){
788
+        String openId = getOpenId(request);
789
+        return taPersonService.updateUserPhoto(photoUrl, openId);
790
+    }
786 791
 }

+ 3
- 0
src/main/java/com/huiju/estateagents/entity/TaBuilding.java Целия файл

@@ -351,4 +351,7 @@ public class TaBuilding implements Serializable {
351 351
 
352 352
     @TableField(exist = false)
353 353
     private List<TaSalesBatch> salesBatch;
354
+
355
+    @TableField(exist = false)
356
+    private List<ExtendContent> extendContent;
354 357
 }

+ 9
- 0
src/main/java/com/huiju/estateagents/entity/TaCustomerFrom.java Целия файл

@@ -140,4 +140,13 @@ public class TaCustomerFrom implements Serializable {
140 140
     @TableField(exist = false)
141 141
     private LocalDateTime registerTime;
142 142
 
143
+    /**
144
+     * 渠道 ID
145
+     */
146
+    private Integer channelId;
147
+
148
+    /**
149
+     * 推广码ID
150
+     */
151
+    private Integer qrCodeId;
143 152
 }

+ 10
- 0
src/main/java/com/huiju/estateagents/entity/TaPerson.java Целия файл

@@ -330,4 +330,14 @@ public class TaPerson implements Serializable {
330 330
      */
331 331
     @TableField(exist = false)
332 332
     private String targetName;
333
+
334
+    /**
335
+     * 渠道 ID
336
+     */
337
+    private Integer channelId;
338
+
339
+    /**
340
+     * 推广码ID
341
+     */
342
+    private Integer qrCodeId;
333 343
 }

+ 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
 }

+ 6
- 5
src/main/java/com/huiju/estateagents/service/ITaPersonService.java Целия файл

@@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.huiju.estateagents.base.ResponseBean;
6 6
 import com.huiju.estateagents.center.taUser.entity.TaUser;
7
+import com.huiju.estateagents.entity.TaCustomerFrom;
7 8
 import com.huiju.estateagents.entity.TaPerson;
8 9
 import com.baomidou.mybatisplus.extension.service.IService;
9 10
 import com.huiju.estateagents.entity.TaPersonBuilding;
@@ -115,9 +116,9 @@ public interface ITaPersonService extends IService<TaPerson> {
115 116
                    String openid,
116 117
                    String phone,
117 118
                    String buildingId,
118
-                   String sceneId,
119
-                   String targetType,
120
-                   String targetId,
121
-                   String targetName,
122
-                   String promoter) throws Exception;
119
+                   String promoter,
120
+                   String consultantPersonId,
121
+                   TaCustomerFrom customerFrom) throws Exception;
122
+
123
+    ResponseBean updateUserPhoto(String photoUrl, String openId);
123 124
 }

+ 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
 }

+ 15
- 1
src/main/java/com/huiju/estateagents/service/impl/TaBuildingServiceImpl.java Целия файл

@@ -123,6 +123,9 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
123 123
     @Autowired
124 124
     private ITaRaiseInviteService iTaRaiseInviteService;
125 125
 
126
+    @Autowired
127
+    private IExtendContentService iExtendContentService;
128
+
126 129
     @Override
127 130
     public ResponseBean buildingList(Integer pageNum, Integer pageSize, String name, String code, LocalDateTime startDate, String buildingStatus, String marketStatus, Integer cityId, Integer isMain, Integer orgId, List<TaPersonBuilding> taPersonBuildingList) {
128 131
         Page<TaBuilding> page = new Page<>();
@@ -227,7 +230,7 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
227 230
     }
228 231
 
229 232
     @Override
230
-    public ResponseBean buildingAllSelectId(String id, TaPerson person, Integer orgId) {
233
+    public ResponseBean      buildingAllSelectId(String id, TaPerson person, Integer orgId) {
231 234
         // 查询基础信息
232 235
         QueryWrapper<TaBuilding> buildingtWrapper = new QueryWrapper<>();
233 236
         buildingtWrapper.lambda().gt(TaBuilding::getStatus, -1);
@@ -343,6 +346,17 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
343 346
         salesBatchQueryWrapper.lambda().eq(TaSalesBatch::getStatus, CommConstant.STATUS_NORMAL);
344 347
         List<TaSalesBatch> taSalesBatch = iTaSalesBatchService.list(salesBatchQueryWrapper);
345 348
 
349
+        // 查询关联项目的开屏广告
350
+        QueryWrapper<ExtendContent> taExtendContentQueryWrapper = new QueryWrapper<>();
351
+        taExtendContentQueryWrapper.eq("status", CommConstant.STATUS_NORMAL);
352
+        taExtendContentQueryWrapper.eq("building_id", id);
353
+        taExtendContentQueryWrapper.eq("org_id", orgId);
354
+        taExtendContentQueryWrapper.eq("show_type", CommConstant.OPEN_SCREEN);
355
+        taExtendContentQueryWrapper.eq("show_position", CommConstant.BANNER_BUILDING);
356
+        List<ExtendContent> taExtendContents = iExtendContentService.list(taExtendContentQueryWrapper);
357
+        building.setExtendContent(taExtendContents);
358
+
359
+
346 360
         List<TaSalesBatch> resultSalesBatchList = new ArrayList<>();
347 361
         taSalesBatch.stream().forEach(record -> {
348 362
             // 查询批次下认筹是否开启邀请制

+ 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
 }

+ 46
- 17
src/main/java/com/huiju/estateagents/service/impl/TaPersonServiceImpl.java Целия файл

@@ -1,5 +1,6 @@
1 1
 package com.huiju.estateagents.service.impl;
2 2
 
3
+import ch.qos.logback.core.pattern.util.RegularEscapeUtil;
3 4
 import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
4 5
 import com.alibaba.fastjson.JSONObject;
5 6
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -880,66 +881,76 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
880 881
      * @param openid
881 882
      * @param phone
882 883
      * @param buildingId
883
-     * @param sceneId
884
-     * @param targetType
885
-     * @param targetId
886
-     * @param targetName
887 884
      * @param promoter
885
+     * @param customerFrom
888 886
      * @throws Exception
889 887
      */
890 888
     @Override
891
-    public void authPhone(Integer orgId, String openid, String phone, String buildingId, String sceneId, String targetType, String targetId, String targetName, String promoter) throws Exception {
892
-        log.info("orgId={},openid={},phone={},buildingId={},sceneId={},targetType={},targetId={},targetName={},promoter={}",
893
-                orgId,openid,phone,buildingId,sceneId,targetType,targetId,targetName,promoter);
889
+    public void authPhone(Integer orgId,
890
+                          String openid,
891
+                          String phone,
892
+                          String buildingId,
893
+                          String promoter,
894
+                          String consultantPersonId,
895
+                          TaCustomerFrom customerFrom) throws Exception {
896
+        log.info("orgId={},openid={},phone={},buildingId={},promoter={}, customerFrom={}",
897
+                orgId,openid,phone,buildingId,promoter, JSONObject.toJSONString(customerFrom));
894 898
         //
895 899
         LocalDateTime now = LocalDateTime.now();
896 900
 
897
-        // 更新人员手机号
901
+        // 当前人员
898 902
         List<TaPerson> persons = getPersonsByOpenId(openid);
899 903
         if (null == persons || persons.size() != 1) {
900 904
             throw new Exception("当前人员 openid 异常");
901 905
         }
902 906
         TaPerson person = persons.get(0);
907
+        // 更新手机号
903 908
         person.setPhone(phone);
909
+        // 更新授权时间
904 910
         person.setAuthPhoneTime(now);
905 911
         if (StringUtils.isEmpty(person.getBuildingId())) {
912
+            // 更新楼盘
906 913
             person.setBuildingId(buildingId);
907 914
         }
908 915
         if (CommConstant.PERSON_ESTATE_DRIFT.equals(person.getPersonType())) {
916
+            // 更新人员身份
909 917
             person.setPersonType(CommConstant.PERSON_ESTATE_CUSTOMER);
910 918
         }
919
+        if (null != customerFrom.getChannelId() && null == person.getChannelId()) {
920
+            // 更新渠道
921
+            person.setChannelId(customerFrom.getChannelId());
922
+        }
923
+        if (null != customerFrom.getQrCodeId() && null == person.getQrCodeId()) {
924
+            // 更新推广码
925
+            person.setQrCodeId(customerFrom.getQrCodeId());
926
+        }
911 927
         updateById(person);
912 928
 
913 929
         // 关联推荐客户
914 930
         fixCustomerPersonId(person);
915 931
 
916 932
         // 客户来源
917
-        TaCustomerFrom customerFrom = new TaCustomerFrom();
918 933
         customerFrom.setPersonId(person.getPersonId());
919 934
         customerFrom.setPersonName(StringUtils.ifNull(person.getName(), person.getNickname()));
920
-        customerFrom.setTargetType(targetType);
921
-        customerFrom.setTargetId(targetId);
922
-        customerFrom.setTargetName(targetName);
923
-        customerFrom.setOrgId(orgId);
924
-        customerFrom.setSceneId(sceneId);
925 935
         customerFrom.setCreateDate(now);
926 936
 
927 937
         // 推广人
928 938
         TaPerson recPerson = StringUtils.isEmpty(promoter) ? null : taPersonMapper.getById(promoter);
929 939
         // 推荐楼盘
930 940
         TaBuilding building = StringUtils.isEmpty(buildingId) ? null : taBuildingMapper.selectById(buildingId);
931
-        // 是否置业顾问
941
+        // 置业顾问
932 942
         boolean isConsultant = null != recPerson && CommConstant.PERSON_REALTY_CONSULTANT.equals(recPerson.getPersonType());
943
+        TaPerson consultant = null != consultantPersonId ? getById(consultantPersonId) : (isConsultant ? recPerson : null);
933 944
 
934 945
         try {
935
-            List<TaRecommendCustomer> customerList = iTaRecommendCustomerService.newCustomer(orgId, person, recPerson, isConsultant ? recPerson : null, building, customerFrom);
946
+            List<TaRecommendCustomer> customerList = iTaRecommendCustomerService.newCustomer(orgId, person, recPerson, consultant, building, customerFrom);
936 947
             if (customerList.size() > 0) {
937 948
                 // 发放积分
938 949
                 applicationContext.publishEvent(new EventBus(person, EventBus.EventType.SignUpAgent, orgId));
939 950
 
940 951
                 //授权手机给推广人加积分
941 952
                 String sharePersonId = getSharePersonFrom(person);
942
-                if (validateSceneId(sceneId) && !StringUtils.isEmpty(sharePersonId)){
953
+                if (validateSceneId(customerFrom.getSceneId()) && !StringUtils.isEmpty(sharePersonId)){
943 954
                     applicationContext.publishEvent(new EventBus(promoter != null ? promoter : sharePersonId, EventBus.EventType.SharePosterAll, orgId));
944 955
                 }
945 956
             }
@@ -1255,4 +1266,22 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
1255 1266
     }
1256 1267
 
1257 1268
 
1269
+    @Override
1270
+    public ResponseBean updateUserPhoto(String photoUrl, String openId) {
1271
+        ResponseBean responseBean = new ResponseBean();
1272
+
1273
+        List<TaPerson> taPersons = getPersonsByOpenId(openId);
1274
+        if (null == taPersons || taPersons.size() != 1) {
1275
+            return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
1276
+        }
1277
+
1278
+        TaPerson taPerson = taPersons.get(0);
1279
+        TaUser taUser = new TaUser();
1280
+        taUser.setUserId(taPerson.getUserId());
1281
+        taUser.setPhoto(photoUrl);
1282
+
1283
+        taUserMapper.updateById(taUser);
1284
+        responseBean.addSuccess("修改成功");
1285
+        return responseBean;
1286
+    }
1258 1287
 }

+ 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>

+ 22
- 12
src/main/resources/mapper/statistic/TsPersonFromStatisticMapper.xml Целия файл

@@ -47,29 +47,38 @@
47 47
     </select>
48 48
     <select id="selectPersonFromGroupByData"
49 49
             resultType="com.huiju.estateagents.statistic.entity.TsPersonFromStatistic">
50
+        select ifnull(tp.from_num, 0) as from_num , ifnull(tp.registered_num, 0) AS registered_num , ifnull(tp.create_time, date.date) AS create_time, ifnull(tp.scene_type, 'other') as scene_type from (
51
+
50 52
         SELECT
51
-        sum( tp.from_num ) AS from_num,
52
-        sum( tp.registered_num ) AS registered_num,
53
-        DATE_FORMAT( tp.create_date, '%Y-%m-%d' ) AS create_time,
54
-        tp.scene_type
55
-        FROM
56
-        ts_person_from_statistic tp
57
-        WHERE
58
-        tp.org_id = #{orgId}
53
+        DATE_FORMAT(
54
+        DATE_ADD( STR_TO_DATE(#{startDate}, '%Y-%m-%d' ), INTERVAL rownum DAY ), '%Y-%m-%d' ) AS date
55
+        FROM sequence
56
+        WHERE rownum &lt; DATEDIFF(STR_TO_DATE( #{endDate}, '%Y-%m-%d' ), STR_TO_DATE( #{startDate}, '%Y-%m-%d' )) ) as date
57
+
58
+        left join (SELECT sum( tp.from_num ) AS from_num, sum( tp.registered_num ) AS registered_num, DATE_FORMAT( tp.create_date, '%Y-%m-%d' ) AS create_time, tp.scene_type
59
+        FROM ts_person_from_statistic tp
60
+        WHERE tp.org_id = #{orgId}
59 61
         <if test="startDate != null or endDate != null">
60 62
             AND  DATE_FORMAT( tp.create_date, '%Y-%m-%d' ) BETWEEN #{startDate} and #{endDate}
61 63
         </if>
62 64
         <if test="startDate == null or endDate == null">
63 65
             AND DATE_FORMAT( tp.create_date, '%Y-%m-%d' ) BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
64 66
         </if>
65
-        GROUP BY
66
-        DATE_FORMAT( tp.create_date, '%Y-%m-%d' ),
67
-        tp.scene_type
68
-        ORDER BY tp.create_date
67
+        GROUP BY DATE_FORMAT( tp.create_date, '%Y-%m-%d' ), tp.scene_type ORDER BY tp.create_date
68
+        ) as tp on date.date = tp.create_time
69
+
69 70
     </select>
70 71
     <select id="selectNewLinePersonFromGroupByData"
71 72
             resultType="com.huiju.estateagents.statistic.entity.TsPersonFromStatistic">
73
+        select ifnull(tp.from_num, 0) as from_num , ifnull(tp.registered_num, 0) AS registered_num , ifnull(tp.create_time, date.date) AS create_time, ifnull(tp.scene_type, 'other') as scene_type from (
74
+
72 75
         SELECT
76
+        DATE_FORMAT(
77
+        DATE_ADD( STR_TO_DATE(#{startDate}, '%Y-%m-%d' ), INTERVAL rownum DAY ), '%Y-%m-%d' ) AS date
78
+        FROM sequence
79
+        WHERE rownum &lt; DATEDIFF(STR_TO_DATE( #{endDate}, '%Y-%m-%d' ), STR_TO_DATE( #{startDate}, '%Y-%m-%d' )) ) as date
80
+
81
+        left join (SELECT
73 82
         sum( tp.from_num ) AS from_num,
74 83
         sum( tp.registered_num ) AS registered_num,
75 84
         DATE_FORMAT( tp.create_date, '%Y-%m-%d' ) AS create_time,
@@ -89,5 +98,6 @@
89 98
         GROUP BY
90 99
         DATE_FORMAT( tp.create_date, '%Y-%m-%d' )
91 100
         ORDER BY tp.create_date
101
+        ) as tp on date.date = tp.create_time
92 102
     </select>
93 103
 </mapper>