Эх сурвалжийг харах

Merge branch 'master' of https://app.yhyue.com/moapp/jypkg

wangchuanjin 2 жил өмнө
parent
commit
5541595140
4 өөрчлөгдсөн 76 нэмэгдсэн , 112 устгасан
  1. 1 1
      compatible/compatible.go
  2. 69 105
      ent/entity/customer.go
  3. 2 2
      go.mod
  4. 4 4
      go.sum

+ 1 - 1
compatible/compatible.go

@@ -234,7 +234,7 @@ func (c *Compatible) updateDo(id string, identity *pb.Identity, update map[strin
 				"i_entid":  identity.EntId,
 				"i_userid": identity.EntUserId,
 				"i_type":   tp,
-			}, up2, false, false)
+			}, up2, true, false)
 		}
 		return ok1 || ok2
 	}

+ 69 - 105
ent/entity/customer.go

@@ -269,11 +269,11 @@ pageSize 每页数据量
 */
 func (this *Customer) GetDeptCustomerList(dept_id, ent_id int, name, alloc, staff_names string, area map[string]interface{}, startTme, endTime int64, pageIndex, pageSize int, sourceType []int, industry string) (count int64, customerList *[]map[string]interface{}) {
 	customerList = &[]map[string]interface{}{}
-	searchSql := ` a.ent_id=? and a.state=1 `
+	searchSql := ` 1=1 `
 	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 := ``
@@ -335,109 +335,73 @@ func (this *Customer) GetDeptCustomerList(dept_id, ent_id int, name, alloc, staf
 			}
 		}
 		searchValues = append(searchValues, (pageIndex-1)*pageSize, pageSize)
