|
@@ -5,6 +5,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
5
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
6
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
7
|
7
|
import com.yunzhi.marketing.base.ResponseBean;
|
|
8
|
+import com.yunzhi.marketing.broker.entity.BkAgentRule;
|
|
9
|
+import com.yunzhi.marketing.broker.entity.BkInviteRecord;
|
|
10
|
+import com.yunzhi.marketing.broker.mapper.BkAgentRuleMapper;
|
|
11
|
+import com.yunzhi.marketing.broker.mapper.BkInviteRecordMapper;
|
8
|
12
|
import com.yunzhi.marketing.center.taUser.entity.TaUser;
|
9
|
13
|
import com.yunzhi.marketing.center.taUser.mapper.TaUserMapper;
|
10
|
14
|
import com.yunzhi.marketing.common.CommConstant;
|
|
@@ -65,6 +69,13 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
|
65
|
69
|
|
66
|
70
|
@Autowired
|
67
|
71
|
private InstitutionMapper institutionMapper;
|
|
72
|
+
|
|
73
|
+ @Autowired
|
|
74
|
+ private BkInviteRecordMapper bkInviteRecordMapper;
|
|
75
|
+
|
|
76
|
+ @Autowired
|
|
77
|
+ private BkAgentRuleMapper bkAgentRuleMapper;
|
|
78
|
+
|
68
|
79
|
/**
|
69
|
80
|
* 审核
|
70
|
81
|
*
|
|
@@ -511,6 +522,20 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
|
511
|
522
|
}
|
512
|
523
|
taRecommendCustomer.setStatus(bizStatus);
|
513
|
524
|
taRecommendCustomerMapper.updateById(taRecommendCustomer);
|
|
525
|
+ //
|
|
526
|
+ customerSignatory.setOrgId(taRecommendCustomer.getOrgId());
|
|
527
|
+ customerSignatory.setBuildingId(taRecommendCustomer.getBuildingId());
|
|
528
|
+ TaBuilding taBuilding = taBuildingMapper.selectById(taRecommendCustomer.getBuildingId());
|
|
529
|
+ if (taBuilding == null) {
|
|
530
|
+ throw new Exception("校验客户及楼盘信息异常");
|
|
531
|
+ }
|
|
532
|
+
|
|
533
|
+ // 推荐人
|
|
534
|
+ customerSignatory.setRecommendPerson(taRecommendCustomer.getRecommendPerson());
|
|
535
|
+ TaPerson recommendPerson = taPersonMapper.getById(taRecommendCustomer.getRecommendPerson());
|
|
536
|
+ if (null != recommendPerson) {
|
|
537
|
+ customerSignatory.setRecommendName(recommendPerson.getName());
|
|
538
|
+ }
|
514
|
539
|
|
515
|
540
|
// 更新报备记录
|
516
|
541
|
LambdaQueryWrapper<ChannelCustomer> channelCustomerLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
@@ -532,18 +557,14 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
|
532
|
557
|
// 全民经纪人佣金处理
|
533
|
558
|
boolean isBroker = CommConstant.PERSON_BROKER.equals(customer.getRecommendPersonType());
|
534
|
559
|
if (isBroker) {
|
535
|
|
-
|
536
|
|
- }
|
537
|
|
- }
|
|
560
|
+ // 处理推荐金额问题
|
|
561
|
+ processInviteRecord(recommendPerson, taBuilding);
|
|
562
|
+ //
|
538
|
563
|
|
539
|
|
- // 推荐人
|
540
|
|
- customerSignatory.setRecommendPerson(taRecommendCustomer.getRecommendPerson());
|
541
|
|
- TaPerson recommendPerson = taPersonMapper.getById(taRecommendCustomer.getRecommendPerson());
|
542
|
|
- if (null != recommendPerson) {
|
543
|
|
- customerSignatory.setRecommendName(recommendPerson.getName());
|
|
564
|
+ }
|
544
|
565
|
}
|
545
|
566
|
|
546
|
|
- // 职业顾问-接待人
|
|
567
|
+ // 置业顾问-接待人
|
547
|
568
|
if (!StringUtils.isEmpty(customerSignatory.getRealtyConsultant())) {
|
548
|
569
|
TaPerson realtyConsultant = taPersonMapper.getById(customerSignatory.getRealtyConsultant());
|
549
|
570
|
if (null != realtyConsultant) {
|
|
@@ -551,10 +572,6 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
|
551
|
572
|
}
|
552
|
573
|
}
|
553
|
574
|
|
554
|
|
- //
|
555
|
|
- customerSignatory.setOrgId(taRecommendCustomer.getOrgId());
|
556
|
|
- customerSignatory.setBuildingId(taRecommendCustomer.getBuildingId());
|
557
|
|
-
|
558
|
575
|
// 更新
|
559
|
576
|
if (StringUtils.isEmpty(customerSignatory.getCustomerSignatoryId())){
|
560
|
577
|
customerSignatoryMapper.insert(customerSignatory);
|
|
@@ -562,4 +579,32 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
|
562
|
579
|
customerSignatoryMapper.updateById(customerSignatory);
|
563
|
580
|
}
|
564
|
581
|
}
|
|
582
|
+
|
|
583
|
+ /**
|
|
584
|
+ * 处理推荐金
|
|
585
|
+ * @param recommendPerson
|
|
586
|
+ * @param taBuilding
|
|
587
|
+ */
|
|
588
|
+ private void processInviteRecord(TaPerson recommendPerson, TaBuilding taBuilding) {
|
|
589
|
+ // 推荐人员
|
|
590
|
+ String personId = recommendPerson.getRecommendAgent();
|
|
591
|
+ if (StringUtils.isEmpty(personId)) return;
|
|
592
|
+
|
|
593
|
+ // 查询推荐记录
|
|
594
|
+ BkInviteRecord bkInviteRecord = bkInviteRecordMapper.getByPerson(personId, recommendPerson.getPersonId());
|
|
595
|
+ if (null == bkInviteRecord) {
|
|
596
|
+ bkInviteRecordMapper.createBy(personId, recommendPerson.getPersonId());
|
|
597
|
+ bkInviteRecord = bkInviteRecordMapper.getByPerson(personId, recommendPerson.getPersonId());
|
|
598
|
+ }
|
|
599
|
+
|
|
600
|
+ // 大于0 代表已经计算过推荐费用
|
|
601
|
+ if (bkInviteRecord.getReferralFee() > 0) return;
|
|
602
|
+
|
|
603
|
+ // 查询推荐费用
|
|
604
|
+ BkAgentRule agentRule = bkAgentRuleMapper.getByCity(taBuilding.getCityId());
|
|
605
|
+ if (null == agentRule) return;
|
|
606
|
+
|
|
607
|
+ bkInviteRecord.setReferralFee(agentRule.getReferralFee());
|
|
608
|
+ bkInviteRecordMapper.updateById(bkInviteRecord);
|
|
609
|
+ }
|
565
|
610
|
}
|