Browse Source

冲突合并

WH01243 2 years ago
parent
commit
524cded457
2 changed files with 120 additions and 118 deletions
  1. 1 1
      jyBXSubscribe/rpc/etc/db.yaml
  2. 119 117
      jyBXSubscribe/rpc/model/push.go

+ 1 - 1
jyBXSubscribe/rpc/etc/db.yaml

@@ -1,7 +1,7 @@
 mysql:
     main:
         dbName: jianyu
-        address: 192.168.3.242:3306
+        address: 192.168.3.149:3306
         userName: root
         password: Topnet123
         maxOpenConns: 5

+ 119 - 117
jyBXSubscribe/rpc/model/push.go

@@ -521,81 +521,6 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 			} else if spqp.FileExists == "-1" {
 				querys = append(querys, fmt.Sprintf("a.attachment_count is null"))
 			}
-		// 是否已读
-		if spqp.IsRead != "" {
-			if spqp.IsRead == "0" {
-				userStr += " and a.isvisit IS NULL"
-			} else if spqp.IsRead == "1" {
-				userStr += " and a.isvisit=1"
-			}
-		}
-		// 信息来源
-		if spqp.Source == "1" || spqp.Source == "2" || spqp.Source == "3" {
-			userStr += " and a.source=" + spqp.Source
-		}
-		if spqp.IsEnt {
-			var staffs []string
-			userStr += fmt.Sprintf(" and  a.entid='%s' ", spqp.EntId)
-			//判断是企业管理员还是部门管理员 部门管理员获取所有子部门
-			userEnt := EntInfo(common.IntAll(spqp.EntId), common.IntAll(spqp.EntUserId))
-			if !(userEnt.Role_admin_system || userEnt.Role_admin_department) {
-				result = []*bxsubscribe.SubscribeInfo{}
-				return
-			}
-			if userEnt.Role_admin_department { //部门管理员 获取所有部门和子部门员工
-				users := GetDisUsers(common.IntAll(spqp.EntId), userEnt.Dept.Id)
-				if users != nil && len(*users) > 0 {
-					for _, v := range *users {
-						if len(spqp.Staffs) > 0 {
-							for _, vv := range spqp.Staffs {
-								if fmt.Sprintf("%d", v.Id) == vv {
-									staffs = append(staffs, common.InterfaceToStr(v.Id))
-								}
-							}
-						} else {
-							staffs = append(staffs, common.InterfaceToStr(v.Id))
-						}
-					}
-				} else {
-					log.Printf("部门管理员为获取到部门员工:%s", spqp.EntUserId)
-					result = []*bxsubscribe.SubscribeInfo{}
-					return
-				}
-			} else if len(spqp.Staffs) > 0 {
-				staffs = spqp.Staffs
-			}
-			//老板商机管理需要查询全部来源
-			isNew := true
-			//商机管理判断
-			newCount := IC.MainMysql.CountBySql("select  count(id) from  entniche_info where  id =? and  isNew != 1 and  status=1", spqp.EntId)
-			if newCount > 0 {
-				isNew = false
-			}
-			// 无查询分配人员、是否已读
-			if spqp.IsRead == "" && len(staffs) == 0 {
-				//查询数量(需要去重)
-				countSql = fmt.Sprintf("select count(1) from %s a    where %s %s %s", aboutDbMsg[s.ModuleFlag].MysqlTable, strings.Join(querys, " and "), userStr, common.If(isNew, " and a.source = 2 ", ""))
-				//列表查询
-				findSql = fmt.Sprintf("select a.id,a.infoid,a.matchkeys,a.attachment_count from %s a  where  %s %s %s order by a.date desc,a.id desc",
-					aboutDbMsg[s.ModuleFlag].MysqlTable, userStr, common.If(isNew, " and a.source = 2 ", ""))
-			} else {
-				//查询分配人员或是否已读
-				staffQuery := " 1=1 "
-				if len(staffs) > 0 {
-					staffQuery += fmt.Sprintf(" and  a.userid in ('%s')  ", strings.Join(staffs, "','"))
-				}
-				if spqp.IsRead != "" {
-					if spqp.IsRead == "0" {
-						staffQuery += " and a.isvisit IS NULL"
-					} else if spqp.IsRead == "1" {
-						staffQuery += " and a.isvisit=1"
-					}
-				}
-				countSql = fmt.Sprintf("select count(1) from %s a s where %s %s %s and ((%s) or EXISTS (SELECT 1 from %s c  WHERE c.source=3 %s and %s and a.id=c.pid and (%s))) ", aboutDbMsg[s.ModuleFlag].MysqlTable, strings.Join(querys, " and "), userStr, common.If(isNew, " and a.source = 2 ", ""), staffQuery, aboutDbMsg[s.ModuleFlag].MysqlTable, strings.ReplaceAll(userStr, "a.", "c."), strings.Join(querys, " and "), strings.ReplaceAll(staffQuery, "a.", "c."))
-				//列表查询
-				findSql = fmt.Sprintf("select a.id,a.infoid,a.matchkeys,a.attachment_count from %s a where %s %s %s and ((%s) or EXISTS (SELECT 1 from %s c  WHERE c.source=3 %s and %s and a.id=c.pid and (%s))) order by a.date desc,a.id desc ", aboutDbMsg[s.ModuleFlag].MysqlTable, strings.Join(querys, " and "), userStr, common.If(isNew, " and a.source = 2 ", ""), staffQuery, aboutDbMsg[s.ModuleFlag].MysqlTable, strings.ReplaceAll(userStr, "a.", "c."), strings.Join(querys, " and "), strings.ReplaceAll(staffQuery, "a.", "c."))
-			}
-		} else {
 			// 是否已读
 			if spqp.IsRead != "" {
 				if spqp.IsRead == "0" {
@@ -608,57 +533,134 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 			if spqp.Source == "1" || spqp.Source == "2" || spqp.Source == "3" {
 				userStr += " and a.source=" + spqp.Source
 			}
-			if spqp.PositionType == 1 {
-				//企业主体是企业的个人查询
-				if spqp.UserType == SubVipFlag {
-					userStr += fmt.Sprintf(" and  a.userid='%s' and (  a.product=1 or a.product=3 or a.source>1     ) ", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
-				} else if spqp.UserType == MemberFlag {
-					userStr += fmt.Sprintf(" and  a.userid='%s' and (  a.product=2 or a.product=3  or a.source>1  ) ", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
-				} else if spqp.UserType == EntnicheFlag {
-					userStr += fmt.Sprintf(" and  a.userid='%s' and (  a.product is null or a.product=3  or a.source>1  ) ", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+			if spqp.IsEnt {
+				var staffs []string
+				userStr += fmt.Sprintf(" and  a.entid='%s' ", spqp.EntId)
+				//判断是企业管理员还是部门管理员 部门管理员获取所有子部门
+				userEnt := EntInfo(common.IntAll(spqp.EntId), common.IntAll(spqp.EntUserId))
+				if !(userEnt.Role_admin_system || userEnt.Role_admin_department) {
+					result = []*bxsubscribe.SubscribeInfo{}
+					return
+				}
+				if userEnt.Role_admin_department { //部门管理员 获取所有部门和子部门员工
+					users := GetDisUsers(common.IntAll(spqp.EntId), userEnt.Dept.Id)
+					if users != nil && len(*users) > 0 {
+						for _, v := range *users {
+							if len(spqp.Staffs) > 0 {
+								for _, vv := range spqp.Staffs {
+									if fmt.Sprintf("%d", v.Id) == vv {
+										staffs = append(staffs, common.InterfaceToStr(v.Id))
+									}
+								}
+							} else {
+								staffs = append(staffs, common.InterfaceToStr(v.Id))
+							}
+						}
+					} else {
+						log.Printf("部门管理员为获取到部门员工:%s", spqp.EntUserId)
+						result = []*bxsubscribe.SubscribeInfo{}
+						return
+					}
+				} else if len(spqp.Staffs) > 0 {
+					staffs = spqp.Staffs
+				}
+				//老板商机管理需要查询全部来源
+				isNew := true
+				//商机管理判断
+				newCount := IC.MainMysql.CountBySql("select  count(id) from  entniche_info where  id =? and  isNew != 1 and  status=1", spqp.EntId)
+				if newCount > 0 {
+					isNew = false
+				}
+				// 无查询分配人员、是否已读
+				if spqp.IsRead == "" && len(staffs) == 0 {
+					//查询数量(需要去重)
+					countSql = fmt.Sprintf("select count(1) from %s a    where %s %s %s", aboutDbMsg[s.ModuleFlag].MysqlTable, strings.Join(querys, " and "), userStr, common.If(isNew, " and a.source = 2 ", ""))
+					//列表查询
+					findSql = fmt.Sprintf("select a.id,a.infoid,a.matchkeys,a.attachment_count from %s a  where  %s %s %s order by a.date desc,a.id desc",
+						aboutDbMsg[s.ModuleFlag].MysqlTable, userStr, common.If(isNew, " and a.source = 2 ", ""))
 				} else {
-					userStr += fmt.Sprintf(" and  a.userid='%s' ", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+					//查询分配人员或是否已读
+					staffQuery := " 1=1 "
+					if len(staffs) > 0 {
+						staffQuery += fmt.Sprintf(" and  a.userid in ('%s')  ", strings.Join(staffs, "','"))
+					}
+					if spqp.IsRead != "" {
+						if spqp.IsRead == "0" {
+							staffQuery += " and a.isvisit IS NULL"
+						} else if spqp.IsRead == "1" {
+							staffQuery += " and a.isvisit=1"
+						}
+					}
+					countSql = fmt.Sprintf("select count(1) from %s a s where %s %s %s and ((%s) or EXISTS (SELECT 1 from %s c  WHERE c.source=3 %s and %s and a.id=c.pid and (%s))) ", aboutDbMsg[s.ModuleFlag].MysqlTable, strings.Join(querys, " and "), userStr, common.If(isNew, " and a.source = 2 ", ""), staffQuery, aboutDbMsg[s.ModuleFlag].MysqlTable, strings.ReplaceAll(userStr, "a.", "c."), strings.Join(querys, " and "), strings.ReplaceAll(staffQuery, "a.", "c."))
+					//列表查询
+					findSql = fmt.Sprintf("select a.id,a.infoid,a.matchkeys,a.attachment_count from %s a where %s %s %s and ((%s) or EXISTS (SELECT 1 from %s c  WHERE c.source=3 %s and %s and a.id=c.pid and (%s))) order by a.date desc,a.id desc ", aboutDbMsg[s.ModuleFlag].MysqlTable, strings.Join(querys, " and "), userStr, common.If(isNew, " and a.source = 2 ", ""), staffQuery, aboutDbMsg[s.ModuleFlag].MysqlTable, strings.ReplaceAll(userStr, "a.", "c."), strings.Join(querys, " and "), strings.ReplaceAll(staffQuery, "a.", "c."))
 				}
 			} else {
-				if s.ModuleFlag == EntnicheFlag {
-					//老商机管理个人订阅查询
-					userStr += fmt.Sprintf(" and  a.userid='%s'  and a.product is null", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+				// 是否已读
+				if spqp.IsRead != "" {
+					if spqp.IsRead == "0" {
+						userStr += " and a.isvisit IS NULL"
+					} else if spqp.IsRead == "1" {
+						userStr += " and a.isvisit=1"
+					}
+				}
+				// 信息来源
+				if spqp.Source == "1" || spqp.Source == "2" || spqp.Source == "3" {
+					userStr += " and a.source=" + spqp.Source
+				}
+				if spqp.PositionType == 1 {
+					//企业主体是企业的个人查询
+					if spqp.UserType == SubVipFlag {
+						userStr += fmt.Sprintf(" and  a.userid='%s' and (  a.product=1 or a.product=3 or a.source>1     ) ", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+					} else if spqp.UserType == MemberFlag {
+						userStr += fmt.Sprintf(" and  a.userid='%s' and (  a.product=2 or a.product=3  or a.source>1  ) ", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+					} else if spqp.UserType == EntnicheFlag {
+						userStr += fmt.Sprintf(" and  a.userid='%s' and (  a.product is null or a.product=3  or a.source>1  ) ", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+					} else {
+						userStr += fmt.Sprintf(" and  a.userid='%s' ", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+					}
 				} else {
-					//个人订阅查询
-					userStr += fmt.Sprintf(" and  a.userid='%s'", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+					if s.ModuleFlag == EntnicheFlag {
+						//老商机管理个人订阅查询
+						userStr += fmt.Sprintf(" and  a.userid='%s'  and a.product is null", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+					} else {
+						//个人订阅查询
+						userStr += fmt.Sprintf(" and  a.userid='%s'", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+					}
 				}
+				//查询数量
+				countSql = fmt.Sprintf("select count(1) as count from %s  a  where 1=1 %s and %s", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr, strings.Join(querys, " and "))
+				//列表查询语句
+				findSql = "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,a.attachment_count"
+				if s.ModuleFlag == EntnicheFlag {
+					findSql += ", IF(a.source is NULL,1,a.source) as  source "
+				}
+				if s.ModuleFlag != MemberFlag && s.ModuleFlag != EntnicheFlag {
+					findSql += ",a.isvip"
+				}
+				findSql = fmt.Sprintf("%s from %s  a  where  %s %s "+
+					" order by a.date desc,a.id desc", findSql, aboutDbMsg[s.ModuleFlag].MysqlTable, strings.Join(querys, " and "), userStr)
 			}
-			//查询数量
-			countSql = fmt.Sprintf("select count(1) as count from %s  a  where 1=1 %s and %s", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr, strings.Join(querys, " and "))
-			//列表查询语句
-			findSql = "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,a.attachment_count"
-			if s.ModuleFlag == EntnicheFlag {
-				findSql += ", IF(a.source is NULL,1,a.source) as  source "
-			}
-			if s.ModuleFlag != MemberFlag && s.ModuleFlag != EntnicheFlag {
-				findSql += ",a.isvip"
-			}
-			findSql = fmt.Sprintf("%s from %s  a  where  %s %s "+
-				" order by a.date desc,a.id desc", findSql, aboutDbMsg[s.ModuleFlag].MysqlTable, strings.Join(querys, " and "), userStr)
+			//查询总数
+			logx.Info("countSql", countSql)
+			count = spqp.BaseServiceMysql.CountBySql(countSql)
 		}
-		//查询总数
-		logx.Info("countSql", countSql)
-		count = spqp.BaseServiceMysql.CountBySql(countSql)
-	}
-	if isLimit {
-		findSql += fmt.Sprintf(" limit %d,%d", (spqp.PageNum-1)*size, size)
-	}
-	logx.Info(spqp.NewUserId, "subscribePush query sql:", findSql)
-	list := spqp.BaseServiceMysql.SelectBySql(findSql)
-	if list != nil && len(*list) > 0 {
-		pushCas := s.GetJyPushs(*list)
-		if !spqp.Export {
-			result = s.GetInfoByIds(spqp.Mgo_bidding, spqp.Bidding, spqp.Bidding_back, pushCas, spqp.IsPayUser)
+		if isLimit {
+			findSql += fmt.Sprintf(" limit %d,%d", (spqp.PageNum-1)*size, size)
+		}
+		logx.Info(spqp.NewUserId, "subscribePush query sql:", findSql)
+		list := spqp.BaseServiceMysql.SelectBySql(findSql)
+		if list != nil && len(*list) > 0 {
+			pushCas := s.GetJyPushs(*list)
+			if !spqp.Export {
+				result = s.GetInfoByIds(spqp.Mgo_bidding, spqp.Bidding, spqp.Bidding_back, pushCas, spqp.IsPayUser)
+			} else {
+				result = s.GetOnlyExportInfo(pushCas)
+			}
 		} else {
-			result = s.GetOnlyExportInfo(pushCas)
+			result = []*bxsubscribe.SubscribeInfo{}
 		}
-	} else {
-		result = []*bxsubscribe.SubscribeInfo{}
+		return
 	}
 	return
 }