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

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

张延森 преди 5 години
родител
ревизия
57f7abae7c

+ 44
- 0
src/main/java/com/huiju/estateagents/bo/request/ActivityStatisticResponseBO.java Целия файл

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 Целия файл

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 Целия файл

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

+ 6
- 6
src/main/java/com/huiju/estateagents/excel/ActivityStatistics/ShareNum.java Целия файл

37
     @ExcelProperty(value = "分享时间", index = 3)
37
     @ExcelProperty(value = "分享时间", index = 3)
38
     private String shareTime;
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
     @ExcelIgnore
47
     @ExcelIgnore
48
     private String sharePersonId;
48
     private String sharePersonId;

+ 18
- 10
src/main/java/com/huiju/estateagents/excel/ActivityStatistics/VisitPersonNum.java Целия файл

56
     private String realtyConsultantPhone;
56
     private String realtyConsultantPhone;
57
 
57
 
58
     /**
58
     /**
59
-     * 分享者
59
+     * 推广人
60
      */
60
      */
61
     @ColumnWidth(15)
61
     @ColumnWidth(15)
62
-    @ExcelProperty(value = "分享者", index = 7)
62
+    @ExcelProperty(value = "推广人", index = 7)
63
     private String sharePersonName;
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
     @ColumnWidth(15)
81
     @ColumnWidth(15)
76
-    @ExcelProperty(value = "访问次数", index = 9)
82
+    @ExcelProperty(value = "访问次数", index = 8)
77
     private String visitNum;
83
     private String visitNum;
84
+
85
+
78
 }
86
 }

+ 41
- 0
src/main/java/com/huiju/estateagents/excel/IntentionUser.java Целия файл

35
     @ExcelProperty(value = "意向值", index = 3)
35
     @ExcelProperty(value = "意向值", index = 3)
36
     private Integer intention;
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 Целия файл

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 Целия файл

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

+ 27
- 0
src/main/java/com/huiju/estateagents/service/IActivityManageService.java Целия файл

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 Целия файл

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 Целия файл

64
 
64
 
65
     @Autowired
65
     @Autowired
66
     private TdCityMapper cityMapper;
66
     private TdCityMapper cityMapper;
67
-    
67
+
68
     @Autowired
68
     @Autowired
69
     private TaCustomerFollowUpRecordMapper customerFollowUpRecordMapper;
69
     private TaCustomerFollowUpRecordMapper customerFollowUpRecordMapper;
70
 
70
 
217
     }
217
     }
218
 
218
 
219
     @Override
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
         JSONObject params = JSONObject.parseObject(paramStr);
221
         JSONObject params = JSONObject.parseObject(paramStr);
