傅行帆 пре 5 година
родитељ
комит
134c155fb7

+ 56
- 1
src/main/java/com/huiju/estateagents/controller/TaRecommendCustomerController.java Прегледај датотеку

@@ -749,5 +749,60 @@ public class TaRecommendCustomerController extends BaseController {
749 749
 
750 750
 
751 751
     }
752
-
752
+    
753
+    /**
754
+     * 查询判客工具下的我的客户人数集合
755
+     * @param request
756
+     * @return
757
+     */
758
+    @GetMapping("/wx/inventory/customer/statistics")
759
+    @ApiOperation(value = "查询我的客户人数统计", notes = "查询我的客户人数统计")
760
+    public ResponseBean getMyCustStatistics(HttpServletRequest request) {
761
+        String openid = getOpenId(request);
762
+        return taRecommendCustomerService.getMyCustStatistics(openid);
763
+    }
764
+    
765
+    /**
766
+     * 分页查询判客工具下的我的客户跟进人集合
767
+     *  根据type区分  follow 跟进  clinch 成交
768
+     * @param request
769
+     * @return
770
+     */
771
+    @GetMapping("/wx/inventory/customer/{type}")
772
+    @ApiOperation(value = "查询我的客户人数统计", notes = "查询我的客户人数统计")
773
+    public ResponseBean getMyCustFollows(@PathVariable(value = "type") String type,
774
+                                         @RequestParam(value = "pageNumber",defaultValue = "0") Integer pageNumber,
775
+                                         @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
776
+                                         @RequestParam(value = "name",required = false) String name,
777
+                                         @RequestParam(value = "phone",required = false) String phone,
778
+                                         @RequestParam(value = "status",required = false) Integer status,HttpServletRequest request) {
779
+        String openid = getOpenId(request);
780
+        return taRecommendCustomerService.getMyCustFollowOrClinch(pageNumber,pageSize,openid,type,name,phone,status);
781
+    }
782
+    
783
+    /**
784
+     * 查询盘客工具下我的客户详情
785
+     * @param request
786
+     * @return
787
+     */
788
+    @GetMapping("/wx/inventory/customer/{customerId}")
789
+    @ApiOperation(value = "查询客户详情", notes = "查询客户详情")
790
+    public ResponseBean getMyCustDetail(@PathVariable(value = "customerId") String customerId,HttpServletRequest request) {
791
+        String openid = getOpenId(request);
792
+        return taRecommendCustomerService.getMyCustDetail(customerId,openid);
793
+    }
794
+    
795
+    /**
796
+     * 查询盘客工具下编辑基本信息
797
+     * @param request
798
+     * @return
799
+     */
800
+    @PutMapping("/wx/inventory/customer/{customerId}")
801
+    @ApiOperation(value = "编辑客户信息", notes = "编辑客户信息")
802
+    public ResponseBean updateMyCustDetail(@PathVariable(value = "customerId") String customerId,
803
+                                           @RequestBody TaRecommendCustomer taRecommendCustomer, HttpServletRequest request) {
804
+        String openid = getOpenId(request);
805
+        taRecommendCustomer.setCustomerId(customerId);
806
+        return taRecommendCustomerService.updateMyCust(taRecommendCustomer,openid);
807
+    }
753 808
 }

+ 30
- 1
src/main/java/com/huiju/estateagents/mapper/TaRecommendCustomerMapper.java Прегледај датотеку

@@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
9 9
 import org.apache.ibatis.annotations.Param;
10 10
 
11 11
 import java.util.List;
12
+import java.util.Map;
12 13
 
13 14
 /**
14 15
  * <p>
@@ -149,5 +150,33 @@ public interface TaRecommendCustomerMapper extends BaseMapper<TaRecommendCustome
149 150
      * @return
150 151
      */
151 152
     List<PrivateCustomerExport> getCustomerExportList(@Param("pageCode") Integer pageCode, @Param("pageSize") Integer pageSize, @Param("building") String buildingId, @Param("name") String name, @Param("tel") String tel, @Param("consultName") String consultName, @Param("consultTel") String consultTel, @Param("entryType") String entryType, @Param("verifyStatus") String verifyStatus, @Param("sex") Integer sex, @Param("orgId") Integer orgId, @Param("status")Integer status);
