Commit 8fec5e21 by 284718418@qq.com

1.CRM-业务员统计数据

2.修改所有客户查询BUG
parent bcfaf00b
......@@ -15,6 +15,7 @@ import java.util.stream.Collectors;
import cn.timer.api.bean.crm.*;
import cn.timer.api.bean.insure.InsurePolicy;
import cn.timer.api.bean.insure.InsureProductPlan;
import cn.timer.api.bean.qyzx.QyzxEmpLogin;
import cn.timer.api.controller.insure.CallBackContorll;
import cn.timer.api.controller.zpgl.sevice.ZpglService;
import cn.timer.api.dao.crm.*;
......@@ -1553,6 +1554,7 @@ public class CrmController {
}
map.put("name", name);
map.put("num", num);
map.put("userId", belonger);
return map;
}
......@@ -1627,6 +1629,7 @@ public class CrmController {
String name = ClientTypeClass.builder().id(level).build().selectById().getName();
map.put("name", name);
map.put("num", num);
map.put("userId", belonger);
} else {
num = CrmClientData.builder().build()
......@@ -1638,6 +1641,7 @@ public class CrmController {
String name = ClientTypeClass.builder().id(level).build().selectById().getName();
map.put("name", name);
map.put("num", num);
map.put("userId", belonger);
}
return map;
}
......@@ -2098,4 +2102,36 @@ public class CrmController {
return ResultUtil.pageData(result, (long) crmClientDatas.size(), "查询成功");
}
}
@PostMapping(value = "/get_crm_top_count")
@ApiOperation(value = "所有客户头部统计", httpMethod = "POST", notes = "所有客户头部统计")
public Result<Object> getCrmTopCount(@CurrentUser UserBean userBean, @RequestBody CrmClientDataCountParam param) {
param.setOrgCode(userBean.getOrgCode());
CrmClientDataCountDto dto = crmClientDataMapper.getCrmTopCount(param);
if(!org.springframework.util.StringUtils.isEmpty(param)
&& !org.springframework.util.StringUtils.isEmpty(param.getCreateUser())){
QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().id(param.getCreateUser()).build().selectById();
if(!org.springframework.util.StringUtils.isEmpty(qyzxEmpLogin)){
dto.setUserName(qyzxEmpLogin.getUsername());
dto.setPhone(qyzxEmpLogin.getPhone());
dto.setHeadUrl(qyzxEmpLogin.getHeadUrl());
}
}
return ResultUtil.data(dto, "成功");
}
@ApiOperation(value = "所有客户头部统计:客户折线图")
@PostMapping(value = "/crm_line")
public Result<Object> getCrmLine(@CurrentUser UserBean userBean, @RequestBody CrmClientDataCountParam param) {
param.setOrgCode(userBean.getOrgCode());
return ResultUtil.data(crmClientDataMapper.getCrmLine(param), "成功");
}
@ApiOperation(value = "所有客户头部统计:跟进折线图")
@PostMapping(value = "/follow_line")
public Result<Object> getFollowLine(@CurrentUser UserBean userBean, @RequestBody CrmClientDataCountParam param) {
param.setOrgCode(userBean.getOrgCode());
return ResultUtil.data(crmClientFollowMapper.getFollowLine(param), "成功");
}
}
......@@ -9,7 +9,7 @@ package cn.timer.api.dao.crm;
import java.util.List;
import cn.timer.api.dto.crm.CrmCartogramCountExportDto;
import cn.timer.api.dto.crm.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
......@@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.timer.api.bean.crm.CrmClientData;
import cn.timer.api.dto.crm.CrmCartogramDto;
/**
* Title: CrmClientDataMapper.java Description:
......@@ -113,5 +112,13 @@ public interface CrmClientDataMapper extends BaseMapper<CrmClientData> {
@Param("endCreateTime") String endCreateTime, @Param("startFollowTime") String startFollowTime,
@Param("endFollowTime") String endFollowTime,@Param("type") Integer type,
@Param("industry") Integer industry,@Param("remindDay")String remindDay);
CrmClientDataCountDto getCrmTopCount(@Param("param") CrmClientDataCountParam param);
/**
* 根据条件查询 当月统计每日新增数据
* @param param
* @return
*/
List<CrmClientDataLineDto> getCrmLine(@Param("param") CrmClientDataCountParam param);
}
......@@ -7,9 +7,7 @@
*/
package cn.timer.api.dao.crm;
import cn.timer.api.dto.crm.CrmCartogramCountExportDto;
import cn.timer.api.dto.crm.CrmClientFollowCountDto;
import cn.timer.api.dto.crm.CrmClientFollowCountParam;
import cn.timer.api.dto.crm.*;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.timer.api.bean.crm.CrmClientFollow;
......@@ -47,5 +45,12 @@ public interface CrmClientFollowMapper extends BaseMapper<CrmClientFollow> {
*/
Integer selectCountByParam(@Param("param") CrmClientFollowCountParam param);
/**
* 根据条件查询 当月统计每日跟进数据
* @param param
* @return
*/
List<CrmClientFollowLineDto> getFollowLine(@Param("param") CrmClientDataCountParam param);
}
package cn.timer.api.dto.crm;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author wuqingjun
* @version 1.0
* @Description: 所有客户头部统计
* @date 2023年8月10日
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CrmClientDataCountDto implements Serializable {
private static final long serialVersionUID = 3241644321635711234L;
/**
* 客户总数
*/
private Integer crmCount;
/**
* 1-潜在客户总数
*/
private Integer crmCount1;
/**
* 2-意向客户总数
*/
private Integer crmCount2;
/**
* 3-签约客户总数
*/
private Integer crmCount3;
/**
* 4-合作中客户总数
*/
private Integer crmCount4;
/**
* 5-已封档客户总数
*/
private Integer crmCount5;
/**
* 今日新增客户数量
*/
private Integer todayCrmCount;
/**
* 昨日新增客户数量
*/
private Integer yesterdayCrmCount;
/**
* 近30天未跟进数量,5-已封档不统计
*/
private Integer last30DaysFollowCount;
/**
* 近60天未跟进数量,5-已封档不统计
*/
private Integer last60DaysFollowCount;
/**
* 近90天未跟进数量,5-已封档不统计
*/
private Integer last90DaysFollowCount;
/**
* 近180天未跟进数量,5-已封档不统计
*/
private Integer last180DaysFollowCount;
/**
* 签约转化率
*/
private double crmSignRate;
/**
* 合作转化率
*/
private double crmPartnerRate;
/**
* 流失率
*/
private double crmLossRate;
/**
* 今日新增跟进数量
*/
private Integer todayFollowCount;
/**
* 昨日新增跟进数量
*/
private Integer yesterdayFollowCount;
/**
* 姓名
*/
private String userName;
/**
* 手机号码
*/
private String phone;
/**
* 手机号码
*/
private String headUrl;
}
package cn.timer.api.dto.crm;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 所有客户头部统计入参
* @author wuqingjun
* @date 2023年8月10日
* @version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CrmClientDataCountParam implements Serializable {
private static final long serialVersionUID = -1230023773946170911L;
/**
* 当前企业id
*/
@ApiModelProperty(value = "当前企业id")
private Integer orgCode;
/**
* 当前用户ID
*/
@ApiModelProperty(value = "当前用户ID")
private Integer createUser;
}
package cn.timer.api.dto.crm;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author wuqingjun
* @version 1.0
* @Description: 客户统计折现图
* @date 2023年8月11日
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "客户统计折现图")
public class CrmClientDataLineDto implements Serializable {
private static final long serialVersionUID = 3241644321635711236L;
@ApiModelProperty(value = "日期")
private String dateStr;
@ApiModelProperty(value = "统计")
private Integer countCrm;
}
package cn.timer.api.dto.crm;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author wuqingjun
* @version 1.0
* @Description: 客户跟进统计折现图
* @date 2023年8月11日
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "客户跟进统计折现图")
public class CrmClientFollowLineDto implements Serializable {
private static final long serialVersionUID = 3241644321635711235L;
@ApiModelProperty(value = "日期")
private String dateStr;
@ApiModelProperty(value = "统计")
private Integer countCrm;
}
......@@ -98,7 +98,6 @@
SELECT ccd.*
FROM crm_client_data ccd
WHERE ccd.org_code = #{orgCode}
AND ccd.belong_user = #{empNum}
<if test="industry != null and industry > 0">
AND ccd.industry = #{industry}
</if>
......@@ -146,7 +145,6 @@
SELECT *
FROM crm_client_data ccd
WHERE ccd.org_code = #{orgCode}
AND ccd.belong_user = #{empNum}
<if test="industry != null and industry > 0">
AND ccd.industry = #{industry}
</if>
......@@ -434,4 +432,97 @@
</if>
ORDER BY ccd.create_time DESC
</select>
<select id="getCrmTopCount" resultType="cn.timer.api.dto.crm.CrmClientDataCountDto">
SELECT
-- 客户总数
crmCount,
-- 1-潜在客户总数
crmCount1,
-- 2-意向客户总数
crmCount2,
-- 3-签约客户总数
crmCount3,
-- 4-合作中客户总数
crmCount4,
-- 5-已封档客户总数
crmCount5,
-- 今日新增客户数量
todayCrmCount,
-- 昨日新增客户数量
yesterdayCrmCount ,
-- 近30天未跟进数量,5-已封档不统计
last30DaysFollowCount,
-- 近60天未跟进数量,5-已封档不统计
last60DaysFollowCount,
-- 近90天未跟进数量,5-已封档不统计
last90DaysFollowCount,
-- 近180天未跟进数量,5-已封档不统计
last180DaysFollowCount,
-- 签约转化率
crmSignRate,
-- 合作转化率
crmPartnerRate,
-- 流失率
crmLossRate,
-- 今日新增跟进数量
todayFollowCount,
-- 昨日新增跟进数量
yesterdayFollowCount
FROM (
SELECT
COUNT(*) AS crmCount,
COUNT(IF(client_status = 1,id,NULL)) AS crmCount1,
COUNT(IF(client_status = 2,id,NULL)) AS crmCount2,
COUNT(IF(client_status = 3,id,NULL)) AS crmCount3,
COUNT(IF(client_status = 4,id,NULL)) AS crmCount4,
COUNT(IF(client_status = 5,id,NULL)) AS crmCount5,
COALESCE( SUM( CASE WHEN DATE( create_time ) = CURDATE( ) THEN 1 ELSE 0 END ), 0 ) AS todayCrmCount,
COALESCE( SUM( CASE WHEN DATE( create_time ) = CURDATE( ) - INTERVAL 1 DAY THEN 1 ELSE 0 END ),0) AS yesterdayCrmCount ,
COALESCE( SUM( CASE WHEN DATE( last_follow_time ) <![CDATA[ >= ]]> CURDATE( ) - INTERVAL 30 DAY AND client_status <![CDATA[ < ]]> 5 THEN 1 ELSE 0 END ),0) AS last30DaysFollowCount,
COALESCE( SUM( CASE WHEN DATE( last_follow_time ) <![CDATA[ >= ]]> CURDATE( ) - INTERVAL 60 DAY AND client_status <![CDATA[ < ]]> 5 THEN 1 ELSE 0 END ),0) AS last60DaysFollowCount,
COALESCE( SUM( CASE WHEN DATE( last_follow_time ) <![CDATA[ >= ]]> CURDATE( ) - INTERVAL 90 DAY AND client_status <![CDATA[ < ]]> 5 THEN 1 ELSE 0 END ),0) AS last90DaysFollowCount,
COALESCE( SUM( CASE WHEN DATE( last_follow_time ) <![CDATA[ >= ]]> CURDATE( ) - INTERVAL 180 DAY AND client_status <![CDATA[ < ]]> 5 THEN 1 ELSE 0 END ),0) AS last180DaysFollowCount,
COALESCE((COUNT(IF(client_status = 3,id,NULL))/COUNT(*))*100, 0)AS crmSignRate,
COALESCE((COUNT(IF(client_status = 4,id,NULL))/COUNT(*))*100, 0)AS crmPartnerRate,
COALESCE((COUNT(IF(client_status between 0 AND 3 AND DATE( last_follow_time ) <![CDATA[ >= ]]> CURDATE( ) - INTERVAL 360 DAY AND client_status <![CDATA[ < ]]> 4 ,id,NULL))/COUNT(*))*100, 0)AS crmLossRate
FROM
crm_client_data
<where>
org_code = #{param.orgCode}
<if test='null != param.createUser and param.createUser !=""'>
AND create_user = #{param.createUser}
</if>
</where>
)AS crmClientCount
CROSS JOIN (
SELECT
COALESCE ( SUM( CASE WHEN DATE( create_time ) = CURDATE( ) THEN 1 ELSE 0 END ),0) AS todayFollowCount,
COALESCE ( SUM( CASE WHEN DATE( create_time ) = CURDATE( ) - INTERVAL 1 DAY THEN 1 ELSE 0 END ),0) AS yesterdayFollowCount
FROM
crm_client_follow
<where>
org_code = #{param.orgCode}
<if test='null != param.createUser and param.createUser !=""'>
AND create_user = #{param.createUser}
</if>
</where>
) AS followCount
</select>
<select id="getCrmLine" resultType="cn.timer.api.dto.crm.CrmClientDataLineDto">
SELECT
DATE_FORMAT( create_time, '%m-%d' ) AS date_str,
COUNT( * ) AS count_crm
FROM
crm_client_data
<where>
org_code = #{param.orgCode} and DATE_FORMAT( create_time, '%Y-%m' ) = DATE_FORMAT( CURDATE( ), '%Y-%m' )
<if test='null != param.createUser and param.createUser !=""'>
AND create_user = #{param.createUser}
</if>
</where>
GROUP BY
DATE( create_time )
ORDER BY
DATE( create_time )
</select>
</mapper>
......@@ -66,4 +66,21 @@
</if>
</where>
</select>
<select id="getFollowLine" resultType="cn.timer.api.dto.crm.CrmClientFollowLineDto">
SELECT
DATE_FORMAT( create_time, '%m-%d' ) AS date_str,
COUNT( * ) AS count_crm
FROM
crm_client_follow
<where>
org_code = #{param.orgCode} and DATE_FORMAT( create_time, '%Y-%m' ) = DATE_FORMAT( CURDATE( ), '%Y-%m' )
<if test='null != param.createUser and param.createUser !=""'>
AND create_user = #{param.createUser}
</if>
</where>
GROUP BY
DATE( create_time )
ORDER BY
DATE( create_time )
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment