Your Name преди 3 години
родител
ревизия
8040f7f347

+ 34
- 0
src/main/java/com/yunzhi/marketing/controller/TaRecommendCustomerController.java Целия файл

@@ -16,6 +16,7 @@ import com.yunzhi.marketing.common.StringUtils;
16 16
 import com.yunzhi.marketing.dto.ChannelReportDTO;
17 17
 import com.yunzhi.marketing.entity.TaBuilding;
18 18
 import com.yunzhi.marketing.entity.TaPerson;
19
+import com.yunzhi.marketing.entity.TaPersonBuilding;
19 20
 import com.yunzhi.marketing.entity.TaRecommendCustomer;
20 21
 import com.yunzhi.marketing.event.EventBus;
21 22
 import com.yunzhi.marketing.excel.handler.CustomCellWriteHandler;
@@ -251,6 +252,39 @@ public class TaRecommendCustomerController extends BaseController {
251 252
         return taRecommendCustomerService.reportCust(paramStr, openid, orgId);
252 253
     }
253 254
 
255
+    /**
256
+     * 置业顾问手动报备客户
257
+     * @param reportCust
258
+     * @param request
259
+     * @return
260
+     */
261
+    @PostMapping("/wx/customer/manualReport")
262
+    public ResponseBean manualReport(@RequestBody ChannelReportDTO reportCust, HttpServletRequest request) {
263
+        Integer orgId = getOrgId(request);
264
+        String personId = getPersonId(request);
265
+        TaPerson taPerson = taPersonService.getById(personId);
266
+        if (null == taPerson) {
267
+            return ResponseBean.error("校验人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
268
+        }
269
+
270
+        if (!CommConstant.PERSON_REALTY_CONSULTANT.equals(taPerson.getPersonType())) {
271
+            return ResponseBean.error("暂时只支持置业顾问报备", ResponseBean.ERROR_UNAVAILABLE);
272
+        }
273
+
274
+        // 客户电话
275
+        String phone = reportCust.getPhone();
276
+        if (StringUtils.isEmpty(phone)) {
277
+            return ResponseBean.error("请填写客户电话", ResponseBean.ERROR_UNAVAILABLE);
278
+        }
279
+
280
+        try {
281
+            taRecommendCustomerService.manualReport(orgId, taPerson, reportCust);
282
+            return ResponseBean.success("报备成功");
283
+        } catch (Exception e) {
284
+            return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
285
+        }
286
+    }
287
+
254 288
 
255 289
     /**
256 290
      * 顾客列表

+ 2
- 0
src/main/java/com/yunzhi/marketing/service/ITaRecommendCustomerService.java Целия файл

@@ -207,4 +207,6 @@ public interface ITaRecommendCustomerService extends IService<TaRecommendCustome
207 207
      * @return
208 208
      */
209 209
     ResponseBean getMarkingCustList(String openid, String keywords, int pageNumber, int pageSize, String buildingId);
210
+
211
+    void manualReport(Integer orgId, TaPerson consultant, ChannelReportDTO reportCust) throws Exception;
210 212
 }

+ 102
- 0
src/main/java/com/yunzhi/marketing/service/impl/TaRecommendCustomerServiceImpl.java Целия файл

@@ -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);