|
@@ -593,92 +593,95 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
} else {
|
|
|
//查询分配人员或是否已读
|
|
|
staffQuery := " 1=1 "
|
|
|
- if len(staffs) > 0 {
|
|
|
+ if len(spqp.Staffs) > 0 {
|
|
|
+ staffQuery += fmt.Sprintf(" and a.userid in ('%s') ", strings.Join(staffs, "','"))
|
|
|
+ } else {
|
|
|
staffQuery += fmt.Sprintf(" and a.userid in (0,'%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 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)
|
|
|
-
|
|
|
- //列表查询
|
|
|
- //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)
|
|
|
-
|
|
|
}
|
|
|
- } else {
|
|
|
- // 是否已读
|
|
|
if spqp.IsRead != "" {
|
|
|
if spqp.IsRead == "0" {
|
|
|
- userStr += " and a.isvisit IS NULL"
|
|
|
+ staffQuery += " and a.isvisit IS NULL"
|
|
|
} else if spqp.IsRead == "1" {
|
|
|
- userStr += " and a.isvisit=1"
|
|
|
+ staffQuery += " 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)))
|
|
|
- }
|
|
|
+ //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)
|
|
|
+
|
|
|
+ //列表查询
|
|
|
+ //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)
|
|
|
+
|
|
|
+ }
|
|
|
+ } 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 {
|
|
|
+ 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 {
|
|
|
- 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)))
|
|
|
- }
|
|
|
+ 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"
|
|
|
+ } else {
|
|
|
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"
|
|
|
+ //老商机管理个人订阅查询
|
|
|
+ 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)))
|
|
|
}
|
|
|
- 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)
|
|
|
- if spqp.NotReturnCount == 0 {
|
|
|
- count = spqp.BaseServiceMysql.CountBySql(countSql)
|
|
|
+ //查询数量
|
|
|
+ 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 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)
|
|
|
+ if s.ModuleFlag != MemberFlag && s.ModuleFlag != EntnicheFlag {
|
|
|
+ findSql += ",a.isvip"
|
|
|
}
|
|
|
- } else {
|
|
|
- result = []*bxsubscribe.SubscribeInfo{}
|
|
|
+ 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)
|
|
|
}
|
|
|
- return
|
|
|
+ //查询总数
|
|
|
+ logx.Info("countSql", countSql)
|
|
|
+ if spqp.NotReturnCount == 0 {
|
|
|
+ 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)
|
|
|
+} else {
|
|
|
+result = s.GetOnlyExportInfo(pushCas)
|
|
|
+}
|
|
|
+} else {
|
|
|
+result = []*bxsubscribe.SubscribeInfo{}
|
|
|
+}
|
|
|
+return
|
|
|
}
|
|
|
|
|
|
// GetOnlyInfoId 获取信息id
|