Parcourir la source

Merge branch 'dev' of http://git.ycjcjy.com/zhiyuxing/estateagents into dev

张延森 il y a 5 ans
Parent
révision
57f7abae7c

+ 44
- 0
src/main/java/com/huiju/estateagents/bo/request/ActivityStatisticResponseBO.java Voir le fichier

@@ -0,0 +1,44 @@
1
+package com.huiju.estateagents.bo.request;
2
+
3
+import lombok.Data;
4
+
5
+/**
6
+ * 活动统计返回实体
7
+ *
8
+ * @author gusy
9
+ * @date 2020/4/26 13:15
10
+ */
11
+@Data
12
+public class ActivityStatisticResponseBO {
13
+
14
+    /**
15
+     * 活动分享人数
16
+     */
17
+    private Integer sharePersons;
18
+
19
+    /**
20
+     * 活动分享次数
21
+     */
22
+    private Integer shareNum;
23
+
24
+    /**
25
+     * 活动访问人数
26
+     */
27
+    private Integer visitPersons;
28
+
29
+    /**
30
+     * 活动访问次数
31
+     */
32
+    private Integer visitNum;
33
+
34
+    /**
35
+     * 分享新增用户
36
+     */
37
+    private Integer newPersons;
38
+
39
+    /**
40
+     * 分享新增客户
41
+     */
42
+    private Integer newCustomers;
43
+
44
+}

+ 65
- 0
src/main/java/com/huiju/estateagents/controller/ActivityManageController.java Voir le fichier

@@ -0,0 +1,65 @@
1
+package com.huiju.estateagents.controller;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.huiju.estateagents.base.BaseController;
5
+import com.huiju.estateagents.base.ResponseBean;
6
+import com.huiju.estateagents.service.impl.ActivityManageServiceImpl;
7
+import org.apache.commons.lang3.StringUtils;
8
+import org.slf4j.Logger;
9
+import org.slf4j.LoggerFactory;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.stereotype.Controller;
12
+import org.springframework.web.bind.annotation.RequestMapping;
13
+import org.springframework.web.bind.annotation.RequestMethod;
14
+import org.springframework.web.bind.annotation.ResponseBody;
15
+
16
+import javax.servlet.http.HttpServletRequest;
17
+
18
+/**
19
+ * 活动管理
20
+ *
21
+ * @author gusy
22
+ * @date 2020/4/26 10:42
23
+ */
24
+@Controller
25
+@RequestMapping("/api")
26
+public class ActivityManageController extends BaseController {
27
+
28
+    private Logger logger = LoggerFactory.getLogger(ActivityManageController.class);
29
+
30
+    @Autowired
31
+    private ActivityManageServiceImpl activityManageService;
32
+
33
+    /**
34
+     * 根据类型获取统计数据
35
+     *
36
+     * @param type 报名活动:activity、
37
+     *             H5:h5、
38
+     *             助力:help、
39
+     *             拼团:group、
40
+     *             直播:live
41
+     * @return
42
+     */
43
+    @RequestMapping(value = "/admin/activityManage/getStatisticData", method = RequestMethod.GET)
44
+    @ResponseBody
45
+    public ResponseBean getStatisticDataByType(String type, String id, HttpServletRequest request) {
46
+        logger.info("getStatisticDataByType 接收参数:type:{},id:{}", type, id);
47
+
48
+        ResponseBean responseBean = new ResponseBean();
49
+
50
+        // 校验参数
51
+        if (StringUtils.isBlank(type) || StringUtils.isBlank(id)) {
52
+            responseBean.addError("参数错误");
53
+            return responseBean;
54
+        }
55
+
56
+        try {
57
+            responseBean = activityManageService.getStatisticDataByType(type, id,getOrgId(request));
58
+            logger.info("getStatisticDataByType 返回结果:{}", JSONObject.toJSONString(responseBean));
59
+        } catch (Exception e) {
60
+            logger.error("异常:", e);
61
+            responseBean.addError(e.getMessage());
62
+        }
63
+        return responseBean;
64
+    }
65
+}

+ 1
- 0
src/main/java/com/huiju/estateagents/controller/TdPointsRulesController.java Voir le fichier

