mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
fix: selectCustomerDealCycleGroupByProductId使用LEFT JOIN替换子查询
This commit is contained in:
parent
ed5f3a6bc2
commit
488f99b512
@ -243,14 +243,17 @@
|
|||||||
|
|
||||||
<select id="selectCustomerDealCycleGroupByProductId"
|
<select id="selectCustomerDealCycleGroupByProductId"
|
||||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerDealCycleByProductRespVO">
|
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerDealCycleByProductRespVO">
|
||||||
SELECT (SELECT name FROM crm_product WHERE id = product.id) AS product_name,
|
SELECT product.name AS product_name,
|
||||||
IFNULL(TRUNCATE(AVG(TIMESTAMPDIFF(DAY, customer.create_time, contract.order_date)), 1), 0) AS customer_deal_cycle,
|
IFNULL(TRUNCATE(AVG(TIMESTAMPDIFF(DAY, customer.create_time, contract.order_date)), 1), 0) AS customer_deal_cycle,
|
||||||
COUNT(DISTINCT customer.id) AS customer_deal_count
|
COUNT(DISTINCT customer.id) AS customer_deal_count
|
||||||
FROM crm_customer AS customer
|
FROM crm_customer AS customer
|
||||||
LEFT JOIN crm_contract AS contract ON customer.id = contract.customer_id
|
LEFT JOIN crm_contract AS contract ON customer.id = contract.customer_id
|
||||||
LEFT JOIN crm_contract_product AS product ON product.contract_id = contract.id
|
LEFT JOIN crm_contract_product AS contract_product ON contract_product.contract_id = contract.id
|
||||||
|
LEFT JOIN crm_product AS product ON contract_product.product_id = product.id
|
||||||
WHERE customer.deleted = 0
|
WHERE customer.deleted = 0
|
||||||
AND contract.deleted = 0
|
AND contract.deleted = 0
|
||||||
|
AND contract_product.deleted = 0
|
||||||
|
AND product.deleted = 0
|
||||||
AND contract.audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status}
|
AND contract.audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status}
|
||||||
AND customer.owner_user_id IN
|
AND customer.owner_user_id IN
|
||||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||||
|
Loading…
Reference in New Issue
Block a user