WH01243 2 ani în urmă
părinte
comite
d27327660a
1 a modificat fișierele cu 11 adăugiri și 11 ștergeri
  1. 11 11
      ent/entity/customer.go

+ 11 - 11
ent/entity/customer.go

@@ -273,7 +273,7 @@ func (this *Customer) GetDeptCustomerList(dept_id, ent_id int, name, alloc, staf
 	searchValues := []interface{}{}
 	searchValues = append(searchValues, dept_id, dept_id, ent_id)
 	if name != "" { //名字模糊查询
-		searchSql += ` and a.name like ? `
+		searchSql += ` and b.name like ? `
 		searchValues = append(searchValues, "%"+name+"%")
 	}
 	if len(area) > 0 {
@@ -292,33 +292,33 @@ func (this *Customer) GetDeptCustomerList(dept_id, ent_id int, name, alloc, staf
 		cityValue, citystr := util.GetInForComma(cityStr)
 		if len(areastr) > 0 {
 			if len(citystr) > 0 {
-				searchSql += fmt.Sprintf(` and ( a.area in (%s)  or a.city in (%s))`, areastr, citystr)
+				searchSql += fmt.Sprintf(` and ( b.area in (%s)  or b.city in (%s))`, areastr, citystr)
 				searchValues = append(searchValues, areaValue...)
 				searchValues = append(searchValues, cityValue...)
 			} else {
-				searchSql += fmt.Sprintf(` and ( a.area in (%s) )`, areastr)
+				searchSql += fmt.Sprintf(` and ( b.area in (%s) )`, areastr)
 				searchValues = append(searchValues, areaValue...)
 			}
 		} else {
 			if len(citystr) > 0 {
-				searchSql += fmt.Sprintf(` and ( a.city in (%s))`, citystr)
+				searchSql += fmt.Sprintf(` and ( b.city in (%s))`, citystr)
 				searchValues = append(searchValues, cityValue...)
 			}
 		}
 
 	}
 	if startTme > 0 { //开始时间查询
-		searchSql += ` and a.updatetime >= ? `
+		searchSql += ` and b.updatetime >= ? `
 		searchValues = append(searchValues, time.Unix(startTme, 0).Format(Date_Full_Layout))
 	}
 	if endTime > 0 { //开始时间查询
-		searchSql += ` and a.updatetime <= ? `
+		searchSql += ` and b.updatetime <= ? `
 		searchValues = append(searchValues, time.Unix(endTime, 0).Format(Date_Full_Layout))
 	}
 
 	if industry != "" {
 		industryValue, industrystr := util.GetInForComma(industry)
-		searchSql += fmt.Sprintf(` and ( a.industry in (%s))`, industrystr)
+		searchSql += fmt.Sprintf(` and ( b.industry in (%s))`, industrystr)
 		searchValues = append(searchValues, industryValue...)
 	}
 	allocSql := ``
@@ -360,11 +360,11 @@ func (this *Customer) GetDeptCustomerList(dept_id, ent_id int, name, alloc, staf
 							OR ( a.pid = ? AND a.id = b.dept_id ))
 							INNER JOIN entniche_user c ON ( c.ent_id = ? AND b.user_id = c.id ) 
 						) b ON ( a.user_id = b.id ) 
-				WHERE ` + searchSql + `  limit 100000) as a
+				 limit 100000) as a
 					LEFT JOIN entniche_customer b ON ( a.customer_id = b.id ) 
 				AND b.ent_id = 14640 
 				AND b.state = 1
-				LEFT JOIN entniche_user c ON ( a.user_id = c.id ) 
+				LEFT JOIN entniche_user c ON ( a.user_id = c.id ) WHERE ` + searchSql + ` 
 							GROUP BY  a.customer_id  ` + allocSql + ` order by updatetime desc,	b.createtime desc`
 		customerList = util.Mysql.SelectBySql(customersql+` limit ?,?`, searchValues...)
 		countValue = searchValues[:len(searchValues)-2]
@@ -395,11 +395,11 @@ func (this *Customer) GetDeptCustomerList(dept_id, ent_id int, name, alloc, staf
 							OR ( a.pid = ? AND a.id = b.dept_id ))
 							INNER JOIN entniche_user c ON ( c.ent_id = ? AND b.user_id = c.id ) 
 						) b ON ( a.user_id = b.id ) 
-				WHERE ` + searchSql + `  limit ?,? ) as a
+				  limit ?,? ) as a
 					LEFT JOIN entniche_customer b ON ( a.customer_id = b.id ) 
 				AND b.ent_id = 14640 
 				AND b.state = 1
-				LEFT JOIN entniche_user c ON ( a.user_id = c.id ) 
+				LEFT JOIN entniche_user c ON ( a.user_id = c.id )  WHERE ` + searchSql + `
 							GROUP BY  a.customer_id  ` + allocSql + ` order by updatetime desc,	b.createtime desc`
 		customerList = util.Mysql.SelectBySql(customersql, searchValues...)
 		countValue = searchValues