@@ -118,6 +118,7 @@ public class TdPointsRulesController extends BaseController {
118 118
             queryWrapper.eq(StringUtils.isNotBlank(buildingId),"building_id", buildingId);
119 119
             Integer orgId = getOrgId(request);
120 120
             queryWrapper.eq(orgId != null,"org_id",orgId);
121
+            queryWrapper.eq("status", CommConstant.STATUS_NORMAL);
121 122
             if(null != type){
122 123
                 if (CommConstant.POINTS_RULE_PLATFORM.equals(type)) {
123 124
                     queryWrapper.isNull("building_id");

+ 6
- 6
src/main/java/com/huiju/estateagents/excel/ActivityStatistics/ShareNum.java Voir le fichier

@@ -37,12 +37,12 @@ public class ShareNum {
37 37
     @ExcelProperty(value = "分享时间", index = 3)
38 38
     private String shareTime;
39 39
 
40
-    /**
41
-     * 访问人数
42
-     */
43
-    @ColumnWidth(15)
44
-    @ExcelProperty(value = "访问人数", index = 4)
45
-    private Integer visitPersonNum;
40
+//    /**
41
+//     * 访问人数
42
+//     */
43
+//    @ColumnWidth(15)
44
+//    @ExcelProperty(value = "访问人数", index = 4)
45
+//    private Integer visitPersonNum;
46 46
 
47 47
     @ExcelIgnore
48 48
     private String sharePersonId;

+ 18
- 10
src/main/java/com/huiju/estateagents/excel/ActivityStatistics/VisitPersonNum.java Voir le fichier

@@ -56,23 +56,31 @@ public class VisitPersonNum {
56 56
     private String realtyConsultantPhone;
57 57
 
58 58
     /**
59
-     * 分享者
59
+     * 推广人
60 60
      */
61 61
     @ColumnWidth(15)
62
-    @ExcelProperty(value = "分享者", index = 7)
62
+    @ExcelProperty(value = "推广人", index = 7)
63 63
     private String sharePersonName;
64
-
65
-    /**
66
-     * 分享者电话
67
-     */
68
-    @ColumnWidth(15)
69
-    @ExcelProperty(value = "分享者电话", index = 8)
70
-    private String sharePersonPhone;
64
+//    /**
65
+//     * 分享者
66
+//     */
67
+//    @ColumnWidth(15)
68
+//    @ExcelProperty(value = "分享者", index = 7)
69
+//    private String sharePersonName;
70
+//
71
+//    /**
72
+//     * 分享者电话
73
+//     */
74
+//    @ColumnWidth(15)
75
+//    @ExcelProperty(value = "分享者电话", index = 8)
76
+//    private String sharePersonPhone;
71 77
 
72 78
     /**
73 79
      * 访问次数
74 80
      */
75 81
     @ColumnWidth(15)
76
-    @ExcelProperty(value = "访问次数", index = 9)
82
+    @ExcelProperty(value = "访问次数", index = 8)
77 83
     private String visitNum;
84
+
85
+
78 86
 }

+ 41
- 0
src/main/java/com/huiju/estateagents/excel/IntentionUser.java Voir le fichier

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

+ 25
- 0
src/main/java/com/huiju/estateagents/mapper/ActivityManageMapper.java Voir le fichier

@@ -0,0 +1,25 @@
1
+package com.huiju.estateagents.mapper;
2
+
3
+import com.huiju.estateagents.bo.request.ActivityStatisticResponseBO;
4
+import org.apache.ibatis.annotations.Mapper;
5
+import org.apache.ibatis.annotations.Param;
6
+import org.springframework.stereotype.Component;
7
+
8
+/**
9
+ * @author gusy
10
+ * @date 2020/4/26 11:16
11
+ */
12
+@Component
13
+@Mapper
14
+public interface ActivityManageMapper {
15
+
16
+    /**
17
+     * 获取活动统计数据
18
+     *
19
+     * @return
20
+     */
21
+    ActivityStatisticResponseBO getStatisticDataByType(@Param("type") String type,
22
+                                                       @Param("id") String id,
23
+                                                       @Param("orgId") Integer orgId);
24
+
25
+}

+ 1
- 0
src/main/java/com/huiju/estateagents/mapper/TaBuildingDynamicMapper.java Voir le fichier

@@ -3,6 +3,7 @@ package com.huiju.estateagents.mapper;
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.huiju.estateagents.bo.request.ActivityStatisticResponseBO;
6 7
 import com.huiju.estateagents.entity.TaBuildingDynamic;
7 8
 import com.huiju.estateagents.entity.TaPersonBuilding;
8 9
 import org.apache.ibatis.annotations.Mapper;

+ 27
- 0
src/main/java/com/huiju/estateagents/service/IActivityManageService.java Voir le fichier

@@ -0,0 +1,27 @@
1
+package com.huiju.estateagents.service;
2
+
3
+import com.huiju.estateagents.base.ResponseBean;
4
+import com.huiju.estateagents.bo.request.ActivityStatisticResponseBO;
5
+import com.huiju.estateagents.mapper.ActivityManageMapper;
6
+import com.huiju.estateagents.service.impl.ActivityManageServiceImpl;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.stereotype.Service;
9
+
10
+/**
11
+ * @author gusy
12
+ * @date 2020/4/26 11:14
13
+ */
14
+@Service
15
+public class IActivityManageService implements ActivityManageServiceImpl {
16
+
17
+    @Autowired
18
+    private ActivityManageMapper activityManageMapper;
19
+
20
+    @Override
21
+    public ResponseBean getStatisticDataByType(String type, String id,Integer orgId) {
22
+        ResponseBean responseBean = new ResponseBean();
23
+        ActivityStatisticResponseBO responseBO = activityManageMapper.getStatisticDataByType(type, id,orgId);
24
+        responseBean.addSuccess(responseBO);
25
+        return responseBean;
26
+    }
27
+}

+ 12
- 0
src/main/java/com/huiju/estateagents/service/impl/ActivityManageServiceImpl.java Voir le fichier

@@ -0,0 +1,12 @@
1
+package com.huiju.estateagents.service.impl;
2
+
3
+import com.huiju.estateagents.base.ResponseBean;
4
+
5
+/**
6
+ * @author gusy
7
+ * @date 2020/4/26 11:13
8
+ */
9
+public interface ActivityManageServiceImpl {
10
+
11
+    ResponseBean getStatisticDataByType(String type,String id,Integer orgId);
12
+}

+ 142
- 146
src/main/java/com/huiju/estateagents/service/impl/TaRecommendCustomerServiceImpl.java Voir le fichier

@@ -64,7 +64,7 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
64 64
 
65 65
     @Autowired
66 66
     private TdCityMapper cityMapper;
67
-    
67
+
68 68
     @Autowired
69 69
     private TaCustomerFollowUpRecordMapper customerFollowUpRecordMapper;
70 70
 
@@ -217,7 +217,7 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
217 217
     }
218 218
 
219 219
     @Override
220
-    public synchronized ResponseBean recommendCust(String paramStr, String openid,Integer orgId) {
220
+    public synchronized ResponseBean recommendCust(String paramStr, String openid, Integer orgId) {
221 221
         JSONObject params = JSONObject.parseObject(paramStr);
222 222
         if (null == params) {
223 223
             return ResponseBean.error("解析参数失败", ResponseBean.ERROR_ILLEGAL_PARAMS);
@@ -233,8 +233,17 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
233 233
             return ResponseBean.error(checkResult, ResponseBean.ERROR_MISSING_PARAMS);
234 234
         }
235 235
 
236
-        TaRecommendCustomer taRecommendCustomer = new TaRecommendCustomer();
236
+        // 报备有 10 天有效期
237
+        QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
238
+        queryWrapper.eq("phone", params.getString("phone"));
239
+        queryWrapper.eq("building_id", params.getString("intention"));
240
+        queryWrapper.in("verify_status", CommConstant.VERIFY_AGREE, CommConstant.VERIFY_READY);
241
+        List<TaRecommendCustomer> result = taRecommendCustomerMapper.selectList(queryWrapper);
242
+        if (null != result && result.size() > 0) {
243
+            return ResponseBean.error("当前客户已被推荐, 不能再次推荐", ResponseBean.ERROR_ILLEGAL_PARAMS);
244
+        }
237 245
 
246
+        TaRecommendCustomer taRecommendCustomer = new TaRecommendCustomer();
238 247
         taRecommendCustomer.setName(params.getString("name"));
239 248
         taRecommendCustomer.setPicture(params.getString("picture"));
240 249
         taRecommendCustomer.setPhone(params.getString("phone"));
@@ -248,11 +257,11 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
248 257
         taRecommendCustomer.setCreateDate(LocalDateTime.now());
249 258
         taRecommendCustomer.setReportDate(LocalDateTime.now());
250 259
         taRecommendCustomer.setOrgId(orgId);
251
-       QueryWrapper<TaPerson> personQueryWrapper = new QueryWrapper<>();
252
-       personQueryWrapper.eq("org_id",orgId);
253
-       personQueryWrapper.eq("phone",params.getString("phone"));
260
+        QueryWrapper<TaPerson> personQueryWrapper = new QueryWrapper<>();
261
+        personQueryWrapper.eq("org_id", orgId);
262
+        personQueryWrapper.eq("phone", params.getString("phone"));
254 263
         TaPerson currentPerson = taPersonMapper.selectOne(personQueryWrapper);
255
-        if(null != currentPerson){
264
+        if (null != currentPerson) {
256 265
             taRecommendCustomer.setPersonId(currentPerson.getPersonId());
257 266
         }
258 267
 
@@ -277,24 +286,14 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
277 286
 
278 287
         String status = params.getString("status");
279 288
         int statusInt = 0;
280
-        if (StringUtils.isEmpty(status)){
289
+        if (StringUtils.isEmpty(status)) {
281 290
             taRecommendCustomer.setStatus(statusInt);
282
-        }else{
291
+        } else {
283 292
             taRecommendCustomer.setStatus(Integer.parseInt(status));
284 293
         }
285 294
 
286 295
         taRecommendCustomer.setRecommendPerson(taPerson.getPersonId());
287 296
 
288
-        // 报备有 10 天有效期
289
-        QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
290
-        queryWrapper.eq("phone", taRecommendCustomer.getPhone());
291
-        queryWrapper.eq("building_id",taRecommendCustomer.getBuildingId());
292
-        queryWrapper.in("verify_status",CommConstant.VERIFY_AGREE,CommConstant.VERIFY_READY);
293
-        List<TaRecommendCustomer> result = taRecommendCustomerMapper.selectList(queryWrapper);
294
-        if (null != result && result.size() > 0) {
295
-            return ResponseBean.error("当前客户已被推荐, 不能再次推荐", ResponseBean.ERROR_ILLEGAL_PARAMS);
296
-        }
297
-
298 297
         int row = taRecommendCustomerMapper.insert(taRecommendCustomer);
299 298
         if (row < 1) {
300 299
             return ResponseBean.error("推荐客户失败", ResponseBean.ERROR_UNAVAILABLE);
@@ -311,9 +310,8 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
311 310
     }
312 311
 
313 312
 
314
-
315 313
     @Override
316
-    public ResponseBean reportCust(String paramStr, String openid,Integer orgId) {
314
+    public ResponseBean reportCust(String paramStr, String openid, Integer orgId) {
317 315
         JSONObject params = JSONObject.parseObject(paramStr);
318 316
         if (null == params) {
319 317
             return ResponseBean.error("解析参数失败", ResponseBean.ERROR_ILLEGAL_PARAMS);
@@ -367,12 +365,12 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
367 365
 //        taRecommendCustomer.setDescribe(params.getString("describe"));
368 366
         taRecommendCustomer.setRealtyConsultant(consultantUser.getUserId().toString());
369 367
         //如果没有传building_id的情况构造building_id
370
-        if (StringUtils.isEmpty(params.getString("buildingId")) && !StringUtils.isEmpty(params.getString("realtyConsultant"))){
368
+        if (StringUtils.isEmpty(params.getString("buildingId")) && !StringUtils.isEmpty(params.getString("realtyConsultant"))) {
371 369
             QueryWrapper<TaPersonBuilding> taPersonBuildingQueryWrapper = new QueryWrapper<>();
372 370
             taPersonBuildingQueryWrapper.eq("person_id", consultantPerson.getPersonId()).or().eq("user_id", consultantUser.getUserId());
373 371
             List<TaPersonBuilding> taPersonBuildingList = taPersonBuildingMapper.selectList(taPersonBuildingQueryWrapper);
374
-            if (taPersonBuildingList.size() > 0){
375
-                params.put("buildingId",taPersonBuildingList.get(0).getBuildingId());
372
+            if (taPersonBuildingList.size() > 0) {
373
+                params.put("buildingId", taPersonBuildingList.get(0).getBuildingId());
376 374
             }
377 375
         }
378 376
         taRecommendCustomer.setBuildingId(params.getString("buildingId"));
@@ -399,11 +397,11 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
399 397
         taRecommendCustomer.setVerifyStatus(CommConstant.VERIFY_AGREE);
400 398
         taRecommendCustomer.setStatus(CommConstant.CUSTOMER_REPORT);
401 399
         QueryWrapper<TaPerson> personQueryWrapper = new QueryWrapper<>();
402
-        personQueryWrapper.eq("org_id",orgId);
403
-        personQueryWrapper.eq("phone",params.getString("phone"));
400
+        personQueryWrapper.eq("org_id", orgId);
401
+        personQueryWrapper.eq("phone", params.getString("phone"));
404 402
         TaPerson currentPerson = taPersonMapper.selectOne(personQueryWrapper);
405
-        if(null != currentPerson){
406
-            if (currentPerson.getPersonType().equals(CommConstant.PERSON_REALTY_CONSULTANT)){
403
+        if (null != currentPerson) {
404
+            if (currentPerson.getPersonType().equals(CommConstant.PERSON_REALTY_CONSULTANT)) {
407 405
                 return ResponseBean.error("置业顾问不可以绑定置业顾问", ResponseBean.ERROR_ILLEGAL_PARAMS);
408 406
             }
409 407
             taRecommendCustomer.setPersonId(currentPerson.getPersonId());
@@ -419,29 +417,29 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
419 417
         // 报备有 10 天有效期
420 418
         QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
421 419
         queryWrapper.eq("phone", taRecommendCustomer.getPhone());
422
-        queryWrapper.eq("building_id",taRecommendCustomer.getBuildingId());
420
+        queryWrapper.eq("building_id", taRecommendCustomer.getBuildingId());
423 421
         queryWrapper.eq("org_id", taRecommendCustomer.getOrgId());
424
-        queryWrapper.in("verify_status",CommConstant.VERIFY_AGREE,CommConstant.VERIFY_READY);
422
+        queryWrapper.in("verify_status", CommConstant.VERIFY_AGREE, CommConstant.VERIFY_READY);
425 423
         List<TaRecommendCustomer> result = taRecommendCustomerMapper.selectList(queryWrapper);
426 424
         if (null != result && result.size() > 0) {
427 425
             String conName = "";
428 426
             TaPerson conPerson = taPersonMapper.selectById(result.get(0).getRealtyConsultant());
429
-            if (null != conPerson){
430
-                if(null != consultantPerson && consultantPerson.getPersonId().equals(conPerson.getPersonId())){
431
-                   return  ResponseBean.success("bound");
427
+            if (null != conPerson) {
428
+                if (null != consultantPerson && consultantPerson.getPersonId().equals(conPerson.getPersonId())) {
429
+                    return ResponseBean.success("bound");
432 430
                 }
433 431
                 conName = conPerson.getName();
434
-            }else {
432
+            } else {
435 433
                 TaUser conUser = userService.getById(result.get(0).getRealtyConsultant());
436
-                if(null != conUser){
437
-                    if(consultantUser.getUserId().equals(conUser.getUserId())){
434
+                if (null != conUser) {
435
+                    if (consultantUser.getUserId().equals(conUser.getUserId())) {
438 436
                         return ResponseBean.success("bound");
439 437
                     }
440 438
                     conName = conUser.getUserName();
441 439
 
442 440
                 }
443 441
             }
444
-            return ResponseBean.error("您在当前项目的置业顾问是:"+conName, ResponseBean.ERROR_ILLEGAL_PARAMS);
442
+            return ResponseBean.error("您在当前项目的置业顾问是:" + conName, ResponseBean.ERROR_ILLEGAL_PARAMS);
445 443
         }
446 444
 
447 445
         int row = taRecommendCustomerMapper.insert(taRecommendCustomer);
@@ -518,106 +516,104 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
518 516
     }
519 517
 
520 518
 
521
-
522
-
523 519
     List<TaPerson> getPersonsByOpenId(String openid) {
524 520
         return taPersonMapper.getPersonByOpenId(openid);
525 521
     }
526 522
 
527 523
     @Override
528
-    public IPage<TaRecommendCustomer> getUnSignedCustomerList(int pageNumber, int pageSize,String building,String personId){
529
-        QueryWrapper<TaRecommendCustomer>queryWrapper = new QueryWrapper<>();
524
+    public IPage<TaRecommendCustomer> getUnSignedCustomerList(int pageNumber, int pageSize, String building, String personId) {
525
+        QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
530 526
 //        queryWrapper.eq("building_id",building);
531
-        queryWrapper.eq("realty_consultant",personId);
527
+        queryWrapper.eq("realty_consultant", personId);
532 528
         queryWrapper.gt("status", CommConstant.MESSAGE_UNREAD);
533
-        IPage<TaRecommendCustomer>page = new Page<>(pageNumber,pageSize);
534
-        return taRecommendCustomerMapper.selectPage(page,queryWrapper);
529
+        IPage<TaRecommendCustomer> page = new Page<>(pageNumber, pageSize);
530
+        return taRecommendCustomerMapper.selectPage(page, queryWrapper);
535 531
     }
536 532
 
537 533
     @Override
538
-    public IPage getCustomerList(Integer status,int pageNumber, int pageSize,String building,String name,String tel,String consultName,String consultTel,String entryType,String verifyStatus,Integer sex, String customerType, Integer orgId,List<TaPersonBuilding> taPersonBuildingList,String sceneType, String startCreateDate, String endCreateDate){
534
+    public IPage getCustomerList(Integer status, int pageNumber, int pageSize, String building, String name, String tel, String consultName, String consultTel, String entryType, String verifyStatus, Integer sex, String customerType, Integer orgId, List<TaPersonBuilding> taPersonBuildingList, String sceneType, String startCreateDate, String endCreateDate) {
539 535
 
540 536
         if (CommConstant.CUTOMER_TYPE_PUBLIC.equals(customerType)) {
541 537
             // 公客
542
-            IPage<TaPerson>page = new Page<>(pageNumber,pageSize);
538
+            IPage<TaPerson> page = new Page<>(pageNumber, pageSize);
543 539
             // 公客就不用 buildingId 进行查询
544
-            return taRecommendCustomerMapper.getPublicCustomerList(page,name, tel,  entryType, verifyStatus, sex, orgId,consultTel,sceneType, taPersonBuildingList,building, startCreateDate, endCreateDate);
540
+            return taRecommendCustomerMapper.getPublicCustomerList(page, name, tel, entryType, verifyStatus, sex, orgId, consultTel, sceneType, taPersonBuildingList, building, startCreateDate, endCreateDate);
545 541
         } else {
546 542
             // 私客
547
-            IPage<TaRecommendCustomer>page = new Page<>(pageNumber,pageSize);
548
-            return taRecommendCustomerMapper.getCustomerList(page, building, name, tel, consultName, consultTel, entryType, verifyStatus, sex, orgId,status,taPersonBuildingList,sceneType, startCreateDate, endCreateDate);
543
+            IPage<TaRecommendCustomer> page = new Page<>(pageNumber, pageSize);
544
+            return taRecommendCustomerMapper.getCustomerList(page, building, name, tel, consultName, consultTel, entryType, verifyStatus, sex, orgId, status, taPersonBuildingList, sceneType, startCreateDate, endCreateDate);
549 545
         }
550 546
 
551 547
     }
552 548
 
553 549
     @Override
554
-    public IPage<TaPerson> getIndependentAgents(int pageNumber, int pageSize,String name,String tel, Integer orgId){
555
-        IPage<TaPerson>page = new Page<>(pageNumber,pageSize);
556
-        return taRecommendCustomerMapper.getIndependentAgents(page,name,tel, orgId);
550
+    public IPage<TaPerson> getIndependentAgents(int pageNumber, int pageSize, String name, String tel, Integer orgId) {
551
+        IPage<TaPerson> page = new Page<>(pageNumber, pageSize);
552
+        return taRecommendCustomerMapper.getIndependentAgents(page, name, tel, orgId);
557 553
     }
558 554
 
559 555
     @Override
560
-    public IPage<TaRecommendCustomer> getRecCustomerList(int pageNumber, int pageSize,String building,String name,String tel,String consultName,String consultTel,String entryType,String verifyStatus,Integer sex, Integer orgId,List<TaPersonBuilding> taPersonBuildingList){
561
-        IPage<TaRecommendCustomer>page = new Page<>(pageNumber,pageSize);
562
-        return taRecommendCustomerMapper.getRecCustomerList(page,building,name,tel,consultName,consultTel,entryType,verifyStatus,sex, orgId,taPersonBuildingList);
556
+    public IPage<TaRecommendCustomer> getRecCustomerList(int pageNumber, int pageSize, String building, String name, String tel, String consultName, String consultTel, String entryType, String verifyStatus, Integer sex, Integer orgId, List<TaPersonBuilding> taPersonBuildingList) {
557
+        IPage<TaRecommendCustomer> page = new Page<>(pageNumber, pageSize);
558
+        return taRecommendCustomerMapper.getRecCustomerList(page, building, name, tel, consultName, consultTel, entryType, verifyStatus, sex, orgId, taPersonBuildingList);
563 559
     }
564 560
 
565 561
 
566 562
     @Override
567
-    public IPage<TaRecommendCustomer> getRepCustomerList(int pageNumber, int pageSize,String building,String name,String tel,String consultName,String consultTel,String entryType,String verifyStatus,Integer sex, Integer orgId,List<TaPersonBuilding> taPersonBuildingList){
568
-        IPage<TaRecommendCustomer>page = new Page<>(pageNumber,pageSize);
569
-        return taRecommendCustomerMapper.getRepCustomerList(page,building,name,tel,consultName,consultTel,entryType,verifyStatus,sex, orgId,taPersonBuildingList);
563
+    public IPage<TaRecommendCustomer> getRepCustomerList(int pageNumber, int pageSize, String building, String name, String tel, String consultName, String consultTel, String entryType, String verifyStatus, Integer sex, Integer orgId, List<TaPersonBuilding> taPersonBuildingList) {
564
+        IPage<TaRecommendCustomer> page = new Page<>(pageNumber, pageSize);
565
+        return taRecommendCustomerMapper.getRepCustomerList(page, building, name, tel, consultName, consultTel, entryType, verifyStatus, sex, orgId, taPersonBuildingList);
570 566
     }
571 567
 
572 568
     @Override
573
-    public TaRecommendCustomer getCustomerById(String customerId){
569
+    public TaRecommendCustomer getCustomerById(String customerId) {
574 570
         return taRecommendCustomerMapper.getCustomerById(customerId);
575 571
     }
576 572
 
577 573
 
578 574
     @Override
579
-    public TaRecommendCustomer getCustomerDetail(String customerId,int pageNumber, int pageSize,List<TaPersonBuilding> taPersonBuildingList,String buildingId){
575
+    public TaRecommendCustomer getCustomerDetail(String customerId, int pageNumber, int pageSize, List<TaPersonBuilding> taPersonBuildingList, String buildingId) {
580 576
         String personId = taRecommendCustomerMapper.getCustomerById(customerId).getPersonId();
581
-        TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.getCustomerDetail(customerId,personId);
577
+        TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.getCustomerDetail(customerId, personId);
582 578
         TaPerson person = taPersonMapper.selectById(personId);
583
-        if(!StringUtils.isEmpty(personId)){
584
-            IPage<TaPersonVisitRecord>page = new Page<>(pageNumber,pageSize);
585
-            IPage<TaPersonVisitRecord> taPersonVisitRecordIPage = taPersonVisitRecordMapper.visitRecordByPersonId(page,personId,taPersonBuildingList,buildingId);
579
+        if (!StringUtils.isEmpty(personId)) {
580
+            IPage<TaPersonVisitRecord> page = new Page<>(pageNumber, pageSize);
581
+            IPage<TaPersonVisitRecord> taPersonVisitRecordIPage = taPersonVisitRecordMapper.visitRecordByPersonId(page, personId, taPersonBuildingList, buildingId);
586 582
             List<TaPersonVisitRecord> records = taPersonVisitRecordIPage.getRecords();
587 583
             records.forEach(e -> {
588 584
                 //获取活动标题
589
-                if ("activity".equals(e.getEventType()) && null != e.getTargetId()){
585
+                if ("activity".equals(e.getEventType()) && null != e.getTargetId()) {
590 586
                     TaBuildingDynamic taBuildingDynamic = taBuildingDynamicMapper.selectById(e.getTargetId());
591
-                    if (null != taBuildingDynamic){
587
+                    if (null != taBuildingDynamic) {
592 588
                         e.setActivityName(taBuildingDynamic.getTitle());
593 589
                     }
594 590
 
595 591
                 }
596 592
                 //获取拼团标题
597
-                if ("group".equals(e.getEventType()) && null != e.getTargetId()){
593
+                if ("group".equals(e.getEventType()) && null != e.getTargetId()) {
598 594
                     TaShareActivity taShareActivity = taShareActivityMapper.selectById(e.getTargetId());
599
-                    if (null != taShareActivity){
595
+                    if (null != taShareActivity) {
600 596
                         e.setActivityName(taShareActivity.getActivityName());
601 597
                     }
602 598
                 }
603 599
                 //获取助力标题
604
-                if ("help".equals(e.getEventType()) && null != e.getTargetId()){
600
+                if ("help".equals(e.getEventType()) && null != e.getTargetId()) {
605 601
                     HelpActivity helpActivity = helpActivityMapper.selectById(e.getTargetId());
606
-                    if (null != helpActivity){
602
+                    if (null != helpActivity) {
607 603
                         e.setActivityName(helpActivity.getTitle());
608 604
                     }
609 605
                 }
610 606
                 //获取咨询标题
611
-                if ("news".equals(e.getEventType()) && null != e.getTargetId()){
607
+                if ("news".equals(e.getEventType()) && null != e.getTargetId()) {
612 608
                     TaNews taNews = taNewsMapper.selectById(e.getTargetId());
613
-                    if (null != taNews){
609
+                    if (null != taNews) {
614 610
                         e.setActivityName(taNews.getNewsName());
615 611
                     }
616 612
                 }
617 613
                 //获取H5活动标题
618
-                if ("h5".equals(e.getEventType()) && null != e.getTargetId()){
614
+                if ("h5".equals(e.getEventType()) && null != e.getTargetId()) {
619 615
                     TaDrainage taDrainage = taDrainageMapper.selectById(e.getTargetId());
620
-                    if (null != taDrainage){
616
+                    if (null != taDrainage) {
621 617
                         e.setActivityName(taDrainage.getName());
622 618
                     }
623 619
                 }
@@ -625,19 +621,19 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
625 621
             taPersonVisitRecordIPage.setRecords(records);
626 622
             taRecommendCustomer.setVisitRecords(taPersonVisitRecordIPage);
627 623
             taRecommendCustomer.setVisitTimes(taPersonVisitRecordIPage.getRecords().size());
628
-            taRecommendCustomer.setIntentions(taRecommendCustomerMapper.getCustomerIntentions(personId,taPersonBuildingList));
624
+            taRecommendCustomer.setIntentions(taRecommendCustomerMapper.getCustomerIntentions(personId, taPersonBuildingList));
629 625
         }
630
-        if(!StringUtils.isEmpty(taRecommendCustomer.getRealtyConsultant())){
631
-            TaPerson consultant =  taPersonMapper.getById(taRecommendCustomer.getRealtyConsultant());
626
+        if (!StringUtils.isEmpty(taRecommendCustomer.getRealtyConsultant())) {
627
+            TaPerson consultant = taPersonMapper.getById(taRecommendCustomer.getRealtyConsultant());
632 628
             TaUser user = new TaUser();
633
-            if(null == consultant){
629
+            if (null == consultant) {
634 630
                 user = userService.getById(taRecommendCustomer.getRealtyConsultant());
635
-            }else {
631
+            } else {
636 632
                 user = userService.getById(consultant.getUserId());
637 633
             }
638
-            if (null != user){
634
+            if (null != user) {
639 635
                 List<String> projects = taPersonMapper.getUserProjects(user.getUserId());
640
-                if (projects.size()>0){
636
+                if (projects.size() > 0) {
641 637
                     user.setProjects(projects);
642 638
                 }
643 639
                 taRecommendCustomer.setConsultant(user);
@@ -645,26 +641,26 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
645 641
         }
646 642
         //构造来源类型
647 643
         taRecommendCustomer.setPersonFrom("");
648
-        if (null != person){
649
-            Map<String,String>geoInfo = new HashMap<>();
650
-            geoInfo.put("provience",person.getProvince());
651
-            geoInfo.put("country",person.getCountry());
644
+        if (null != person) {
645
+            Map<String, String> geoInfo = new HashMap<>();
646
+            geoInfo.put("provience", person.getProvince());
647
+            geoInfo.put("country", person.getCountry());
652 648
             TdCity city = cityMapper.selectById(person.getCity());
653
-            if(null!=city){
654
-                geoInfo.put("city",city.getName());
655
-            }else {
656
-                geoInfo.put("city","未知");
649
+            if (null != city) {
650
+                geoInfo.put("city", city.getName());
651
+            } else {
652
+                geoInfo.put("city", "未知");
657 653
             }
658 654
             taRecommendCustomer.setGeoInfo(geoInfo);
659 655
 
660 656
             QueryWrapper<TaPersonFromRecord> queryWrapper = new QueryWrapper<>();
661
-            queryWrapper.eq("org_id",person.getOrgId());
662
-            queryWrapper.eq("person_id",person.getPersonId());
663
-            queryWrapper.eq("is_first_time",1);
657
+            queryWrapper.eq("org_id", person.getOrgId());
658
+            queryWrapper.eq("person_id", person.getPersonId());
659
+            queryWrapper.eq("is_first_time", 1);
664 660
             List<TaPersonFromRecord> taPersonFromRecords = taPersonFromRecordMapper.selectList(queryWrapper);
665
-            if (taPersonFromRecords.size() > 0){
661
+            if (taPersonFromRecords.size() > 0) {
666 662
                 QueryWrapper<TdWxDict> tdWxDictQueryWrapper = new QueryWrapper<>();
667
-                tdWxDictQueryWrapper.eq("scene_id",taPersonFromRecords.get(0).getSceneId());
663
+                tdWxDictQueryWrapper.eq("scene_id", taPersonFromRecords.get(0).getSceneId());
668 664
                 TdWxDict tdWxDict = tdWxDictMapper.selectOne(tdWxDictQueryWrapper);
669 665
                 taRecommendCustomer.setPersonFrom(null != tdWxDict ? tdWxDict.getSceneAlias() : "");
670 666
             }
@@ -674,46 +670,46 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
674 670
     }
675 671
 
676 672
     @Override
677
-    public TaPerson getPublicCustomerDetail(String personId,int pageNumber, int pageSize,List<TaPersonBuilding> taPersonBuildingList,String buildingId){
673
+    public TaPerson getPublicCustomerDetail(String personId, int pageNumber, int pageSize, List<TaPersonBuilding> taPersonBuildingList, String buildingId) {
678 674
         TaPerson taPerson = taPersonMapper.getById(personId);
679
-        if(!StringUtils.isEmpty(personId)){
680
-            IPage<TaPersonVisitRecord>page = new Page<>(pageNumber,pageSize);
681
-            IPage<TaPersonVisitRecord> taPersonVisitRecordIPage = taPersonVisitRecordMapper.visitRecordByPersonId(page,personId,taPersonBuildingList,buildingId);
675
+        if (!StringUtils.isEmpty(personId)) {
676
+            IPage<TaPersonVisitRecord> page = new Page<>(pageNumber, pageSize);
677
+            IPage<TaPersonVisitRecord> taPersonVisitRecordIPage = taPersonVisitRecordMapper.visitRecordByPersonId(page, personId, taPersonBuildingList, buildingId);
682 678
             List<TaPersonVisitRecord> records = taPersonVisitRecordIPage.getRecords();
683 679
             records.forEach(e -> {
684 680
                 //获取活动标题
685
-                if ("activity".equals(e.getEventType()) && null != e.getTargetId()){
681
+                if ("activity".equals(e.getEventType()) && null != e.getTargetId()) {
686 682
                     TaBuildingDynamic taBuildingDynamic = taBuildingDynamicMapper.selectById(e.getTargetId());
687
-                    if (null != taBuildingDynamic){
683
+                    if (null != taBuildingDynamic) {
688 684
                         e.setActivityName(taBuildingDynamic.getTitle());
689 685
                     }
690 686
 
691 687
                 }
692 688
                 //获取拼团标题
693
-                if ("group".equals(e.getEventType()) && null != e.getTargetId()){
689
+                if ("group".equals(e.getEventType()) && null != e.getTargetId()) {
694 690
                     TaShareActivity taShareActivity = taShareActivityMapper.selectById(e.getTargetId());
695
-                    if (null != taShareActivity){
691
+                    if (null != taShareActivity) {
696 692
                         e.setActivityName(taShareActivity.getActivityName());
697 693
                     }
698 694
                 }
699 695
                 //获取助力标题
700
-                if ("help".equals(e.getEventType()) && null != e.getTargetId()){
696
+                if ("help".equals(e.getEventType()) && null != e.getTargetId()) {
701 697
                     HelpActivity helpActivity = helpActivityMapper.selectById(e.getTargetId());
702
-                    if (null != helpActivity){
698
+                    if (null != helpActivity) {
703 699
                         e.setActivityName(helpActivity.getTitle());
704 700
                     }
705 701
                 }
706 702
                 //获取咨询标题
707
-                if ("news".equals(e.getEventType()) && null != e.getTargetId()){
703
+                if ("news".equals(e.getEventType()) && null != e.getTargetId()) {
708 704
                     TaNews taNews = taNewsMapper.selectById(e.getTargetId());
709
-                    if (null != taNews){
705
+                    if (null != taNews) {
710 706
                         e.setActivityName(taNews.getNewsName());
711 707
                     }
712 708
                 }
713 709
                 //获取H5活动标题
714
-                if ("h5".equals(e.getEventType()) && null != e.getTargetId()){
710
+                if ("h5".equals(e.getEventType()) && null != e.getTargetId()) {
715 711
                     TaDrainage taDrainage = taDrainageMapper.selectById(e.getTargetId());
716
-                    if (null != taDrainage){
712
+                    if (null != taDrainage) {
717 713
                         e.setActivityName(taDrainage.getName());
718 714
                     }
719 715
                 }
@@ -721,25 +717,25 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
721 717
             taPersonVisitRecordIPage.setRecords(records);
722 718
             taPerson.setVisitRecords(taPersonVisitRecordIPage);
723 719
             taPerson.setVisitTimes(taPersonVisitRecordIPage.getRecords().size());
724
-            taPerson.setIntentions(taRecommendCustomerMapper.getCustomerIntentions(personId,taPersonBuildingList));
720
+            taPerson.setIntentions(taRecommendCustomerMapper.getCustomerIntentions(personId, taPersonBuildingList));
725 721
             taPerson.setDuration(taPersonVisitRecordMapper.getDurationByPersonId(personId));
726 722
             taPerson.setVisitTime(taPersonVisitRecordMapper.getFirstVisitTimeByPersonId(personId));
727 723
             TdCity city = cityMapper.selectById(taPerson.getCity());
728
-            if(null != city){
724
+            if (null != city) {
729 725
                 taPerson.setCity(city.getName());
730 726
             }
731 727
 
732 728
             //构造来源类型
733 729
             taPerson.setPersonFrom("");
734
-            if (null != taPerson){
730
+            if (null != taPerson) {
735 731
                 QueryWrapper<TaPersonFromRecord> queryWrapper = new QueryWrapper<>();
736
-                queryWrapper.eq("org_id",taPerson.getOrgId());
737
-                queryWrapper.eq("person_id",taPerson.getPersonId());
738
-                queryWrapper.eq("is_first_time",1);
732
+                queryWrapper.eq("org_id", taPerson.getOrgId());
733
+                queryWrapper.eq("person_id", taPerson.getPersonId());
734
+                queryWrapper.eq("is_first_time", 1);
739 735
                 List<TaPersonFromRecord> taPersonFromRecords = taPersonFromRecordMapper.selectList(queryWrapper);
740
-                if (taPersonFromRecords.size() > 0){
736
+                if (taPersonFromRecords.size() > 0) {
741 737
                     QueryWrapper<TdWxDict> tdWxDictQueryWrapper = new QueryWrapper<>();
742
-                    tdWxDictQueryWrapper.eq("scene_id",taPersonFromRecords.get(0).getSceneId());
738
+                    tdWxDictQueryWrapper.eq("scene_id", taPersonFromRecords.get(0).getSceneId());
743 739
                     TdWxDict tdWxDict = tdWxDictMapper.selectOne(tdWxDictQueryWrapper);
744 740
                     taPerson.setPersonFrom(null != tdWxDict ? tdWxDict.getSceneAlias() : "");
745 741
                 }
@@ -749,17 +745,17 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
749 745
     }
750 746
 
751 747
     @Override
752
-    public IPage<TaRecommendCustomer>getCustomersIRecommended(int pageNumber, int pageSize,String customerId,Integer orgId,List<TaPersonBuilding> taPersonBuildingList){
748
+    public IPage<TaRecommendCustomer> getCustomersIRecommended(int pageNumber, int pageSize, String customerId, Integer orgId, List<TaPersonBuilding> taPersonBuildingList) {
753 749
 
754
-        QueryWrapper<TaRecommendCustomer>queryWrapper = new QueryWrapper<>();
750
+        QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
755 751
         // todo
756 752
         // 此处可能不是 person_id 而是 recommend_person
757
-        IPage<TaRecommendCustomer>page = new Page<>(pageNumber,pageSize);
753
+        IPage<TaRecommendCustomer> page = new Page<>(pageNumber, pageSize);
758 754
 //        queryWrapper.eq("recommend_person",customerId);
759 755
 ////        queryWrapper.eq("building_id",building);
760 756
 //        queryWrapper.eq("status", CommConstant.VERIFY_AGREE);
761 757
 //        queryWrapper.eq("org_id", orgId);
762
-        return taRecommendCustomerMapper.getCustomersIRecommended(page,customerId,CommConstant.STATUS_NORMAL,orgId,taPersonBuildingList);
758
+        return taRecommendCustomerMapper.getCustomersIRecommended(page, customerId, CommConstant.STATUS_NORMAL, orgId, taPersonBuildingList);
763 759
     }
764 760
 
765 761
     @Override
@@ -801,8 +797,8 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
801 797
 
802 798
     @Override
803 799
     public ResponseBean batchConsultantAssist(TaUser taUser, Integer orgId) {
804
-        if (CollectionUtils.isNotEmpty(taUser.getPersonIds())){
805
-            for (TaPerson taPerson : taUser.getPersonIds()){
800
+        if (CollectionUtils.isNotEmpty(taUser.getPersonIds())) {
801
+            for (TaPerson taPerson : taUser.getPersonIds()) {
806 802
                 consultantAssist(taUser, taPerson.getPersonId(), orgId);
807 803
             }
808 804
         }
@@ -881,24 +877,24 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
881 877
 
882 878
 
883 879
     @Override
884
-    public List<ExcelRecommendCustomer> getRecCustomerExport(Integer orgId, Integer pageCode, Integer pageSize,List<TaPersonBuilding> taPersonBuildingList) {
885
-        return taRecommendCustomerMapper.getRecCustomerExport(orgId, pageCode, pageSize,taPersonBuildingList);
880
+    public List<ExcelRecommendCustomer> getRecCustomerExport(Integer orgId, Integer pageCode, Integer pageSize, List<TaPersonBuilding> taPersonBuildingList) {
881
+        return taRecommendCustomerMapper.getRecCustomerExport(orgId, pageCode, pageSize, taPersonBuildingList);
886 882
     }
887 883
 
888 884
     @Override
889
-    public Integer getRecCustomerExportCount(Integer orgId,List<TaPersonBuilding> taPersonBuildingList) {
890
-        return taRecommendCustomerMapper.getRecCustomerExportCount(orgId,taPersonBuildingList);
885
+    public Integer getRecCustomerExportCount(Integer orgId, List<TaPersonBuilding> taPersonBuildingList) {
886
+        return taRecommendCustomerMapper.getRecCustomerExportCount(orgId, taPersonBuildingList);
891 887
     }
892 888
 
893 889
 
894 890
     @Override
895
-    public Integer getRepCustomerReportCount(String building, String name, String tel, String consultName, String consultTel, String entryType, String verifyStatus, Integer sex,Integer orgId,List<TaPersonBuilding> taPersonBuildingList) {
896
-        return taRecommendCustomerMapper.getRepCustomerReportCount(building, name, tel, consultName, consultTel, entryType, verifyStatus, sex, orgId,taPersonBuildingList);
891
+    public Integer getRepCustomerReportCount(String building, String name, String tel, String consultName, String consultTel, String entryType, String verifyStatus, Integer sex, Integer orgId, List<TaPersonBuilding> taPersonBuildingList) {
892
+        return taRecommendCustomerMapper.getRepCustomerReportCount(building, name, tel, consultName, consultTel, entryType, verifyStatus, sex, orgId, taPersonBuildingList);
897 893
     }
898 894
 
899 895
     @Override
900
-    public List<ReporRecommendCustomer> getRepCustomerReportExport(String building, String name, String tel, String consultName, String consultTel, String entryType, String verifyStatus, Integer sex, Integer orgId, Integer pageCode, Integer pageSize,List<TaPersonBuilding> taPersonBuildingList) {
901
-        return taRecommendCustomerMapper.getRepCustomerReportExport(building, name, tel, consultName, consultTel, entryType,verifyStatus,sex, orgId, pageCode, pageSize,taPersonBuildingList);
896
+    public List<ReporRecommendCustomer> getRepCustomerReportExport(String building, String name, String tel, String consultName, String consultTel, String entryType, String verifyStatus, Integer sex, Integer orgId, Integer pageCode, Integer pageSize, List<TaPersonBuilding> taPersonBuildingList) {
897
+        return taRecommendCustomerMapper.getRepCustomerReportExport(building, name, tel, consultName, consultTel, entryType, verifyStatus, sex, orgId, pageCode, pageSize, taPersonBuildingList);
902 898
     }
903 899
 
904 900
 
@@ -911,7 +907,7 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
911 907
     public List<AgentsRecommendCustomer> getIndependentAgentsExport(Integer orgId, Integer pageCode, Integer pageSize) {
912 908
         return taRecommendCustomerMapper.getIndependentAgentsExport(orgId, pageCode, pageSize);
913 909
     }
914
-    
910
+
915 911
     /**
916 912
      * 查询我的客户人数集合
917 913
      *
@@ -924,12 +920,12 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
924 920
         if (null == taPersons || taPersons.size() != 1) {
925 921
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
926 922
         }
927
-    
923
+
928 924
         TaPerson taPerson = taPersons.get(0);
929
-        Map<String,Object> map = taRecommendCustomerMapper.getMyCustStatistics(taPerson.getPersonId(),taPerson.getUserId(),taPerson.getOrgId());
925
+        Map<String, Object> map = taRecommendCustomerMapper.getMyCustStatistics(taPerson.getPersonId(), taPerson.getUserId(), taPerson.getOrgId());
930 926
         return ResponseBean.success(map);
931 927
     }
932
-    
928
+
933 929
     /**
934 930
      * 分页查询我的跟进客户集合
935 931
      *
@@ -951,18 +947,18 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
951 947
         if (null == taPersons || taPersons.size() != 1) {
952 948
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
953 949
         }
954
-    
950
+
955 951
         TaPerson taPerson = taPersons.get(0);
956
-        
952
+
957 953
         IPage<TaRecommendCustomer> page = new Page<>();
958 954
         page.setCurrent(pageNumber);
959 955
         page.setSize(pageSize);
960
-        
956
+
961 957
         //分页获取跟进客户status != 4的为跟进客户, status = 4的为成交客户 根据type区分  follow 跟进  clinch 成交
962
-        IPage<TaRecommendCustomer> result = taRecommendCustomerMapper.getMyCustFollowOrClinch(page, taPerson.getPersonId(),taPerson.getUserId(),taPerson.getOrgId(), type,name,phone,status,startReportDate,endReportDate,startArrivalDate,endArrivalDate);
958
+        IPage<TaRecommendCustomer> result = taRecommendCustomerMapper.getMyCustFollowOrClinch(page, taPerson.getPersonId(), taPerson.getUserId(), taPerson.getOrgId(), type, name, phone, status, startReportDate, endReportDate, startArrivalDate, endArrivalDate);
963 959
         return ResponseBean.success(result);
964 960
     }
965
-    
961
+
966 962
     /**
967 963
      * 获取盘客工具下我的客户详情
968 964
      *
@@ -976,14 +972,14 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
976 972
         if (null == taPersons || taPersons.size() != 1) {
977 973
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
978 974
         }
979
-    
975
+
980 976
         TaPerson taPerson = taPersons.get(0);
981 977
         TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.getMyCustDetailById(customerId);
982 978
         //添加跟进行为
983
-        addCustomerFpllowUp(taPerson,taRecommendCustomer,"查看客户详情");
979
+        addCustomerFpllowUp(taPerson, taRecommendCustomer, "查看客户详情");
984 980
         return ResponseBean.success(taRecommendCustomer);
985 981
     }
986
-    
982
+
987 983
     /**
988 984
      * 更新我的客户基本信息
989 985
      *
@@ -997,16 +993,16 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
997 993
         if (null == taPersons || taPersons.size() != 1) {
998 994
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
999 995
         }
1000
-    
996
+
1001 997
         TaPerson taPerson = taPersons.get(0);
1002 998
         taRecommendCustomerMapper.updateById(taRecommendCustomer);
1003 999
         //添加跟进行为
1004
-        addCustomerFpllowUp(taPerson,taRecommendCustomer,"编辑客户信息");
1000
+        addCustomerFpllowUp(taPerson, taRecommendCustomer, "编辑客户信息");
1005 1001
         return ResponseBean.success(taRecommendCustomer);
1006 1002
     }
1007
-    
1003
+
1008 1004
     //添加跟进行为
1009
-    private void addCustomerFpllowUp(TaPerson taPerson,TaRecommendCustomer taRecommendCustomer,String recordType) {
1005
+    private void addCustomerFpllowUp(TaPerson taPerson, TaRecommendCustomer taRecommendCustomer, String recordType) {
1010 1006
         TaCustomerFollowUpRecord taCustomerFollowUpRecord = new TaCustomerFollowUpRecord();
1011 1007
         taCustomerFollowUpRecord.setOrgId(taPerson.getOrgId());
1012 1008
         taCustomerFollowUpRecord.setCreateDate(LocalDateTime.now());

+ 168
- 0
src/main/resources/mapper/ActivityManageMapper.xml Voir le fichier

@@ -0,0 +1,168 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.huiju.estateagents.mapper.ActivityManageMapper">
4
+
5
+    <select id = "getStatisticDataByType" resultType="com.huiju.estateagents.bo.request.ActivityStatisticResponseBO">
6
+      select
7
+        -- 活动分享人数
8
+        (SELECT count(DISTINCT b.person_id) FROM ta_share_count b
9
+        WHERE b.org_id = a.org_id
10
+            <choose>
11
+                <when test=" type == 'live'">
12
+                    AND b.tagert_type like concat('%',a.target_type,'%')
13
+                </when>
14
+                <otherwise>
15
+                    AND b.tagert_type = a.target_type
16
+                </otherwise>
17
+            </choose>
18
+            AND b.be_share = a.target_id
19
+        ) as share_persons,
20
+
21
+        -- 活动分享次数
22
+        (SELECT count(*) FROM ta_share_count c
23
+        WHERE c.org_id = a.org_id
24
+            <choose>
25
+                <when test=" type == 'live'">
26
+                    AND c.tagert_type like concat('%',a.target_type,'%')
27
+                </when>
28
+                <otherwise>
29
+                    AND c.tagert_type = a.target_type
30
+                </otherwise>
31
+            </choose>
32
+            AND c.be_share = a.target_id
33
+        ) as share_num,
34
+
35
+        -- 活动访问人数
36
+        (select count( DISTINCT d.person_id ) from ta_person_visit_record d
37
+        WHERE d.org_id = a.org_id
38
+            AND (d.target_type = a.target_type OR d.event_type = a.target_type)
39
+            AND d.target_id = a.target_id
40
+            AND d.`event` = 'detail'
41
+        ) as visit_persons,
42
+
43
+        -- 活动访问次数
44
+        (select count(*) from ta_person_visit_record e
45
+        WHERE e.org_id = a.org_id
46
+            AND (e.target_type = a.target_type OR e.event_type = a.target_type)
47
+            AND e.target_id = a.target_id
48
+            AND e.`event` = 'detail'
49
+        ) as visit_num,
50
+
51
+        -- 分享新增用户
52
+        (select count(*) from ta_share_person_from f
53
+        where	f.org_id = a.org_id
54
+        <choose>
55
+            <when test=" type == 'live'">
56
+                AND f.target_type = concat('%',REPLACE(a.target_type, 'activity', 'dynamic'), '_share%')
57
+            </when>
58
+            <otherwise>
59
+                AND f.target_type = concat(REPLACE(a.target_type, 'activity', 'dynamic'), '_share')
60
+            </otherwise>
61
+        </choose>
62
+        AND f.target_id = a.target_id
63
+        AND f.`status` > 0
64
+        AND f.is_first_time = 1
65
+        ) as new_persons,
66
+
67
+        -- 分享新增客户
68
+        (select count(*) from ta_share_person_from g
69
+        inner join ta_person h on h.person_id = g.person_id
70
+        where	g.org_id = a.org_id
71
+        <choose>
72
+            <when test=" type == 'live'">
73
+                AND g.target_type = concat('%',REPLACE(a.target_type, 'activity', 'dynamic'), '_share%')
74
+            </when>
75
+            <otherwise>
76
+                AND g.target_type = concat(REPLACE(a.target_type, 'activity', 'dynamic'), '_share')
77
+            </otherwise>
78
+        </choose>
79
+        AND g.target_id = a.target_id
80
+        AND g.`status` > 0
81
+        AND g.is_first_time = 1
82
+        AND h.phone is not null
83
+        ) as new_customers
84
+
85
+        from (
86
+            <if test=" type == 'activity' ">
87
+                SELECT
88
+                    t.org_id,
89
+                    t.building_id,
90
+                    s.building_name,
91
+                    t.dynamic_id AS target_id,
92
+                    t.title AS target_name,
93
+                    'activity' AS target_type
94
+                FROM
95
+                    ta_building_dynamic t
96
+                LEFT JOIN ta_building s ON s.building_id = t.building_id
97
+                WHERE
98
+                   t.dynamic_id = #{id}
99
+                  AND t.org_id = #{orgId}
100
+            </if>
101
+
102
+            <if test=" type == 'h5' " >
103
+                    SELECT
104
+                    t.org_id,
105
+                    t.building_id,
106
+                    s.building_name,
107
+                    t.drainage_id AS target_id,
108
+                    t.`name` AS target_name,
109
+                    'h5' AS target_type
110
+                FROM
111
+                  ta_drainage t
112
+                LEFT JOIN ta_building s ON s.building_id = t.building_id
113
+                WHERE
114
+                  t.drainage_id = #{id}
115
+                  AND t.org_id = #{orgId}
116
+            </if>
117
+
118
+            <if test=" type == 'help' ">
119
+                SELECT
120
+                    t.org_id,
121
+                    t.building_id,
122
+                    s.building_name,
123
+                    t.help_activity_id AS target_id,
124
+                    t.title AS target_name,
125
+                    'help' AS target_type
126
+                FROM
127
+                    ta_help_activity t
128
+                LEFT JOIN ta_building s ON s.building_id = t.building_id
129
+                WHERE
130
+                    t.help_activity_id = #{id}
131
+                    AND t.org_id = #{orgId}
132
+            </if>
133
+
134
+            <if test=" type == 'group' ">
135
+                SELECT
136
+                    t.org_id,
137
+                    t.building_id,
138
+                    s.building_name,
139
+                    t.group_activity_id AS target_id,
140
+                    t.activity_name AS target_name,
141
+                    'group' AS target_type
142
+                FROM
143
+                    ta_share_activity t
144
+                LEFT JOIN ta_building s ON s.building_id = t.building_id
145
+                WHERE
146
+                    t.group_activity_id = #{id}
147
+                    AND t.org_id = #{orgId}
148
+            </if>
149
+
150
+            <if test=" type == 'live' ">
151
+                SELECT
152
+                    t.org_id,
153
+                    t.building_id,
154
+                    s.building_name,
155
+                    t.live_activity_id AS target_id,
156
+                    t.live_activity_title AS target_name,
157
+                    'live' AS target_type
158
+                FROM
159
+                    ta_live_activity t
160
+                LEFT JOIN ta_building s ON s.building_id = t.building_id
161
+                WHERE
162
+                    t.live_activity_id = #{id}
163
+                    AND t.org_id = #{orgId}
164
+            </if>
165
+        ) a
166
+    </select>
167
+
168
+</mapper>

+ 0
- 1
src/main/resources/mapper/TaBuildingDynamicMapper.xml Voir le fichier

@@ -190,5 +190,4 @@
190 190
         from ta_building_dynamic
191 191
         where org_id = #{orgId}
192 192
     </select>
193
-
194 193
 </mapper>

+ 27
- 19
src/main/resources/mapper/TaBuildingMapper.xml Voir le fichier

@@ -432,7 +432,7 @@
432 432
                     b.STATUS > 0
433 433
                     AND b.org_id = #{orgId}
434 434
                     AND IFNULL( b.person_type, '' ) IN ( 'estate agent', 'customer' )
435
-                    AND b.person_id NOT IN ( SELECT c.person_id FROM ta_recommend_customer c WHERE c.org_id = 84 AND person_id IS NOT NULL AND person_id != '' )
435
+                    AND b.person_id NOT IN ( SELECT c.person_id FROM ta_recommend_customer c WHERE c.org_id = #{orgId} AND person_id IS NOT NULL AND person_id != '' )
436 436
                     <if test="startDate != null">
437 437
                         and  TO_DAYS(b.create_date) >= TO_DAYS(#{startDate})
438 438
                     </if>
@@ -451,8 +451,10 @@
451 451
                 u.be_uv AS building_id
452 452
             FROM
453 453
                 ta_uv u
454
-            WHERE
454
+            LEFT JOIN ta_person p ON u.person_id = p.person_id
455
+        WHERE
455 456
                 u.tagert_type = 'project'
457
+                AND p.org_id = #{orgId}
456 458
             <if test="startDate != null">
457 459
                 and  TO_DAYS(u.create_date) >= TO_DAYS(#{startDate})
458 460
             </if>
@@ -523,7 +525,7 @@
523 525
         b.STATUS > 0
524 526
         AND b.org_id = #{orgId}
525 527
         AND IFNULL( b.person_type, '' ) IN ( 'estate agent', 'customer' )
526
-        AND b.person_id NOT IN ( SELECT c.person_id FROM ta_recommend_customer c WHERE c.org_id = 84 AND person_id IS NOT NULL AND person_id != '' )
528
+        AND b.person_id NOT IN ( SELECT c.person_id FROM ta_recommend_customer c WHERE c.org_id = #{orgId} AND person_id IS NOT NULL AND person_id != '' )
527 529
         <if test="startDate != null">
528 530
             and  TO_DAYS(b.create_date) >= TO_DAYS(#{startDate})
529 531
         </if>
@@ -542,8 +544,10 @@
542 544
         u.be_uv AS building_id
543 545
         FROM
544 546
         ta_uv u
547
+        LEFT JOIN ta_person p ON u.person_id = p.person_id
545 548
         WHERE
546 549
         u.tagert_type = 'project'
550
+        AND p.org_id = #{orgId}
547 551
         <if test="startDate != null">
548 552
             and  TO_DAYS(u.create_date) >= TO_DAYS(#{startDate})
549 553
         </if>
@@ -631,21 +635,23 @@
631 635
         LEFT JOIN (
632 636
             SELECT
633 637
                 count( * ) AS uv_num,
634
-                be_uv AS building_id,
635
-                DATE_FORMAT( create_date, '%Y-%m-%d' ) AS create_date
638
+                u.be_uv AS building_id,
639
+                DATE_FORMAT( u.create_date, '%Y-%m-%d' ) AS create_date
636 640
             FROM
637
-                ta_uv
641
+                ta_uv u
642
+                LEFT JOIN ta_person p ON u.person_id = p.person_id
638 643
             WHERE
639 644
                 tagert_type = 'project'
640
-                AND be_uv = #{buildingId}
645
+                AND p.org_id = #{orgId}
646
+                AND u.be_uv = #{buildingId}
641 647
                 <if test="startDate != null">
642
-                    and  TO_DAYS(create_date) >= TO_DAYS(#{startDate})
648
+                    and  TO_DAYS(u.create_date) >= TO_DAYS(#{startDate})
643 649
                 </if>
644 650
                 <if test="endDate != null">
645
-                    and  TO_DAYS(create_date) &lt;= TO_DAYS(#{endDate})
651
+                    and  TO_DAYS(u.create_date) &lt;= TO_DAYS(#{endDate})
646 652
                 </if>
647 653
             GROUP BY
648
-                DATE_FORMAT( create_date, '%Y-%m-%d' )
654
+                DATE_FORMAT( u.create_date, '%Y-%m-%d' )
649 655
         ) u ON t.date = u.create_date
650 656
         ORDER BY create_date
651 657
     </select>
@@ -714,27 +720,29 @@
714 720
         LEFT JOIN (
715 721
         SELECT
716 722
         count( * ) AS uv_num,
717
-        be_uv AS building_id,
718
-        DATE_FORMAT( create_date, '%Y-%m-%d' ) AS create_date
723
+        u.be_uv AS building_id,
724
+        DATE_FORMAT( u.create_date, '%Y-%m-%d' ) AS create_date
719 725
         FROM
720
-        ta_uv
726
+        ta_uv u
727
+        LEFT JOIN ta_person p ON u.person_id = p.person_id
721 728
         WHERE
722
-        tagert_type = 'project'
723
-        AND be_uv = #{buildingId}
729
+        u.tagert_type = 'project'
730
+        AND p.org_id = #{orgId}
731
+        AND u.be_uv = #{buildingId}
724 732
         <if test="startDate != null">
725
-            and  TO_DAYS(create_date) >= TO_DAYS(#{startDate})
733
+            and  TO_DAYS(u.create_date) >= TO_DAYS(#{startDate})
726 734
         </if>
727 735
         <if test="endDate != null">
728
-            and  TO_DAYS(create_date) &lt;= TO_DAYS(#{endDate})
736
+            and  TO_DAYS(u.create_date) &lt;= TO_DAYS(#{endDate})
729 737
         </if>
730 738
         GROUP BY
731
-        DATE_FORMAT( create_date, '%Y-%m-%d' )
739
+        DATE_FORMAT( u.create_date, '%Y-%m-%d' )
732 740
         ) u ON t.date = u.create_date
733 741
         ORDER BY
734 742
         <if test="sortField != null and sortField != ''">
735 743
              ${sortField} ${orderType},
736 744
         </if>
737
-        create_date
745
+        create_date desc
738 746
     </select>
739 747
 
740 748
 </mapper>

+ 60
- 12
src/main/resources/mapper/TaPersonIntentionRecordMapper.xml Voir le fichier

@@ -43,31 +43,79 @@
43 43
         ORDER BY SUM(tpir.intention) DESC
44 44
     </select>
45 45
     <select id="selectExportIntentionUser" resultType="com.huiju.estateagents.excel.IntentionUser">
46
+        select t.*, IFNULL(b.nickname, c.user_name) as sharePersonName, ifnull(b.phone, c.phone) as sharePersonPhone From (
47
+
46 48
         SELECT
47
-        tpir.person_name as  person_name,
49
+        tpir.person_name as person_name,
50
+        if(tp.gender = '1' , '男', if(tp.gender = '2', '女', '未知')) as gender,
48 51
         tp.phone as phone,
49
-        tpir.building_name as building_name,
52
+        tp.province,
53
+        tpir.person_id,
54
+        tpir.building_name,
55
+        tpir.building_id,
56
+        d.user_name as realtyConsultant,
57
+        d.phone as realtyConsultantPhone,
50 58
         SUM(tpir.intention) as intention
51
-        FROM
52
-        ta_person_intention_record tpir
53
-        LEFT JOIN ta_person tp on tpir.person_id = tp.person_id
59
+
60
+        FROM ta_person_intention_record tpir
61
+        LEFT JOIN ta_person tp ON tpir.person_id = tp.person_id
62
+        left join ta_recommend_customer c on c.person_id = tpir.person_id
63
+        left join ta_user d on c.realty_consultant = d.user_id
54 64
         <trim prefix="where" prefixOverrides="and | or">
55
-            <if test="buildingId != null and buildingId != ''">
56
-                tpir.building_id = #{buildingId}
57
-            </if>
58 65
             <if test="orgId != null">
59 66
                 AND tpir.org_id = #{orgId}
60 67
                 AND tp.org_id = #{orgId}
61 68
             </if>
69
+        </trim>
70
+        GROUP BY tpir.person_id, tpir.building_id
71
+
72
+        ) as t
73
+        left join ta_share_person_from a on t.person_id = a.person_id
74
+        left join ta_user c on a.share_person = c.user_id
75
+        left join ta_person b on a.share_person = b.person_id
76
+
77
+        <trim prefix="where" prefixOverrides="and | or">
78
+            <if test="buildingId != null and buildingId != ''">
79
+                t.building_id = #{buildingId}
80
+            </if>
62 81
             <if test="personBuildingList != null and personBuildingList.size > 0">
63
-                AND tpir.building_id in
82
+                AND t.building_id in
64 83
                 <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
65 84
                     #{personBuilding.buildingId}
66 85
                 </foreach>
67 86
             </if>
68 87
         </trim>
69
-        GROUP BY
70
-        tpir.person_id, tpir.building_id
71
-        ORDER BY SUM(tpir.intention) DESC
88
+
89
+        group by t.person_id, t.building_id
90
+        order by t.intention desc
91
+
92
+
93
+
94
+<!--        SELECT-->
95
+<!--        tpir.person_name as  person_name,-->
96
+<!--        tp.phone as phone,-->
97
+<!--        tpir.building_name as building_name,-->
98
+<!--        SUM(tpir.intention) as intention-->
99
+<!--        FROM-->
100
+<!--        ta_person_intention_record tpir-->
101
+<!--        LEFT JOIN ta_person tp on tpir.person_id = tp.person_id-->
102
+<!--        <trim prefix="where" prefixOverrides="and | or">-->
103
+<!--            <if test="buildingId != null and buildingId != ''">-->
104
+<!--                tpir.building_id = #{buildingId}-->
105
+<!--            </if>-->
106
+<!--            <if test="orgId != null">-->
107
+<!--                AND tpir.org_id = #{orgId}-->
108
+<!--                AND tp.org_id = #{orgId}-->
109
+<!--            </if>-->
110
+<!--            <if test="personBuildingList != null and personBuildingList.size > 0">-->
111
+<!--                AND tpir.building_id in-->
112
+<!--                <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">-->
113
+<!--                    #{personBuilding.buildingId}-->
114
+<!--                </foreach>-->
115
+<!--            </if>-->
116
+<!--        </trim>-->
117
+<!--        GROUP BY-->
118
+<!--        tpir.person_id, tpir.building_id-->
119
+<!--        ORDER BY SUM(tpir.intention) DESC-->
72 120
     </select>
73 121
 </mapper>

+ 178
- 69
src/main/resources/mapper/statistic/TaActivityStaticMapper.xml Voir le fichier

@@ -47,6 +47,16 @@
47 47
                 <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
48 48
                     #{taPersonBuilding.buildingId}
49 49
                 </foreach>
50
+            or
51
+                c.building_id in
52
+                <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
53
+                    #{taPersonBuilding.buildingId}
54
+                </foreach>
55
+            or
56
+            d.building_id in
57
+                <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
58
+                    #{taPersonBuilding.buildingId}
59
+                </foreach>
50 60
               or d.create_user = #{userId}
51 61
               or c.create_user = #{userId}
52 62
             )
@@ -100,6 +110,16 @@
100 110
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
101 111
                 #{taPersonBuilding.buildingId}
102 112
             </foreach>
113
+            or
114
+            c.building_id in
115
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
116
+                #{taPersonBuilding.buildingId}
117
+            </foreach>
118
+            or
119
+            d.building_id in
120
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
121
+                #{taPersonBuilding.buildingId}
122
+            </foreach>
103 123
             or d.create_user = #{userId}
104 124
             or c.create_user = #{userId}
105 125
             )
@@ -232,6 +252,16 @@
232 252
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
233 253
                 #{taPersonBuilding.buildingId}
234 254
             </foreach>
255
+            or
256
+            c.building_id in
257
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
258
+                #{taPersonBuilding.buildingId}
259
+            </foreach>
260
+            or
261
+            d.building_id in
262
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
263
+                #{taPersonBuilding.buildingId}
264
+            </foreach>
235 265
             or d.create_user = #{userId}
236 266
             or c.create_user = #{userId}
237 267
             )
@@ -310,6 +340,16 @@
310 340
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
311 341
                 #{taPersonBuilding.buildingId}
312 342
             </foreach>
343
+            or
344
+            c.building_id in
345
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
346
+                #{taPersonBuilding.buildingId}
347
+            </foreach>
348
+            or
349
+            d.building_id in
350
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
351
+                #{taPersonBuilding.buildingId}
352
+            </foreach>
313 353
             or d.create_user = #{userId}
314 354
             or c.create_user = #{userId}
315 355
             )
@@ -561,6 +601,16 @@
561 601
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
562 602
                 #{taPersonBuilding.buildingId}
563 603
             </foreach>
604
+            or
605
+            c.building_id in
606
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
607
+                #{taPersonBuilding.buildingId}
608
+            </foreach>
609
+            or
610
+            d.building_id in
611
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
612
+                #{taPersonBuilding.buildingId}
613
+            </foreach>
564 614
             or d.create_user = #{userId}
565 615
             or c.create_user = #{userId}
566 616
             )
@@ -786,6 +836,16 @@
786 836
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
787 837
                 #{taPersonBuilding.buildingId}
788 838
             </foreach>
839
+            or
840
+            c.building_id in
841
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
842
+                #{taPersonBuilding.buildingId}
843
+            </foreach>
844
+            or
845
+            d.building_id in
846
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
847
+                #{taPersonBuilding.buildingId}
848
+            </foreach>
789 849
             or d.create_user = #{userId}
790 850
             or c.create_user = #{userId}
791 851
             )
@@ -857,7 +917,8 @@
857 917
             and t.building_id = #{buildingId}
858 918
         </if>
859 919
         <if test="targetType != null and targetType != ''">
860
-            and t.target_type = #{targetType}
920
+            and (case when #{targetType} = 'activity' then t.target_type = 'dynamic' else t.target_type = #{targetType}
921
+            end)
861 922
         </if>
862 923
         <if test="startDate != null">
863 924
             and t.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
@@ -890,7 +951,8 @@
890 951
             and t.building_id = #{buildingId}
891 952
         </if>
892 953
         <if test="targetType != null and targetType != ''">
893
-            and t.target_type = #{targetType}
954
+            and (case when #{targetType} = 'activity' then t.target_type = 'dynamic' else t.target_type = #{targetType}
955
+            end)
894 956
         </if>
895 957
         <if test="startDate != null">
896 958
             and t.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
@@ -1043,7 +1105,7 @@
1043 1105
         ) as activity
1044 1106
 
1045 1107
         left join (
1046
-            SELECT count(1) as shareNum, a.be_share, case when a.tagert_type = 'liveApp' then 'live' when a.tagert_type = 'livePost' then 'live' else a.tagert_type end as tagert_type
1108
+            SELECT count(1) as shareNum, a.be_share, case when a.tagert_type = 'liveApp' then 'live' when a.tagert_type = 'livePost' then 'live' else a.tagert_type end as tagert_type, a.create_date
1047 1109
             FROM ta_share_count a where a.tagert_type in (
1048 1110
             'activity', 'group','h5','help','liveApp','livePost')
1049 1111
             and a.org_id = #{orgId}
@@ -1060,7 +1122,7 @@
1060 1122
             <if test="startDate == null or endDate == null ">
1061 1123
                 AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1062 1124
             </if>
1063
-            group by a.be_share,a.tagert_type
1125
+            group by a.be_share,a.tagert_type order by a.create_date desc limit 9999999
1064 1126
         ) as shareNum on shareNum.be_share = activity.activityId and shareNum.tagert_type = activity.activityType
1065 1127
 
1066 1128
         left join (
@@ -1081,7 +1143,7 @@
1081 1143
         <if test="startDate == null or endDate == null ">
1082 1144
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1083 1145
         </if>
1084
-        group by a.person_id
1146
+        group by a.person_id, be_share
1085 1147
 <!--        , be_share, tagert_type-->
1086 1148
         ) as sharePersonNum group by sharePersonNum.be_share, sharePersonNum.tagert_type
1087 1149
         ) as sharePersonNum on sharePersonNum.be_share = activity.activityId and sharePersonNum.tagert_type =
@@ -1135,7 +1197,7 @@
1135 1197
         and a.status = 1
1136 1198
         and a.is_first_time = 1
1137 1199
         <if test="targetType != null and targetType != '' and targetType != 'h5'">
1138
-            and a.target_type = #{targetType}
1200
+            and a.target_type = concat(REPLACE(#{targetType}, 'activity', 'dynamic'), '_share')
1139 1201
         </if>
1140 1202
         <if test="startDate != null ">
1141 1203
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
@@ -1148,8 +1210,7 @@
1148 1210
         </if>
1149 1211
         group by a.person_id, a.target_type ,a.target_id
1150 1212
         ) as addRegistNum group by addRegistNum.target_type, addRegistNum.target_id
1151
-        ) as addRegistNum on addRegistNum.target_id = activity.activityId and substring_index(addRegistNum.target_type,
1152
-        '_share', 1) = activity.activityType
1213
+        ) as addRegistNum on addRegistNum.target_id = activity.activityId and activity.activityType  = substring_index(REPLACE(addRegistNum.target_type, 'dynamic_share', 'activity_share') , '_share', 1)
1153 1214
         <if test="targetType != null and targetType != ''">
1154 1215
             where activity.activityType = #{targetType}
1155 1216
         </if>
@@ -1179,7 +1240,7 @@
1179 1240
             and a.building_id = #{buildingId}
1180 1241
         </if>
1181 1242
         <if test="activityName != null and activityName != '' ">
1182
-            and a.title = #{activityName}
1243
+            and a.title like concat('%', #{activityName}, '%')
1183 1244
         </if>
1184 1245
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1185 1246
             and a.building_id in
@@ -1194,7 +1255,7 @@
1194 1255
             and b.building_id = #{buildingId}
1195 1256
         </if>
1196 1257
         <if test="activityName != null and activityName != '' ">
1197
-            and b.title = #{activityName}
1258
+            and b.title like concat('%', #{activityName}, '%')
1198 1259
         </if>
1199 1260
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1200 1261
             and b.building_id in
@@ -1210,7 +1271,7 @@
1210 1271
             and c.building_id = #{buildingId}
1211 1272
         </if>
1212 1273
         <if test="activityName != null and activityName != '' ">
1213
-            and c.activity_name = #{activityName}
1274
+            and c.activity_name like concat('%', #{activityName}, '%')
1214 1275
         </if>
1215 1276
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1216 1277
             and c.building_id in
@@ -1225,7 +1286,7 @@
1225 1286
             and d.building_id = #{buildingId}
1226 1287
         </if>
1227 1288
         <if test="activityName != null and activityName != '' ">
1228
-            and d.name = #{activityName}
1289
+            and d.name like concat('%', #{activityName}, '%')
1229 1290
         </if>
1230 1291
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1231 1292
             and (d.building_id in
@@ -1243,7 +1304,7 @@
1243 1304
             and e.building_id = #{buildingId}
1244 1305
         </if>
1245 1306
         <if test="activityName != null and activityName != '' ">
1246
-            and e.live_activity_title = #{activityName}
1307
+            and e.live_activity_title like concat('%', #{activityName}, '%')
1247 1308
         </if>
1248 1309
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1249 1310
             and (e.building_id in
@@ -1256,12 +1317,13 @@
1256 1317
         ) as activity
1257 1318
 
1258 1319
         left join (
1259
-        SELECT count(1) as shareNum, a.be_share, case when a.tagert_type = 'liveApp' then 'live' when a.tagert_type = 'livePost' then 'live' else a.tagert_type end as tagert_type
1320
+        SELECT count(1) as shareNum, a.be_share, case when a.tagert_type = 'liveApp' then 'live' when a.tagert_type = 'livePost' then 'live' else a.tagert_type end as tagert_type, a.create_date
1260 1321
         FROM ta_share_count a where a.tagert_type in (
1261 1322
         'activity', 'group','h5','help','liveApp','livePost')
1262 1323
         and a.org_id = #{orgId}
1263 1324
         <if test="targetType != null and targetType != ''">
1264
-            and a.tagert_type = #{targetType}
1325
+            and (case when #{targetType} = 'live' then a.tagert_type in ('liveApp', 'livePost') else a.tagert_type = #{targetType}
1326
+            end)
1265 1327
         </if>
1266 1328
         <if test="startDate != null ">
1267 1329
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
@@ -1272,7 +1334,7 @@
1272 1334
         <if test="startDate == null or endDate == null ">
1273 1335
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1274 1336
         </if>
1275
-        group by a.be_share,a.tagert_type
1337
+        group by a.be_share,a.tagert_type order by a.create_date desc limit 9999999
1276 1338
         ) as shareNum on shareNum.be_share = activity.activityId and shareNum.tagert_type = activity.activityType
1277 1339
 
1278 1340
         left join (
@@ -1281,7 +1343,8 @@
1281 1343
         From ta_share_count a where a.tagert_type in ( 'activity', 'group','h5','help','liveApp','livePost')
1282 1344
         and a.org_id = #{orgId}
1283 1345
         <if test="targetType != null and targetType != ''">
1284
-            and a.tagert_type = #{targetType}
1346
+            and (case when #{targetType} = 'live' then a.tagert_type in ('liveApp', 'livePost') else a.tagert_type = #{targetType}
1347
+            end)
1285 1348
         </if>
1286 1349
         <if test="startDate != null ">
1287 1350
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
@@ -1292,7 +1355,8 @@
1292 1355
         <if test="startDate == null or endDate == null ">
1293 1356
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1294 1357
         </if>
1295
-        group by a.person_id, be_share, tagert_type
1358
+        group by a.person_id, be_share
1359
+        <!--        , be_share, tagert_type-->
1296 1360
         ) as sharePersonNum group by sharePersonNum.be_share, sharePersonNum.tagert_type
1297 1361
         ) as sharePersonNum on sharePersonNum.be_share = activity.activityId and sharePersonNum.tagert_type =
1298 1362
         activity.activityType
@@ -1345,7 +1409,7 @@
1345 1409
         and a.status = 1
1346 1410
         and a.is_first_time = 1
1347 1411
         <if test="targetType != null and targetType != '' and targetType != 'h5'">
1348
-            and a.target_type = #{targetType}
1412
+            and a.target_type = concat(REPLACE(#{targetType}, 'activity', 'dynamic'), '_share')
1349 1413
         </if>
1350 1414
         <if test="startDate != null ">
1351 1415
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
@@ -1358,8 +1422,7 @@
1358 1422
         </if>
1359 1423
         group by a.person_id, a.target_type ,a.target_id
1360 1424
         ) as addRegistNum group by addRegistNum.target_type, addRegistNum.target_id
1361
-        ) as addRegistNum on addRegistNum.target_id = activity.activityId and substring_index(addRegistNum.target_type,
1362
-        '_share', 1) = activity.activityType
1425
+        ) as addRegistNum on addRegistNum.target_id = activity.activityId and activity.activityType  = substring_index(REPLACE(addRegistNum.target_type, 'dynamic_share', 'activity_share') , '_share', 1)
1363 1426
         <if test="targetType != null and targetType != ''">
1364 1427
             where activity.activityType = #{targetType}
1365 1428
         </if>
@@ -1419,6 +1482,16 @@
1419 1482
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1420 1483
                 #{taPersonBuilding.buildingId}
1421 1484
             </foreach>
1485
+            or
1486
+            c.building_id in
1487
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1488
+                #{taPersonBuilding.buildingId}
1489
+            </foreach>
1490
+            or
1491
+            d.building_id in
1492
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1493
+                #{taPersonBuilding.buildingId}
1494
+            </foreach>
1422 1495
             or d.create_user = #{userId}
1423 1496
             or c.create_user = #{userId}
1424 1497
             )
@@ -1443,8 +1516,8 @@
1443 1516
         ) as person
1444 1517
 
1445 1518
         left join (
1446
-            select * from (
1447
-                SELECT count(*) as shareNum, t.person_id
1519
+            select count(*) as shareNum, temp.person_id from (
1520
+                SELECT t.person_id, t.create_date
1448 1521
                 FROM ta_share_count t
1449 1522
                 LEFT JOIN ta_help_activity a ON t.be_share = a.help_activity_id
1450 1523
                 LEFT JOIN ta_share_activity b ON t.be_share = b.share_id
@@ -1463,8 +1536,8 @@
1463 1536
                     and (case when #{activityType} = 'live' then t.tagert_type in ('liveApp', 'livePost') else t.tagert_type = #{activityType}
1464 1537
                     end)
1465 1538
                 </if>
1466
-                group by person_id
1467
-            ) as temp
1539
+                order by t.create_date desc limit 999999
1540
+            ) as temp group by temp.person_id order by temp.create_date desc
1468 1541
         ) as shareNum on person.person_id = shareNum.person_id
1469 1542
 
1470 1543
         left join (
@@ -1523,7 +1596,14 @@
1523 1596
         ifnull(shareNum, 0) as shareNum,
1524 1597
         ifnull(visitNum, 0) as visitNum,
1525 1598
         ifnull(visitPersonNum, 0) as visitPersonNum,
1526
-        person.person_type as sharePersonType,
1599
+        CASE
1600
+        WHEN person.person_type = 'drift' THEN
1601
+        "游客"
1602
+        WHEN person.person_type = 'customer' THEN
1603
+        "普通客户"
1604
+        WHEN person.person_type = 'Realty Consultant' THEN
1605
+        "置业顾问"
1606
+        END `sharePersonType`,
1527 1607
         person.person_id
1528 1608
         from (
1529 1609
         SELECT t.*, f.nickname, f.phone, f.person_type
@@ -1563,6 +1643,16 @@
1563 1643
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1564 1644
                 #{taPersonBuilding.buildingId}
1565 1645
             </foreach>
1646
+            or
1647
+            c.building_id in
1648
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1649
+                #{taPersonBuilding.buildingId}
1650
+            </foreach>
1651
+            or
1652
+            d.building_id in
1653
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1654
+                #{taPersonBuilding.buildingId}
1655
+            </foreach>
1566 1656
             or d.create_user = #{userId}
1567 1657
             or c.create_user = #{userId}
1568 1658
             )
@@ -1587,8 +1677,8 @@
1587 1677
         ) as person
1588 1678
 
1589 1679
         left join (
1590
-        select * from (
1591
-        SELECT count(*) as shareNum, t.person_id
1680
+        select count(*) as shareNum, temp.person_id from (
1681
+        SELECT t.person_id, t.create_date
1592 1682
         FROM ta_share_count t
1593 1683
         LEFT JOIN ta_help_activity a ON t.be_share = a.help_activity_id
1594 1684
         LEFT JOIN ta_share_activity b ON t.be_share = b.share_id
@@ -1607,8 +1697,8 @@
1607 1697
             and (case when #{activityType} = 'live' then t.tagert_type in ('liveApp', 'livePost') else t.tagert_type = #{activityType}
1608 1698
             end)
1609 1699
         </if>
1610
-        group by person_id
1611
-        ) as temp
1700
+        order by t.create_date desc limit 999999
1701
+        ) as temp group by temp.person_id order by temp.create_date desc
1612 1702
         ) as shareNum on person.person_id = shareNum.person_id
1613 1703
 
1614 1704
         left join (
@@ -1645,7 +1735,9 @@
1645 1735
             and t.target_type = concat(REPLACE(#{activityType}, 'activity', 'dynamic'), '_share')
1646 1736
         </if>
1647 1737
         and t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share')
1648
-        and t.org_id = #{orgId} group by t.share_person ) t
1738
+        and t.org_id = #{orgId}
1739
+        <!--        group by t.share_person -->
1740
+        ) t
1649 1741
         left join ta_person a on t.share_person = a.person_id
1650 1742
         left join ta_person b on t.share_person = b.user_id
1651 1743
         ) as visitPersonNum on visitPersonNum.person_id = person.person_id
@@ -1707,6 +1799,16 @@
1707 1799
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1708 1800
                 #{taPersonBuilding.buildingId}
1709 1801
             </foreach>
1802
+            or
1803
+            c.building_id in
1804
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1805
+                #{taPersonBuilding.buildingId}
1806
+            </foreach>
1807
+            or
1808
+            d.building_id in
1809
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1810
+                #{taPersonBuilding.buildingId}
1811
+            </foreach>
1710 1812
             or d.create_user = #{userId}
1711 1813
             or c.create_user = #{userId}
1712 1814
             )
@@ -1779,7 +1881,8 @@
1779 1881
             and t.be_share = #{activityId}
1780 1882
         </if>
1781 1883
         <if test="activityType != null and activityType != ''">
1782
-            and t.tagert_type = #{activityType}
1884
+            and (case when #{activityType} = 'live' then t.tagert_type in ('liveApp', 'livePost') else t.tagert_type = #{activityType}
1885
+            end)
1783 1886
         </if>
1784 1887
         <if test="buildingId != null and buildingId != ''">
1785 1888
             and (
@@ -1806,6 +1909,16 @@
1806 1909
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1807 1910
                 #{taPersonBuilding.buildingId}
1808 1911
             </foreach>
1912
+            or
1913
+            c.building_id in
1914
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1915
+                #{taPersonBuilding.buildingId}
1916
+            </foreach>
1917
+            or
1918
+            d.building_id in
1919
+            <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1920
+                #{taPersonBuilding.buildingId}
1921
+            </foreach>
1809 1922
             or d.create_user = #{userId}
1810 1923
             or c.create_user = #{userId}
1811 1924
             )
@@ -1857,18 +1970,18 @@
1857 1970
         if(a.gender = '1', '男', if(a.gender = '2', '女','未知') ) as gender,
1858 1971
         a.province,
1859 1972
         b1.scene_alias as personFrom,
1860
-        GROUP_CONCAT(c.name) as realtyConsultant,
1861
-        ifnull(d.phone, d.tel) as realtyConsultantPhone,
1862
-        ifnull(e.nickname, f.user_name) as sharePersonName,
1863
-        ifnull(e.phone, e.tel) as sharePersonPhone
1973
+        GROUP_CONCAT(d.user_name) as realtyConsultant,
1974
+        d.phone as realtyConsultantPhone,
1975
+        ifnull(e.nickname, f.name) as sharePersonName,
1976
+        ifnull(e.phone, f.phone) as sharePersonPhone
1864 1977
         FROM ta_share_person_from t
1865 1978
         left join ta_person a on t.person_id = a.person_id
1866 1979
         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
1867 1980
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
1868 1981
         left join ta_recommend_customer c on c.person_id = t.person_id
1869
-        left join ta_person d on c.recommend_person = d.person_id
1870
-        left join ta_person e on t.share_person = e.person_id
1871
-        left join ta_user f on t.share_person = f.user_id
1982
+        LEFT JOIN ta_user d ON c.realty_consultant = d.user_id
1983
+        LEFT JOIN ta_person e ON t.share_person = e.person_id
1984
+        LEFT JOIN ta_person f ON t.share_person = f.user_id
1872 1985
         WHERE t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id =
1873 1986
         #{orgId} and t.status = 1
1874 1987
         and t.is_first_time = 1
@@ -1878,7 +1991,7 @@
1878 1991
             and t.target_id = #{activityId}
1879 1992
         </if>
1880 1993
         <if test="activityType != null and activityType != ''">
1881
-            and t.target_type = concat(#{activityType}, '_share')
1994
+            and t.target_type = concat(REPLACE(#{activityType}, 'activity', 'dynamic'), '_share')
1882 1995
         </if>
1883 1996
         <if test="province != null and province != ''">
1884 1997
             and a.province like concat('%', #{province}, '%')
@@ -1889,7 +2002,7 @@
1889 2002
         <if test="buildingId != null and buildingId != ''">
1890 2003
             and c.building_id = #{buildingId}
1891 2004
         </if>
1892
-        group by t.person_id
2005
+        group by t.person_id order by t.create_date desc
1893 2006
     </select>
1894 2007
 
1895 2008
     <select id="selectActivityAddRegistNumExport"
@@ -1899,18 +2012,18 @@
1899 2012
         if(a.gender = '1', '男', if(a.gender = '2', '女','未知') ) as gender,
1900 2013
         a.province,
1901 2014
         b1.scene_alias as personFrom,
1902
-        GROUP_CONCAT(c.name) as realtyConsultant,
1903
-        ifnull(d.phone, d.tel) as realtyConsultantPhone,
1904
-        ifnull(e.nickname, f.user_name) as sharePersonName,
1905
-        ifnull(e.phone, e.tel) as sharePersonPhone
2015
+        GROUP_CONCAT(d.user_name) as realtyConsultant,
2016
+        d.phone as realtyConsultantPhone,
2017
+        ifnull(e.nickname, f.name) as sharePersonName,
2018
+        ifnull(e.phone, f.phone) as sharePersonPhone
1906 2019
         FROM ta_share_person_from t
1907 2020
         left join ta_person a on t.person_id = a.person_id
1908 2021
         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
1909 2022
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
1910 2023
         left join ta_recommend_customer c on c.person_id = t.person_id
1911
-        left join ta_person d on c.recommend_person = d.person_id
1912
-        left join ta_person e on t.share_person = e.person_id
1913
-        left join ta_user f on t.share_person = f.user_id
2024
+        LEFT JOIN ta_user d ON c.realty_consultant = d.user_id
2025
+        LEFT JOIN ta_person e ON t.share_person = e.person_id
2026
+        LEFT JOIN ta_person f ON t.share_person = f.user_id
1914 2027
         WHERE t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id =
1915 2028
         #{orgId} and t.status = 1
1916 2029
         and t.is_first_time = 1
@@ -1920,7 +2033,7 @@
1920 2033
             and t.target_id = #{activityId}
1921 2034
         </if>
1922 2035
         <if test="activityType != null and activityType != ''">
1923
-            and t.target_type = concat(#{activityType}, '_share')
2036
+            and t.target_type = concat(REPLACE(#{activityType}, 'activity', 'dynamic'), '_share')
1924 2037
         </if>
1925 2038
         <if test="province != null and province != ''">
1926 2039
             and a.province like concat('%', #{province}, '%')
@@ -1931,7 +2044,7 @@
1931 2044
         <if test="buildingId != null and buildingId != ''">
1932 2045
             and c.building_id = #{buildingId}
1933 2046
         </if>
1934
-        group by t.person_id
2047
+        group by t.person_id order by t.create_date desc
1935 2048
     </select>
1936 2049
 
1937 2050
     <select id="selectActivityVisitNum" resultType="com.huiju.estateagents.excel.ActivityStatistics.VisitNum">
@@ -2068,7 +2181,7 @@
2068 2181
         GROUP_CONCAT(d.user_name) as realtyConsultant,
2069 2182
         GROUP_CONCAT(d.phone) as realtyConsultantPhone,
2070 2183
         t.create_date as visitDate,
2071
-        ifnull(e.nickName, f.user_name) as sharePersonName,
2184
+        e.nickName as sharePersonName,
2072 2185
         t.visitNum
2073 2186
         from (
2074 2187
         SELECT
@@ -2101,12 +2214,11 @@
2101 2214
         GROUP BY
2102 2215
         t.person_id ) as t
2103 2216
         left join ta_person a on t.person_id = a.person_id
2104
-        left join ta_person_from_record b on a.person_id = b.person_id and b.org_id = #{orgId}
2217
+        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
2105 2218
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
2106 2219
         LEFT JOIN ta_recommend_customer c on c.person_id = t.person_id
2107 2220
         left join ta_user d on c.realty_consultant = d.user_id
2108
-        left join ta_person e on e.person_id = c.recommend_person
2109
-        left join ta_user f on f.user_id = c.recommend_person
2221
+        LEFT JOIN ta_person e ON e.person_id = b.share_person_id
2110 2222
         <where>
2111 2223
             <if test="personFrom != null and personFrom != ''">
2112 2224
                 and b.scene_type = #{personFrom}
@@ -2135,7 +2247,7 @@
2135 2247
         GROUP_CONCAT(d.user_name) as realtyConsultant,
2136 2248
         GROUP_CONCAT(d.phone) as realtyConsultantPhone,
2137 2249
         t.create_date as visitDate,
2138
-        ifnull(e.nickName, f.user_name) as sharePersonName,
2250
+        e.nickName as sharePersonName,
2139 2251
         t.visitNum
2140 2252
         from (
2141 2253
         SELECT
@@ -2172,8 +2284,7 @@
2172 2284
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
2173 2285
         LEFT JOIN ta_recommend_customer c on c.person_id = t.person_id
2174 2286
         left join ta_user d on c.realty_consultant = d.user_id
2175
-        left join ta_person e on e.person_id = c.recommend_person
2176
-        left join ta_user f on f.user_id = c.recommend_person
2287
+        LEFT JOIN ta_person e ON e.person_id = b.share_person_id
2177 2288
         <where>
2178 2289
             <if test="personFrom != null and personFrom != ''">
2179 2290
                 and b.scene_type = #{personFrom}
@@ -2202,7 +2313,7 @@
2202 2313
         GROUP_CONCAT(d.user_name) as realtyConsultant,
2203 2314
         GROUP_CONCAT(d.phone) as realtyConsultantPhone,
2204 2315
         t.create_date as visitDate,
2205
-        ifnull(e.nickName, f.user_name) as sharePersonName,
2316
+        e.nickName as sharePersonName,
2206 2317
         t.visitNum
2207 2318
         From (
2208 2319
         SELECT count(1) as visitNum, t.person_id, t.create_date
@@ -2228,8 +2339,7 @@
2228 2339
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
2229 2340
         LEFT JOIN ta_recommend_customer c on c.person_id = t.person_id
2230 2341
         left join ta_user d on c.realty_consultant = d.user_id
2231
-        left join ta_person e on e.person_id = c.recommend_person
2232
-        left join ta_user f on f.user_id = c.recommend_person
2342
+        LEFT JOIN ta_person e ON e.person_id = b.share_person_id
2233 2343
         group by t.person_id
2234 2344
     </select>
2235 2345
 
@@ -2287,20 +2397,21 @@
2287 2397
         GROUP_CONCAT(d.user_name) as realtyConsultant,
2288 2398
         GROUP_CONCAT(d.phone) as realtyConsultantPhone,
2289 2399
         t.create_date as visitDate,
2290
-        ifnull(e.nickName, f.user_name) as sharePersonName,
2400
+        e.nickName as sharePersonName,
2291 2401
         t.visitNum
2292 2402
         From (
2293 2403
         SELECT count(1) as visitNum, t.person_id, t.create_date
2294 2404
         FROM ta_share_person_from t
2295 2405
         WHERE t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
2296
-        DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' ) and t.target_type in
2297
-        ('dynamic_share','h5_share','help_share','live_share', 'group_share')
2406
+        DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
2298 2407
         <if test="activityId != null and activityId != ''">
2299 2408
             and t.target_id = #{activityId}
2300 2409
         </if>
2301 2410
         <if test="activityType != null and activityType != ''">
2302 2411
             and t.target_type = concat(REPLACE(#{activityType}, 'activity', 'dynamic'), '_share')
2303 2412
         </if>
2413
+        and t.target_type in
2414
+        ('dynamic_share','h5_share','help_share','live_share', 'group_share')
2304 2415
         and
2305 2416
         (t.share_person = (select b.user_id from ta_person t left join ta_user b on t.user_id = b.user_id where t.person_id = #{personId})
2306 2417
         or t.share_person = #{personId})
@@ -2312,8 +2423,7 @@
2312 2423
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
2313 2424
         LEFT JOIN ta_recommend_customer c on c.person_id = t.person_id
2314 2425
         left join ta_user d on c.realty_consultant = d.user_id
2315
-        left join ta_person e on e.person_id = c.recommend_person
2316
-        left join ta_user f on f.user_id = c.recommend_person
2426
+        LEFT JOIN ta_person e ON e.person_id = b.share_person_id
2317 2427
         group by t.person_id
2318 2428
     </select>
2319 2429
 
@@ -2330,17 +2440,16 @@
2330 2440
         ifnull(e.nickname, f.user_name) as sharePersonName,
2331 2441
         ifnull(e.phone, f.phone) as sharePersonPhone
2332 2442
         From (
2333
-        SELECT t.person_id, t.create_date
2443
+        SELECT t.person_id, t.create_date, t.share_person
2334 2444
         FROM ta_share_person_from t
2335 2445
         LEFT JOIN (
2336
-        SELECT a.person_id, b.user_id, t.share_person
2446
+        SELECT a.person_id, b.user_id
2337 2447
         FROM ta_person a
2338 2448
         LEFT JOIN ta_user b
2339 2449
         ON a.user_id = b.user_id
2340 2450
         WHERE a.org_id = #{orgId} ) as a ON t.share_person = a.person_id or t.share_person = a.user_id
2341 2451
         WHERE t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
2342
-        DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
2343
-        and t.target_type in
2452
+        DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' ) and t.target_type in
2344 2453
         ('dynamic_share','h5_share','help_share','live_share', 'group_share')
2345 2454
         <if test="activityId != null and activityId != ''">
2346 2455
             and t.target_id = #{activityId}