152
-
153
+    
154
+    /**
155
+     * 获取我的客户的人数统计
156
+     * @param personId
157
+     * @param userId
158
+     * @return
159
+     */
160
+	List<Map<String, Object>> getMyCustStatistics(@Param("personId") String personId,@Param("userId") Integer userId,@Param("orgId") Integer orgId);
161
+    
162
+    /**
163
+     * 获取我的跟进客户数据
164
+     * @param page
165
+     * @param personId
166
+     * @param userId
167
+     * @param orgId
168
+     * @param type
169
+     * @param name
170
+     * @param phone
171
+     * @param status
172
+     * @return
173
+     */
174
+    IPage<TaRecommendCustomer> getMyCustFollowOrClinch(IPage<TaRecommendCustomer> page, @Param("personId") String personId, @Param("userId") Integer userId, @Param("orgId") Integer orgId, @Param("type") String type, @Param("name") String name, @Param("phone") String phone,@Param("status") Integer status);
175
+    
176
+    /**
177
+     * 获取我的客户详情数据
178
+     * @param customerId
179
+     * @return
180
+     */
181
+    TaRecommendCustomer getMyCustDetailById(String customerId);
153 182
 }

+ 35
- 1
src/main/java/com/huiju/estateagents/service/ITaRecommendCustomerService.java Прегледај датотеку

@@ -95,5 +95,39 @@ public interface ITaRecommendCustomerService extends IService<TaRecommendCustome
95 95
      * @return
96 96
      */
97 97
     List<AgentsRecommendCustomer> getIndependentAgentsExport(Integer orgId, Integer pageCode, Integer pageSize);
98
-
98
+    
99
+    /**
100
+     * 查询我的客户人数集合
101
+     * @param openid
102
+     * @return
103
+     */
104
+    ResponseBean getMyCustStatistics(String openid);
105
+    
106
+    /**
107
+     * 分页查询我的跟进客户集合
108
+     * @param pageNumber
109
+     * @param pageSize
110
+     * @param openid
111
+     * @param name
112
+     * @param phone
113
+     * @param status
114
+     * @return
115
+     */
116
+    ResponseBean getMyCustFollowOrClinch(Integer pageNumber, Integer pageSize, String openid, String type, String name, String phone, Integer status);
117
+    
118
+    /**
119
+     * 获取盘客工具下我的客户详情
120
+     * @param customerId
121
+     * @param openid
122
+     * @return
123
+     */
124
+    ResponseBean getMyCustDetail(String customerId, String openid);
125
+    
126
+    /**
127
+     * 更新我的客户基本信息
128
+     * @param taRecommendCustomer
129
+     * @param openid
130
+     * @return
131
+     */
132
+    ResponseBean updateMyCust(TaRecommendCustomer taRecommendCustomer, String openid);
99 133
 }

+ 106
- 2
src/main/java/com/huiju/estateagents/service/impl/TaRecommendCustomerServiceImpl.java Прегледај датотеку

@@ -1,6 +1,5 @@
1 1
 package com.huiju.estateagents.service.impl;
2 2
 
3
-import ch.qos.logback.core.status.StatusUtil;
4 3
 import com.alibaba.fastjson.JSONObject;
5 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
6 5
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -23,10 +22,11 @@ import com.huiju.estateagents.mapper.*;
23 22
 import com.huiju.estateagents.service.IMiniAppService;
24 23
 import com.huiju.estateagents.service.ITaRecommendCustomerService;
25 24
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
25
+import com.huiju.estateagents.statistic.entity.TaCustomerFollowUpRecord;
26
+import com.huiju.estateagents.statistic.mapper.TaCustomerFollowUpRecordMapper;
26 27
 import org.springframework.beans.factory.annotation.Autowired;
27 28
 import org.springframework.stereotype.Service;
28 29
 
29
-import javax.naming.spi.ResolveResult;
30 30
 import java.time.LocalDateTime;
31 31
 import java.util.HashMap;
32 32
 import java.util.List;
@@ -63,6 +63,9 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
63 63
 
64 64
     @Autowired
65 65
     private TdCityMapper cityMapper;
66
+    
67
+    @Autowired
68
+    private TaCustomerFollowUpRecordMapper customerFollowUpRecordMapper;
66 69
 
67 70
     @Override
68 71
     public ResponseBean getMyCustList(String openid, String keywords, int pageNumber, int pageSize) {
@@ -579,4 +582,105 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
579 582
     public List<AgentsRecommendCustomer> getIndependentAgentsExport(Integer orgId, Integer pageCode, Integer pageSize) {
580 583
         return taRecommendCustomerMapper.getIndependentAgentsExport(orgId, pageCode, pageSize);
581 584
     }
585
+    
586
+    /**
587
+     * 查询我的客户人数集合
588
+     *
589
+     * @param openid
590
+     * @return
591
+     */
592
+    @Override
593
+    public ResponseBean getMyCustStatistics(String openid) {
594
+        List<TaPerson> taPersons = getPersonsByOpenId(openid);
595
+        if (null == taPersons || taPersons.size() != 1) {
596
+            return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
597
+        }
598
+    
599
+        TaPerson taPerson = taPersons.get(0);
600
+        List<Map<String,Object>> list = taRecommendCustomerMapper.getMyCustStatistics(taPerson.getPersonId(),taPerson.getUserId(),taPerson.getOrgId());
601
+        return ResponseBean.success(list);
602
+    }
603
+    
604
+    /**
605
+     * 分页查询我的跟进客户集合
606
+     *
607
+     * @param pageNumber
608
+     * @param pageSize
609
+     * @param openid
610
+     * @param name
611
+     * @param phone
612
+     * @param status
613
+     * @return
614
+     */
615
+    @Override
616
+    public ResponseBean getMyCustFollowOrClinch(Integer pageNumber, Integer pageSize, String openid, String type, String name, String phone, Integer status) {
617
+        List<TaPerson> taPersons = getPersonsByOpenId(openid);
618
+        if (null == taPersons || taPersons.size() != 1) {
619
+            return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
620
+        }
621
+    
622
+        TaPerson taPerson = taPersons.get(0);
623
+        
624
+        IPage<TaRecommendCustomer> page = new Page<>();
625
+        page.setCurrent(pageNumber);
626
+        page.setSize(pageSize);
627
+        
628
+        //分页获取跟进客户status != 4的为跟进客户, status = 4的为成交客户 根据type区分  follow 跟进  clinch 成交
629
+        IPage<TaRecommendCustomer> result = taRecommendCustomerMapper.getMyCustFollowOrClinch(page, taPerson.getPersonId(),taPerson.getUserId(),taPerson.getOrgId(), type,name,phone,status);
630
+        return ResponseBean.success(result);
631
+    }
632
+    
633
+    /**
634
+     * 获取盘客工具下我的客户详情
635
+     *
636
+     * @param customerId
637
+     * @param openid
638
+     * @return
639
+     */
640
+    @Override
641
+    public ResponseBean getMyCustDetail(String customerId, String openid) {
642
+        List<TaPerson> taPersons = getPersonsByOpenId(openid);
643
+        if (null == taPersons || taPersons.size() != 1) {
644
+            return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
645
+        }
646
+    
647
+        TaPerson taPerson = taPersons.get(0);
648
+        TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.getMyCustDetailById(customerId);
649
+        //添加跟进行为
650
+        addCustomerFpllowUp(taPerson,taRecommendCustomer,"查看客户详情");
651
+        return ResponseBean.success(taRecommendCustomer);
652
+    }
653
+    
654
+    /**
655
+     * 更新我的客户基本信息
656
+     *
657
+     * @param taRecommendCustomer
658
+     * @param openid
659
+     * @return
660
+     */
661
+    @Override
662
+    public ResponseBean updateMyCust(TaRecommendCustomer taRecommendCustomer, String openid) {
663
+        List<TaPerson> taPersons = getPersonsByOpenId(openid);
664
+        if (null == taPersons || taPersons.size() != 1) {
665
+            return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
666
+        }
667
+    
668
+        TaPerson taPerson = taPersons.get(0);
669
+        taRecommendCustomerMapper.updateById(taRecommendCustomer);
670
+        //添加跟进行为
671
+        addCustomerFpllowUp(taPerson,taRecommendCustomer,"编辑客户信息");
672
+        return ResponseBean.success(taRecommendCustomer);
673
+    }
674
+    
675
+    //添加跟进行为
676
+    private void addCustomerFpllowUp(TaPerson taPerson,TaRecommendCustomer taRecommendCustomer,String recordType) {
677
+        TaCustomerFollowUpRecord taCustomerFollowUpRecord = new TaCustomerFollowUpRecord();
678
+        taCustomerFollowUpRecord.setOrgId(taPerson.getOrgId());
679
+        taCustomerFollowUpRecord.setCreateDate(LocalDateTime.now());
680
+        taCustomerFollowUpRecord.setCustomerId(taRecommendCustomer.getCustomerId());
681
+        taCustomerFollowUpRecord.setRecordType(recordType);
682
+        taCustomerFollowUpRecord.setFollowerId(taPerson.getPersonId());
683
+        taCustomerFollowUpRecord.setCustomerSex(taRecommendCustomer.getSex());
684
+        customerFollowUpRecordMapper.insert(taCustomerFollowUpRecord);
685
+    }
582 686
 }

