Bläddra i källkod

fix:sql优化

Roc 2 år sedan
förälder
incheckning
3fdb6cd907
1 ändrade filer med 2 tillägg och 2 borttagningar
  1. 2 2
      models/company_view_statistics.go

+ 2 - 2
models/company_view_statistics.go

@@ -65,7 +65,7 @@ type CompanyViewTotalSlice struct {
 func GetCompanyViewMobileTotalList(date string) (items []*CompanyViewTotalSlice, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT sum(a.view_num) total,a.date,b.company_id FROM user_view_statistics a join wx_user b on a.mobile=b.mobile 
-WHERE a.mobile != "" and a.date = ? group by company_id`
+WHERE a.mobile != "" and b.mobile != "" and a.date = ? group by company_id`
 	_, err = o.Raw(sql, date).QueryRows(&items)
 	return
 }
@@ -74,7 +74,7 @@ WHERE a.mobile != "" and a.date = ? group by company_id`
 func GetCompanyViewEmailTotalList(date string) (items []*CompanyViewTotalSlice, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT sum(a.view_num) total,a.date,b.company_id FROM user_view_statistics a join wx_user b on a.email=b.email 
-WHERE a.email != "" and a.date = ? group by company_id`
+WHERE a.email != "" and b.email != "" and a.date = ? group by company_id`
 	_, err = o.Raw(sql, date).QueryRows(&items)
 	return
 }