|
@@ -15,12 +15,8 @@ import (
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
"app.yhyue.com/moapp/jybase/date"
|
|
|
"app.yhyue.com/moapp/jybase/encrypt"
|
|
|
-<<<<<<< HEAD
|
|
|
- "app.yhyue.com/moapp/jybase/esv1"
|
|
|
- P "app.yhyue.com/moapp/jybase/mapping"
|
|
|
-=======
|
|
|
elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
->>>>>>> feature/v1.1.18
|
|
|
+ P "app.yhyue.com/moapp/jybase/mapping"
|
|
|
"app.yhyue.com/moapp/jybase/mongodb"
|
|
|
"app.yhyue.com/moapp/jybase/mysql"
|
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
@@ -586,7 +582,6 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
} else if len(spqp.Staffs) > 0 {
|
|
|
staffs = spqp.Staffs
|
|
|
}
|
|
|
-<<<<<<< HEAD
|
|
|
//老板商机管理需要查询全部来源
|
|
|
isNew := true
|
|
|
//商机管理判断
|
|
@@ -601,40 +596,19 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
//列表查询
|
|
|
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, strings.Join(querys, " and "), userStr, common.If(isNew, " and a.source = 2 ", ""))
|
|
|
-=======
|
|
|
- // 空查询优化,不走关联表计算数量
|
|
|
- if len(querys) == 1 {
|
|
|
- countSql = fmt.Sprintf("select count(1) from %s a %s where 1=1 %s ", aboutDbMsg[s.ModuleFlag].MysqlTable, leftJoinStr, userStr)
|
|
|
- //列表查询
|
|
|
- findSql = fmt.Sprintf("select a.id,a.infoid,a.matchkeys,b.isvalidfile as attachment_count, IF(a.source is NULL,1,a.source) as source from %s a LEFT JOIN %s b ON a.infoid = b.infoid %s where 1=1 %s order by a.date desc,a.id desc",
|
|
|
- aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, userStr)
|
|
|
->>>>>>> feature/v1.1.18
|
|
|
} else {
|
|
|
- // 无查询分配人员、是否已读
|
|
|
- if spqp.IsRead == "" && len(staffs) == 0 {
|
|
|
- //查询数量(需要去重)
|
|
|
- countSql = fmt.Sprintf("select count(1) from %s a STRAIGHT_JOIN %s b ON a.infoid = b.infoid %s where %s %s ", 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, IF(a.source is NULL,1,a.source) as source from %s a STRAIGHT_JOIN %s b ON a.infoid = b.infoid %s where %s %s order by a.date desc,a.id desc",
|
|
|
- aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.Join(querys, " and "), userStr)
|
|
|
- } 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"
|
|
|
- }
|
|
|
+ //查询分配人员或是否已读
|
|
|
+ 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 STRAIGHT_JOIN %s b ON a.infoid = b.infoid %s where %s %s and %s ", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.Join(querys, " and "), userStr, staffQuery)
|
|
|
- //列表查询
|
|
|
- findSql = fmt.Sprintf("select a.id,a.infoid,a.matchkeys,b.isvalidfile as attachment_count,IF(a.source is NULL,1,a.source) as source from %s a STRAIGHT_JOIN %s b ON a.infoid = b.infoid %s where %s %s and %s order by a.date desc,a.id desc ", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.Join(querys, " and "), userStr, staffQuery)
|
|
|
}
|
|
|
-<<<<<<< HEAD
|
|
|
//countSql = fmt.Sprintf("select count(1) from %s a where %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, staffQuery, aboutDbMsg[s.ModuleFlag].MysqlTable, strings.ReplaceAll(userStr, "a.", "c."), strings.Join(querys, " and "), strings.ReplaceAll(staffQuery, "a.", "c."))
|
|
|
countSql = fmt.Sprintf("select count(1) from %s a where %s %s and %s ", aboutDbMsg[s.ModuleFlag].MysqlTable, strings.Join(querys, " and "), userStr, staffQuery)
|
|
|
|
|
@@ -642,8 +616,6 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
//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."))
|
|
|
findSql = fmt.Sprintf("select a.id,a.infoid,a.matchkeys,a.attachment_count,IF(a.source is NULL,1,a.source) as source from %s a where %s %s and %s order by a.date desc,a.id desc ", aboutDbMsg[s.ModuleFlag].MysqlTable, strings.Join(querys, " and "), userStr, staffQuery)
|
|
|
|
|
|
-=======
|
|
|
->>>>>>> feature/v1.1.18
|
|
|
}
|
|
|
} else {
|
|
|
// 是否已读
|