Преглед изворни кода

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

魏超 пре 5 година
родитељ
комит
ba93511a37

+ 8
- 0
src/main/java/com/huiju/estateagents/controller/MiniAppController.java Прегледај датотеку

@@ -17,6 +17,7 @@ import com.huiju.estateagents.drainage.service.ITaDrainageService;
17 17
 import com.huiju.estateagents.entity.*;
18 18
 import com.huiju.estateagents.event.EventBus;
19 19
 import com.huiju.estateagents.mapper.TaOrgCityMapper;
20
+import com.huiju.estateagents.mapper.TaSalesBatchMapper;
20 21
 import com.huiju.estateagents.service.*;
21 22
 import com.huiju.estateagents.third.service.ITaThirdPartyMiniappConfigService;
22 23
 import me.chanjar.weixin.common.error.WxErrorException;
@@ -110,6 +111,9 @@ public class MiniAppController extends BaseController {
110 111
     @Autowired
111 112
     private ITaDrainageService taDrainageService;
112 113
 
114
+    @Autowired
115
+    private TaSalesBatchMapper taSalesBatchMapper;
116
+
113 117
     /**
114 118
      * 验证接入
115 119
      */
@@ -318,6 +322,10 @@ public class MiniAppController extends BaseController {
318 322
                     TaDrainage taDrainage = taDrainageService.getById(targetId);
319 323
                     taSharePersonFrom.setBuildingId(taDrainage.getBuildingId());
320 324
                     sharePersonFromQueryWrapper.eq("building_id", taDrainage.getBuildingId());
325
+                }else if (from.contains("house")) {
326
+                    TaSalesBatch taSalesBatch = taSalesBatchMapper.selectById(targetId);
327
+                    taSharePersonFrom.setBuildingId(taSalesBatch.getBuildingId());
328
+                    sharePersonFromQueryWrapper.eq("building_id", taSalesBatch.getBuildingId());
321 329
                 }
322 330
                 Integer isFirstTime = taSharePersonFromService.count(sharePersonFromQueryWrapper);
323 331
                 if (isFirstTime > 0) {

+ 4
- 0
src/main/java/com/huiju/estateagents/mapper/TaCustomerFromMapper.java Прегледај датотеку

@@ -3,6 +3,9 @@ package com.huiju.estateagents.mapper;
3 3
 import com.huiju.estateagents.entity.TaCustomerFrom;
4 4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 5
 import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.Map;
6 9
 
7 10
 /**
8 11
  * <p>
@@ -15,4 +18,5 @@ import org.apache.ibatis.annotations.Mapper;
15 18
 @Mapper
16 19
 public interface TaCustomerFromMapper extends BaseMapper<TaCustomerFrom> {
17 20
 
21
+    Map<String, Number> countPerson(@Param("orgId") Integer orgId, @Param("buildingId") String buildingId, @Param("personId") String personId);
18 22
 }

+ 177
- 47
src/main/java/com/huiju/estateagents/service/impl/TaPersonServiceImpl.java Прегледај датотеку

@@ -897,7 +897,7 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
897 897
 
898 898
                 withBuildings = taUserMapper.getBuildingIdsOf(taUser.getUserId(), null);
899 899
 
900
-                if (taUser.getIsAdmin()) {
900
+                if (null != taUser.getIsAdmin() && taUser.getIsAdmin()) {
901 901
                     isAssociated = true;
902 902
                 } else {
903 903
                     if (null != withBuildings && withBuildings.size() > 0 && !StringUtils.isEmpty(buildingId)) {
@@ -921,26 +921,40 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
921 921
             return ;
922 922
         }
923 923
 
924
-        // 3. 处理客户, 没有新增一条记录, 有就依据手机号建立关联
925
-        TaRecommendCustomer customer = mergeCustomerByPhone(person, taUser, taBuilding, isAssociated, now);
924
+        // 3. 修正客户信息
925
+        List<TaBuilding> withBuildingList = null;
926
+        if (null != withBuildings && withBuildings.size() > 0) {
927
+            QueryWrapper<TaBuilding> queryBuilding = new QueryWrapper<>();
928
+            queryBuilding.in("building_id", withBuildings);
929
+            withBuildingList = taBuildingMapper.selectList(queryBuilding);
930
+        }
931
+        List<TaRecommendCustomer> customers = mergeCustomerByPhone(person, taUser, taBuilding, withBuildingList, isAssociated, now);
932
+        if (null == customers || customers.size() == 0) {
933
+            throw new Exception("生成客户信息异常, 请联系技术人员");
934
+        }
926 935
 
927 936
         // 4. 客户来源, 注意不是用户来源
928 937
         TaCustomerFrom customerFrom = new TaCustomerFrom();
929 938
         customerFrom.setPersonId(person.getPersonId());
930
-        customerFrom.setCustomerId(customer != null ? customer.getCustomerId() :  null);    // 辅助字段, 不必填
931 939
         customerFrom.setPersonName(StringUtils.ifNull(person.getName(), person.getNickname()));
932 940
         customerFrom.setTargetType(targetType);
933 941
         customerFrom.setTargetId(targetId);
934 942
         customerFrom.setTargetName(targetName);
935
-        customerFrom.setOrgId(person.getOrgId());
943
+        customerFrom.setOrgId(orgId);
936 944
         customerFrom.setSceneId(sceneId);
937
-        customerFrom.setIsOrgFirst(true);   // 授权手机号, 肯定是首次进入
945
+        customerFrom.setIsOrgFirst(true);   // 授权手机号, 肯定是第一次
938 946
         customerFrom.setCreateDate(now);
939 947
 
940 948
         if (null != taBuilding) {
941 949
             customerFrom.setBuildingId(buildingId);
942 950
             customerFrom.setBuildingName(taBuilding.getBuildingName());
943 951
             customerFrom.setIsProjectFirst(true);
952
+
953
+            for (TaRecommendCustomer cust : customers) {
954
+                if (buildingId.equals(cust.getBuildingId())) {
955
+                    customerFrom.setCustomerId(cust.getCustomerId());
956
+                }
957
+            }
944 958
         }
945 959
         if (null != recPerson) {
946 960
             customerFrom.setSharePersonId(recPerson.getPersonId());
@@ -950,69 +964,185 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
950 964
         taCustomerFromMapper.insert(customerFrom);
951 965
     }
952 966
 
967
+    /**
968
+     * 此处逻辑按照复杂流程处理
969
+     * 除了新增客户外,还有修正原有数据的目的
970
+     * @param person
971
+     * @param taUser
972
+     * @param building
973
+     * @param withBuildings
974
+     * @param isAssociated
975
+     * @param now
976
+     * @return
977
+     * @throws Exception
978
+     */
979
+    private List<TaRecommendCustomer> mergeCustomerByPhone(TaPerson person, TaUser taUser, TaBuilding building, List<TaBuilding> withBuildings, boolean isAssociated, LocalDateTime now) throws Exception {
980
+
981
+        // 先更新之前的数据, 有一种可能的情况, 客户是推荐的,之前未进入过小程序
982
+        // 后面所有的查询就可以不需要 phone , 改用 person_id 了
983
+        QueryWrapper<TaRecommendCustomer> q1 = new QueryWrapper<>();
984
+        q1.eq("org_id", person.getOrgId());
985
+        q1.eq("phone", person.getPhone());
986
+        q1.isNull("person_id");
987
+        List<TaRecommendCustomer> customers = taRecommendCustomerMapper.selectList(q1);
988
+        if (null != customers) {
989
+            for (int i = 0; i < customers.size(); i++) {
990
+                TaRecommendCustomer cust = customers.get(i);
991
+                cust = copyByPerosn(person, cust);
992
+                taRecommendCustomerMapper.updateById(cust);
993
+            }
994
+        }
995
+
996
+        /**
997
+         * 新增客户流程
998
+         * 1. 推广人是置业, 楼盘跟置业关联 => return 新增一条客户
999
+         * 2. 有楼盘  => 新增一条项目公客  continue
1000
+         * 3. 有推广人 => 更新为私客, 或者新增一条公客 continue
1001
+         * 4. return
1002
+         */
953 1003
 
954
-    private TaRecommendCustomer mergeCustomerByPhone(TaPerson person, TaUser taUser, TaBuilding building, boolean isAssociated, LocalDateTime now) throws Exception {
955 1004
         TaPerson recPerson = null;
956 1005
         if (null != taUser) {
957 1006
             recPerson = taUser.getPersonIds().get(0);
958 1007
         }
959
-
960
-        QueryWrapper<TaRecommendCustomer> query = new QueryWrapper<>();
961
-        query.eq("org_id", person.getOrgId());
962
-        query.eq("phone", person.getPhone());
963
-
964
-        List<TaRecommendCustomer> customers = taRecommendCustomerMapper.selectList(query);
965
-
966
-        // 如果用户不存在, 则新建一个
967
-        // 推广人为 TaUser
968
-        if (null == customers || customers.size() == 0) {
969
-            TaRecommendCustomer customer = copyByPerosn(person, new TaRecommendCustomer());
970
-            customer.setVerifyStatus(CommConstant.VERIFY_AGREE);
971
-            customer.setStatus(CommConstant.CUSTOMER_REPORT);
972
-            customer.setEntryType(CommConstant.ENTRY_INPUT);
973
-            customer.setCreateDate(now);
974
-            if (null != recPerson) {
1008
+        // 推广人是否置业
1009
+        boolean isConsultant = taUser != null && taUser.getIsConsultant() != null && taUser.getIsConsultant();
1010
+        // 置业授权的楼盘
1011
+        TaBuilding taBuilding = null != withBuildings ? withBuildings.get(0) : null;
1012
+
1013
+        // 1. 如果置业跟楼盘是关联的
1014
+        if (isAssociated) {
1015
+            // 查询是否已经存在记录
1016
+            QueryWrapper<TaRecommendCustomer> q2 = new QueryWrapper<>();
1017
+            q2.eq("org_id", person.getOrgId());
1018
+            q2.eq("building_id", building.getBuildingId());
1019
+            q2.eq("person_id", person.getPersonId());
1020
+            List<TaRecommendCustomer> existsRows = taRecommendCustomerMapper.selectList(q2);
1021
+
1022
+            if (null == existsRows || existsRows.size() < 1) {
1023
+                TaRecommendCustomer customer = copyByPerosn(person, new TaRecommendCustomer());
1024
+                customer.setVerifyStatus(CommConstant.VERIFY_AGREE);
1025
+                customer.setStatus(CommConstant.CUSTOMER_REPORT);
1026
+                customer.setEntryType(CommConstant.ENTRY_INPUT);
1027
+                customer.setCreateDate(now);
1028
+                customer.setReportDate(now);
975 1029
                 customer.setRecommendPerson(recPerson.getPersonId());
976
-            }
977
-
978
-            if (taUser.getIsConsultant()) {
979 1030
                 customer.setRealtyConsultant(taUser.getUserId().toString());
1031
+                customer.setBuildingId(building.getBuildingId());
1032
+                customer.setIntention(building.getBuildingName());
1033
+                taRecommendCustomerMapper.insert(customer);
1034
+
1035
+                return new ArrayList<TaRecommendCustomer>(){{
1036
+                    add(customer);
1037
+                }};
980 1038
             }
1039
+        }
981 1040
 
982
-            if (null != building && (isAssociated || null == taUser)) {
1041
+        // 2. 有楼盘
1042
+        if (null != building) {
1043
+            // 查询是否已经存在记录
1044
+            QueryWrapper<TaRecommendCustomer> q3 = new QueryWrapper<>();
1045
+            q3.eq("org_id", person.getOrgId());
1046
+            q3.eq("building_id", building.getBuildingId());
1047
+            q3.eq("person_id", person.getPersonId());
1048
+            List<TaRecommendCustomer> existsRows = taRecommendCustomerMapper.selectList(q3);
1049
+
1050
+            if (null == existsRows || existsRows.size() < 1) {
1051
+                TaRecommendCustomer customer = copyByPerosn(person, new TaRecommendCustomer());
1052
+                customer.setVerifyStatus(CommConstant.VERIFY_AGREE);
1053
+                customer.setStatus(CommConstant.CUSTOMER_REPORT);
1054
+                customer.setEntryType(CommConstant.ENTRY_INPUT);
1055
+                customer.setCreateDate(now);
1056
+                customer.setReportDate(now);
983 1057
                 customer.setBuildingId(building.getBuildingId());
984 1058
                 customer.setIntention(building.getBuildingName());
1059
+                taRecommendCustomerMapper.insert(customer);
985 1060
             }
1061
+        }
986 1062
 
987
-            taRecommendCustomerMapper.insert(customer);
988
-            return customer;
989
-        } else {
990
-            for (int i = 0; i < customers.size(); i++) {
991
-                TaRecommendCustomer customer = customers.get(i);
992
-                if (null == customer.getPersonId()) {
993
-                    customer = copyByPerosn(person, customer);
1063
+        // 3. 有推广人
1064
+        if (null != recPerson) {
1065
+            if (isConsultant) {
1066
+                // 如果是置业, 需要验证是否置业所在项目的客户
1067
+                if (null != taBuilding) {
1068
+                    // 查询是否已经存在记录
1069
+                    // 客户是以项目为纬度的, 因此验证查询不能加置业的条件
1070
+                    QueryWrapper<TaRecommendCustomer> q4 = new QueryWrapper<>();
1071
+                    q4.eq("org_id", person.getOrgId());
1072
+                    q4.eq("building_id", taBuilding.getBuildingId());
1073
+                    q4.eq("person_id", person.getPersonId());
1074
+                    List<TaRecommendCustomer> existsRows = taRecommendCustomerMapper.selectList(q4);
1075
+
1076
+                    if (null == existsRows || existsRows.size() < 1) {
1077
+                        TaRecommendCustomer customer = copyByPerosn(person, new TaRecommendCustomer());
1078
+                        customer.setVerifyStatus(CommConstant.VERIFY_AGREE);
1079
+                        customer.setStatus(CommConstant.CUSTOMER_REPORT);
1080
+                        customer.setEntryType(CommConstant.ENTRY_INPUT);
1081
+                        customer.setCreateDate(now);
1082
+                        customer.setReportDate(now);
1083
+                        customer.setRecommendPerson(recPerson.getPersonId());
1084
+                        customer.setRealtyConsultant(taUser.getUserId().toString());
1085
+                        customer.setBuildingId(taBuilding.getBuildingId());
1086
+                        customer.setIntention(taBuilding.getBuildingName());
1087
+                        taRecommendCustomerMapper.insert(customer);
1088
+                    } else {
1089
+                        // 如果存在项目公客, 把公客绑定为置业的私客
1090
+                        for (int i = 0; i < existsRows.size(); i ++) {
1091
+                            TaRecommendCustomer cust = existsRows.get(0);
1092
+                            if (StringUtils.isEmpty(cust.getRealtyConsultant())) {
1093
+                                cust.setRealtyConsultant(taUser.getUserId().toString());
1094
+                                cust.setReportDate(now);    // 这个更新会覆盖原来的真实时间
1095
+                                taRecommendCustomerMapper.updateById(cust);
1096
+                                break;
1097
+                            }
1098
+                        }
1099
+                    }
994 1100
                 }
1101
+            }
995 1102
 
996
-                if (taUser.getIsConsultant() && StringUtils.isEmpty(customer.getRealtyConsultant())) {
997
-                    customer.setRealtyConsultant(taUser.getUserId().toString());
1103
+            // 如果不是置业, 那么就是普通人推荐
1104
+            // 如果置业没有绑定项目, 则认为置业是以普通人身份推荐
1105
+            // 新增一个公客
1106
+            if (!isConsultant || null == taBuilding) {
1107
+                // 查询是否已经存在记录
1108
+                QueryWrapper<TaRecommendCustomer> q5 = new QueryWrapper<>();
1109
+                q5.eq("org_id", person.getOrgId());
1110
+                q5.eq("person_id", person.getPersonId());
1111
+                List<TaRecommendCustomer> existsRows = taRecommendCustomerMapper.selectList(q5);
1112
+
1113
+                if (null == existsRows || existsRows.size() < 1) {
1114
+                    TaRecommendCustomer customer = copyByPerosn(person, new TaRecommendCustomer());
1115
+                    customer.setVerifyStatus(CommConstant.VERIFY_AGREE);
1116
+                    customer.setStatus(CommConstant.CUSTOMER_REPORT);
1117
+                    customer.setEntryType(CommConstant.ENTRY_INPUT);
1118
+                    customer.setCreateDate(now);
1119
+                    customer.setReportDate(now);
1120
+                    customer.setRecommendPerson(recPerson.getPersonId());
1121
+                    taRecommendCustomerMapper.insert(customer);
998 1122
                 }
1123
+            }
1124
+        }
999 1125
 
1000
-                if (building != null && (isAssociated || null == taUser)) {
1001
-                    if (StringUtils.isEmpty(customer.getBuildingId())) {
1002
-                        customer.setBuildingId(building.getBuildingId());
1003
-                    }
1004
-                    if (StringUtils.isEmpty(customer.getIntention())) {
1005
-                        customer.setIntention(building.getBuildingName());
1006
-                    }
1007
-                }
1126
+        // 返回当前人作为客户的数据
1127
+        QueryWrapper<TaRecommendCustomer> query = new QueryWrapper<>();
1128
+        query.eq("org_id", person.getOrgId());
1129
+        query.eq("person_id", person.getPersonId());
1008 1130
 
1009
-                taRecommendCustomerMapper.updateById(customer);
1010
-            }
1011
-            return null;
1131
+        List<String> buildingIds = new ArrayList<>();
1132
+        if (null != building) {
1133
+            buildingIds.add(building.getBuildingId());
1012 1134
         }
1135
+        if (null != taBuilding) {
1136
+            buildingIds.add(taBuilding.getBuildingId());
1137
+        }
1138
+
1139
+        query.in(buildingIds.size() > 0,"building_id", buildingIds);
1140
+        query.orderByAsc("create_date");
1141
+        return taRecommendCustomerMapper.selectList(query);
1013 1142
     }
1014 1143
 
1015 1144
     private TaRecommendCustomer copyByPerosn(TaPerson person, TaRecommendCustomer cust) {
1145
+        cust.setPersonId(person.getPersonId());
1016 1146
         cust.setName(StringUtils.ifNull(person.getName(), person.getNickname()));
1017 1147
         cust.setSex(null == person.getSex() ? str2Int(person.getGender()) : person.getSex());
1018 1148
         cust.setPhone(StringUtils.ifNull(person.getPhone(), person.getTel()));

+ 47
- 41
src/main/java/com/huiju/estateagents/service/impl/TaRecommendCustomerServiceImpl.java Прегледај датотеку

@@ -414,6 +414,49 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
414 414
 //        taRecommendCustomer.setRecommendPerson(taPerson.getPersonId());
415 415
         taRecommendCustomer.setRecommendPerson(params.getString("realtyConsultant"));
416 416
 
417
+        // 插入客户来源逻辑, 防止下面 if 里面的 return
418
+        // 首次报备的客户, 写入客户来源表
419
+        TaCustomerFrom customerFrom = null;
420
+        if (!StringUtils.isEmpty(taRecommendCustomer.getBuildingId())) {
421
+            Map<String, Number> counter = taCustomerFromMapper.countPerson(taRecommendCustomer.getOrgId(), taRecommendCustomer.getBuildingId() ,taRecommendCustomer.getPersonId());
422
+            boolean orgFirst = counter.get("orgCount").longValue() < 1;
423
+            boolean projectFirst = counter.get("projectCount").longValue() < 1;
424
+            if (projectFirst) {
425
+                TaBuilding taBuilding = taBuildingMapper.selectById(taRecommendCustomer.getBuildingId());
426
+
427
+                customerFrom = new TaCustomerFrom();
428
+                customerFrom.setPersonId(taRecommendCustomer.getPersonId());
429
+                customerFrom.setCustomerId(taRecommendCustomer.getCustomerId());
430
+                customerFrom.setPersonName(taRecommendCustomer.getName());
431
+                customerFrom.setOrgId(taRecommendCustomer.getOrgId());
432
+//              customerFrom.setSceneId(sceneId);
433
+                customerFrom.setIsOrgFirst(orgFirst);
434
+                customerFrom.setIsProjectFirst(true);
435
+                customerFrom.setCreateDate(LocalDateTime.now());
436
+                customerFrom.setBuildingId(taRecommendCustomer.getBuildingId());
437
+                customerFrom.setBuildingName(taBuilding.getBuildingName());
438
+                customerFrom.setSharePersonId(consultantPerson.getPersonId());
439
+                customerFrom.setSharePersonName(consultantUser.getUserName());
440
+
441
+                // 半小时内如果有当前人员的分享记录
442
+                // 那么就认为当前客户是通过分享进入的
443
+                TaSharePersonFrom personShare = taSharePersonFromMapper.getConsultantLastShare(taRecommendCustomer.getOrgId(),
444
+                        taRecommendCustomer.getBuildingId(),
445
+                        consultantUser.getUserId(),
446
+                        taRecommendCustomer.getPersonId());
447
+                if (null != personShare) {
448
+                    // 强制转换 targetType
449
+                    String targetType = personShare.getTargetType().replace("_share", "").replace("dynamic", "activity");
450
+                    customerFrom.setTargetType(targetType);
451
+                    customerFrom.setTargetId(personShare.getTargetId());
452
+                    customerFrom.setTargetName(personShare.getTargetName());
453
+                }
454
+
455
+                taCustomerFromMapper.insert(customerFrom);
456
+            }
457
+        }
458
+
459
+
417 460
         // 报备有 10 天有效期
418 461
         QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
419 462
         queryWrapper.eq("phone", taRecommendCustomer.getPhone());
@@ -446,6 +489,10 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
446 489
         if (row < 1) {
447 490
             return ResponseBean.error("报备客户失败", ResponseBean.ERROR_UNAVAILABLE);
448 491
         }
492
+        if (null != customerFrom) {
493
+            customerFrom.setCustomerId(taRecommendCustomer.getCustomerId());
494
+            taCustomerFromMapper.updateById(customerFrom);
495
+        }
449 496
 
450 497
         // 找到销售经理,并推送消息
451 498
 //        TaPerson saleMan = taPersonMapper.getSalesExecutive();
@@ -454,47 +501,6 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
454 501
 //            iMiniAppService.sendNewCustomerMessage(saleMan, CommConstant.MINIAPP_INDEX, taRecommendCustomer.getName(), taRecommendCustomer.getPhone(), "", taPerson.getName());
455 502
 //        }
456 503
 
457
-        // 首次报备的客户, 写入客户来源表
458
-        if (!StringUtils.isEmpty(taRecommendCustomer.getBuildingId())) {
459
-            QueryWrapper<TaCustomerFrom> queryFrom = new QueryWrapper<>();
460
-            queryFrom.eq("org_id", taRecommendCustomer.getOrgId());
461
-            queryFrom.eq("building_id", taRecommendCustomer.getBuildingId());
462
-            boolean has = taCustomerFromMapper.selectCount(queryFrom) > 0;
463
-            if (!has) {
464
-                TaBuilding taBuilding = taBuildingMapper.selectById(taRecommendCustomer.getBuildingId());
465
-
466
-                TaCustomerFrom customerFrom = new TaCustomerFrom();
467
-                customerFrom.setPersonId(taRecommendCustomer.getPersonId());
468
-                customerFrom.setCustomerId(taRecommendCustomer.getCustomerId());
469
-                customerFrom.setPersonName(taRecommendCustomer.getName());
470
-                customerFrom.setOrgId(taRecommendCustomer.getOrgId());
471
-//              customerFrom.setSceneId(sceneId);
472
-                customerFrom.setIsOrgFirst(false);
473
-                customerFrom.setIsProjectFirst(true);
474
-                customerFrom.setCreateDate(LocalDateTime.now());
475
-                customerFrom.setBuildingId(taRecommendCustomer.getBuildingId());
476
-                customerFrom.setBuildingName(taBuilding.getBuildingName());
477
-                customerFrom.setSharePersonId(consultantPerson.getPersonId());
478
-                customerFrom.setSharePersonName(consultantUser.getUserName());
479
-
480
-                // 半小时内如果有当前人员的分享记录
481
-                // 那么就认为当前客户是通过分享进入的
482
-                TaSharePersonFrom personShare = taSharePersonFromMapper.getConsultantLastShare(taRecommendCustomer.getOrgId(),
483
-                        taRecommendCustomer.getBuildingId(),
484
-                        consultantUser.getUserId(),
485
-                        taRecommendCustomer.getPersonId());
486
-                if (null != personShare) {
487
-                    // 强制转换 targetType
488
-                    String targetType = personShare.getTargetType().replace("_share", "").replace("dynamic", "activity");
489
-                    customerFrom.setTargetType(targetType);
490
-                    customerFrom.setTargetId(personShare.getTargetId());
491
-                    customerFrom.setTargetName(personShare.getTargetName());
492
-                }
493
-
494
-                taCustomerFromMapper.insert(customerFrom);
495
-            }
496
-        }
497
-
498 504
         return ResponseBean.success(taRecommendCustomer);
499 505
     }
500 506
 

+ 10
- 0
src/main/resources/mapper/TaCustomerFromMapper.xml Прегледај датотеку

@@ -2,4 +2,14 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.huiju.estateagents.mapper.TaCustomerFromMapper">
4 4
 
5
+    <select id="countPerson" resultType="java.util.HashMap">
6
+        SELECT
7
+            count( 1 ) AS orgCount,
8
+            IFNULL( sum( IF ( t.building_id = #{buildingId}, 1, 0 ) ), 0 ) AS projectCount
9
+        FROM
10
+            ta_customer_from t
11
+        WHERE
12
+            t.org_id = #{orgId}
13
+        AND t.person_id = #{personId}
14
+    </select>
5 15
 </mapper>

+ 2
- 1
src/main/resources/mapper/TsConsultantKpiMapper.xml Прегледај датотеку

@@ -157,6 +157,7 @@
157 157
             e.create_date as visit_time
158 158
         FROM ta_customer_from e
159 159
         INNER JOIN ta_person t ON t.person_id = e.person_id
160
+        INNER JOIN ta_person s ON s.person_id = e.share_person_id
160 161
         WHERE e.org_id = #{orgId}
161 162
         <if test="buildingId != null and buildingId !=''">
162 163
             AND e.building_id = #{buildingId}
@@ -164,7 +165,7 @@
164 165
         AND e.target_type is not null
165 166
         AND e.create_date BETWEEN #{startDate} and #{endDate}
166 167
         AND e.is_project_first = 1
167
-        AND t.user_id = #{userId}
168
+        AND s.user_id = #{userId}
168 169
 
169 170
         AND t.person_type != 'Realty Consultant'
170 171