|
@@ -193,21 +193,27 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
|
193
|
193
|
from.setPersonName(StringUtils.ifNull(person.getName(), person.getNickname()));
|
194
|
194
|
from.setCreateDate(now);
|
195
|
195
|
|
196
|
|
- Map<String, Number> checkNum = taRecommendCustomerMapper.checkCustomerBy(orgId, person.getPersonId(), consultBuildingIds, null != building ? building.getBuildingId() : null, consultant != null ? consultant.getPersonId() : null, consultant != null ? consultant.getUserId() : null);
|
|
196
|
+ Map<String, Number> checkNum = taRecommendCustomerMapper.checkCustomerBy(orgId, person.getPersonId(), consultBuildingIds, null != building ? building.getBuildingId() : null);
|
|
197
|
+ // 是否存在小程序客户记录
|
197
|
198
|
boolean hasOrgCust = checkNum.get("orgNum").intValue() > 0;
|
198
|
|
- boolean hasConsultBingBuildCust = checkNum.get("consultBindBuildingNum").intValue() > 0;
|
|
199
|
+ // 是否存在置业绑定的楼盘客户记录
|
|
200
|
+ boolean hasConsultBuildingCust = checkNum.get("consultBuildingNum").intValue() > 0;
|
|
201
|
+ // 是否存在置业绑定的楼盘私客记录
|
|
202
|
+ boolean hasConsultCust = checkNum.get("consultNum").intValue() > 0;
|
|
203
|
+ // 是否存在当前内容楼盘的客户记录
|
199
|
204
|
boolean hasBuildingCust = checkNum.get("buildingNum").intValue() > 0;
|
200
|
|
- boolean hasConstCust = checkNum.get("consultNum") == null ? true : checkNum.get("consultNum").intValue() > 0;
|
201
|
205
|
|
202
|
|
- // 控制是否需要插入小程序级别公客
|
203
|
|
- boolean inserted = false;
|
204
|
|
- // 置业与楼盘是否有关联关系
|
|
206
|
+ // 置业与内容楼盘是否有关联关系
|
205
|
207
|
boolean builingAssociated = false;
|
206
|
208
|
|
207
|
|
- boolean personTypeFlag = CommConstant.PERSON_REALTY_CONSULTANT.equals(person.getPersonType()) ? true : false;
|
|
209
|
+ // 职业顾问不插入客户表
|
|
210
|
+ boolean personIsConsultant = CommConstant.PERSON_REALTY_CONSULTANT.equals(person.getPersonType()) ? true : false;
|
|
211
|
+ if (personIsConsultant) {
|
|
212
|
+ return result;
|
|
213
|
+ }
|
208
|
214
|
|
209
|
|
- // 私客
|
210
|
|
- if (null != consultant && hasConsultBingBuildCust && null != consultBuildings && !hasConstCust) {
|
|
215
|
+ // 置业项目
|
|
216
|
+ if (null != consultant && null != consultBuildings && !hasConsultCust) {
|
211
|
217
|
TaBuilding taBuilding = null;
|
212
|
218
|
if (consultBuildingIds.contains(null != building ? building.getBuildingId() : null)) {
|
213
|
219
|
taBuilding = building;
|
|
@@ -216,46 +222,62 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
|
216
|
222
|
taBuilding = consultBuildings.get(0);
|
217
|
223
|
}
|
218
|
224
|
|
219
|
|
- //如果公客绑定的项目和分享活动关联的项目相同,从公客列表移除该人员
|
220
|
|
- QueryWrapper<TaRecommendCustomer> taRecommendCustomerQueryWrapper = new QueryWrapper<>();
|
221
|
|
- taRecommendCustomerQueryWrapper.eq("building_id", taBuilding.getBuildingId());
|
222
|
|
- taRecommendCustomerQueryWrapper.isNull("realty_consultant");
|
223
|
|
- List<TaRecommendCustomer> taRecommendCustomers = taRecommendCustomerMapper.selectList(taRecommendCustomerQueryWrapper);
|
224
|
|
- for (TaRecommendCustomer customer : taRecommendCustomers){
|
225
|
|
- if (customer.getBuildingId().equals(taBuilding.getBuildingId()) && person.getPersonId().equals(customer.getPersonId())){
|
226
|
|
- delPubCust(customer.getPersonId(), customer.getBuildingId());
|
|
225
|
+ if (hasConsultBuildingCust) {
|
|
226
|
+ // 如果是项目公客
|
|
227
|
+ QueryWrapper<TaRecommendCustomer> taRecommendCustomerQueryWrapper = new QueryWrapper<>();
|
|
228
|
+ taRecommendCustomerQueryWrapper.eq("building_id", taBuilding.getBuildingId());
|
|
229
|
+ taRecommendCustomerQueryWrapper.gt("status", CommConstant.STATUS_DELETE);
|
|
230
|
+ taRecommendCustomerQueryWrapper.orderByAsc("create_date");
|
|
231
|
+ taRecommendCustomerQueryWrapper.last("limit 1");
|
|
232
|
+ TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.selectOne(taRecommendCustomerQueryWrapper);
|
|
233
|
+
|
|
234
|
+ taRecommendCustomer = copyFromPerosn(person, taRecommendCustomer);
|
|
235
|
+ taRecommendCustomer.setRealtyConsultant(consultant.getUserId().toString());
|
|
236
|
+ taRecommendCustomerMapper.updateById(taRecommendCustomer);
|
|
237
|
+ result.add(taRecommendCustomer);
|
|
238
|
+ } else {
|
|
239
|
+ // 如果没有任何置业及置业楼盘相关的数据, 则插入新记录
|
|
240
|
+ TaRecommendCustomer customer = copyFromPerosn(person, new TaRecommendCustomer());
|
|
241
|
+ fillSomeFieldsOfCustomer(customer, recommender, now);
|
|
242
|
+ customer.setBuildingId(taBuilding.getBuildingId());
|
|
243
|
+ customer.setBuildingName(taBuilding.getBuildingName());
|
|
244
|
+ customer.setRealtyConsultant(consultant.getUserId().toString());
|
|
245
|
+ taRecommendCustomerMapper.insert(customer);
|
|
246
|
+ result.add(customer);
|
|
247
|
+
|
|
248
|
+ // 如果非小程序公客, 即首次进入
|
|
249
|
+ if (!hasOrgCust) {
|
|
250
|
+ // 如果分享内容的楼盘跟置业楼盘一致
|
|
251
|
+ if (builingAssociated) {
|
|
252
|
+ hasOrgCust = true;
|
|
253
|
+ }
|
227
|
254
|
}
|
228
|
|
- }
|
229
|
|
-
|
230
|
|
- TaRecommendCustomer customer = copyFromPerosn(person, new TaRecommendCustomer());
|
231
|
|
- fillSomeFieldsOfCustomer(customer, recommender, now);
|
232
|
|
- customer.setBuildingId(taBuilding.getBuildingId());
|
233
|
|
- customer.setBuildingName(taBuilding.getBuildingName());
|
234
|
|
- customer.setRealtyConsultant(consultant.getUserId().toString());
|
235
|
|
- taRecommendCustomerMapper.insert(customer);
|
236
|
|
- result.add(customer);
|
237
|
|
- inserted = true;
|
238
|
255
|
|
239
|
|
- TaCustomerFrom customerFrom = copyPropertiesFrom(from);
|
240
|
|
- customerFrom.setCustomerId(customer.getCustomerId());
|
241
|
|
- customerFrom.setSharePersonId(recommender.getPersonId());
|
242
|
|
- customerFrom.setSharePersonName(StringUtils.ifNull(recommender.getName(), recommender.getNickname()));
|
243
|
|
- customerFrom.setBuildingId(taBuilding.getBuildingId());
|
244
|
|
- customerFrom.setBuildingName(taBuilding.getBuildingName());
|
245
|
|
- customerFrom.setIsOrgFirst(!hasOrgCust);
|
246
|
|
- customerFrom.setIsProjectFirst(true);
|
247
|
|
- customerFrom.setCreateDate(now);
|
248
|
|
- taCustomerFromMapper.insert(customerFrom);
|
|
256
|
+ TaCustomerFrom customerFrom = copyPropertiesFrom(from);
|
|
257
|
+ customerFrom.setCustomerId(customer.getCustomerId());
|
|
258
|
+ customerFrom.setSharePersonId(recommender.getPersonId());
|
|
259
|
+ customerFrom.setSharePersonName(StringUtils.ifNull(recommender.getName(), recommender.getNickname()));
|
|
260
|
+ customerFrom.setBuildingId(taBuilding.getBuildingId());
|
|
261
|
+ customerFrom.setBuildingName(taBuilding.getBuildingName());
|
|
262
|
+ customerFrom.setIsOrgFirst(hasOrgCust);
|
|
263
|
+ customerFrom.setIsProjectFirst(true);
|
|
264
|
+ customerFrom.setCreateDate(now);
|
|
265
|
+ taCustomerFromMapper.insert(customerFrom);
|
|
266
|
+ }
|
249
|
267
|
}
|
250
|
268
|
|
251
|
269
|
// 项目公客
|
252
|
|
- if (null != building && !hasBuildingCust && !builingAssociated && !personTypeFlag) {
|
|
270
|
+ if (null != building && !hasBuildingCust && !builingAssociated) {
|
253
|
271
|
TaRecommendCustomer customer = copyFromPerosn(person, new TaRecommendCustomer());
|
254
|
272
|
fillSomeFieldsOfCustomer(customer, recommender, now);
|
255
|
273
|
customer.setBuildingId(building.getBuildingId());
|
256
|
274
|
taRecommendCustomerMapper.insert(customer);
|
257
|
275
|
result.add(customer);
|
258
|
|
- inserted = true;
|
|
276
|
+
|
|
277
|
+ // 如果非小程序公客, 即首次进入
|
|
278
|
+ if (!hasOrgCust) {
|
|
279
|
+ hasOrgCust = true;
|
|
280
|
+ }
|
259
|
281
|
|
260
|
282
|
TaCustomerFrom customerFrom = copyPropertiesFrom(from);
|
261
|
283
|
customerFrom.setCustomerId(customer.getCustomerId());
|
|
@@ -263,14 +285,14 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
|
263
|
285
|
customerFrom.setSharePersonName(null == recommender ? null : StringUtils.ifNull(recommender.getName(), recommender.getNickname()));
|
264
|
286
|
customerFrom.setBuildingId(building.getBuildingId());
|
265
|
287
|
customerFrom.setBuildingName(building.getBuildingName());
|
266
|
|
- customerFrom.setIsOrgFirst(!hasOrgCust);
|
|
288
|
+ customerFrom.setIsOrgFirst(hasOrgCust);
|
267
|
289
|
customerFrom.setIsProjectFirst(true);
|
268
|
290
|
customerFrom.setCreateDate(now);
|
269
|
291
|
taCustomerFromMapper.insert(customerFrom);
|
270
|
292
|
}
|
271
|
293
|
|
272
|
294
|
// 小程序公客
|
273
|
|
- if (!hasOrgCust && !inserted && !personTypeFlag) {
|
|
295
|
+ if (!hasOrgCust) {
|
274
|
296
|
TaRecommendCustomer customer = copyFromPerosn(person, new TaRecommendCustomer());
|
275
|
297
|
fillSomeFieldsOfCustomer(customer, recommender, now);
|
276
|
298
|
taRecommendCustomerMapper.insert(customer);
|