于继渤 2 лет назад
Родитель
Сommit
69cc6124bb

+ 6 - 2
src/main/java/com/dk/mdm/controller/mst/CusFollowController.java

@@ -56,8 +56,12 @@ public class CusFollowController{
     public ResponseResultVO<?> insert(@RequestBody CusFollowVO cusFollowVO) {
         return cusFollowService.insert(cusFollowVO);
     }
-
-    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
+    /**
+     * @desc   : 查询跟进记录
+     * @author : 于继渤
+     * @date : 2024/2/26 10:36
+     */
+    @ApiOperation(value = "条件查询", notes = "条件查询")
     @PostMapping({"select_by_list"})
     public ResponseResultVO<List<CusFollowResponse>> selectByList(@RequestBody CusFollowQuery customerQuery) {
         return cusFollowService.selectByList(customerQuery);

+ 10 - 1
src/main/java/com/dk/mdm/mapper/mst/CusFollowMapper.java

@@ -23,7 +23,9 @@ public interface CusFollowMapper extends BaseMapper<CusFollow>{
      * @date : 2024/2/26 10:36
      */
     List<CusFollowResponse> selectByCond(CusFollowQuery cusFollowQuery);
-    List<CusFollowResponse> selectByList(CusFollowQuery cusFollowQuery);
+
+
+
 
     /**
      * @desc   : 根据条件进行查询(数量)
@@ -31,6 +33,13 @@ public interface CusFollowMapper extends BaseMapper<CusFollow>{
      * @date : 2024/2/26 10:36
      */
     Long countByCond(CusFollowQuery cusFollowQuery);
+
+    /**
+     * @desc   : 查询跟进记录
+     * @author : 于继渤
+     * @date : 2024/2/26 10:36
+     */
+    List<CusFollowResponse> selectByList(CusFollowQuery cusFollowQuery);
 	
 }
 

+ 14 - 5
src/main/java/com/dk/mdm/mapper/mst/CusFollowMapper.xml

@@ -74,8 +74,8 @@
         <result column="follow_count" property="followCount"/>
         <result column="follow_staff_name" property="followStaffName"/>
         <result column="create_time" property="createTime"  typeHandler="TimestampTypeHandler"/>
-
-
+        <result column="follow_status_name" property="followStatusName"/>
+        <result column="follow_type_name" property="followTypeName"/>
     </resultMap>
 
     <!-- 通用条件列 -->
@@ -248,18 +248,22 @@
         tmc.address_full AS "addressFull",
         tmo.org_name  AS  "orgName",
         tms.staff_name  AS  "staffName",
-        tmc.follow_count AS follow_count
+        tmc.follow_count AS follow_count,
+        tdk1.kind_name_i18n  ->> 'zh_CN' AS "follow_status_name",
+        tdk2.kind_name_i18n  ->> 'zh_CN' AS "follow_type_name"
         FROM dkic_b.t_crm_cus_follow tccf
         LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = tccf.cus_id
         LEFT JOIN dkic_b.t_mst_org tmo on tmo.org_id = tccf.follow_org
         LEFT JOIN dkic_b.t_mst_staff tms on tms.staff_id = tccf.follow_staff
+        LEFT JOIN  sys.t_data_kind tdk1  on tdk1.kind_code =  tccf.follow_status
+        LEFT JOIN  sys.t_data_kind tdk2  on tdk2.kind_code =  tccf.follow_type
         <include refid="Condition_Join"/>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>
     </select>
 
-
+<!--查询跟进记录-->
     <select id="selectByList" resultMap="BaseResultMapResponse">
         SELECT
         <include refid="Base_Column_List_Join"/>,
@@ -270,11 +274,16 @@
         tms.staff_name  AS  "staffName",
         tmc.follow_count AS follow_count,
         tms.staff_name AS follow_staff_name,
-        tccf.op_create_time AS create_time
+        tccf.op_create_time AS create_time,
+        tdk1.kind_name_i18n  ->> 'zh_CN' AS "follow_status_name",
+        tdk2.kind_name_i18n  ->> 'zh_CN' AS "follow_type_name"
         FROM dkic_b.t_crm_cus_follow tccf
         LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = tccf.cus_id
         LEFT JOIN dkic_b.t_mst_org tmo on tmo.org_id = tccf.follow_org
         LEFT JOIN dkic_b.t_mst_staff tms on tms.staff_id = tccf.follow_staff
+
+        LEFT JOIN  sys.t_data_kind tdk1  on tdk1.kind_code =  tccf.follow_status
+        LEFT JOIN  sys.t_data_kind tdk2  on tdk2.kind_code =  tccf.follow_type
         <include refid="Condition_Join"/>
 
     </select>

+ 18 - 10
src/main/java/com/dk/mdm/mapper/mst/CustomerMapper.xml

@@ -91,6 +91,10 @@
         <result column="followStaffName" property="followStaffName"/>
         <result column="lastFollowStaffName" property="lastFollowStaffName"/>
         <result column="saleStatusName" property="saleStatusName"/>
+        <result column="next_follow_time" property="nextFollowTime" typeHandler="TimestampTypeHandler"/>
+
+        <result column="follow_staff" property="followStaff"/>
+        <result column="follow_staff_name" property="followStaffName"/>
 
     </resultMap>
 
@@ -176,13 +180,14 @@
                 AND tmc.cp_id = #{cpId}
             </if>
             <if  test="searchText != null">
-                AND (data_value  like concat('%', my_ex.likequery(#{searchText}) , '%')
-                OR  dict_code  like concat('%', my_ex.likequery(#{searchText}) , '%')
-                OR  remarks like concat('%', my_ex.likequery(#{searchText}) , '%')
+                AND (tmc.cus_code  like concat('%', my_ex.likequery(#{searchText}) , '%')
+                OR  tmc.cus_name  like concat('%', my_ex.likequery(#{searchText}) , '%')
+                OR  tmc.cus_phone like concat('%', my_ex.likequery(#{searchText}) , '%')
+                OR  tmc.address_full like concat('%', my_ex.likequery(#{searchText}) , '%')
+                OR  tmc.remarks like concat('%', my_ex.likequery(#{searchText}) , '%')
                 )
             </if>
 
-
         </where>
     </sql>
 
@@ -203,19 +208,18 @@
         tmo.org_name  AS  "orgName",
         tms.staff_name  AS  "staffName",
         tms2.staff_name  AS  "reportStaffName",
-        tdk.kind_name_i18n  ->> 'zh_CN' AS "saleStatusName"
---         tms3.staff_name  AS  "followStaffName",
---         tms4.staff_name  AS  "lastFollowStaffName"
+        tdk.kind_name_i18n  ->> 'zh_CN' AS "saleStatusName",
+        tcf.next_follow_time
         FROM dkic_b.t_mst_customer tmc
+        LEFT JOIN  ( select tccff.cus_id, max (tccff.next_follow_time)as next_follow_time from dkic_b.t_crm_cus_follow tccff group by tccff.cus_id )  tcf on tmc.cus_id = tcf.cus_id
         LEFT JOIN  dkic_b.t_mst_dictionary_data tmd  on tmd.data_id =  tmc.cus_from
         LEFT JOIN  dkic_b.t_mst_sale_channel tmsc  on tmsc.channel_id =  tmc.channel_id
         LEFT JOIN  dkic_b.t_mst_org tmo  on tmo.org_id =  tmc.org_id
         LEFT JOIN  dkic_b.t_mst_staff tms  on tms.staff_id =  tmc.staff_id
         LEFT JOIN  dkic_b.t_mst_staff tms2  on tms2.staff_id =  tmc.report_staff
         LEFT JOIN  sys.t_data_kind tdk  on tdk.kind_code =  tmc.sale_status
---         LEFT JOIN  dkic_b.t_mst_staff tms3  on tms3.staff_id =  tmc.follow_staffs
---         LEFT JOIN  dkic_b.t_mst_staff tms4  on tms4.staff_id =  tmc.last_follow_staff
         <include refid="Condition"/>
+        order by tmc.cus_id DESC
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>
@@ -249,6 +253,8 @@
         tms.staff_name  AS  "staffName",
         tms2.staff_name  AS  "reportStaffName",
         tdk.kind_name_i18n  ->> 'zh_CN' AS "saleStatusName"
+--         tccfs.follow_staff  as follow_staff,
+--         tms1.staff_name  as follow_staff_name
         FROM dkic_b.t_mst_customer tmc
         LEFT JOIN  dkic_b.t_mst_dictionary_data tmd  on tmd.data_id =  tmc.cus_from
         LEFT JOIN  dkic_b.t_mst_sale_channel tmsc  on tmsc.channel_id =  tmc.channel_id
@@ -256,7 +262,9 @@
         LEFT JOIN  dkic_b.t_mst_staff tms  on tms.staff_id =  tmc.staff_id
         LEFT JOIN  dkic_b.t_mst_staff tms2  on tms2.staff_id =  tmc.report_staff
         LEFT JOIN  sys.t_data_kind tdk  on tdk.kind_code =  tmc.sale_status
-        WHERE cus_id = #{cusId}::uuid
+--         LEFT JOIN  dkic_b.t_crm_cus_follow_staff  tccfs on tccfs.follow_staff = any(tmc.follow_staffs)
+--         LEFT JOIN  dkic_b.t_mst_staff tms1  on tms1.staff_id =  tccfs.follow_staff
+        WHERE tmc.cus_id = #{cusId}::uuid
     </select>
 
     <!-- 根据主键锁定表t_mst_customer的一行数据 -->

+ 2 - 1
src/main/java/com/dk/mdm/model/query/mst/CusFollowQuery.java

@@ -282,7 +282,8 @@ public class CusFollowQuery extends PageInfo<CusFollowQuery> implements Serializ
     @ApiModelProperty(value = "数据操作数据库用户 (触发器自动处理)")
     private String opDbUser;
 
-
+    @ApiModelProperty(value = "模糊查询")
+    private String searchText;
     /*
      * 相关属性
      * @TableField(exist = false)

+ 3 - 0
src/main/java/com/dk/mdm/model/query/mst/CustomerQuery.java

@@ -336,6 +336,9 @@ public class CustomerQuery extends PageInfo<CustomerQuery> implements Serializab
     @ApiModelProperty(value = "数据操作数据库用户 (触发器自动处理)")
     private String opDbUser;
 
+    @ApiModelProperty(value = "模糊查询")
+    private String searchText;
+
 
     /*
      * 相关属性

+ 20 - 1
src/main/java/com/dk/mdm/model/response/mst/CusFollowResponse.java

@@ -216,13 +216,25 @@ public class CusFollowResponse implements Serializable {
     @ApiModelProperty(value = "企业ID")
     private Integer cpId;
 
-
+    @ApiModelProperty(value = "客户名称")
     private String cusName;
+
+    @ApiModelProperty(value = "客户电话")
     private String cusPhone;
+
+    @ApiModelProperty(value = "销售部门")
     private String orgName;
+
+    @ApiModelProperty(value = "销售人员")
     private String staffName;
+
+    @ApiModelProperty(value = "跟进员工")
     private String followStaffName;
+
+    @ApiModelProperty(value = "详细地址")
     private String addressFull;
+
+    @ApiModelProperty(value = "跟进次数")
     private Integer followCount;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@@ -230,6 +242,13 @@ public class CusFollowResponse implements Serializable {
     private LocalDateTime createTime;
 
 
+    @ApiModelProperty(value = "跟进状态 (【系统字典】陌生接待、留资接待(报备)、跟进、邀约、约尺)")
+    private String followStatusName;
+
+    @ApiModelProperty(value = "跟进方式 (【系统字典】电话、微信、上门、进店)")
+    private String followTypeName;
+
+
     private static final long serialVersionUID = 1L;
 
 }

+ 8 - 0
src/main/java/com/dk/mdm/model/response/mst/CustomerResponse.java

@@ -289,6 +289,8 @@ public class CustomerResponse extends PageInfo<CustomerResponse> implements Seri
 
     @ApiModelProperty(value = "报备人")
     private String reportStaffName;
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String followStaff;
 
     @ApiModelProperty(value = "跟进人")
     private String followStaffName;
@@ -298,6 +300,12 @@ public class CustomerResponse extends PageInfo<CustomerResponse> implements Seri
 
     private String saleStatusName;
 
+    @ApiModelProperty(value = "提醒日期")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDateTime nextFollowTime;
+
+
     private static final long serialVersionUID = 1L;
 
 }

+ 1 - 1
src/main/java/com/dk/mdm/service/common/CommonService.java

@@ -699,7 +699,7 @@ public class CommonService extends BaseService<Map<String, Object>> {
             list = commonMapper.getDataKind(map);
         }
         //邀约结果
-        if (dataSourceCode.equals("invitationResults")) {
+        if (dataSourceCode.equals("inviteResult")) {
             map.put("kindType","邀约结果");
             list = commonMapper.getDataKind(map);
         }

+ 26 - 12
src/main/java/com/dk/mdm/service/mst/CusFollowService.java

@@ -101,7 +101,16 @@ public class CusFollowService extends BaseService<CusFollow> {
             rollbackFor = {Exception.class}
     )
     public ResponseResultVO<?> insert(CusFollowVO cusFollowVO) {
-
+        CusFollow cusFollow = cusFollowConvert.convertToPo(cusFollowVO);
+        //设置ID
+        Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.CUSTOMERFOLLOW.getName(), true);
+        cusFollow.setFollowId(uniqueNoteCode.get("outId").toString());
+        //跟进时间
+        cusFollow.setFollowTime(LocalDateTime.now());
+        //跟进人
+        cusFollow.setFollowStaff(authUtils.getStaff().getStaffId());
+        //跟进部门
+        cusFollow.setFollowOrg(authUtils.getStaff().getOrgId());
         if (cusFollowVO.getCusId() != null) {
             //查询客户
             Customer customer = customerMapper.selectById(cusFollowVO.getCusId());
@@ -176,12 +185,21 @@ public class CusFollowService extends BaseService<CusFollow> {
                 throw new BaseBusinessException(ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getCode(),
                         ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getMessage());
             }
+            customer.setLastFollowId(cusFollow.getFollowId());
+            customer.setLastFollowTime(cusFollow.getFollowTime());
+            customer.setLastFollowStaff(cusFollow.getFollowStaff());
             //修改跟进次数
             customer.setFollowCount(customer.getFollowCount() + 1);
             customerService.updateByUuid(customer);
         } else if (cusFollowVO.getCusPhone() != null && cusFollowVO.getCusName() != null) {
             //留资接待 新建客户
             Customer customer = new Customer();
+            //设置编码
+            Map<String, Object> customerNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.CUSTOMER.getName(), true);
+            customer.setCusId(customerNoteCode.get("outId").toString());
+            customer.setCusCode(customerNoteCode.get("outNote").toString());
+            //TODO  渠道 取当前登录人员工的渠道
+            customer.setChannelId("10112024-0302-0000-0000-00000759d8a4");
             customer.setCusName(cusFollowVO.getCusName());
             customer.setCusPhone(cusFollowVO.getCusPhone());
             customer.setAddressName(cusFollowVO.getAddressName());
@@ -192,9 +210,13 @@ public class CusFollowService extends BaseService<CusFollow> {
             customer.setReportStaff(authUtils.getStaff().getStaffId());
             customer.setReportTime(LocalDateTime.now());
             customer.setCpId(authUtils.getStaff().getCpId());
+            customer.setStaffId(authUtils.getStaff().getStaffId());
             customer.setOrgId(authUtils.getStaff().getOrgId());
             customer.setFollowCount(1);
-//            customer.setCustomerFrom(-1L);
+            customer.setLastFollowId(cusFollow.getFollowId());
+            customer.setLastFollowTime(cusFollow.getFollowTime());
+            customer.setLastFollowStaff(cusFollow.getFollowStaff());
+
 
             // 同商户 电话不同
             Long count = customerMapper.countByCond(
@@ -225,16 +247,8 @@ public class CusFollowService extends BaseService<CusFollow> {
         }
 
 
-        CusFollow cusFollow = cusFollowConvert.convertToPo(cusFollowVO);
-        //设置ID
-        Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.CUSTOMERFOLLOW.getName(), true);
-        cusFollow.setFollowId(uniqueNoteCode.get("outId").toString());
-        //跟进时间
-        cusFollow.setFollowTime(LocalDateTime.now());
-        //跟进人
-        cusFollow.setFollowStaff(authUtils.getStaff().getStaffId());
-        //跟进部门
-        cusFollow.setFollowOrg(authUtils.getStaff().getOrgId());
+
+
 
         // 约量尺
         if (Constant.BasicDataConstant.FOLLOW_STATUS_3.getValue().equals(cusFollow.getFollowStatus())) {