+ 1
- 1
src/main/java/com/huiju/estateagents/statistic/entity/TaCustomerFollowUpRecord.java Прегледај датотеку

@@ -58,7 +58,7 @@ public class TaCustomerFollowUpRecord implements Serializable {
58 58
     /**
59 59
      * 跟进人ID
60 60
      */
61
-    private Integer followerId;
61
+    private String followerId;
62 62
     
63 63
     /**
64 64
      * 客户性别

+ 43
- 0
src/main/resources/mapper/TaRecommendCustomerMapper.xml Прегледај датотеку

@@ -606,4 +606,47 @@ FROM
606 606
         limit #{pageCode}, #{pageSize}
607 607
     </select>
608 608
 
609
+    <select id="getMyCustStatistics" resultType="java.util.Map">
610
+        SELECT
611
+            sum( IF ( STATUS = 4, 1, 0 ) ) AS followSum,
612
+            sum( IF ( STATUS != 4 AND STATUS != 4, 1, 0 ) ) AS clinchSum
613
+        FROM
614
+            ta_recommend_customer
615
+        WHERE
616
+            org_id = #{orgId}
617
+        AND ( realty_consultant = #{personId} OR realty_consultant = #{userId} )
618
+    </select>
619
+
620
+    <select id="getMyCustFollowOrClinch" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
621
+        SELECT
622
+            *
623
+        FROM
624
+            ta_recommend_customer
625
+        WHERE
626
+            org_id = #{orgId}
627
+        AND ( realty_consultant = #{personId} OR realty_consultant = #{userId} )
628
+        <if test="type == 'follow'">
629
+          AND STATUS != 4
630
+            <if test="name != null and name !=''">
631
+                and `name` like CONCAT('%',#{name}, '%')
632
+            </if>
633
+            <if test="phone != null and phone !=''">
634
+                and phone like CONCAT('%',#{phone}, '%')
635
+            </if>
636
+            <if test="status != null and status !=''">
637
+                and status = #{status}
638
+            </if>
639
+        </if>
640
+        <if test="type == 'clinch'">
641
+          AND STATUS = 4
642
+        </if>
643
+    </select>
644
+    <select id="getMyCustDetailById" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
645
+        SELECT
646
+            *
647
+        FROM
648
+            ta_recommend_customer
649
+        where customer_id = #{customerId}
650
+    </select>
651
+
609 652
 </mapper>