Explorar el Código

wip:旧版商机管理查询所有信息修改

wangkaiyue hace 2 años
padre
commit
77d517cdec
Se han modificado 1 ficheros con 13 adiciones y 13 borrados
  1. 13 13
      jyBXSubscribe/rpc/model/push.go

+ 13 - 13
jyBXSubscribe/rpc/model/push.go

@@ -530,17 +530,21 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 				staffs = spqp.Staffs
 			}
 
+			//老板商机管理需要查询全部来源
+			isNew := false
+			//商机管理判断
+			newCount := IC.MainMysql.CountBySql("select  count(id) from  entniche_info where  id =? and  isNew != 1 and  status=1", spqp.EntId)
+			if newCount > 0 { //新商机管理
+				isNew = true
+			}
+
 			// 无查询分配人员、是否已读
 			if spqp.IsRead == "" && len(staffs) == 0 {
 				//查询数量(需要去重)
-				//if len(querys) > 1 {
-				countSql = fmt.Sprintf("select count(1) from %s a STRAIGHT_JOIN %s b ON  a.infoid = b.infoid  %s where  %s %s and a.source = 2", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.Join(querys, " and "), userStr)
-				//} else {
-				//	countSql = fmt.Sprintf("select count(1) from %s a WHERE 1=1 %s ", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr)
-				//}
+				countSql = fmt.Sprintf("select count(1) from %s a STRAIGHT_JOIN %s b ON  a.infoid = b.infoid  %s where %s %s %s", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.Join(querys, " and "), userStr, common.If(isNew, " and a.source = 2 ", ""))
 				//列表查询
-				findSql = fmt.Sprintf("select a.id,a.infoid,a.matchkeys,b.isvalidfile as attachment_count from %s a STRAIGHT_JOIN %s b ON a.infoid = b.infoid  %s where  %s %s and a.source = 2 order by a.date desc,a.id desc",
-					aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.Join(querys, " and "), userStr)
+				findSql = fmt.Sprintf("select a.id,a.infoid,a.matchkeys,b.isvalidfile as attachment_count from %s a STRAIGHT_JOIN %s b ON a.infoid = b.infoid  %s where  %s %s %s order by a.date desc,a.id desc",
+					aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.Join(querys, " and "), userStr, common.If(isNew, " and a.source = 2 ", ""))
 			} else {
 				//查询分配人员或是否已读
 				staffQuery := " 1=1 "
@@ -554,13 +558,9 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 						staffQuery += " and a.isvisit=1"
 					}
 				}
-				//if len(querys) > 1 {
-				countSql = fmt.Sprintf("select count(1) from %s a STRAIGHT_JOIN %s b ON  a.infoid = b.infoid  %s where a.source=2 %s and %s and ((%s) or EXISTS (SELECT 1 from %s c STRAIGHT_JOIN %s b ON c.infoid = b.infoid  %s WHERE c.source=3 %s and %s and a.id=c.pid and (%s))) ", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, userStr, strings.Join(querys, " and "), staffQuery, aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.ReplaceAll(userStr, "a.", "c."), strings.Join(querys, " and "), strings.ReplaceAll(staffQuery, "a.", "c."))
-				//} else {
-				//	countSql = fmt.Sprintf("select count(1) from %s a WHERE a.source=2 %s and ((%s) or EXISTS (SELECT 1 from %s c WHERE c.source=3 %s and a.id=pid and (%s))) ", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr, staffQuery, aboutDbMsg[s.ModuleFlag].MysqlTable, strings.ReplaceAll(userStr, "a.", "c."), strings.ReplaceAll(staffQuery, "a.", "c."))
-				//}
+				countSql = fmt.Sprintf("select count(1) from %s a STRAIGHT_JOIN %s b ON  a.infoid = b.infoid  %s where %s %s %s and ((%s) or EXISTS (SELECT 1 from %s c STRAIGHT_JOIN %s b ON c.infoid = b.infoid  %s WHERE c.source=3 %s and %s and a.id=c.pid and (%s))) ", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.Join(querys, " and "), userStr, common.If(isNew, " and a.source = 2 ", ""), staffQuery, aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.ReplaceAll(userStr, "a.", "c."), strings.Join(querys, " and "), strings.ReplaceAll(staffQuery, "a.", "c."))
 				//列表查询
-				findSql = fmt.Sprintf("select a.id,a.infoid,a.matchkeys,b.isvalidfile as attachment_count from %s a STRAIGHT_JOIN %s b ON  a.infoid = b.infoid  %s where a.source=2 %s and %s and ((%s) or EXISTS (SELECT 1 from %s c STRAIGHT_JOIN %s b ON c.infoid = b.infoid  %s 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, Baseinfo, leftJoinStr, userStr, strings.Join(querys, " and "), staffQuery, aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.ReplaceAll(userStr, "a.", "c."), strings.Join(querys, " and "), strings.ReplaceAll(staffQuery, "a.", "c."))
+				findSql = fmt.Sprintf("select a.id,a.infoid,a.matchkeys,b.isvalidfile as attachment_count from %s a STRAIGHT_JOIN %s b ON  a.infoid = b.infoid  %s where %s %s %s and ((%s) or EXISTS (SELECT 1 from %s c STRAIGHT_JOIN %s b ON c.infoid = b.infoid  %s 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, Baseinfo, leftJoinStr, strings.Join(querys, " and "), userStr, common.If(isNew, " and a.source = 2 ", ""), staffQuery, aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.ReplaceAll(userStr, "a.", "c."), strings.Join(querys, " and "), strings.ReplaceAll(staffQuery, "a.", "c."))
 			}
 		} else {
 			// 是否已读