CRM--首页数据--商机转化龙虎榜 (接口实现)

CRM--首页数据--商机转化龙虎榜 (接口实现)_第1张图片

需求:

在一段时间范围内,统计哪些部门员工将商机转合同的最多,并计算转化率

对于商机总数来说这里的时间范围指的是商机的创建时间

对于每个用户转化了多少个商机来说,时间范围指的是合同的创建时间

合同的创建时间即商机转合同的时间

注意:最多展示10条

接口名/index/businessChangeStatistics

请求方式Get

参数列表

传入参数:

/index/businessChangeStatistics?beginCreateTime=2021-02-02&endCreateTime=2022-02-17

beginCreateTime 开始时间

endCreateTime 结束时间

返回值:

{
    "msg":"操作成功",
    "code":200,
    "data":[
        {
            "create_by":"zhangkai",			   		用户名称
            "deptName":"商机部",					  部门名称
            "num":100,								转化数量
            "radio":31.65							转化率
        },
        {
            "create_by":"admin",
            "deptName":"研发部门",
            "num":9,
            "radio":2.85
        },
        {
            "create_by":"shangji",
            "deptName":"新人创建演示用部门",
            "num":1,
            "radio":0.32
        },
        {
            "create_by":"shangji1",
            "deptName":"销售部门",
            "num":1,
            "radio":0.32
        }
    ]
}

步骤:

1.阅读产品文档(接口名,请求方式,参数列表)

2.根据产品的返回值和接收参数构建VO类

3.编写mapper层操作数据库

4.编写service层操作数据

5.编写controller层接收参数和返回数据

TbBusinessMapper.xml

 

 

TbBusinessMapper

	public int countAllBusiness(@Param("beginCreateTime") String beginCreateTime, @Param("endCreateTime") String endCreateTime);
public List> countAllContractByUser(@Param("indexVo")IndexStatisticsVo vo);

ReportServiceImpl

 /**
     * 商机转换龙虎榜
     * @param request
     * @return
     */
    @Override
    public List> businessChangeStatisticsForIndex(IndexStatisticsVo request) {
        int allBusiness=  businessMapper.countAllBusiness(request.getBeginCreateTime(),request.getEndCreateTime());
        List> list= businessMapper.countAllContractByUser(request);
        for (Map datum : list) {
            Long num= (Long) datum.get("num");
            datum.put("radio",getRadio(allBusiness,num));
        }
        return list;
    }

IReportService

 public List> businessChangeStatisticsForIndex(IndexStatisticsVo request);

 IndexController

@GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(IndexStatisticsVo request){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        request.setBeginCreateTime(request.getBeginCreateTime()+" 00:00:00");
        request.setEndCreateTime(request.getEndCreateTime()+" 23:59:59");
        List> list= reportService.businessChangeStatisticsForIndex(request);
        return AjaxResult.success(list);
    }

你可能感兴趣的:(CRM客户管理系统,mybatis,java,servlet)