diff --git a/app/api/enterprise/model/manage_expert.go b/app/api/enterprise/model/manage_expert.go index 03a1b09..4517d76 100644 --- a/app/api/enterprise/model/manage_expert.go +++ b/app/api/enterprise/model/manage_expert.go @@ -33,7 +33,7 @@ func (m *ManageExpert) Experts(page, pageSize int, count *int64, where ...*model db := orm.GetDB().Table(m.TableName()+" e"). Select("e.id", "e.name", "e.mobile", "e.industry", "v.count AS visit_count", "c.count AS collect_count", "e.examine_at AS settled_at"). - Joins(fmt.Sprintf("LEFT JOIN (SELECT expert_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY expert_id) AS v ON e.id = v.expert_id", + Joins(fmt.Sprintf("LEFT JOIN (SELECT expert_id, SUM(count) AS count FROM %s WHERE is_deleted = %d GROUP BY expert_id) AS v ON e.id = v.expert_id", model.NewManageExpertVisit().TableName(), model.DeleteStatusForNot)). Joins(fmt.Sprintf("LEFT JOIN (SELECT expert_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY expert_id) AS c ON e.id = c.expert_id", model.NewManageExpertCollect().TableName(), model.DeleteStatusForNot)). diff --git a/app/api/enterprise/model/manage_laboratory.go b/app/api/enterprise/model/manage_laboratory.go index fade74d..05245b7 100644 --- a/app/api/enterprise/model/manage_laboratory.go +++ b/app/api/enterprise/model/manage_laboratory.go @@ -28,7 +28,7 @@ func (m *ManageLaboratory) Laboratory(page, pageSize int, count *int64, where .. Select("l.id", "l.name", "l.industry", "u.name AS username", "u.mobile", "v.count AS visit_count", "c.count AS collect_count", "l.examine_at AS settled_at"). Joins(fmt.Sprintf("LEFT JOIN %s AS u ON l.uid = u.uuid", model.NewUserInstance().TableName())). - Joins(fmt.Sprintf("LEFT JOIN (SELECT laboratory_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY laboratory_id) AS v ON l.id = v.laboratory_id", + Joins(fmt.Sprintf("LEFT JOIN (SELECT laboratory_id, SUM(count) AS count FROM %s WHERE is_deleted = %d GROUP BY laboratory_id) AS v ON l.id = v.laboratory_id", model.NewManageLaboratoryVisit().TableName(), model.DeleteStatusForNot)). Joins(fmt.Sprintf("LEFT JOIN (SELECT laboratory_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY laboratory_id) AS c ON l.id = c.laboratory_id", model.NewManageLaboratoryCollect().TableName(), model.DeleteStatusForNot)) diff --git a/app/api/enterprise/model/technology_product.go b/app/api/enterprise/model/technology_product.go index 4db547a..2eb4adc 100644 --- a/app/api/enterprise/model/technology_product.go +++ b/app/api/enterprise/model/technology_product.go @@ -30,7 +30,7 @@ func (m *TechnologyProduct) Product(page, pageSize int, count *int64, where ...* db := orm.GetDB().Table(m.TableName()+" AS p"). Select("p.id", "p.title", "p.image", "p.maturity", "p.industry", "p.cooperation_mode", "p.keyword", "v.count AS v visit_count", "c.count AS collect_count"). - Joins(fmt.Sprintf("LEFT JOIN (SELECT product_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY product_id) AS v ON p.id = v.product_id", + Joins(fmt.Sprintf("LEFT JOIN (SELECT product_id, SUM(count) AS count FROM %s WHERE is_deleted = %d GROUP BY product_id) AS v ON p.id = v.product_id", model.NewTechnologyProductVisit().TableName(), model.DeleteStatusForNot)). Joins(fmt.Sprintf("LEFT JOIN (SELECT product_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY product_id) AS c ON p.id = c.product_id", model.NewTechnologyProductCollect().TableName(), model.DeleteStatusForNot))