|
@@ -461,6 +461,108 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
|
461
|
461
|
return ResponseBean.success(result);
|
462
|
462
|
}
|
463
|
463
|
|
|
464
|
+ @Override
|
|
465
|
+ public void manualReport(Integer orgId, TaPerson consultant, ChannelReportDTO reportCust) throws Exception {
|
|
466
|
+ TaRecommendCustomer recommendCustomer;
|
|
467
|
+ TaCustomerFrom customerFrom = new TaCustomerFrom();
|
|
468
|
+ String phone = reportCust.getPhone();
|
|
469
|
+ String consultantUser = consultant.getUserId().toString();
|
|
470
|
+
|
|
471
|
+ // 客户对应人员
|
|
472
|
+ QueryWrapper<TaPerson> query1 = new QueryWrapper<>();
|
|
473
|
+ query1.eq("org_id", orgId);
|
|
474
|
+ query1.eq("phone", phone);
|
|
475
|
+ TaPerson custPerson = taPersonMapper.selectOne(query1);
|
|
476
|
+ if (null != custPerson) {
|
|
477
|
+ if (CommConstant.PERSON_REALTY_CONSULTANT.equals(custPerson.getPersonType())) {
|
|
478
|
+ throw new Exception("置业顾问不可以绑定置业顾问");
|
|
479
|
+ }
|
|
480
|
+ }
|
|
481
|
+
|
|
482
|
+ // 查询置业授权的楼盘
|
|
483
|
+ QueryWrapper<TaPersonBuilding> query2 = new QueryWrapper<>();
|
|
484
|
+ query2.eq("user_id", consultant.getUserId());
|
|
485
|
+ List<TaPersonBuilding> taPersonBuildingList = taPersonBuildingMapper.selectList(query2);
|
|
486
|
+ if (taPersonBuildingList.size() < 1) {
|
|
487
|
+ throw new Exception("置业未绑定楼盘");
|
|
488
|
+ }
|
|
489
|
+ TaPersonBuilding taPersonBuilding = taPersonBuildingList.get(0);
|
|
490
|
+
|
|
491
|
+ // 查询楼盘下是否有该客户
|
|
492
|
+ QueryWrapper<TaRecommendCustomer> query3 = new QueryWrapper<>();
|
|
493
|
+ query3.eq("phone", phone);
|
|
494
|
+ query3.eq("building_id", taPersonBuilding.getBuildingId());
|
|
495
|
+ query3.eq("org_id", orgId);
|
|
496
|
+ List<TaRecommendCustomer> lst = list(query3);
|
|
497
|
+ if (lst.size() > 0) {
|
|
498
|
+ TaRecommendCustomer orign = lst.get(0);
|
|
499
|
+ if (!StringUtils.isEmpty(orign.getRealtyConsultant())) {
|
|
500
|
+ // 如果当前人员已经是当前置业的私客
|
|
501
|
+ if (orign.getRealtyConsultant().equals(consultantUser)) {
|
|
502
|
+ return;
|
|
503
|
+ } else {
|
|
504
|
+ throw new Exception("当前人员是其他置业的私客");
|
|
505
|
+ }
|
|
506
|
+ } else {
|
|
507
|
+ // 如果是项目公客, 则直接绑定为当前置业的私客
|
|
508
|
+ orign.setRealtyConsultant(consultantUser);
|
|
509
|
+ orign.setVerifyStatus(CommConstant.VERIFY_AGREE);
|
|
510
|
+ orign.setStatus(CommConstant.CUSTOMER_REPORT);
|
|
511
|
+ orign.setEntryType(CommConstant.ENTRY_INPUT);
|
|
512
|
+ orign.setReportDate(LocalDateTime.now());
|
|
513
|
+ recommendCustomer = orign;
|
|
514
|
+// updateById(orign);
|
|
515
|
+// return;
|
|
516
|
+ }
|
|
517
|
+ } else {
|
|
518
|
+ // 如果表中无此人员数据
|
|
519
|
+ recommendCustomer = new TaRecommendCustomer();
|
|
520
|
+
|
|
521
|
+ recommendCustomer.setOrgId(orgId);
|
|
522
|
+ recommendCustomer.setName(reportCust.getName());
|
|
523
|
+ recommendCustomer.setPicture(null != custPerson ? custPerson.getAvatarurl() : null);
|
|
524
|
+ recommendCustomer.setPhone(phone);
|
|
525
|
+ recommendCustomer.setSex(reportCust.getSex());
|
|
526
|
+ recommendCustomer.setRealtyConsultant(consultantUser);
|
|
527
|
+ recommendCustomer.setBuildingId(taPersonBuilding.getBuildingId());
|
|
528
|
+ TaBuilding building = taBuildingMapper.selectById(taPersonBuilding.getBuildingId());
|
|
529
|
+ recommendCustomer.setIntention(building.getBuildingName());
|
|
530
|
+ recommendCustomer.setReportRecommendStatus(CommConstant.VERIFY_AGREE);
|
|
531
|
+ recommendCustomer.setCreateDate(LocalDateTime.now());
|
|
532
|
+ recommendCustomer.setReportDate(LocalDateTime.now());
|
|
533
|
+ recommendCustomer.setPersonId(null != custPerson ? custPerson.getPersonId() : null);
|
|
534
|
+ recommendCustomer.setEntryType(CommConstant.ENTRY_INPUT);
|
|
535
|
+ recommendCustomer.setVerifyStatus(CommConstant.VERIFY_AGREE);
|
|
536
|
+ recommendCustomer.setStatus(CommConstant.CUSTOMER_REPORT);
|
|
537
|
+ recommendCustomer.setRecommendPerson(consultant.getPersonId());
|
|
538
|
+ customerFrom.setIsProjectFirst(true);
|
|
539
|
+ customerFrom.setIsOrgFirst(true);
|
|
540
|
+ }
|
|
541
|
+
|
|
542
|
+ if (StringUtils.isEmpty(recommendCustomer.getCustomerId())) {
|
|
543
|
+ if (!save(recommendCustomer)) {
|
|
544
|
+ throw new Exception("报备客户异常, 请重试");
|
|
545
|
+ }
|
|
546
|
+ } else {
|
|
547
|
+ if (!updateById(recommendCustomer)) {
|
|
548
|
+ throw new Exception("报备客户异常, 请重试");
|
|
549
|
+ }
|
|
550
|
+ }
|
|
551
|
+
|
|
552
|
+ customerFrom.setPersonId(recommendCustomer.getPersonId());
|
|
553
|
+ customerFrom.setCustomerId(recommendCustomer.getCustomerId());
|
|
554
|
+ customerFrom.setPersonName(recommendCustomer.getName());
|
|
555
|
+ customerFrom.setOrgId(recommendCustomer.getOrgId());
|
|
556
|
+ customerFrom.setCreateDate(LocalDateTime.now());
|
|
557
|
+ customerFrom.setBuildingId(recommendCustomer.getBuildingId());
|
|
558
|
+ customerFrom.setBuildingName(recommendCustomer.getIntention());
|
|
559
|
+ customerFrom.setSharePersonId(consultant.getPersonId());
|
|
560
|
+ customerFrom.setSharePersonName(consultant.getName());
|
|
561
|
+
|
|
562
|
+ taCustomerFromMapper.insert(customerFrom);
|
|
563
|
+ return;
|
|
564
|
+ }
|
|
565
|
+
|
464
|
566
|
private void fillSomeFieldsOfCustomer(TaRecommendCustomer customer, TaPerson recommender, LocalDateTime now) {
|
465
|
567
|
customer.setVerifyStatus(CommConstant.VERIFY_AGREE);
|
466
|
568
|
customer.setStatus(CommConstant.CUSTOMER_REPORT);
|