-		log.Println(`SELECT GROUP_CONCAT(c.name) as staff_names,a.industry,a.createtime,a.name as customer_name,a.id as customer_id,
-				(SELECT b.time  FROM entniche_project ep INNER JOIN entniche_project_track b ON ep.id = b.project_id WHERE ep.customer_id = a.id  ORDER BY b.time desc LIMIT 0,1 ) AS updatetime from 
-				(select a.name,a.id,a.createtime,a.area,a.industry FROM entniche_customer a
-				INNER JOIN (SELECT
-				id
+		customersql = `SELECT
+					GROUP_CONCAT( c.NAME ) AS staff_names,
+					b.createtime,
+					b.area,
+					b.industry,
+					b.NAME AS customer_name,
+					b.id AS customer_id,
+					( SELECT b.time FROM entniche_project_track b WHERE b.customer_id = a.customer_id ORDER BY b.time DESC LIMIT 0, 1 ) AS updatetime 
 				FROM
-				(
-				SELECT
-					t1.id,
-					t1.NAME,
-					IF( find_in_set( pid, @pids ) > 0, @pids := concat( @pids, ",", id ), 0 ) AS ischild 
-					FROM( 
-						SELECT id, pid, NAME 
-						FROM 
-						entniche_department t 
-						ORDER BY pid, id ) t1,
-						(SELECT @pids := ?) t2 ) t3 
-					where ischild != 0 
-							or  id=?
-				) b on (a.dept_id=b.id)
-				WHERE `+searchSql+` order by updatetime desc limit 100000) as a
-				LEFT JOIN entniche_user_customer b on (a.id=b.customer_id)
-				LEFT JOIN entniche_user c on (b.user_id=c.id)
-				GROUP BY  a.id  `+allocSql+` order by updatetime desc,	a.createtime  desc  limit ?,?`, searchValues)
-		customersql = `SELECT GROUP_CONCAT(c.name) as staff_names,a.industry,a.createtime,a.name as customer_name,a.id as customer_id,
-				(SELECT b.time  FROM entniche_project ep INNER JOIN entniche_project_track b ON ep.id = b.project_id WHERE ep.customer_id = a.id  ORDER BY b.time desc LIMIT 0,1 ) AS updatetime from 
-				(select a.name,a.id,a.createtime,a.area,a.industry FROM entniche_customer a
-				INNER JOIN (SELECT
-				id
-				FROM
-				(
-				SELECT
-					t1.id,
-					t1.NAME,
-					IF( find_in_set( pid, @pids ) > 0, @pids := concat( @pids, ",", id ), 0 ) AS ischild 
-					FROM( 
-						SELECT id, pid, NAME 
-						FROM 
-						entniche_department t 
-						ORDER BY pid, id ) t1,
-						(SELECT @pids := ?) t2 ) t3 
-					where ischild != 0 
-							or  id=?
-				) b on (a.dept_id=b.id)
-				WHERE ` + searchSql + ` order by updatetime desc limit 100000) as a
-				LEFT JOIN entniche_user_customer b on (a.id=b.customer_id)
-				LEFT JOIN entniche_user c on (b.user_id=c.id)
-				GROUP BY  a.id  ` + allocSql + ` order by updatetime desc,	a.createtime desc`
+					(
+					SELECT
+						a.customer_id,
+						a.user_id
+					FROM
+						entniche_user_customer a
+						INNER JOIN (
+						SELECT DISTINCT
+							c.id 
+						FROM
+							entniche_department_parent a
+							INNER JOIN entniche_department_user b ON (
+								b.dept_id = ? 
+							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 ) 
+				 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 ) 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]
 	} else {
 		searchValues = append(searchValues, (pageIndex-1)*pageSize, pageSize)
-		log.Println(`SELECT GROUP_CONCAT(c.name) as staff_names,a.industry,a.createtime,a.name as customer_name,a.id as customer_id,
-				(SELECT b.time  FROM  entniche_project_track b WHERE b.customer_id = a.id  ORDER BY b.time desc LIMIT 0,1 ) AS updatetime
-				 from
-				(select a.name,a.id,a.createtime,a.area,a.industry FROM entniche_customer a
-				INNER JOIN (SELECT
-				id
-				FROM
-				(
-				SELECT
-					t1.id,
-					t1.NAME,
-					IF( find_in_set( pid, @pids ) > 0, @pids := concat( @pids, ",", id ), 0 ) AS ischild 
-					FROM( 
-						SELECT id, pid, NAME 
-						FROM 
-						entniche_department t 
-						ORDER BY pid, id ) t1,
-						(SELECT @pids := ?) t2 ) t3 
-					where ischild != 0 
-							or  id=?
-				) b on (a.dept_id=b.id)
-				WHERE `+searchSql+` order by updatetime desc limit ?,?) as a
-				LEFT JOIN entniche_user_customer b on (a.id=b.customer_id)
-				LEFT JOIN entniche_user c on (b.user_id=c.id)
-				GROUP BY  a.id  order by updatetime desc,	a.createtime  desc`, searchValues)
-		customersql = `SELECT GROUP_CONCAT(c.name) as staff_names,a.industry,a.createtime,a.name as customer_name,a.id as customer_id,
-				(SELECT b.time  FROM  entniche_project_track b WHERE b.customer_id = a.id  ORDER BY b.time desc LIMIT 0,1 ) AS updatetime
-				 from
-				(select a.name,a.id,a.createtime,a.area,a.industry FROM entniche_customer a
-				INNER JOIN (SELECT
-				id
+		customersql = `SELECT
+					GROUP_CONCAT( c.NAME ) AS staff_names,
+					b.createtime,
+					b.area,
+					b.industry,
+					b.NAME AS customer_name,
+					b.id AS customer_id,
+					( SELECT b.time FROM entniche_project_track b WHERE b.customer_id = a.customer_id ORDER BY b.time DESC LIMIT 0, 1 ) AS updatetime 
 				FROM
-				(
-				SELECT
-					t1.id,
-					t1.NAME,
-					IF( find_in_set( pid, @pids ) > 0, @pids := concat( @pids, ",", id ), 0 ) AS ischild 
-					FROM( 
-						SELECT id, pid, NAME 
-						FROM 
-						entniche_department t 
-						ORDER BY pid, id ) t1,
-						(SELECT @pids := ?) t2 ) t3 
-					where ischild != 0 
-							or  id=?
-				) b on (a.dept_id=b.id)
-				WHERE ` + searchSql + ` order by updatetime desc limit ?,?) as a
-				LEFT JOIN entniche_user_customer b on (a.id=b.customer_id)
-				LEFT JOIN entniche_user c on (b.user_id=c.id)
-				GROUP BY  a.id  order by updatetime desc,	a.createtime  desc`
-		customerList = util.Mysql.SelectBySql(customersql, searchValues...)
+					(
+					SELECT
+						a.customer_id,
+						a.user_id
+					FROM
+						entniche_user_customer a
+						INNER JOIN (
+						SELECT DISTINCT
+							c.id 
+						FROM
+							entniche_department_parent a
+							INNER JOIN entniche_department_user b ON (
+								b.dept_id = ? 
+							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 ) 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 )  WHERE ` + searchSql + `
+							GROUP BY  a.customer_id  ` + allocSql + ` order by updatetime desc,	b.createtime desc `
+		customerList = util.Mysql.SelectBySql(customersql+` limit ?,?`, searchValues...)
 		countValue = searchValues
 	}
 	countSql := `select count(*) from (` + customersql + `) d`

+ 2 - 2
go.mod

@@ -6,9 +6,9 @@ require (
 	app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a
 	app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae
 	bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230214091519-89a98c01ab0e
-	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230210052334-7b32c3b8c773
+	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230222052351-9d6fad062447
 	bp.jydev.jianyu360.cn/BaseService/resourceCenter v0.0.7
-	bp.jydev.jianyu360.cn/BaseService/userCenter v0.0.0-20230220014527-d2ee17034d1e
+	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.13
 	github.com/nsqio/go-nsq v1.1.0
 	github.com/robfig/cron v1.2.0
 	github.com/tealeg/xlsx v1.0.5

+ 4 - 4
go.sum

@@ -8,12 +8,12 @@ app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae h1:6rDDaz6yxvE8vi
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae/go.mod h1:b0zZHev3gmJao1Fo+2Z2KPVjsuLOJVvVxf+kCnu9WkA=
 bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230214091519-89a98c01ab0e h1:h+VEI3o1qC0jeCzkFGTrLI4f27cfa/W/y+0sXokWMgE=
 bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230214091519-89a98c01ab0e/go.mod h1:7Xhygw0KBuL4h0G76FnFg4otQcA9bmOO0c8M0FCjAyQ=
-bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230210052334-7b32c3b8c773 h1:IbbM9kFSbqJ44UpN99C2cZKX/X/yC03baBYJ7oc0j/w=
-bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230210052334-7b32c3b8c773/go.mod h1:5nimT8GJh46AyfeeDeyRlDQygMlO7TRM8Pwm41Gxemc=
+bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230222052351-9d6fad062447 h1:hrBqrsf2QHTrnoR9VTV4w7g2akDfbpQ+umNQvkkNs+Y=
+bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230222052351-9d6fad062447/go.mod h1:5nimT8GJh46AyfeeDeyRlDQygMlO7TRM8Pwm41Gxemc=
 bp.jydev.jianyu360.cn/BaseService/resourceCenter v0.0.7 h1:G6PHMWAHfYEuY6kbl7OM/KnCQf1Xa54mdhuP7JzK8/I=
 bp.jydev.jianyu360.cn/BaseService/resourceCenter v0.0.7/go.mod h1:rRiGzKG4F/fmkNxXQCxrkxNWc8yf1SmW8qWCKfGIQSM=
-bp.jydev.jianyu360.cn/BaseService/userCenter v0.0.0-20230220014527-d2ee17034d1e h1:7z7RA0hhnGXHWiLigKQSX/IpnLXqX/gFXPp8iJXx0Dc=
-bp.jydev.jianyu360.cn/BaseService/userCenter v0.0.0-20230220014527-d2ee17034d1e/go.mod h1:vDEKni2rnCraKgKnnCEIwsFmO92GxnpfKmNQ+83wKP0=
+bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.13 h1:aK3ya7aznINdAuEl7sKq9U2MvJidUfk6nxPGjjX+t3Y=
+bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.13/go.mod h1:vDEKni2rnCraKgKnnCEIwsFmO92GxnpfKmNQ+83wKP0=
 cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=