!866 新增:CRM 商业智能,其他排名接口

Merge pull request !866 from 安浩浩/develop
This commit is contained in:
芋道源码 2024-02-17 10:06:18 +00:00 committed by Gitee
commit bba32c6ba3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 266 additions and 9 deletions

View File

@ -42,4 +42,46 @@ public class CrmBiRankController {
return success(rankingService.getReceivablePriceRank(rankingReqVO));
}
@GetMapping("/get-contract-count-rank")
@Operation(summary = "获得签约合同数量排行榜")
@PreAuthorize("@ss.hasPermission('crm:bi-rank:query')")
public CommonResult<List<CrmBiRanKRespVO>> getContractCountRank(@Valid CrmBiRankReqVO rankingReqVO) {
return success(rankingService.getContractCountRank(rankingReqVO));
}
@GetMapping("/get-product-sales-rank")
@Operation(summary = "获得产品销量排行榜")
@PreAuthorize("@ss.hasPermission('crm:bi-rank:query')")
public CommonResult<List<CrmBiRanKRespVO>> getProductSalesRank(@Valid CrmBiRankReqVO rankingReqVO) {
return success(rankingService.getProductSalesRank(rankingReqVO));
}
@GetMapping("/get-customer-count-rank")
@Operation(summary = "获得新增客户数排行榜")
@PreAuthorize("@ss.hasPermission('crm:bi-rank:query')")
public CommonResult<List<CrmBiRanKRespVO>> getCustomerCountRank(@Valid CrmBiRankReqVO rankingReqVO) {
return success(rankingService.getCustomerCountRank(rankingReqVO));
}
@GetMapping("/get-contacts-count-rank")
@Operation(summary = "获得新增联系人数排行榜")
@PreAuthorize("@ss.hasPermission('crm:bi-rank:query')")
public CommonResult<List<CrmBiRanKRespVO>> getContactsCountRank(@Valid CrmBiRankReqVO rankingReqVO) {
return success(rankingService.getContactsCountRank(rankingReqVO));
}
@GetMapping("/get-follow-count-rank")
@Operation(summary = "获得跟进次数排行榜")
@PreAuthorize("@ss.hasPermission('crm:bi-rank:query')")
public CommonResult<List<CrmBiRanKRespVO>> getFollowCountRank(@Valid CrmBiRankReqVO rankingReqVO) {
return success(rankingService.getFollowCountRank(rankingReqVO));
}
@GetMapping("/get-follow-customer-count-rank")
@Operation(summary = "获得跟进客户数排行榜")
@PreAuthorize("@ss.hasPermission('crm:bi-rank:query')")
public CommonResult<List<CrmBiRanKRespVO>> getFollowCustomerCountRank(@Valid CrmBiRankReqVO rankingReqVO) {
return success(rankingService.getFollowCustomerCountRank(rankingReqVO));
}
}

View File

@ -30,4 +30,51 @@ public interface CrmBiRankingMapper {
*/
List<CrmBiRanKRespVO> selectReceivablePriceRank(CrmBiRankReqVO rankReqVO);
/**
* 查询签约合同数量排行榜
*
* @param rankReqVO 参数
* @return 签约合同数量排行榜
*/
List<CrmBiRanKRespVO> selectContractCountRank(CrmBiRankReqVO rankReqVO);
/**
* 查询产品销量排行榜
*
* @param rankReqVO 参数
* @return 产品销量排行榜
*/
List<CrmBiRanKRespVO> selectProductSalesRank(CrmBiRankReqVO rankReqVO);
/**
* 查询新增客户数排行榜
*
* @param rankReqVO 参数
* @return 新增客户数排行榜
*/
List<CrmBiRanKRespVO> selectCustomerCountRank(CrmBiRankReqVO rankReqVO);
/**
* 查询联系人数量排行榜
*
* @param rankReqVO 参数
* @return 联系人数量排行榜
*/
List<CrmBiRanKRespVO> selectContactsCountRank(CrmBiRankReqVO rankReqVO);
/**
* 查询跟进次数排行榜
*
* @param rankReqVO 参数
* @return 跟进次数排行榜
*/
List<CrmBiRanKRespVO> selectFollowCountRank(CrmBiRankReqVO rankReqVO);
/**
* 查询跟进客户数排行榜
*
* @param rankReqVO 参数
* @return 跟进客户数排行榜
*/
List<CrmBiRanKRespVO> selectFollowCustomerCountRank(CrmBiRankReqVO rankReqVO);
}

View File