222
         if (null == params) {
222
         if (null == params) {
223
             return ResponseBean.error("解析参数失败", ResponseBean.ERROR_ILLEGAL_PARAMS);
223
             return ResponseBean.error("解析参数失败", ResponseBean.ERROR_ILLEGAL_PARAMS);
233
             return ResponseBean.error(checkResult, ResponseBean.ERROR_MISSING_PARAMS);
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
         taRecommendCustomer.setName(params.getString("name"));
247
         taRecommendCustomer.setName(params.getString("name"));
239
         taRecommendCustomer.setPicture(params.getString("picture"));
248
         taRecommendCustomer.setPicture(params.getString("picture"));
240
         taRecommendCustomer.setPhone(params.getString("phone"));
249
         taRecommendCustomer.setPhone(params.getString("phone"));
248
         taRecommendCustomer.setCreateDate(LocalDateTime.now());
257
         taRecommendCustomer.setCreateDate(LocalDateTime.now());
249
         taRecommendCustomer.setReportDate(LocalDateTime.now());
258
         taRecommendCustomer.setReportDate(LocalDateTime.now());
250
         taRecommendCustomer.setOrgId(orgId);
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
         TaPerson currentPerson = taPersonMapper.selectOne(personQueryWrapper);
263
         TaPerson currentPerson = taPersonMapper.selectOne(personQueryWrapper);
255
-        if(null != currentPerson){
264
+        if (null != currentPerson) {
256
             taRecommendCustomer.setPersonId(currentPerson.getPersonId());
265
             taRecommendCustomer.setPersonId(currentPerson.getPersonId());
257
         }
266
         }
258
 
267
 
277
 
286
 
278
         String status = params.getString("status");
287
         String status = params.getString("status");
279
         int statusInt = 0;
288
         int statusInt = 0;
280
-        if (StringUtils.isEmpty(status)){
289
+        if (StringUtils.isEmpty(status)) {
281
             taRecommendCustomer.setStatus(statusInt);
290
             taRecommendCustomer.setStatus(statusInt);
282
-        }else{
291
+        } else {
283
             taRecommendCustomer.setStatus(Integer.parseInt(status));
292
             taRecommendCustomer.setStatus(Integer.parseInt(status));
284
         }
293
         }
285
 
294
 
286
         taRecommendCustomer.setRecommendPerson(taPerson.getPersonId());
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
         int row = taRecommendCustomerMapper.insert(taRecommendCustomer);
297
         int row = taRecommendCustomerMapper.insert(taRecommendCustomer);
299
         if (row < 1) {
298
         if (row < 1) {
300
             return ResponseBean.error("推荐客户失败", ResponseBean.ERROR_UNAVAILABLE);
299
             return ResponseBean.error("推荐客户失败", ResponseBean.ERROR_UNAVAILABLE);
311
     }
310
     }
312
 
311
 
313
 
312
 
314
-
315
     @Override
313
     @Override
316
-    public ResponseBean reportCust(String paramStr, String openid,Integer orgId) {
314
+    public ResponseBean reportCust(String paramStr, String openid, Integer orgId) {
317
         JSONObject params = JSONObject.parseObject(paramStr);
315
         JSONObject params = JSONObject.parseObject(paramStr);
318
         if (null == params) {
316
         if (null == params) {
319
             return ResponseBean.error("解析参数失败", ResponseBean.ERROR_ILLEGAL_PARAMS);
317
             return ResponseBean.error("解析参数失败", ResponseBean.ERROR_ILLEGAL_PARAMS);
367
 //        taRecommendCustomer.setDescribe(params.getString("describe"));
365
 //        taRecommendCustomer.setDescribe(params.getString("describe"));
368
         taRecommendCustomer.setRealtyConsultant(consultantUser.getUserId().toString());
366
         taRecommendCustomer.setRealtyConsultant(consultantUser.getUserId().toString());
369
         //如果没有传building_id的情况构造building_id
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
             QueryWrapper<TaPersonBuilding> taPersonBuildingQueryWrapper = new QueryWrapper<>();
369
             QueryWrapper<TaPersonBuilding> taPersonBuildingQueryWrapper = new QueryWrapper<>();
372
             taPersonBuildingQueryWrapper.eq("person_id", consultantPerson.getPersonId()).or().eq("user_id", consultantUser.getUserId());
370
             taPersonBuildingQueryWrapper.eq("person_id", consultantPerson.getPersonId()).or().eq("user_id", consultantUser.getUserId());
373
             List<TaPersonBuilding> taPersonBuildingList = taPersonBuildingMapper.selectList(taPersonBuildingQueryWrapper);
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
         taRecommendCustomer.setBuildingId(params.getString("buildingId"));
376
         taRecommendCustomer.setBuildingId(params.getString("buildingId"));
399
         taRecommendCustomer.setVerifyStatus(CommConstant.VERIFY_AGREE);
397
         taRecommendCustomer.setVerifyStatus(CommConstant.VERIFY_AGREE);
400
         taRecommendCustomer.setStatus(CommConstant.CUSTOMER_REPORT);
398
         taRecommendCustomer.setStatus(CommConstant.CUSTOMER_REPORT);
401
         QueryWrapper<TaPerson> personQueryWrapper = new QueryWrapper<>();
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
         TaPerson currentPerson = taPersonMapper.selectOne(personQueryWrapper);
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
                 return ResponseBean.error("置业顾问不可以绑定置业顾问", ResponseBean.ERROR_ILLEGAL_PARAMS);
405
                 return ResponseBean.error("置业顾问不可以绑定置业顾问", ResponseBean.ERROR_ILLEGAL_PARAMS);
408
             }
406
             }
409
             taRecommendCustomer.setPersonId(currentPerson.getPersonId());
407
             taRecommendCustomer.setPersonId(currentPerson.getPersonId());
419
         // 报备有 10 天有效期
417
         // 报备有 10 天有效期
420
         QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
418
         QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
421
         queryWrapper.eq("phone", taRecommendCustomer.getPhone());
419
         queryWrapper.eq("phone", taRecommendCustomer.getPhone());
422
-        queryWrapper.eq("building_id",taRecommendCustomer.getBuildingId());
420
+        queryWrapper.eq("building_id", taRecommendCustomer.getBuildingId());
423
         queryWrapper.eq("org_id", taRecommendCustomer.getOrgId());
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
         List<TaRecommendCustomer> result = taRecommendCustomerMapper.selectList(queryWrapper);
423
         List<TaRecommendCustomer> result = taRecommendCustomerMapper.selectList(queryWrapper);
426
         if (null != result && result.size() > 0) {
424
         if (null != result && result.size() > 0) {
427
             String conName = "";
425
             String conName = "";
428
             TaPerson conPerson = taPersonMapper.selectById(result.get(0).getRealtyConsultant());
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
                 conName = conPerson.getName();
431
                 conName = conPerson.getName();
434
-            }else {
432
+            } else {
435
                 TaUser conUser = userService.getById(result.get(0).getRealtyConsultant());
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
                         return ResponseBean.success("bound");
436
                         return ResponseBean.success("bound");
439
                     }
437
                     }
440
                     conName = conUser.getUserName();
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
         int row = taRecommendCustomerMapper.insert(taRecommendCustomer);
445
         int row = taRecommendCustomerMapper.insert(taRecommendCustomer);
518
     }
516
     }
519
 
517
 
520
 
518
 
521
-
522
-
523
     List<TaPerson> getPersonsByOpenId(String openid) {
519
     List<TaPerson> getPersonsByOpenId(String openid) {
524
         return taPersonMapper.getPersonByOpenId(openid);
520
         return taPersonMapper.getPersonByOpenId(openid);
525
     }
521
     }
526
 
522
 
527
     @Override
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
 //        queryWrapper.eq("building_id",building);
526
 //        queryWrapper.eq("building_id",building);
531
-        queryWrapper.eq("realty_consultant",personId);
527
+        queryWrapper.eq("realty_consultant", personId);
532
         queryWrapper.gt("status", CommConstant.MESSAGE_UNREAD);
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
     @Override
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
         if (CommConstant.CUTOMER_TYPE_PUBLIC.equals(customerType)) {
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
             // 公客就不用 buildingId 进行查询
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
         } else {
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
     @Override
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
     @Override
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
     @Override
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
     @Override
568
     @Override
573
-    public TaRecommendCustomer getCustomerById(String customerId){
569
+    public TaRecommendCustomer getCustomerById(String customerId) {
574
         return taRecommendCustomerMapper.getCustomerById(customerId);
570
         return taRecommendCustomerMapper.getCustomerById(customerId);
575
     }
571
     }
576
 
572
 
577
 
573
 
578
     @Override
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
         String personId = taRecommendCustomerMapper.getCustomerById(customerId).getPersonId();
576
         String personId = taRecommendCustomerMapper.getCustomerById(customerId).getPersonId();
581
-        TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.getCustomerDetail(customerId,personId);
577
+        TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.getCustomerDetail(customerId, personId);
582
         TaPerson person = taPersonMapper.selectById(personId);
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
             List<TaPersonVisitRecord> records = taPersonVisitRecordIPage.getRecords();
582
             List<TaPersonVisitRecord> records = taPersonVisitRecordIPage.getRecords();
587
             records.forEach(e -> {
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
                     TaBuildingDynamic taBuildingDynamic = taBuildingDynamicMapper.selectById(e.getTargetId());
586
                     TaBuildingDynamic taBuildingDynamic = taBuildingDynamicMapper.selectById(e.getTargetId());
591
-                    if (null != taBuildingDynamic){
587
+                    if (null != taBuildingDynamic) {
592
                         e.setActivityName(taBuildingDynamic.getTitle());
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
                     TaShareActivity taShareActivity = taShareActivityMapper.selectById(e.getTargetId());
594
                     TaShareActivity taShareActivity = taShareActivityMapper.selectById(e.getTargetId());
599
-                    if (null != taShareActivity){
595
+                    if (null != taShareActivity) {
600
                         e.setActivityName(taShareActivity.getActivityName());
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
                     HelpActivity helpActivity = helpActivityMapper.selectById(e.getTargetId());
601
                     HelpActivity helpActivity = helpActivityMapper.selectById(e.getTargetId());
606
-                    if (null != helpActivity){
602
+                    if (null != helpActivity) {
607
                         e.setActivityName(helpActivity.getTitle());
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
                     TaNews taNews = taNewsMapper.selectById(e.getTargetId());
608
                     TaNews taNews = taNewsMapper.selectById(e.getTargetId());
613
-                    if (null != taNews){
609
+                    if (null != taNews) {
614
                         e.setActivityName(taNews.getNewsName());
610
                         e.setActivityName(taNews.getNewsName());
615
                     }
611
                     }
616
                 }
612
                 }
617
                 //获取H5活动标题
613
                 //获取H5活动标题
618
-                if ("h5".equals(e.getEventType()) && null != e.getTargetId()){
614
+                if ("h5".equals(e.getEventType()) && null != e.getTargetId()) {
619
                     TaDrainage taDrainage = taDrainageMapper.selectById(e.getTargetId());
615
                     TaDrainage taDrainage = taDrainageMapper.selectById(e.getTargetId());
620
-                    if (null != taDrainage){
616
+                    if (null != taDrainage) {
621
                         e.setActivityName(taDrainage.getName());
617
                         e.setActivityName(taDrainage.getName());
622
                     }
618
                     }
623
                 }
619
                 }
625
             taPersonVisitRecordIPage.setRecords(records);
621
             taPersonVisitRecordIPage.setRecords(records);
626
             taRecommendCustomer.setVisitRecords(taPersonVisitRecordIPage);
622
             taRecommendCustomer.setVisitRecords(taPersonVisitRecordIPage);
627
             taRecommendCustomer.setVisitTimes(taPersonVisitRecordIPage.getRecords().size());
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
             TaUser user = new TaUser();
628
             TaUser user = new TaUser();
633
-            if(null == consultant){
629
+            if (null == consultant) {
634
                 user = userService.getById(taRecommendCustomer.getRealtyConsultant());
630
                 user = userService.getById(taRecommendCustomer.getRealtyConsultant());
635
-            }else {
631
+            } else {
636
                 user = userService.getById(consultant.getUserId());
632
                 user = userService.getById(consultant.getUserId());
637
             }
633
             }
638
-            if (null != user){
634
+            if (null != user) {
639
                 List<String> projects = taPersonMapper.getUserProjects(user.getUserId());
635
                 List<String> projects = taPersonMapper.getUserProjects(user.getUserId());
640
-                if (projects.size()>0){
636
+                if (projects.size() > 0) {
641
                     user.setProjects(projects);
637
                     user.setProjects(projects);
642
                 }
638
                 }
643
                 taRecommendCustomer.setConsultant(user);
639
                 taRecommendCustomer.setConsultant(user);
645
         }
641
         }
646
         //构造来源类型
642
         //构造来源类型
647
         taRecommendCustomer.setPersonFrom("");
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
             TdCity city = cityMapper.selectById(person.getCity());
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
             taRecommendCustomer.setGeoInfo(geoInfo);
654
             taRecommendCustomer.setGeoInfo(geoInfo);
659
 
655
 
660
             QueryWrapper<TaPersonFromRecord> queryWrapper = new QueryWrapper<>();
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
             List<TaPersonFromRecord> taPersonFromRecords = taPersonFromRecordMapper.selectList(queryWrapper);
660
             List<TaPersonFromRecord> taPersonFromRecords = taPersonFromRecordMapper.selectList(queryWrapper);
665
-            if (taPersonFromRecords.size() > 0){
661
+            if (taPersonFromRecords.size() > 0) {
666
                 QueryWrapper<TdWxDict> tdWxDictQueryWrapper = new QueryWrapper<>();
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
                 TdWxDict tdWxDict = tdWxDictMapper.selectOne(tdWxDictQueryWrapper);
664
                 TdWxDict tdWxDict = tdWxDictMapper.selectOne(tdWxDictQueryWrapper);
669
                 taRecommendCustomer.setPersonFrom(null != tdWxDict ? tdWxDict.getSceneAlias() : "");
665
                 taRecommendCustomer.setPersonFrom(null != tdWxDict ? tdWxDict.getSceneAlias() : "");
670
             }
666
             }
674
     }
670
     }
675
 
671
 
676
     @Override
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
         TaPerson taPerson = taPersonMapper.getById(personId);
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
             List<TaPersonVisitRecord> records = taPersonVisitRecordIPage.getRecords();
678
             List<TaPersonVisitRecord> records = taPersonVisitRecordIPage.getRecords();
683
             records.forEach(e -> {
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
                     TaBuildingDynamic taBuildingDynamic = taBuildingDynamicMapper.selectById(e.getTargetId());
682
                     TaBuildingDynamic taBuildingDynamic = taBuildingDynamicMapper.selectById(e.getTargetId());
687
-                    if (null != taBuildingDynamic){
683
+                    if (null != taBuildingDynamic) {
688
                         e.setActivityName(taBuildingDynamic.getTitle());
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
                     TaShareActivity taShareActivity = taShareActivityMapper.selectById(e.getTargetId());
690
                     TaShareActivity taShareActivity = taShareActivityMapper.selectById(e.getTargetId());
695
-                    if (null != taShareActivity){
691
+                    if (null != taShareActivity) {
696
                         e.setActivityName(taShareActivity.getActivityName());
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
                     HelpActivity helpActivity = helpActivityMapper.selectById(e.getTargetId());
697
                     HelpActivity helpActivity = helpActivityMapper.selectById(e.getTargetId());
702
-                    if (null != helpActivity){
698
+                    if (null != helpActivity) {
703
                         e.setActivityName(helpActivity.getTitle());
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
                     TaNews taNews = taNewsMapper.selectById(e.getTargetId());
704
                     TaNews taNews = taNewsMapper.selectById(e.getTargetId());
709
-                    if (null != taNews){
705
+                    if (null != taNews) {
710
                         e.setActivityName(taNews.getNewsName());
706
                         e.setActivityName(taNews.getNewsName());
711
                     }
707
                     }
712
                 }
708
                 }
713
                 //获取H5活动标题
709
                 //获取H5活动标题
714
-                if ("h5".equals(e.getEventType()) && null != e.getTargetId()){
710
+                if ("h5".equals(e.getEventType()) && null != e.getTargetId()) {
715
                     TaDrainage taDrainage = taDrainageMapper.selectById(e.getTargetId());
711
                     TaDrainage taDrainage = taDrainageMapper.selectById(e.getTargetId());
716
-                    if (null != taDrainage){
712
+                    if (null != taDrainage) {
717
                         e.setActivityName(taDrainage.getName());
713
                         e.setActivityName(taDrainage.getName());
718
                     }
714
                     }
719
                 }
715
                 }
721
             taPersonVisitRecordIPage.setRecords(records);
717
             taPersonVisitRecordIPage.setRecords(records);
722
             taPerson.setVisitRecords(taPersonVisitRecordIPage);
718
             taPerson.setVisitRecords(taPersonVisitRecordIPage);
723
             taPerson.setVisitTimes(taPersonVisitRecordIPage.getRecords().size());
719
             taPerson.setVisitTimes(taPersonVisitRecordIPage.getRecords().size());
724
-            taPerson.setIntentions(taRecommendCustomerMapper.getCustomerIntentions(personId,taPersonBuildingList));
720
+            taPerson.setIntentions(taRecommendCustomerMapper.getCustomerIntentions(personId, taPersonBuildingList));
725
             taPerson.setDuration(taPersonVisitRecordMapper.getDurationByPersonId(personId));
721
             taPerson.setDuration(taPersonVisitRecordMapper.getDurationByPersonId(personId));
726
             taPerson.setVisitTime(taPersonVisitRecordMapper.getFirstVisitTimeByPersonId(personId));
722
             taPerson.setVisitTime(taPersonVisitRecordMapper.getFirstVisitTimeByPersonId(personId));
727
             TdCity city = cityMapper.selectById(taPerson.getCity());
723
             TdCity city = cityMapper.selectById(taPerson.getCity());
728
-            if(null != city){
724
+            if (null != city) {
729
                 taPerson.setCity(city.getName());
725
                 taPerson.setCity(city.getName());
730
             }
726
             }
731
 
727
 
732
             //构造来源类型
728
             //构造来源类型
733
             taPerson.setPersonFrom("");
729
             taPerson.setPersonFrom("");
734
-            if (null != taPerson){
730
+            if (null != taPerson) {
735
                 QueryWrapper<TaPersonFromRecord> queryWrapper = new QueryWrapper<>();
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
                 List<TaPersonFromRecord> taPersonFromRecords = taPersonFromRecordMapper.selectList(queryWrapper);
735
                 List<TaPersonFromRecord> taPersonFromRecords = taPersonFromRecordMapper.selectList(queryWrapper);
740
-                if (taPersonFromRecords.size() > 0){
736
+                if (taPersonFromRecords.size() > 0) {
741
                     QueryWrapper<TdWxDict> tdWxDictQueryWrapper = new QueryWrapper<>();
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
                     TdWxDict tdWxDict = tdWxDictMapper.selectOne(tdWxDictQueryWrapper);
739
                     TdWxDict tdWxDict = tdWxDictMapper.selectOne(tdWxDictQueryWrapper);
744
                     taPerson.setPersonFrom(null != tdWxDict ? tdWxDict.getSceneAlias() : "");
740
                     taPerson.setPersonFrom(null != tdWxDict ? tdWxDict.getSceneAlias() : "");
745
                 }
741
                 }
749
     }
745
     }
750
 
746
 
751
     @Override
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
         // todo
751
         // todo
756
         // 此处可能不是 person_id 而是 recommend_person
752
         // 此处可能不是 person_id 而是 recommend_person
757
-        IPage<TaRecommendCustomer>page = new Page<>(pageNumber,pageSize);
753
+        IPage<TaRecommendCustomer> page = new Page<>(pageNumber, pageSize);
758
 //        queryWrapper.eq("recommend_person",customerId);
754
 //        queryWrapper.eq("recommend_person",customerId);
759
 ////        queryWrapper.eq("building_id",building);
755
 ////        queryWrapper.eq("building_id",building);
760
 //        queryWrapper.eq("status", CommConstant.VERIFY_AGREE);
756
 //        queryWrapper.eq("status", CommConstant.VERIFY_AGREE);
761
 //        queryWrapper.eq("org_id", orgId);
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
     @Override
761
     @Override
801
 
797
 
802
     @Override
798
     @Override
803
     public ResponseBean batchConsultantAssist(TaUser taUser, Integer orgId) {
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
                 consultantAssist(taUser, taPerson.getPersonId(), orgId);
802
                 consultantAssist(taUser, taPerson.getPersonId(), orgId);
807
             }
803
             }
808
         }
804
         }
881
 
877
 
882
 
878
 
883
     @Override
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
     @Override
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
     @Override
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
     @Override
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
     public List<AgentsRecommendCustomer> getIndependentAgentsExport(Integer orgId, Integer pageCode, Integer pageSize) {
907
     public List<AgentsRecommendCustomer> getIndependentAgentsExport(Integer orgId, Integer pageCode, Integer pageSize) {
912
         return taRecommendCustomerMapper.getIndependentAgentsExport(orgId, pageCode, pageSize);
908
         return taRecommendCustomerMapper.getIndependentAgentsExport(orgId, pageCode, pageSize);
913
     }
909
     }
914
-    
910
+
915
     /**
911
     /**
916
      * 查询我的客户人数集合
912
      * 查询我的客户人数集合
917
      *
913
      *
924
         if (null == taPersons || taPersons.size() != 1) {
920
         if (null == taPersons || taPersons.size() != 1) {
925
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
921
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
926
         }
922
         }
927
-    
923
+
928
         TaPerson taPerson = taPersons.get(0);
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
         return ResponseBean.success(map);
926
         return ResponseBean.success(map);
931
     }
927
     }
932
-    
928
+
933
     /**
929
     /**
934
      * 分页查询我的跟进客户集合
930
      * 分页查询我的跟进客户集合
935
      *
931
      *
951
         if (null == taPersons || taPersons.size() != 1) {
947
         if (null == taPersons || taPersons.size() != 1) {
952
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
948
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
953
         }
949
         }
954
-    
950
+
955
         TaPerson taPerson = taPersons.get(0);
951
         TaPerson taPerson = taPersons.get(0);
956
-        
952
+
957
         IPage<TaRecommendCustomer> page = new Page<>();
953
         IPage<TaRecommendCustomer> page = new Page<>();
958
         page.setCurrent(pageNumber);
954
         page.setCurrent(pageNumber);
959
         page.setSize(pageSize);
955
         page.setSize(pageSize);
960
-        
956
+
961
         //分页获取跟进客户status != 4的为跟进客户, status = 4的为成交客户 根据type区分  follow 跟进  clinch 成交
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
         return ResponseBean.success(result);
959
         return ResponseBean.success(result);
964
     }
960
     }
965
-    
961
+
966
     /**
962
     /**
967
      * 获取盘客工具下我的客户详情
963
      * 获取盘客工具下我的客户详情
968
      *
964
      *
976
         if (null == taPersons || taPersons.size() != 1) {
972
         if (null == taPersons || taPersons.size() != 1) {
977
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
973
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
978
         }
974
         }
979
-    
975
+
980
         TaPerson taPerson = taPersons.get(0);
976
         TaPerson taPerson = taPersons.get(0);
981
         TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.getMyCustDetailById(customerId);
977
         TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.getMyCustDetailById(customerId);
982
         //添加跟进行为
978
         //添加跟进行为
983
-        addCustomerFpllowUp(taPerson,taRecommendCustomer,"查看客户详情");
979
+        addCustomerFpllowUp(taPerson, taRecommendCustomer, "查看客户详情");
984
         return ResponseBean.success(taRecommendCustomer);
980
         return ResponseBean.success(taRecommendCustomer);
985
     }
981
     }
986
-    
982
+
987
     /**
983
     /**
988
      * 更新我的客户基本信息
984
      * 更新我的客户基本信息
989
      *
985
      *
997
         if (null == taPersons || taPersons.size() != 1) {
993
         if (null == taPersons || taPersons.size() != 1) {
998
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
994
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
999
         }
995
         }
1000
-    
996
+
1001
         TaPerson taPerson = taPersons.get(0);
997
         TaPerson taPerson = taPersons.get(0);
1002
         taRecommendCustomerMapper.updateById(taRecommendCustomer);
998
         taRecommendCustomerMapper.updateById(taRecommendCustomer);
1003
         //添加跟进行为
999
         //添加跟进行为
1004
-        addCustomerFpllowUp(taPerson,taRecommendCustomer,"编辑客户信息");
1000
+        addCustomerFpllowUp(taPerson, taRecommendCustomer, "编辑客户信息");
1005
         return ResponseBean.success(taRecommendCustomer);
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
         TaCustomerFollowUpRecord taCustomerFollowUpRecord = new TaCustomerFollowUpRecord();
1006
         TaCustomerFollowUpRecord taCustomerFollowUpRecord = new TaCustomerFollowUpRecord();
1011
         taCustomerFollowUpRecord.setOrgId(taPerson.getOrgId());
1007
         taCustomerFollowUpRecord.setOrgId(taPerson.getOrgId());
1012
         taCustomerFollowUpRecord.setCreateDate(LocalDateTime.now());
1008
         taCustomerFollowUpRecord.setCreateDate(LocalDateTime.now());

+ 168
- 0
src/main/resources/mapper/ActivityManageMapper.xml Целия файл

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 Целия файл

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

+ 27
- 19
src/main/resources/mapper/TaBuildingMapper.xml Целия файл

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

+ 60
- 12
src/main/resources/mapper/TaPersonIntentionRecordMapper.xml Целия файл

43
         ORDER BY SUM(tpir.intention) DESC
43
         ORDER BY SUM(tpir.intention) DESC
44
     </select>
44
     </select>
45
     <select id="selectExportIntentionUser" resultType="com.huiju.estateagents.excel.IntentionUser">
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
         SELECT
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
         tp.phone as phone,
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
         SUM(tpir.intention) as intention
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
         <trim prefix="where" prefixOverrides="and | or">
64
         <trim prefix="where" prefixOverrides="and | or">
55
-            <if test="buildingId != null and buildingId != ''">
56
-                tpir.building_id = #{buildingId}
57
-            </if>
58
             <if test="orgId != null">
65
             <if test="orgId != null">
59
                 AND tpir.org_id = #{orgId}
66
                 AND tpir.org_id = #{orgId}
60
                 AND tp.org_id = #{orgId}
67
                 AND tp.org_id = #{orgId}
61
             </if>
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
             <if test="personBuildingList != null and personBuildingList.size > 0">
81
             <if test="personBuildingList != null and personBuildingList.size > 0">
63
-                AND tpir.building_id in
82
+                AND t.building_id in
64
                 <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
83
                 <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
65
                     #{personBuilding.buildingId}
84
                     #{personBuilding.buildingId}
66
                 </foreach>
85
                 </foreach>
67
             </if>
86
             </if>
68
         </trim>
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
     </select>
120
     </select>
73
 </mapper>
121
 </mapper>

+ 178
- 69
src/main/resources/mapper/statistic/TaActivityStaticMapper.xml Целия файл

47
                 <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
47
                 <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
48
                     #{taPersonBuilding.buildingId}
48
                     #{taPersonBuilding.buildingId}
49
                 </foreach>
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
               or d.create_user = #{userId}
60
               or d.create_user = #{userId}
51
               or c.create_user = #{userId}
61
               or c.create_user = #{userId}
52
             )
62
             )
100
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
110
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
101
                 #{taPersonBuilding.buildingId}
111
                 #{taPersonBuilding.buildingId}
102
             </foreach>
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
             or d.create_user = #{userId}
123
             or d.create_user = #{userId}
104
             or c.create_user = #{userId}
124
             or c.create_user = #{userId}
105
             )
125
             )
232
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
252
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
233
                 #{taPersonBuilding.buildingId}
253
                 #{taPersonBuilding.buildingId}
234
             </foreach>
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
             or d.create_user = #{userId}
265
             or d.create_user = #{userId}
236
             or c.create_user = #{userId}
266
             or c.create_user = #{userId}
237
             )
267
             )
310
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
340
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
311
                 #{taPersonBuilding.buildingId}
341
                 #{taPersonBuilding.buildingId}
312
             </foreach>
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
             or d.create_user = #{userId}
353
             or d.create_user = #{userId}
314
             or c.create_user = #{userId}
354
             or c.create_user = #{userId}
315
             )
355
             )
561
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
601
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
562
                 #{taPersonBuilding.buildingId}
602
                 #{taPersonBuilding.buildingId}
563
             </foreach>
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
             or d.create_user = #{userId}
614
             or d.create_user = #{userId}
565
             or c.create_user = #{userId}
615
             or c.create_user = #{userId}
566
             )
616
             )
786
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
836
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
787
                 #{taPersonBuilding.buildingId}
837
                 #{taPersonBuilding.buildingId}
788
             </foreach>
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
             or d.create_user = #{userId}
849
             or d.create_user = #{userId}
790
             or c.create_user = #{userId}
850
             or c.create_user = #{userId}
791
             )
851
             )
857
             and t.building_id = #{buildingId}
917
             and t.building_id = #{buildingId}
858
         </if>
918
         </if>
859
         <if test="targetType != null and targetType != ''">
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
         </if>
922
         </if>
862
         <if test="startDate != null">
923
         <if test="startDate != null">
863
             and t.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
924
             and t.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
890
             and t.building_id = #{buildingId}
951
             and t.building_id = #{buildingId}
891
         </if>
952
         </if>
892
         <if test="targetType != null and targetType != ''">
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
         </if>
956
         </if>
895
         <if test="startDate != null">
957
         <if test="startDate != null">
896
             and t.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
958
             and t.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1043
         ) as activity
1105
         ) as activity
1044
 
1106
 
1045
         left join (
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
             FROM ta_share_count a where a.tagert_type in (
1109
             FROM ta_share_count a where a.tagert_type in (
1048
             'activity', 'group','h5','help','liveApp','livePost')
1110
             'activity', 'group','h5','help','liveApp','livePost')
1049
             and a.org_id = #{orgId}
1111
             and a.org_id = #{orgId}
1060
             <if test="startDate == null or endDate == null ">
1122
             <if test="startDate == null or endDate == null ">
1061
                 AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1123
                 AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1062
             </if>
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
         ) as shareNum on shareNum.be_share = activity.activityId and shareNum.tagert_type = activity.activityType
1126
         ) as shareNum on shareNum.be_share = activity.activityId and shareNum.tagert_type = activity.activityType
1065
 
1127
 
1066
         left join (
1128
         left join (
1081
         <if test="startDate == null or endDate == null ">
1143
         <if test="startDate == null or endDate == null ">
1082
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1144
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1083
         </if>
1145
         </if>
1084
-        group by a.person_id
1146
+        group by a.person_id, be_share
1085
 <!--        , be_share, tagert_type-->
1147
 <!--        , be_share, tagert_type-->
1086
         ) as sharePersonNum group by sharePersonNum.be_share, sharePersonNum.tagert_type
1148
         ) as sharePersonNum group by sharePersonNum.be_share, sharePersonNum.tagert_type
1087
         ) as sharePersonNum on sharePersonNum.be_share = activity.activityId and sharePersonNum.tagert_type =
1149
         ) as sharePersonNum on sharePersonNum.be_share = activity.activityId and sharePersonNum.tagert_type =
1135
         and a.status = 1
1197
         and a.status = 1
1136
         and a.is_first_time = 1
1198
         and a.is_first_time = 1
1137
         <if test="targetType != null and targetType != '' and targetType != 'h5'">
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
         </if>
1201
         </if>
1140
         <if test="startDate != null ">
1202
         <if test="startDate != null ">
1141
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1203
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1148
         </if>
1210
         </if>
1149
         group by a.person_id, a.target_type ,a.target_id
1211
         group by a.person_id, a.target_type ,a.target_id
1150
         ) as addRegistNum group by addRegistNum.target_type, addRegistNum.target_id
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
         <if test="targetType != null and targetType != ''">
1214
         <if test="targetType != null and targetType != ''">
1154
             where activity.activityType = #{targetType}
1215
             where activity.activityType = #{targetType}
1155
         </if>
1216
         </if>
1179
             and a.building_id = #{buildingId}
1240
             and a.building_id = #{buildingId}
1180
         </if>
1241
         </if>
1181
         <if test="activityName != null and activityName != '' ">
1242
         <if test="activityName != null and activityName != '' ">
1182
-            and a.title = #{activityName}
1243
+            and a.title like concat('%', #{activityName}, '%')
1183
         </if>
1244
         </if>
1184
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1245
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1185
             and a.building_id in
1246
             and a.building_id in
1194
             and b.building_id = #{buildingId}
1255
             and b.building_id = #{buildingId}
1195
         </if>
1256
         </if>
1196
         <if test="activityName != null and activityName != '' ">
1257
         <if test="activityName != null and activityName != '' ">
1197
-            and b.title = #{activityName}
1258
+            and b.title like concat('%', #{activityName}, '%')
1198
         </if>
1259
         </if>
1199
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1260
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1200
             and b.building_id in
1261
             and b.building_id in
1210
             and c.building_id = #{buildingId}
1271
             and c.building_id = #{buildingId}
1211
         </if>
1272
         </if>
1212
         <if test="activityName != null and activityName != '' ">
1273
         <if test="activityName != null and activityName != '' ">
1213
-            and c.activity_name = #{activityName}
1274
+            and c.activity_name like concat('%', #{activityName}, '%')
1214
         </if>
1275
         </if>
1215
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1276
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1216
             and c.building_id in
1277
             and c.building_id in
1225
             and d.building_id = #{buildingId}
1286
             and d.building_id = #{buildingId}
1226
         </if>
1287
         </if>
1227
         <if test="activityName != null and activityName != '' ">
1288
         <if test="activityName != null and activityName != '' ">
1228
-            and d.name = #{activityName}
1289
+            and d.name like concat('%', #{activityName}, '%')
1229
         </if>
1290
         </if>
1230
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1291
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1231
             and (d.building_id in
1292
             and (d.building_id in
1243
             and e.building_id = #{buildingId}
1304
             and e.building_id = #{buildingId}
1244
         </if>
1305
         </if>
1245
         <if test="activityName != null and activityName != '' ">
1306
         <if test="activityName != null and activityName != '' ">
1246
-            and e.live_activity_title = #{activityName}
1307
+            and e.live_activity_title like concat('%', #{activityName}, '%')
1247
         </if>
1308
         </if>
1248
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1309
         <if test="taPersonBuildings != null and taPersonBuildings.size > 0">
1249
             and (e.building_id in
1310
             and (e.building_id in
1256
         ) as activity
1317
         ) as activity
1257
 
1318
 
1258
         left join (
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
         FROM ta_share_count a where a.tagert_type in (
1321
         FROM ta_share_count a where a.tagert_type in (
1261
         'activity', 'group','h5','help','liveApp','livePost')
1322
         'activity', 'group','h5','help','liveApp','livePost')
1262
         and a.org_id = #{orgId}
1323
         and a.org_id = #{orgId}
1263
         <if test="targetType != null and targetType != ''">
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
         </if>
1327
         </if>
1266
         <if test="startDate != null ">
1328
         <if test="startDate != null ">
1267
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1329
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1272
         <if test="startDate == null or endDate == null ">
1334
         <if test="startDate == null or endDate == null ">
1273
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1335
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1274
         </if>
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
         ) as shareNum on shareNum.be_share = activity.activityId and shareNum.tagert_type = activity.activityType
1338
         ) as shareNum on shareNum.be_share = activity.activityId and shareNum.tagert_type = activity.activityType
1277
 
1339
 
1278
         left join (
1340
         left join (
1281
         From ta_share_count a where a.tagert_type in ( 'activity', 'group','h5','help','liveApp','livePost')
1343
         From ta_share_count a where a.tagert_type in ( 'activity', 'group','h5','help','liveApp','livePost')
1282
         and a.org_id = #{orgId}
1344
         and a.org_id = #{orgId}
1283
         <if test="targetType != null and targetType != ''">
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
         </if>
1348
         </if>
1286
         <if test="startDate != null ">
1349
         <if test="startDate != null ">
1287
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1350
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1292
         <if test="startDate == null or endDate == null ">
1355
         <if test="startDate == null or endDate == null ">
1293
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1356
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1294
         </if>
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
         ) as sharePersonNum group by sharePersonNum.be_share, sharePersonNum.tagert_type
1360
         ) as sharePersonNum group by sharePersonNum.be_share, sharePersonNum.tagert_type
1297
         ) as sharePersonNum on sharePersonNum.be_share = activity.activityId and sharePersonNum.tagert_type =
1361
         ) as sharePersonNum on sharePersonNum.be_share = activity.activityId and sharePersonNum.tagert_type =
1298
         activity.activityType
1362
         activity.activityType
1345
         and a.status = 1
1409
         and a.status = 1
1346
         and a.is_first_time = 1
1410
         and a.is_first_time = 1
1347
         <if test="targetType != null and targetType != '' and targetType != 'h5'">
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
         </if>
1413
         </if>
1350
         <if test="startDate != null ">
1414
         <if test="startDate != null ">
1351
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1415
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1358
         </if>
1422
         </if>
1359
         group by a.person_id, a.target_type ,a.target_id
1423
         group by a.person_id, a.target_type ,a.target_id
1360
         ) as addRegistNum group by addRegistNum.target_type, addRegistNum.target_id
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
         <if test="targetType != null and targetType != ''">
1426
         <if test="targetType != null and targetType != ''">
1364
             where activity.activityType = #{targetType}
1427
             where activity.activityType = #{targetType}
1365
         </if>
1428
         </if>
1419
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1482
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1420
                 #{taPersonBuilding.buildingId}
1483
                 #{taPersonBuilding.buildingId}
1421
             </foreach>
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
             or d.create_user = #{userId}
1495
             or d.create_user = #{userId}
1423
             or c.create_user = #{userId}
1496
             or c.create_user = #{userId}
1424
             )
1497
             )
1443
         ) as person
1516
         ) as person
1444
 
1517
 
1445
         left join (
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
                 FROM ta_share_count t
1521
                 FROM ta_share_count t
1449
                 LEFT JOIN ta_help_activity a ON t.be_share = a.help_activity_id
1522
                 LEFT JOIN ta_help_activity a ON t.be_share = a.help_activity_id
1450
                 LEFT JOIN ta_share_activity b ON t.be_share = b.share_id
1523
                 LEFT JOIN ta_share_activity b ON t.be_share = b.share_id
1463
                     and (case when #{activityType} = 'live' then t.tagert_type in ('liveApp', 'livePost') else t.tagert_type = #{activityType}
1536
                     and (case when #{activityType} = 'live' then t.tagert_type in ('liveApp', 'livePost') else t.tagert_type = #{activityType}
1464
                     end)
1537
                     end)
1465
                 </if>
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
         ) as shareNum on person.person_id = shareNum.person_id
1541
         ) as shareNum on person.person_id = shareNum.person_id
1469
 
1542
 
1470
         left join (
1543
         left join (
1523
         ifnull(shareNum, 0) as shareNum,
1596
         ifnull(shareNum, 0) as shareNum,
1524
         ifnull(visitNum, 0) as visitNum,
1597
         ifnull(visitNum, 0) as visitNum,
1525
         ifnull(visitPersonNum, 0) as visitPersonNum,
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
         person.person_id
1607
         person.person_id
1528
         from (
1608
         from (
1529
         SELECT t.*, f.nickname, f.phone, f.person_type
1609
         SELECT t.*, f.nickname, f.phone, f.person_type
1563
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1643
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1564
                 #{taPersonBuilding.buildingId}
1644
                 #{taPersonBuilding.buildingId}
1565
             </foreach>
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
             or d.create_user = #{userId}
1656
             or d.create_user = #{userId}
1567
             or c.create_user = #{userId}
1657
             or c.create_user = #{userId}
1568
             )
1658
             )
1587
         ) as person
1677
         ) as person
1588
 
1678
 
1589
         left join (
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
         FROM ta_share_count t
1682
         FROM ta_share_count t
1593
         LEFT JOIN ta_help_activity a ON t.be_share = a.help_activity_id
1683
         LEFT JOIN ta_help_activity a ON t.be_share = a.help_activity_id
1594
         LEFT JOIN ta_share_activity b ON t.be_share = b.share_id
1684
         LEFT JOIN ta_share_activity b ON t.be_share = b.share_id
1607
             and (case when #{activityType} = 'live' then t.tagert_type in ('liveApp', 'livePost') else t.tagert_type = #{activityType}
1697
             and (case when #{activityType} = 'live' then t.tagert_type in ('liveApp', 'livePost') else t.tagert_type = #{activityType}
1608
             end)
1698
             end)
1609
         </if>
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
         ) as shareNum on person.person_id = shareNum.person_id
1702
         ) as shareNum on person.person_id = shareNum.person_id
1613
 
1703
 
1614
         left join (
1704
         left join (
1645
             and t.target_type = concat(REPLACE(#{activityType}, 'activity', 'dynamic'), '_share')
1735
             and t.target_type = concat(REPLACE(#{activityType}, 'activity', 'dynamic'), '_share')
1646
         </if>
1736
         </if>
1647
         and t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share')
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
         left join ta_person a on t.share_person = a.person_id
1741
         left join ta_person a on t.share_person = a.person_id
1650
         left join ta_person b on t.share_person = b.user_id
1742
         left join ta_person b on t.share_person = b.user_id
1651
         ) as visitPersonNum on visitPersonNum.person_id = person.person_id
1743
         ) as visitPersonNum on visitPersonNum.person_id = person.person_id
1707
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1799
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1708
                 #{taPersonBuilding.buildingId}
1800
                 #{taPersonBuilding.buildingId}
1709
             </foreach>
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
             or d.create_user = #{userId}
1812
             or d.create_user = #{userId}
1711
             or c.create_user = #{userId}
1813
             or c.create_user = #{userId}
1712
             )
1814
             )
1779
             and t.be_share = #{activityId}
1881
             and t.be_share = #{activityId}
1780
         </if>
1882
         </if>
1781
         <if test="activityType != null and activityType != ''">
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
         </if>
1886
         </if>
1784
         <if test="buildingId != null and buildingId != ''">
1887
         <if test="buildingId != null and buildingId != ''">
1785
             and (
1888
             and (
1806
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1909
             <foreach collection="taPersonBuildings" item="taPersonBuilding" open="(" close=")" separator=",">
1807
                 #{taPersonBuilding.buildingId}
1910
                 #{taPersonBuilding.buildingId}
1808
             </foreach>
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
             or d.create_user = #{userId}
1922
             or d.create_user = #{userId}
1810
             or c.create_user = #{userId}
1923
             or c.create_user = #{userId}
1811
             )
1924
             )
1857
         if(a.gender = '1', '男', if(a.gender = '2', '女','未知') ) as gender,
1970
         if(a.gender = '1', '男', if(a.gender = '2', '女','未知') ) as gender,
1858
         a.province,
1971
         a.province,
1859
         b1.scene_alias as personFrom,
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
         FROM ta_share_person_from t
1977
         FROM ta_share_person_from t
1865
         left join ta_person a on t.person_id = a.person_id
1978
         left join ta_person a on t.person_id = a.person_id
1866
         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
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
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
1980
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
1868
         left join ta_recommend_customer c on c.person_id = t.person_id
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
         WHERE t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id =
1985
         WHERE t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id =
1873
         #{orgId} and t.status = 1
1986
         #{orgId} and t.status = 1
1874
         and t.is_first_time = 1
1987
         and t.is_first_time = 1
1878
             and t.target_id = #{activityId}
1991
             and t.target_id = #{activityId}
1879
         </if>
1992
         </if>
1880
         <if test="activityType != null and activityType != ''">
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
         </if>
1995
         </if>
1883
         <if test="province != null and province != ''">
1996
         <if test="province != null and province != ''">
1884
             and a.province like concat('%', #{province}, '%')
1997
             and a.province like concat('%', #{province}, '%')
1889
         <if test="buildingId != null and buildingId != ''">
2002
         <if test="buildingId != null and buildingId != ''">
1890
             and c.building_id = #{buildingId}
2003
             and c.building_id = #{buildingId}
1891
         </if>
2004
         </if>
1892
-        group by t.person_id
2005
+        group by t.person_id order by t.create_date desc
1893
     </select>
2006
     </select>
1894
 
2007
 
1895
     <select id="selectActivityAddRegistNumExport"
2008
     <select id="selectActivityAddRegistNumExport"
1899
         if(a.gender = '1', '男', if(a.gender = '2', '女','未知') ) as gender,
2012
         if(a.gender = '1', '男', if(a.gender = '2', '女','未知') ) as gender,
1900
         a.province,
2013
         a.province,
1901
         b1.scene_alias as personFrom,
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
         FROM ta_share_person_from t
2019
         FROM ta_share_person_from t
1907
         left join ta_person a on t.person_id = a.person_id
2020
         left join ta_person a on t.person_id = a.person_id
1908
         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
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
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
2022
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
1910
         left join ta_recommend_customer c on c.person_id = t.person_id
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
         WHERE t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id =
2027
         WHERE t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id =
1915
         #{orgId} and t.status = 1
2028
         #{orgId} and t.status = 1
1916
         and t.is_first_time = 1
2029
         and t.is_first_time = 1
1920
             and t.target_id = #{activityId}
2033
             and t.target_id = #{activityId}
1921
         </if>
2034
         </if>
1922
         <if test="activityType != null and activityType != ''">
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
         </if>
2037
         </if>
1925
         <if test="province != null and province != ''">
2038
         <if test="province != null and province != ''">
1926
             and a.province like concat('%', #{province}, '%')
2039
             and a.province like concat('%', #{province}, '%')
1931
         <if test="buildingId != null and buildingId != ''">
2044
         <if test="buildingId != null and buildingId != ''">
1932
             and c.building_id = #{buildingId}
2045
             and c.building_id = #{buildingId}
1933
         </if>
2046
         </if>
1934
-        group by t.person_id
2047
+        group by t.person_id order by t.create_date desc
1935
     </select>
2048
     </select>
1936
 
2049
 
1937
     <select id="selectActivityVisitNum" resultType="com.huiju.estateagents.excel.ActivityStatistics.VisitNum">
2050
     <select id="selectActivityVisitNum" resultType="com.huiju.estateagents.excel.ActivityStatistics.VisitNum">
2068
         GROUP_CONCAT(d.user_name) as realtyConsultant,
2181
         GROUP_CONCAT(d.user_name) as realtyConsultant,
2069
         GROUP_CONCAT(d.phone) as realtyConsultantPhone,
2182
         GROUP_CONCAT(d.phone) as realtyConsultantPhone,
2070
         t.create_date as visitDate,
2183
         t.create_date as visitDate,
2071
-        ifnull(e.nickName, f.user_name) as sharePersonName,
2184
+        e.nickName as sharePersonName,
2072
         t.visitNum
2185
         t.visitNum
2073
         from (
2186
         from (
2074
         SELECT
2187
         SELECT
2101
         GROUP BY
2214
         GROUP BY
2102
         t.person_id ) as t
2215
         t.person_id ) as t
2103
         left join ta_person a on t.person_id = a.person_id
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
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
2218
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
2106
         LEFT JOIN ta_recommend_customer c on c.person_id = t.person_id
2219
         LEFT JOIN ta_recommend_customer c on c.person_id = t.person_id
2107
         left join ta_user d on c.realty_consultant = d.user_id
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
         <where>
2222
         <where>
2111
             <if test="personFrom != null and personFrom != ''">
2223
             <if test="personFrom != null and personFrom != ''">
2112
                 and b.scene_type = #{personFrom}
2224
                 and b.scene_type = #{personFrom}
2135
         GROUP_CONCAT(d.user_name) as realtyConsultant,
2247
         GROUP_CONCAT(d.user_name) as realtyConsultant,
2136
         GROUP_CONCAT(d.phone) as realtyConsultantPhone,
2248
         GROUP_CONCAT(d.phone) as realtyConsultantPhone,
2137
         t.create_date as visitDate,
2249
         t.create_date as visitDate,
2138
-        ifnull(e.nickName, f.user_name) as sharePersonName,
2250
+        e.nickName as sharePersonName,
2139
         t.visitNum
2251
         t.visitNum
2140
         from (
2252
         from (
2141
         SELECT
2253
         SELECT
2172
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
2284
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
2173
         LEFT JOIN ta_recommend_customer c on c.person_id = t.person_id
2285
         LEFT JOIN ta_recommend_customer c on c.person_id = t.person_id
2174
         left join ta_user d on c.realty_consultant = d.user_id
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
         <where>
2288
         <where>
2178
             <if test="personFrom != null and personFrom != ''">
2289
             <if test="personFrom != null and personFrom != ''">
2179
                 and b.scene_type = #{personFrom}
2290
                 and b.scene_type = #{personFrom}
2202
         GROUP_CONCAT(d.user_name) as realtyConsultant,
2313
         GROUP_CONCAT(d.user_name) as realtyConsultant,
2203
         GROUP_CONCAT(d.phone) as realtyConsultantPhone,
2314
         GROUP_CONCAT(d.phone) as realtyConsultantPhone,
2204
         t.create_date as visitDate,
2315
         t.create_date as visitDate,
2205
-        ifnull(e.nickName, f.user_name) as sharePersonName,
2316
+        e.nickName as sharePersonName,
2206
         t.visitNum
2317
         t.visitNum
2207
         From (
2318
         From (
2208
         SELECT count(1) as visitNum, t.person_id, t.create_date
2319
         SELECT count(1) as visitNum, t.person_id, t.create_date
2228
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
2339
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
2229
         LEFT JOIN ta_recommend_customer c on c.person_id = t.person_id
2340
         LEFT JOIN ta_recommend_customer c on c.person_id = t.person_id
2230
         left join ta_user d on c.realty_consultant = d.user_id
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
         group by t.person_id
2343
         group by t.person_id
2234
     </select>
2344
     </select>
2235
 
2345
 
2287
         GROUP_CONCAT(d.user_name) as realtyConsultant,
2397
         GROUP_CONCAT(d.user_name) as realtyConsultant,
2288
         GROUP_CONCAT(d.phone) as realtyConsultantPhone,
2398
         GROUP_CONCAT(d.phone) as realtyConsultantPhone,
2289
         t.create_date as visitDate,
2399
         t.create_date as visitDate,
2290
-        ifnull(e.nickName, f.user_name) as sharePersonName,
2400
+        e.nickName as sharePersonName,
2291
         t.visitNum
2401
         t.visitNum
2292
         From (
2402
         From (
2293
         SELECT count(1) as visitNum, t.person_id, t.create_date
2403
         SELECT count(1) as visitNum, t.person_id, t.create_date
2294
         FROM ta_share_person_from t
2404
         FROM ta_share_person_from t
2295
         WHERE t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
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
         <if test="activityId != null and activityId != ''">
2407
         <if test="activityId != null and activityId != ''">
2299
             and t.target_id = #{activityId}
2408
             and t.target_id = #{activityId}
2300
         </if>
2409
         </if>
2301
         <if test="activityType != null and activityType != ''">
2410
         <if test="activityType != null and activityType != ''">
2302
             and t.target_type = concat(REPLACE(#{activityType}, 'activity', 'dynamic'), '_share')
2411
             and t.target_type = concat(REPLACE(#{activityType}, 'activity', 'dynamic'), '_share')
2303
         </if>
2412
         </if>
2413
+        and t.target_type in
2414
+        ('dynamic_share','h5_share','help_share','live_share', 'group_share')
2304
         and
2415
         and
2305
         (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})
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
         or t.share_person = #{personId})
2417
         or t.share_person = #{personId})
2312
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
2423
         left join td_wx_dict b1 on b.scene_id = b1.scene_id
2313
         LEFT JOIN ta_recommend_customer c on c.person_id = t.person_id
2424
         LEFT JOIN ta_recommend_customer c on c.person_id = t.person_id
2314
         left join ta_user d on c.realty_consultant = d.user_id
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
         group by t.person_id
2427
         group by t.person_id
2318
     </select>
2428
     </select>
2319
 
2429
 
2330
         ifnull(e.nickname, f.user_name) as sharePersonName,
2440
         ifnull(e.nickname, f.user_name) as sharePersonName,
2331
         ifnull(e.phone, f.phone) as sharePersonPhone
2441
         ifnull(e.phone, f.phone) as sharePersonPhone
2332
         From (
2442
         From (
2333
-        SELECT t.person_id, t.create_date
2443
+        SELECT t.person_id, t.create_date, t.share_person
2334
         FROM ta_share_person_from t
2444
         FROM ta_share_person_from t
2335
         LEFT JOIN (
2445
         LEFT JOIN (
2336
-        SELECT a.person_id, b.user_id, t.share_person
2446
+        SELECT a.person_id, b.user_id
2337
         FROM ta_person a
2447
         FROM ta_person a
2338
         LEFT JOIN ta_user b
2448
         LEFT JOIN ta_user b
2339
         ON a.user_id = b.user_id
2449
         ON a.user_id = b.user_id
2340
         WHERE a.org_id = #{orgId} ) as a ON t.share_person = a.person_id or t.share_person = a.user_id
2450
         WHERE a.org_id = #{orgId} ) as a ON t.share_person = a.person_id or t.share_person = a.user_id
2341
         WHERE t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
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
         ('dynamic_share','h5_share','help_share','live_share', 'group_share')
2453
         ('dynamic_share','h5_share','help_share','live_share', 'group_share')
2345
         <if test="activityId != null and activityId != ''">
2454
         <if test="activityId != null and activityId != ''">
2346
             and t.target_id = #{activityId}
2455
             and t.target_id = #{activityId}