|
@@ -25,6 +25,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
25
|
25
|
import com.huiju.estateagents.statistic.entity.TaCustomerFollowUpRecord;
|
26
|
26
|
import com.huiju.estateagents.statistic.mapper.TaCustomerFollowUpRecordMapper;
|
27
|
27
|
import org.apache.commons.collections.CollectionUtils;
|
|
28
|
+import org.slf4j.Logger;
|
|
29
|
+import org.slf4j.LoggerFactory;
|
28
|
30
|
import org.springframework.beans.factory.annotation.Autowired;
|
29
|
31
|
import org.springframework.stereotype.Service;
|
30
|
32
|
|
|
@@ -44,6 +46,8 @@ import java.util.Map;
|
44
|
46
|
@Service
|
45
|
47
|
public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCustomerMapper, TaRecommendCustomer> implements ITaRecommendCustomerService {
|
46
|
48
|
|
|
49
|
+ private Logger logger = LoggerFactory.getLogger(TaRecommendCustomerServiceImpl.class);
|
|
50
|
+
|
47
|
51
|
@Autowired
|
48
|
52
|
TaPersonMapper taPersonMapper;
|
49
|
53
|
|
|
@@ -835,9 +839,9 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
|
835
|
839
|
|
836
|
840
|
@Override
|
837
|
841
|
public ResponseBean batchConsultantAssist(TaUser taUser, Integer orgId) {
|
838
|
|
- if (CollectionUtils.isNotEmpty(taUser.getPersonIds())) {
|
839
|
|
- for (TaPerson taPerson : taUser.getPersonIds()) {
|
840
|
|
- consultantAssist(taUser, taPerson.getPersonId(), orgId);
|
|
842
|
+ if (CollectionUtils.isNotEmpty(taUser.getCustomerIds())) {
|
|
843
|
+ for (TaRecommendCustomer taRecommendCustomer : taUser.getCustomerIds()) {
|
|
844
|
+ consultantAssist(taUser, taRecommendCustomer.getCustomerId(), orgId);
|
841
|
845
|
}
|
842
|
846
|
}
|
843
|
847
|
return ResponseBean.success("操作成功");
|
|
@@ -845,6 +849,8 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
|
845
|
849
|
|
846
|
850
|
@Override
|
847
|
851
|
public ResponseBean consultantAssist(TaUser taUser, String customerId, Integer orgId) {
|
|
852
|
+ logger.info("公客分配置业顾问 接收参数,taUser={},customerId={},orgId={}",
|
|
853
|
+ JSONObject.toJSONString(taUser), customerId, orgId);
|
848
|
854
|
|
849
|
855
|
// 1.校验置业顾问
|
850
|
856
|
QueryWrapper<TaUser> queryWrapper = new QueryWrapper();
|
|
@@ -855,27 +861,46 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
|
855
|
861
|
taPersonBuildingQueryWrapper.eq("user_id", taUser.getUserId());
|
856
|
862
|
TaPersonBuilding taPersonBuilding = taPersonBuildingMapper.selectOne(taPersonBuildingQueryWrapper);
|
857
|
863
|
|
858
|
|
- if (null == userInfo || CommConstant.STATUS_NORMAL != userInfo.getStatus() ) {
|
|
864
|
+ if (null == userInfo || CommConstant.STATUS_NORMAL != userInfo.getStatus()) {
|
859
|
865
|
return ResponseBean.error("置业顾问不存在或已被注销", ResponseBean.ERROR_UNAVAILABLE);
|
860
|
866
|
}
|
861
|
867
|
|
862
|
868
|
// 2.根据customerId获取personId
|
863
|
|
- TaRecommendCustomer recommendCustomerInfo = taRecommendCustomerMapper.selectById(customerId);
|
864
|
|
- if(recommendCustomerInfo == null){
|
865
|
|
- return ResponseBean.error("分配客户失败",ResponseBean.ERROR_UNAVAILABLE);
|
|
869
|
+ QueryWrapper<TaRecommendCustomer> customerQueryWrapper = new QueryWrapper<>();
|
|
870
|
+ customerQueryWrapper.eq("customer_id", customerId);
|
|
871
|
+ customerQueryWrapper.isNull("realty_consultant");
|
|
872
|
+ TaRecommendCustomer customerInfo = taRecommendCustomerMapper.selectOne(customerQueryWrapper);
|
|
873
|
+ if (customerInfo == null) {
|
|
874
|
+ logger.info("公客分配置业顾问 customerInfo为空");
|
|
875
|
+ return ResponseBean.error("分配客户失败", ResponseBean.ERROR_UNAVAILABLE);
|
866
|
876
|
}
|
867
|
877
|
|
868
|
878
|
// 3.判断是否有buildingId,有则直接更新数据
|
869
|
|
- if(!StringUtils.isEmpty(recommendCustomerInfo.getBuildingId()) && StringUtils.isEmpty(recommendCustomerInfo.getRealtyConsultant())){
|
870
|
|
- log.error("公客添加置业顾问 customer:" + JSONObject.toJSONString(recommendCustomerInfo));
|
871
|
|
- recommendCustomerInfo.setRealtyConsultant(userInfo.getUserId().toString());
|
872
|
|
- return ResponseBean.success(taRecommendCustomerMapper.updateById(recommendCustomerInfo));
|
|
879
|
+ if (!StringUtils.isEmpty(customerInfo.getBuildingId())) {
|
|
880
|
+ logger.info("公客分配置业顾问 customer={}", JSONObject.toJSONString(customerInfo));
|
|
881
|
+ customerInfo.setRealtyConsultant(userInfo.getUserId().toString());
|
|
882
|
+ return ResponseBean.success(taRecommendCustomerMapper.updateById(customerInfo));
|
|
883
|
+ }
|
|
884
|
+
|
|
885
|
+ // 4.校验公客是否已经是分配项目下的私客
|
|
886
|
+ QueryWrapper<TaRecommendCustomer> customerQueryWrapper2 = new QueryWrapper<>();
|
|
887
|
+ customerQueryWrapper2.eq("org_id", orgId);
|
|
888
|
+ customerQueryWrapper2.eq("person_id", customerInfo.getPersonId());
|
|
889
|
+ customerQueryWrapper2.eq("building_id", taPersonBuilding.getBuildingId());
|
|
890
|
+ customerQueryWrapper2.eq("status", CommConstant.CUSTOMER_REPORT);
|
|
891
|
+ customerQueryWrapper2.eq("verify_status", CommConstant.VERIFY_AGREE);
|
|
892
|
+ customerQueryWrapper2.isNotNull("realty_consultant");
|
|
893
|
+ TaRecommendCustomer customerInfo2 = taRecommendCustomerMapper.selectOne(customerQueryWrapper2);
|
|
894
|
+ if (customerInfo2 != null) {
|
|
895
|
+ logger.info("公客分配置业顾问 customerInfo2为空");
|
|
896
|
+ return ResponseBean.error("分配客户失败", ResponseBean.ERROR_UNAVAILABLE);
|
873
|
897
|
}
|
874
|
898
|
|
875
|
|
- // 4.无buildingId,新增一条私客数据
|
876
|
|
- TaPerson taPerson = taPersonMapper.getById(recommendCustomerInfo.getPersonId());
|
877
|
|
- if(taPerson == null){
|
878
|
|
- return ResponseBean.error("分配客户失败",ResponseBean.ERROR_UNAVAILABLE);
|
|
899
|
+ // 5.无buildingId,新增一条私客数据
|
|
900
|
+ TaPerson taPerson = taPersonMapper.getById(customerInfo.getPersonId());
|
|
901
|
+ if (taPerson == null) {
|
|
902
|
+ logger.info("公客分配置业顾问 taPerson为空");
|
|
903
|
+ return ResponseBean.error("分配客户失败", ResponseBean.ERROR_UNAVAILABLE);
|
879
|
904
|
}
|
880
|
905
|
|
881
|
906
|
TaRecommendCustomer taRecommendCustomer = new TaRecommendCustomer();
|