mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-01 02:38:43 +08:00 
			
		
		
		
	fix: selectCustomerDealCycleGroupByProductId使用LEFT JOIN替换子查询
This commit is contained in:
		| @@ -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=","> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 dhb52
					dhb52