|
@@ -536,7 +536,18 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
querys = append(querys, fmt.Sprintf("b.isvalidfile =0 "))
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ // 是否已读
|
|
|
+ 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)
|
|
@@ -568,20 +579,13 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
} 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 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 ", ""))
|
|
|
+ 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 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 ", ""))
|
|
|
+ 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 order by a.date desc,a.id desc",
|
|
|
+ aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.Join(querys, " and "), userStr)
|
|
|
} else {
|
|
|
//查询分配人员或是否已读
|
|
|
staffQuery := " 1=1 "
|
|
@@ -595,23 +599,11 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
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 %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."))
|
|
|
+ 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 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."))
|
|
|
+ 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 %s order by a.date desc,a.id desc ", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.Join(querys, " and "), userStr, staffQuery)
|
|
|
}
|
|
|
} else {
|
|
|
- // 是否已读
|
|
|
- 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 {
|