@ -29,4 +29,51 @@ public interface CrmBiRankingService {
*/
List<CrmBiRanKRespVO> getReceivablePriceRank(CrmBiRankReqVO rankReqVO);
/**
* 获得签约合同数量排行榜
*
* @param rankReqVO 排行参数
* @return 签约合同数量排行榜
*/
List<CrmBiRanKRespVO> getContractCountRank(CrmBiRankReqVO rankReqVO);
/**
* 获得产品销量排行榜
*
* @param rankReqVO 排行参数
* @return 产品销量排行榜
*/
List<CrmBiRanKRespVO> getProductSalesRank(CrmBiRankReqVO rankReqVO);
/**
* 获得新增客户数排行榜
*
* @param rankReqVO 排行参数
* @return 新增客户数排行榜
*/
List<CrmBiRanKRespVO> getCustomerCountRank(CrmBiRankReqVO rankReqVO);
/**
* 获得联系人数量排行榜
*
* @param rankReqVO 排行参数
* @return 联系人数量排行榜
*/
List<CrmBiRanKRespVO> getContactsCountRank(CrmBiRankReqVO rankReqVO);
/**
* 获得跟进次数排行榜
*
* @param rankReqVO 排行参数
* @return 跟进次数排行榜
*/
List<CrmBiRanKRespVO> getFollowCountRank(CrmBiRankReqVO rankReqVO);
/**
* 获得跟进客户数排行榜
*
* @param rankReqVO 排行参数
* @return 跟进客户数排行榜
*/
List<CrmBiRanKRespVO> getFollowCustomerCountRank(CrmBiRankReqVO rankReqVO);
}

View File

@ -49,6 +49,36 @@ public class CrmBiRankingServiceImpl implements CrmBiRankingService {
return getRank(rankReqVO, biRankingMapper::selectReceivablePriceRank);
}
@Override
public List<CrmBiRanKRespVO> getContractCountRank(CrmBiRankReqVO rankReqVO) {
return getRank(rankReqVO, biRankingMapper::selectContractCountRank);
}
@Override
public List<CrmBiRanKRespVO> getProductSalesRank(CrmBiRankReqVO rankReqVO) {
return getRank(rankReqVO, biRankingMapper::selectProductSalesRank);
}
@Override
public List<CrmBiRanKRespVO> getCustomerCountRank(CrmBiRankReqVO rankReqVO) {
return getRank(rankReqVO, biRankingMapper::selectCustomerCountRank);
}
@Override
public List<CrmBiRanKRespVO> getContactsCountRank(CrmBiRankReqVO rankReqVO) {
return getRank(rankReqVO, biRankingMapper::selectContactsCountRank);
}
@Override
public List<CrmBiRanKRespVO> getFollowCountRank(CrmBiRankReqVO rankReqVO) {
return getRank(rankReqVO, biRankingMapper::selectFollowCountRank);
}
@Override
public List<CrmBiRanKRespVO> getFollowCustomerCountRank(CrmBiRankReqVO rankReqVO) {
return getRank(rankReqVO, biRankingMapper::selectFollowCustomerCountRank);
}
/**
* 获得排行版数据
*

View File

@ -12,7 +12,8 @@
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
AND order_date between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime}
AND order_date between #{times[0],javaType=java.time.LocalDateTime} and
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY owner_user_id
</select>
@ -22,12 +23,102 @@
FROM crm_receivable
WHERE deleted = 0
AND audit_status = 20
and owner_user_id in
AND owner_user_id in
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
AND return_time between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime}
AND return_time between #{times[0],javaType=java.time.LocalDateTime} and
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY owner_user_id
</select>
<select id="selectContractCountRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO">
SELECT COUNT(1) AS count, owner_user_id
FROM crm_contract
WHERE deleted = 0
AND audit_status = 20
AND owner_user_id in
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
AND order_date between #{times[0],javaType=java.time.LocalDateTime} and
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY owner_user_id
</select>
<!-- TODO 待定 这里是否需要关联 crm_contract_product 表,计算销售额 -->
<select id="selectProductSalesRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO">
SELECT COUNT(1) AS count, owner_user_id
FROM crm_contract
WHERE deleted = 0
AND audit_status = 20
AND owner_user_id in
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
AND order_date between #{times[0],javaType=java.time.LocalDateTime} and
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY owner_user_id
</select>
<select id="selectCustomerCountRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO">
SELECT COUNT(1) AS count, owner_user_id
FROM crm_customer
WHERE deleted = 0
AND owner_user_id in
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
AND create_time between #{times[0],javaType=java.time.LocalDateTime} and
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY owner_user_id
</select>
<select id="selectContactsCountRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO">
SELECT COUNT(1) AS count, owner_user_id
FROM crm_contact
WHERE deleted = 0
AND owner_user_id in
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
AND create_time between #{times[0],javaType=java.time.LocalDateTime} and
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY owner_user_id
</select>
<select id="selectFollowCountRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO">
SELECT COUNT(1) AS count, cc.owner_user_id
FROM crm_follow_up_record AS cfur LEFT JOIN crm_contact AS cc ON FIND_IN_SET(cc.id, cfur.contact_ids)
WHERE cfur.deleted = 0
AND cc.deleted = 0
AND cc.owner_user_id in
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
AND cfur.create_time between #{times[0],javaType=java.time.LocalDateTime} and
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY cc.owner_user_id
</select>
<select id="selectFollowCustomerCountRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO">
SELECT COUNT(DISTINCT cc.id) AS count, cc.owner_user_id
FROM crm_follow_up_record AS cfur LEFT JOIN crm_contact AS cc ON FIND_IN_SET(cc.id, cfur.contact_ids)
WHERE cfur.deleted = 0
AND cc.deleted = 0
AND cc.owner_user_id in
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
AND cfur.create_time between #{times[0],javaType=java.time.LocalDateTime} and
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY cc.owner_user_id
</select>
</mapper>