Bladeren bron

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

魏超 5 jaren geleden
bovenliggende
commit
69c6f13785

+ 142
- 146
src/main/java/com/huiju/estateagents/service/impl/TaRecommendCustomerServiceImpl.java Bestand weergeven

@@ -64,7 +64,7 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
64 64
 
65 65
     @Autowired
66 66
     private TdCityMapper cityMapper;
67
-    
67
+
68 68
     @Autowired
69 69
     private TaCustomerFollowUpRecordMapper customerFollowUpRecordMapper;
70 70
 
@@ -211,7 +211,7 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
211 211
     }
212 212
 
213 213
     @Override
214
-    public synchronized ResponseBean recommendCust(String paramStr, String openid,Integer orgId) {
214
+    public synchronized ResponseBean recommendCust(String paramStr, String openid, Integer orgId) {
215 215
         JSONObject params = JSONObject.parseObject(paramStr);
216 216
         if (null == params) {
217 217
             return ResponseBean.error("解析参数失败", ResponseBean.ERROR_ILLEGAL_PARAMS);
@@ -227,8 +227,17 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
227 227
             return ResponseBean.error(checkResult, ResponseBean.ERROR_MISSING_PARAMS);
228 228
         }
229 229
 
230
-        TaRecommendCustomer taRecommendCustomer = new TaRecommendCustomer();
230
+        // 报备有 10 天有效期
231
+        QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
232
+        queryWrapper.eq("phone", params.getString("phone"));
233
+        queryWrapper.eq("building_id", params.getString("intention"));
234
+        queryWrapper.in("verify_status", CommConstant.VERIFY_AGREE, CommConstant.VERIFY_READY);
235
+        List<TaRecommendCustomer> result = taRecommendCustomerMapper.selectList(queryWrapper);
236
+        if (null != result && result.size() > 0) {
237
+            return ResponseBean.error("当前客户已被推荐, 不能再次推荐", ResponseBean.ERROR_ILLEGAL_PARAMS);
238
+        }
231 239
 
240
+        TaRecommendCustomer taRecommendCustomer = new TaRecommendCustomer();
232 241
         taRecommendCustomer.setName(params.getString("name"));
233 242
         taRecommendCustomer.setPicture(params.getString("picture"));
234 243
         taRecommendCustomer.setPhone(params.getString("phone"));
@@ -242,11 +251,11 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
242 251
         taRecommendCustomer.setCreateDate(LocalDateTime.now());
243 252
         taRecommendCustomer.setReportDate(LocalDateTime.now());
244 253
         taRecommendCustomer.setOrgId(orgId);
245
-       QueryWrapper<TaPerson> personQueryWrapper = new QueryWrapper<>();
246
-       personQueryWrapper.eq("org_id",orgId);
247
-       personQueryWrapper.eq("phone",params.getString("phone"));
254
+        QueryWrapper<TaPerson> personQueryWrapper = new QueryWrapper<>();
255
+        personQueryWrapper.eq("org_id", orgId);
256
+        personQueryWrapper.eq("phone", params.getString("phone"));
248 257
         TaPerson currentPerson = taPersonMapper.selectOne(personQueryWrapper);
249
-        if(null != currentPerson){
258
+        if (null != currentPerson) {
250 259
             taRecommendCustomer.setPersonId(currentPerson.getPersonId());
251 260
         }
252 261
 
@@ -271,24 +280,14 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
271 280
 
272 281
         String status = params.getString("status");
273 282
         int statusInt = 0;
274
-        if (StringUtils.isEmpty(status)){
283
+        if (StringUtils.isEmpty(status)) {
275 284
             taRecommendCustomer.setStatus(statusInt);
276
-        }else{
285
+        } else {
277 286
             taRecommendCustomer.setStatus(Integer.parseInt(status));
278 287
         }
279 288
 
280 289
         taRecommendCustomer.setRecommendPerson(taPerson.getPersonId());
281 290
 
282
-        // 报备有 10 天有效期
283
-        QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
284
-        queryWrapper.eq("phone", taRecommendCustomer.getPhone());
285
-        queryWrapper.eq("building_id",taRecommendCustomer.getBuildingId());
286
-        queryWrapper.in("verify_status",CommConstant.VERIFY_AGREE,CommConstant.VERIFY_READY);
287
-        List<TaRecommendCustomer> result = taRecommendCustomerMapper.selectList(queryWrapper);
288
-        if (null != result && result.size() > 0) {
289
-            return ResponseBean.error("当前客户已被推荐, 不能再次推荐", ResponseBean.ERROR_ILLEGAL_PARAMS);
290
-        }
291
-
292 291
         int row = taRecommendCustomerMapper.insert(taRecommendCustomer);
293 292
         if (row < 1) {
294 293
             return ResponseBean.error("推荐客户失败", ResponseBean.ERROR_UNAVAILABLE);
@@ -305,9 +304,8 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
305 304
     }
306 305
 
307 306
 
308
-
309 307
     @Override
310
-    public ResponseBean reportCust(String paramStr, String openid,Integer orgId) {
308
+    public ResponseBean reportCust(String paramStr, String openid, Integer orgId) {
311 309
         JSONObject params = JSONObject.parseObject(paramStr);
312 310
         if (null == params) {
313 311
             return ResponseBean.error("解析参数失败", ResponseBean.ERROR_ILLEGAL_PARAMS);
@@ -361,12 +359,12 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
361 359
 //        taRecommendCustomer.setDescribe(params.getString("describe"));
362 360
         taRecommendCustomer.setRealtyConsultant(consultantUser.getUserId().toString());
363 361
         //如果没有传building_id的情况构造building_id
364
-        if (StringUtils.isEmpty(params.getString("buildingId")) && !StringUtils.isEmpty(params.getString("realtyConsultant"))){
362
+        if (StringUtils.isEmpty(params.getString("buildingId")) && !StringUtils.isEmpty(params.getString("realtyConsultant"))) {
365 363
             QueryWrapper<TaPersonBuilding> taPersonBuildingQueryWrapper = new QueryWrapper<>();
366 364
             taPersonBuildingQueryWrapper.eq("person_id", consultantPerson.getPersonId()).or().eq("user_id", consultantUser.getUserId());
367 365
             List<TaPersonBuilding> taPersonBuildingList = taPersonBuildingMapper.selectList(taPersonBuildingQueryWrapper);
368
-            if (taPersonBuildingList.size() > 0){
369
-                params.put("buildingId",taPersonBuildingList.get(0).getBuildingId());
366
+            if (taPersonBuildingList.size() > 0) {
367
+                params.put("buildingId", taPersonBuildingList.get(0).getBuildingId());
370 368
             }
371 369
         }
372 370
         taRecommendCustomer.setBuildingId(params.getString("buildingId"));
@@ -393,11 +391,11 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
393 391
         taRecommendCustomer.setVerifyStatus(CommConstant.VERIFY_AGREE);
394 392
         taRecommendCustomer.setStatus(CommConstant.CUSTOMER_REPORT);
395 393
         QueryWrapper<TaPerson> personQueryWrapper = new QueryWrapper<>();
396
-        personQueryWrapper.eq("org_id",orgId);
397
-        personQueryWrapper.eq("phone",params.getString("phone"));
394
+        personQueryWrapper.eq("org_id", orgId);
395
+        personQueryWrapper.eq("phone", params.getString("phone"));
398 396
         TaPerson currentPerson = taPersonMapper.selectOne(personQueryWrapper);
399
-        if(null != currentPerson){
400
-            if (currentPerson.getPersonType().equals(CommConstant.PERSON_REALTY_CONSULTANT)){
397
+        if (null != currentPerson) {
398
+            if (currentPerson.getPersonType().equals(CommConstant.PERSON_REALTY_CONSULTANT)) {
401 399
                 return ResponseBean.error("置业顾问不可以绑定置业顾问", ResponseBean.ERROR_ILLEGAL_PARAMS);
402 400
             }
403 401
             taRecommendCustomer.setPersonId(currentPerson.getPersonId());
@@ -413,29 +411,29 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
413 411
         // 报备有 10 天有效期
414 412
         QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
415 413
         queryWrapper.eq("phone", taRecommendCustomer.getPhone());
416
-        queryWrapper.eq("building_id",taRecommendCustomer.getBuildingId());
414
+        queryWrapper.eq("building_id", taRecommendCustomer.getBuildingId());
417 415
         queryWrapper.eq("org_id", taRecommendCustomer.getOrgId());
418
-        queryWrapper.in("verify_status",CommConstant.VERIFY_AGREE,CommConstant.VERIFY_READY);
416
+        queryWrapper.in("verify_status", CommConstant.VERIFY_AGREE, CommConstant.VERIFY_READY);
419 417
         List<TaRecommendCustomer> result = taRecommendCustomerMapper.selectList(queryWrapper);
420 418
         if (null != result && result.size() > 0) {
421 419
             String conName = "";
422 420
             TaPerson conPerson = taPersonMapper.selectById(result.get(0).getRealtyConsultant());
423
-            if (null != conPerson){
424
-                if(null != consultantPerson && consultantPerson.getPersonId().equals(conPerson.getPersonId())){
425
-                   return  ResponseBean.success("bound");
421
+            if (null != conPerson) {
422
+                if (null != consultantPerson && consultantPerson.getPersonId().equals(conPerson.getPersonId())) {
423
+                    return ResponseBean.success("bound");
426 424
                 }
427 425
                 conName = conPerson.getName();
428
-            }else {
426
+            } else {
429 427
                 TaUser conUser = userService.getById(result.get(0).getRealtyConsultant());
430
-                if(null != conUser){
431
-                    if(consultantUser.getUserId().equals(conUser.getUserId())){
428
+                if (null != conUser) {
429
+                    if (consultantUser.getUserId().equals(conUser.getUserId())) {
432 430
                         return ResponseBean.success("bound");
433 431
                     }
434 432
                     conName = conUser.getUserName();
435 433
 
436 434
                 }
437 435
             }
438
-            return ResponseBean.error("您在当前项目的置业顾问是:"+conName, ResponseBean.ERROR_ILLEGAL_PARAMS);
436
+            return ResponseBean.error("您在当前项目的置业顾问是:" + conName, ResponseBean.ERROR_ILLEGAL_PARAMS);
439 437
         }
440 438
 
441 439
         int row = taRecommendCustomerMapper.insert(taRecommendCustomer);
@@ -471,106 +469,104 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
471 469
     }
472 470
 
473 471
 
474
-
475
-
476 472
     List<TaPerson> getPersonsByOpenId(String openid) {
477 473
         return taPersonMapper.getPersonByOpenId(openid);
478 474
     }
479 475
 
480 476
     @Override
481
-    public IPage<TaRecommendCustomer> getUnSignedCustomerList(int pageNumber, int pageSize,String building,String personId){
482
-        QueryWrapper<TaRecommendCustomer>queryWrapper = new QueryWrapper<>();
477
+    public IPage<TaRecommendCustomer> getUnSignedCustomerList(int pageNumber, int pageSize, String building, String personId) {
478
+        QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
483 479
 //        queryWrapper.eq("building_id",building);
484
-        queryWrapper.eq("realty_consultant",personId);
480
+        queryWrapper.eq("realty_consultant", personId);
485 481
         queryWrapper.gt("status", CommConstant.MESSAGE_UNREAD);
486
-        IPage<TaRecommendCustomer>page = new Page<>(pageNumber,pageSize);
487
-        return taRecommendCustomerMapper.selectPage(page,queryWrapper);
482
+        IPage<TaRecommendCustomer> page = new Page<>(pageNumber, pageSize);
483
+        return taRecommendCustomerMapper.selectPage(page, queryWrapper);
488 484
     }
489 485
 
490 486
     @Override
491
-    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){
487
+    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) {
492 488
 
493 489
         if (CommConstant.CUTOMER_TYPE_PUBLIC.equals(customerType)) {
494 490
             // 公客
495
-            IPage<TaPerson>page = new Page<>(pageNumber,pageSize);
491
+            IPage<TaPerson> page = new Page<>(pageNumber, pageSize);
496 492
             // 公客就不用 buildingId 进行查询
497
-            return taRecommendCustomerMapper.getPublicCustomerList(page,name, tel,  entryType, verifyStatus, sex, orgId,consultTel,sceneType, taPersonBuildingList,building, startCreateDate, endCreateDate);
493
+            return taRecommendCustomerMapper.getPublicCustomerList(page, name, tel, entryType, verifyStatus, sex, orgId, consultTel, sceneType, taPersonBuildingList, building, startCreateDate, endCreateDate);
498 494
         } else {
499 495
             // 私客
500
-            IPage<TaRecommendCustomer>page = new Page<>(pageNumber,pageSize);
501
-            return taRecommendCustomerMapper.getCustomerList(page, building, name, tel, consultName, consultTel, entryType, verifyStatus, sex, orgId,status,taPersonBuildingList,sceneType, startCreateDate, endCreateDate);
496
+            IPage<TaRecommendCustomer> page = new Page<>(pageNumber, pageSize);
497
+            return taRecommendCustomerMapper.getCustomerList(page, building, name, tel, consultName, consultTel, entryType, verifyStatus, sex, orgId, status, taPersonBuildingList, sceneType, startCreateDate, endCreateDate);
502 498
         }
503 499
 
504 500
     }
505 501
 
506 502
     @Override
507
-    public IPage<TaPerson> getIndependentAgents(int pageNumber, int pageSize,String name,String tel, Integer orgId){
508
-        IPage<TaPerson>page = new Page<>(pageNumber,pageSize);
509
-        return taRecommendCustomerMapper.getIndependentAgents(page,name,tel, orgId);
503
+    public IPage<TaPerson> getIndependentAgents(int pageNumber, int pageSize, String name, String tel, Integer orgId) {
504
+        IPage<TaPerson> page = new Page<>(pageNumber, pageSize);
505
+        return taRecommendCustomerMapper.getIndependentAgents(page, name, tel, orgId);
510 506
     }
511 507
 
512 508
     @Override
513
-    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){
514
-        IPage<TaRecommendCustomer>page = new Page<>(pageNumber,pageSize);
515
-        return taRecommendCustomerMapper.getRecCustomerList(page,building,name,tel,consultName,consultTel,entryType,verifyStatus,sex, orgId,taPersonBuildingList);
509
+    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) {
510
+        IPage<TaRecommendCustomer> page = new Page<>(pageNumber, pageSize);
511
+        return taRecommendCustomerMapper.getRecCustomerList(page, building, name, tel, consultName, consultTel, entryType, verifyStatus, sex, orgId, taPersonBuildingList);
516 512
     }
517 513
 
518 514
 
519 515
     @Override
520
-    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){
521
-        IPage<TaRecommendCustomer>page = new Page<>(pageNumber,pageSize);
522
-        return taRecommendCustomerMapper.getRepCustomerList(page,building,name,tel,consultName,consultTel,entryType,verifyStatus,sex, orgId,taPersonBuildingList);
516
+    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) {
517
+        IPage<TaRecommendCustomer> page = new Page<>(pageNumber, pageSize);
518
+        return taRecommendCustomerMapper.getRepCustomerList(page, building, name, tel, consultName, consultTel, entryType, verifyStatus, sex, orgId, taPersonBuildingList);
523 519
     }
524 520
 
525 521
     @Override
526
-    public TaRecommendCustomer getCustomerById(String customerId){
522
+    public TaRecommendCustomer getCustomerById(String customerId) {
527 523
         return taRecommendCustomerMapper.getCustomerById(customerId);
528 524
     }
529 525
 
530 526
 
531 527
     @Override
532
-    public TaRecommendCustomer getCustomerDetail(String customerId,int pageNumber, int pageSize,List<TaPersonBuilding> taPersonBuildingList,String buildingId){
528
+    public TaRecommendCustomer getCustomerDetail(String customerId, int pageNumber, int pageSize, List<TaPersonBuilding> taPersonBuildingList, String buildingId) {
533 529
         String personId = taRecommendCustomerMapper.getCustomerById(customerId).getPersonId();
534
-        TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.getCustomerDetail(customerId,personId);
530
+        TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.getCustomerDetail(customerId, personId);
535 531
         TaPerson person = taPersonMapper.selectById(personId);
536
-        if(!StringUtils.isEmpty(personId)){
537
-            IPage<TaPersonVisitRecord>page = new Page<>(pageNumber,pageSize);
538
-            IPage<TaPersonVisitRecord> taPersonVisitRecordIPage = taPersonVisitRecordMapper.visitRecordByPersonId(page,personId,taPersonBuildingList,buildingId);
532
+        if (!StringUtils.isEmpty(personId)) {
533
+            IPage<TaPersonVisitRecord> page = new Page<>(pageNumber, pageSize);
534
+            IPage<TaPersonVisitRecord> taPersonVisitRecordIPage = taPersonVisitRecordMapper.visitRecordByPersonId(page, personId, taPersonBuildingList, buildingId);
539 535
             List<TaPersonVisitRecord> records = taPersonVisitRecordIPage.getRecords();
540 536
             records.forEach(e -> {
541 537
                 //获取活动标题
542
-                if ("activity".equals(e.getEventType()) && null != e.getTargetId()){
538
+                if ("activity".equals(e.getEventType()) && null != e.getTargetId()) {
543 539
                     TaBuildingDynamic taBuildingDynamic = taBuildingDynamicMapper.selectById(e.getTargetId());
544
-                    if (null != taBuildingDynamic){
540
+                    if (null != taBuildingDynamic) {
545 541
                         e.setActivityName(taBuildingDynamic.getTitle());
546 542
                     }
547 543
 
548 544
                 }
549 545
                 //获取拼团标题
550
-                if ("group".equals(e.getEventType()) && null != e.getTargetId()){
546
+                if ("group".equals(e.getEventType()) && null != e.getTargetId()) {
551 547
                     TaShareActivity taShareActivity = taShareActivityMapper.selectById(e.getTargetId());
552
-                    if (null != taShareActivity){
548
+                    if (null != taShareActivity) {
553 549
                         e.setActivityName(taShareActivity.getActivityName());
554 550
                     }
555 551
                 }
556 552
                 //获取助力标题
557
-                if ("help".equals(e.getEventType()) && null != e.getTargetId()){
553
+                if ("help".equals(e.getEventType()) && null != e.getTargetId()) {
558 554
                     HelpActivity helpActivity = helpActivityMapper.selectById(e.getTargetId());
559
-                    if (null != helpActivity){
555
+                    if (null != helpActivity) {
560 556
                         e.setActivityName(helpActivity.getTitle());
561 557
                     }
562 558
                 }
563 559
                 //获取咨询标题
564
-                if ("news".equals(e.getEventType()) && null != e.getTargetId()){
560
+                if ("news".equals(e.getEventType()) && null != e.getTargetId()) {
565 561
                     TaNews taNews = taNewsMapper.selectById(e.getTargetId());
566
-                    if (null != taNews){
562
+                    if (null != taNews) {
567 563
                         e.setActivityName(taNews.getNewsName());
568 564
                     }
569 565
                 }
570 566
                 //获取H5活动标题
571
-                if ("h5".equals(e.getEventType()) && null != e.getTargetId()){
567
+                if ("h5".equals(e.getEventType()) && null != e.getTargetId()) {
572 568
                     TaDrainage taDrainage = taDrainageMapper.selectById(e.getTargetId());
573
-                    if (null != taDrainage){
569
+                    if (null != taDrainage) {
574 570
                         e.setActivityName(taDrainage.getName());
575 571
                     }
576 572
                 }
@@ -578,19 +574,19 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
578 574
             taPersonVisitRecordIPage.setRecords(records);
579 575
             taRecommendCustomer.setVisitRecords(taPersonVisitRecordIPage);
580 576
             taRecommendCustomer.setVisitTimes(taPersonVisitRecordIPage.getRecords().size());
581
-            taRecommendCustomer.setIntentions(taRecommendCustomerMapper.getCustomerIntentions(personId,taPersonBuildingList));
577
+            taRecommendCustomer.setIntentions(taRecommendCustomerMapper.getCustomerIntentions(personId, taPersonBuildingList));
582 578
         }
583
-        if(!StringUtils.isEmpty(taRecommendCustomer.getRealtyConsultant())){
584
-            TaPerson consultant =  taPersonMapper.getById(taRecommendCustomer.getRealtyConsultant());
579
+        if (!StringUtils.isEmpty(taRecommendCustomer.getRealtyConsultant())) {
580
+            TaPerson consultant = taPersonMapper.getById(taRecommendCustomer.getRealtyConsultant());
585 581
             TaUser user = new TaUser();
586
-            if(null == consultant){
582
+            if (null == consultant) {
587 583
                 user = userService.getById(taRecommendCustomer.getRealtyConsultant());
588
-            }else {
584
+            } else {
589 585
                 user = userService.getById(consultant.getUserId());
590 586
             }
591
-            if (null != user){
587
+            if (null != user) {
592 588
                 List<String> projects = taPersonMapper.getUserProjects(user.getUserId());
593
-                if (projects.size()>0){
589
+                if (projects.size() > 0) {
594 590
                     user.setProjects(projects);
595 591
                 }
596 592
                 taRecommendCustomer.setConsultant(user);
@@ -598,26 +594,26 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
598 594
         }
599 595
         //构造来源类型
600 596
         taRecommendCustomer.setPersonFrom("");
601
-        if (null != person){
602
-            Map<String,String>geoInfo = new HashMap<>();
603
-            geoInfo.put("provience",person.getProvince());
604
-            geoInfo.put("country",person.getCountry());
597
+        if (null != person) {
598
+            Map<String, String> geoInfo = new HashMap<>();
599
+            geoInfo.put("provience", person.getProvince());
600
+            geoInfo.put("country", person.getCountry());
605 601
             TdCity city = cityMapper.selectById(person.getCity());
606
-            if(null!=city){
607
-                geoInfo.put("city",city.getName());
608
-            }else {
609
-                geoInfo.put("city","未知");
602
+            if (null != city) {
603
+                geoInfo.put("city", city.getName());
604
+            } else {
605
+                geoInfo.put("city", "未知");
610 606
             }
611 607
             taRecommendCustomer.setGeoInfo(geoInfo);
612 608
 
613 609
             QueryWrapper<TaPersonFromRecord> queryWrapper = new QueryWrapper<>();
614
-            queryWrapper.eq("org_id",person.getOrgId());
615
-            queryWrapper.eq("person_id",person.getPersonId());
616
-            queryWrapper.eq("is_first_time",1);
610
+            queryWrapper.eq("org_id", person.getOrgId());
611
+            queryWrapper.eq("person_id", person.getPersonId());
612
+            queryWrapper.eq("is_first_time", 1);
617 613
             List<TaPersonFromRecord> taPersonFromRecords = taPersonFromRecordMapper.selectList(queryWrapper);
618
-            if (taPersonFromRecords.size() > 0){
614
+            if (taPersonFromRecords.size() > 0) {
619 615
                 QueryWrapper<TdWxDict> tdWxDictQueryWrapper = new QueryWrapper<>();
620
-                tdWxDictQueryWrapper.eq("scene_id",taPersonFromRecords.get(0).getSceneId());
616
+                tdWxDictQueryWrapper.eq("scene_id", taPersonFromRecords.get(0).getSceneId());
621 617
                 TdWxDict tdWxDict = tdWxDictMapper.selectOne(tdWxDictQueryWrapper);
622 618
                 taRecommendCustomer.setPersonFrom(null != tdWxDict ? tdWxDict.getSceneAlias() : "");
623 619
             }
@@ -627,46 +623,46 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
627 623
     }
628 624
 
629 625
     @Override
630
-    public TaPerson getPublicCustomerDetail(String personId,int pageNumber, int pageSize,List<TaPersonBuilding> taPersonBuildingList,String buildingId){
626
+    public TaPerson getPublicCustomerDetail(String personId, int pageNumber, int pageSize, List<TaPersonBuilding> taPersonBuildingList, String buildingId) {
631 627
         TaPerson taPerson = taPersonMapper.getById(personId);
632
-        if(!StringUtils.isEmpty(personId)){
633
-            IPage<TaPersonVisitRecord>page = new Page<>(pageNumber,pageSize);
634
-            IPage<TaPersonVisitRecord> taPersonVisitRecordIPage = taPersonVisitRecordMapper.visitRecordByPersonId(page,personId,taPersonBuildingList,buildingId);
628
+        if (!StringUtils.isEmpty(personId)) {
629
+            IPage<TaPersonVisitRecord> page = new Page<>(pageNumber, pageSize);
630
+            IPage<TaPersonVisitRecord> taPersonVisitRecordIPage = taPersonVisitRecordMapper.visitRecordByPersonId(page, personId, taPersonBuildingList, buildingId);
635 631
             List<TaPersonVisitRecord> records = taPersonVisitRecordIPage.getRecords();
636 632
             records.forEach(e -> {
637 633
                 //获取活动标题
638
-                if ("activity".equals(e.getEventType()) && null != e.getTargetId()){
634
+                if ("activity".equals(e.getEventType()) && null != e.getTargetId()) {
639 635
                     TaBuildingDynamic taBuildingDynamic = taBuildingDynamicMapper.selectById(e.getTargetId());
640
-                    if (null != taBuildingDynamic){
636
+                    if (null != taBuildingDynamic) {
641 637
                         e.setActivityName(taBuildingDynamic.getTitle());
642 638
                     }
643 639
 
644 640
                 }
645 641
                 //获取拼团标题
646
-                if ("group".equals(e.getEventType()) && null != e.getTargetId()){
642
+                if ("group".equals(e.getEventType()) && null != e.getTargetId()) {
647 643
                     TaShareActivity taShareActivity = taShareActivityMapper.selectById(e.getTargetId());
648
-                    if (null != taShareActivity){
644
+                    if (null != taShareActivity) {
649 645
                         e.setActivityName(taShareActivity.getActivityName());
650 646
                     }
651 647
                 }
652 648
                 //获取助力标题
653
-                if ("help".equals(e.getEventType()) && null != e.getTargetId()){
649
+                if ("help".equals(e.getEventType()) && null != e.getTargetId()) {
654 650
                     HelpActivity helpActivity = helpActivityMapper.selectById(e.getTargetId());
655
-                    if (null != helpActivity){
651
+                    if (null != helpActivity) {
656 652
                         e.setActivityName(helpActivity.getTitle());
657 653
                     }
658 654
                 }
659 655
                 //获取咨询标题
660
-                if ("news".equals(e.getEventType()) && null != e.getTargetId()){
656
+                if ("news".equals(e.getEventType()) && null != e.getTargetId()) {
661 657
                     TaNews taNews = taNewsMapper.selectById(e.getTargetId());
662
-                    if (null != taNews){
658
+                    if (null != taNews) {
663 659
                         e.setActivityName(taNews.getNewsName());
664 660
                     }
665 661
                 }
666 662
                 //获取H5活动标题
667
-                if ("h5".equals(e.getEventType()) && null != e.getTargetId()){
663
+                if ("h5".equals(e.getEventType()) && null != e.getTargetId()) {
668 664
                     TaDrainage taDrainage = taDrainageMapper.selectById(e.getTargetId());
669
-                    if (null != taDrainage){
665
+                    if (null != taDrainage) {
670 666
                         e.setActivityName(taDrainage.getName());
671 667
                     }
672 668
                 }
@@ -674,25 +670,25 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
674 670
             taPersonVisitRecordIPage.setRecords(records);
675 671
             taPerson.setVisitRecords(taPersonVisitRecordIPage);
676 672
             taPerson.setVisitTimes(taPersonVisitRecordIPage.getRecords().size());
677
-            taPerson.setIntentions(taRecommendCustomerMapper.getCustomerIntentions(personId,taPersonBuildingList));
673
+            taPerson.setIntentions(taRecommendCustomerMapper.getCustomerIntentions(personId, taPersonBuildingList));
678 674
             taPerson.setDuration(taPersonVisitRecordMapper.getDurationByPersonId(personId));
679 675
             taPerson.setVisitTime(taPersonVisitRecordMapper.getFirstVisitTimeByPersonId(personId));
680 676
             TdCity city = cityMapper.selectById(taPerson.getCity());
681
-            if(null != city){
677
+            if (null != city) {
682 678
                 taPerson.setCity(city.getName());
683 679
             }
684 680
 
685 681
             //构造来源类型
686 682
             taPerson.setPersonFrom("");
687
-            if (null != taPerson){
683
+            if (null != taPerson) {
688 684
                 QueryWrapper<TaPersonFromRecord> queryWrapper = new QueryWrapper<>();
689
-                queryWrapper.eq("org_id",taPerson.getOrgId());
690
-                queryWrapper.eq("person_id",taPerson.getPersonId());
691
-                queryWrapper.eq("is_first_time",1);
685
+                queryWrapper.eq("org_id", taPerson.getOrgId());
686
+                queryWrapper.eq("person_id", taPerson.getPersonId());
687
+                queryWrapper.eq("is_first_time", 1);
692 688
                 List<TaPersonFromRecord> taPersonFromRecords = taPersonFromRecordMapper.selectList(queryWrapper);
693
-                if (taPersonFromRecords.size() > 0){
689
+                if (taPersonFromRecords.size() > 0) {
694 690
                     QueryWrapper<TdWxDict> tdWxDictQueryWrapper = new QueryWrapper<>();
695
-                    tdWxDictQueryWrapper.eq("scene_id",taPersonFromRecords.get(0).getSceneId());
691
+                    tdWxDictQueryWrapper.eq("scene_id", taPersonFromRecords.get(0).getSceneId());
696 692
                     TdWxDict tdWxDict = tdWxDictMapper.selectOne(tdWxDictQueryWrapper);
697 693
                     taPerson.setPersonFrom(null != tdWxDict ? tdWxDict.getSceneAlias() : "");
698 694
                 }
@@ -702,17 +698,17 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
702 698
     }
703 699
 
704 700
     @Override
705
-    public IPage<TaRecommendCustomer>getCustomersIRecommended(int pageNumber, int pageSize,String customerId,Integer orgId,List<TaPersonBuilding> taPersonBuildingList){
701
+    public IPage<TaRecommendCustomer> getCustomersIRecommended(int pageNumber, int pageSize, String customerId, Integer orgId, List<TaPersonBuilding> taPersonBuildingList) {
706 702
 
707
-        QueryWrapper<TaRecommendCustomer>queryWrapper = new QueryWrapper<>();
703
+        QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
708 704
         // todo
709 705
         // 此处可能不是 person_id 而是 recommend_person
710
-        IPage<TaRecommendCustomer>page = new Page<>(pageNumber,pageSize);
706
+        IPage<TaRecommendCustomer> page = new Page<>(pageNumber, pageSize);
711 707
 //        queryWrapper.eq("recommend_person",customerId);
712 708
 ////        queryWrapper.eq("building_id",building);
713 709
 //        queryWrapper.eq("status", CommConstant.VERIFY_AGREE);
714 710
 //        queryWrapper.eq("org_id", orgId);
715
-        return taRecommendCustomerMapper.getCustomersIRecommended(page,customerId,CommConstant.STATUS_NORMAL,orgId,taPersonBuildingList);
711
+        return taRecommendCustomerMapper.getCustomersIRecommended(page, customerId, CommConstant.STATUS_NORMAL, orgId, taPersonBuildingList);
716 712
     }
717 713
 
718 714
     @Override
@@ -754,8 +750,8 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
754 750
 
755 751
     @Override
756 752
     public ResponseBean batchConsultantAssist(TaUser taUser, Integer orgId) {
757
-        if (CollectionUtils.isNotEmpty(taUser.getPersonIds())){
758
-            for (TaPerson taPerson : taUser.getPersonIds()){
753
+        if (CollectionUtils.isNotEmpty(taUser.getPersonIds())) {
754
+            for (TaPerson taPerson : taUser.getPersonIds()) {
759 755
                 consultantAssist(taUser, taPerson.getPersonId(), orgId);
760 756
             }
761 757
         }
@@ -834,24 +830,24 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
834 830
 
835 831
 
836 832
     @Override
837
-    public List<ExcelRecommendCustomer> getRecCustomerExport(Integer orgId, Integer pageCode, Integer pageSize,List<TaPersonBuilding> taPersonBuildingList) {
838
-        return taRecommendCustomerMapper.getRecCustomerExport(orgId, pageCode, pageSize,taPersonBuildingList);
833
+    public List<ExcelRecommendCustomer> getRecCustomerExport(Integer orgId, Integer pageCode, Integer pageSize, List<TaPersonBuilding> taPersonBuildingList) {
834
+        return taRecommendCustomerMapper.getRecCustomerExport(orgId, pageCode, pageSize, taPersonBuildingList);
839 835
     }
840 836
 
841 837
     @Override
842
-    public Integer getRecCustomerExportCount(Integer orgId,List<TaPersonBuilding> taPersonBuildingList) {
843
-        return taRecommendCustomerMapper.getRecCustomerExportCount(orgId,taPersonBuildingList);
838
+    public Integer getRecCustomerExportCount(Integer orgId, List<TaPersonBuilding> taPersonBuildingList) {
839
+        return taRecommendCustomerMapper.getRecCustomerExportCount(orgId, taPersonBuildingList);
844 840
     }
845 841
 
846 842
 
847 843
     @Override
848
-    public Integer getRepCustomerReportCount(String building, String name, String tel, String consultName, String consultTel, String entryType, String verifyStatus, Integer sex,Integer orgId,List<TaPersonBuilding> taPersonBuildingList) {
849
-        return taRecommendCustomerMapper.getRepCustomerReportCount(building, name, tel, consultName, consultTel, entryType, verifyStatus, sex, orgId,taPersonBuildingList);
844
+    public Integer getRepCustomerReportCount(String building, String name, String tel, String consultName, String consultTel, String entryType, String verifyStatus, Integer sex, Integer orgId, List<TaPersonBuilding> taPersonBuildingList) {
845
+        return taRecommendCustomerMapper.getRepCustomerReportCount(building, name, tel, consultName, consultTel, entryType, verifyStatus, sex, orgId, taPersonBuildingList);
850 846
     }
851 847
 
852 848
     @Override
853
-    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) {
854
-        return taRecommendCustomerMapper.getRepCustomerReportExport(building, name, tel, consultName, consultTel, entryType,verifyStatus,sex, orgId, pageCode, pageSize,taPersonBuildingList);
849
+    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) {
850
+        return taRecommendCustomerMapper.getRepCustomerReportExport(building, name, tel, consultName, consultTel, entryType, verifyStatus, sex, orgId, pageCode, pageSize, taPersonBuildingList);
855 851
     }
856 852
 
857 853
 
@@ -864,7 +860,7 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
864 860
     public List<AgentsRecommendCustomer> getIndependentAgentsExport(Integer orgId, Integer pageCode, Integer pageSize) {
865 861
         return taRecommendCustomerMapper.getIndependentAgentsExport(orgId, pageCode, pageSize);
866 862
     }
867
-    
863
+
868 864
     /**
869 865
      * 查询我的客户人数集合
870 866
      *
@@ -877,12 +873,12 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
877 873
         if (null == taPersons || taPersons.size() != 1) {
878 874
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
879 875
         }
880
-    
876
+
881 877
         TaPerson taPerson = taPersons.get(0);
882
-        Map<String,Object> map = taRecommendCustomerMapper.getMyCustStatistics(taPerson.getPersonId(),taPerson.getUserId(),taPerson.getOrgId());
878
+        Map<String, Object> map = taRecommendCustomerMapper.getMyCustStatistics(taPerson.getPersonId(), taPerson.getUserId(), taPerson.getOrgId());
883 879
         return ResponseBean.success(map);
884 880
     }
885
-    
881
+
886 882
     /**
887 883
      * 分页查询我的跟进客户集合
888 884
      *
@@ -904,18 +900,18 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
904 900
         if (null == taPersons || taPersons.size() != 1) {
905 901
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
906 902
         }
907
-    
903
+
908 904
         TaPerson taPerson = taPersons.get(0);
909
-        
905
+
910 906
         IPage<TaRecommendCustomer> page = new Page<>();
911 907
         page.setCurrent(pageNumber);
912 908
         page.setSize(pageSize);
913
-        
909
+
914 910
         //分页获取跟进客户status != 4的为跟进客户, status = 4的为成交客户 根据type区分  follow 跟进  clinch 成交
915
-        IPage<TaRecommendCustomer> result = taRecommendCustomerMapper.getMyCustFollowOrClinch(page, taPerson.getPersonId(),taPerson.getUserId(),taPerson.getOrgId(), type,name,phone,status,startReportDate,endReportDate,startArrivalDate,endArrivalDate);
911
+        IPage<TaRecommendCustomer> result = taRecommendCustomerMapper.getMyCustFollowOrClinch(page, taPerson.getPersonId(), taPerson.getUserId(), taPerson.getOrgId(), type, name, phone, status, startReportDate, endReportDate, startArrivalDate, endArrivalDate);
916 912
         return ResponseBean.success(result);
917 913
     }
918
-    
914
+
919 915
     /**
920 916
      * 获取盘客工具下我的客户详情
921 917
      *
@@ -929,14 +925,14 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
929 925
         if (null == taPersons || taPersons.size() != 1) {
930 926
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
931 927
         }
932
-    
928
+
933 929
         TaPerson taPerson = taPersons.get(0);
934 930
         TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.getMyCustDetailById(customerId);
935 931
         //添加跟进行为
936
-        addCustomerFpllowUp(taPerson,taRecommendCustomer,"查看客户详情");
932
+        addCustomerFpllowUp(taPerson, taRecommendCustomer, "查看客户详情");
937 933
         return ResponseBean.success(taRecommendCustomer);
938 934
     }
939
-    
935
+
940 936
     /**
941 937
      * 更新我的客户基本信息
942 938
      *
@@ -950,16 +946,16 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
950 946
         if (null == taPersons || taPersons.size() != 1) {
951 947
             return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
952 948
         }
953
-    
949
+
954 950
         TaPerson taPerson = taPersons.get(0);
955 951
         taRecommendCustomerMapper.updateById(taRecommendCustomer);
956 952
         //添加跟进行为
957
-        addCustomerFpllowUp(taPerson,taRecommendCustomer,"编辑客户信息");
953
+        addCustomerFpllowUp(taPerson, taRecommendCustomer, "编辑客户信息");
958 954
         return ResponseBean.success(taRecommendCustomer);
959 955
     }
960
-    
956
+
961 957
     //添加跟进行为
962
-    private void addCustomerFpllowUp(TaPerson taPerson,TaRecommendCustomer taRecommendCustomer,String recordType) {
958
+    private void addCustomerFpllowUp(TaPerson taPerson, TaRecommendCustomer taRecommendCustomer, String recordType) {
963 959
         TaCustomerFollowUpRecord taCustomerFollowUpRecord = new TaCustomerFollowUpRecord();
964 960
         taCustomerFollowUpRecord.setOrgId(taPerson.getOrgId());
965 961
         taCustomerFollowUpRecord.setCreateDate(LocalDateTime.now());

+ 2
- 16
src/main/resources/mapper/ActivityManageMapper.xml Bestand weergeven

@@ -35,14 +35,7 @@
35 35
         -- 活动访问人数
36 36
         (select count( DISTINCT d.person_id ) from ta_person_visit_record d
37 37
         WHERE d.org_id = a.org_id
38
-            <choose>
39
-                <when test=" type == 'live'">
40
-                    AND d.target_type like concat('%',REPLACE(a.target_type, 'activity', 'dynamic'),'%')
41
-                </when>
42
-                <otherwise>
43
-                    AND d.target_type = REPLACE(a.target_type, 'activity', 'dynamic')
44
-                </otherwise>
45
-            </choose>
38
+            AND (d.target_type = a.target_type OR d.event_type = a.target_type)
46 39
             AND d.target_id = a.target_id
47 40
             AND d.`event` = 'detail'
48 41
         ) as visit_persons,
@@ -50,14 +43,7 @@
50 43
         -- 活动访问次数
51 44
         (select count(*) from ta_person_visit_record e
52 45
         WHERE e.org_id = a.org_id
53
-            <choose>
54
-                <when test=" type == 'live'">
55
-                    AND e.target_type like concat('%',REPLACE(a.target_type, 'activity', 'dynamic'),'%')
56
-                </when>
57
-                <otherwise>
58
-                    AND e.target_type = REPLACE(a.target_type, 'activity', 'dynamic')
59
-                </otherwise>
60
-            </choose>
46
+            AND (e.target_type = a.target_type OR e.event_type = a.target_type)
61 47
             AND e.target_id = a.target_id
62 48
             AND e.`event` = 'detail'
63 49
         ) as visit_num,

+ 3
- 1
src/main/resources/mapper/TaBuildingMapper.xml Bestand weergeven

@@ -525,7 +525,7 @@
525 525
         b.STATUS > 0
526 526
         AND b.org_id = #{orgId}
527 527
         AND IFNULL( b.person_type, '' ) IN ( 'estate agent', 'customer' )
528
-        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 != '' )
529 529
         <if test="startDate != null">
530 530
             and  TO_DAYS(b.create_date) >= TO_DAYS(#{startDate})
531 531
         </if>
@@ -544,8 +544,10 @@
544 544
         u.be_uv AS building_id
545 545
         FROM
546 546
         ta_uv u
547
+        LEFT JOIN ta_person p ON u.person_id = p.person_id
547 548
         WHERE
548 549
         u.tagert_type = 'project'
550
+        AND p.org_id = #{orgId}
549 551
         <if test="startDate != null">
550 552
             and  TO_DAYS(u.create_date) >= TO_DAYS(#{startDate})
551 553
         </if>