Browse Source

wip:消息分发接口自测提交

wangkaiyue 2 years ago
parent
commit
54aad140c5

+ 12 - 1
jyBXSubscribe/rpc/internal/logic/msgdistributorlogic.go

@@ -3,6 +3,7 @@ package logic
 import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
+	"app.yhyue.com/moapp/jybase/redis"
 	"context"
 	"database/sql"
 	"fmt"
@@ -74,7 +75,7 @@ func (l *MsgDistributorLogic) MsgDistributor(in *bxsubscribe.MsgDistributorReq)
 		}
 	}
 	//查询分发信息内容
-	msgRes := IC.BaseServiceMysql.SelectBySql(fmt.Sprintf("SELECT p.* FROM pushentniche p,(SELECT infoid,MIN(id) as id FROM pushentniche WHERE infoid in ('%s') and entid =? GROUP BY infoid) b WHERE p.id=b.id", strings.Join(infoIds, "','")), in.EntId)
+	msgRes := IC.BaseServiceMysql.SelectBySql(fmt.Sprintf("SELECT p.* FROM pushentniche p,(SELECT infoid,MIN(id) as id FROM pushentniche WHERE infoid in ('%s') and entid =? and source = 2 GROUP BY infoid) b WHERE p.id=b.id", strings.Join(infoIds, "','")), in.EntId)
 	if msgRes == nil || len(*msgRes) == 0 {
 		return &bxsubscribe.StatusResp{ErrorCode: -1, ErrorMsg: "获取分发信息内容异常"}, nil
 	}
@@ -99,6 +100,16 @@ func (l *MsgDistributorLogic) MsgDistributor(in *bxsubscribe.MsgDistributorReq)
 		}
 		return true
 	})
+	//清除推送列表缓存
+	for _, staff := range staffs {
+		//today
+		redis.Del("pushcache_2_b", fmt.Sprintf("entnichepush_%s", staff))
+
+		//all
+		redis.Del("pushcache_2_a", fmt.Sprintf("all_entnichepush_vip_%s", staff))
+		redis.Del("pushcache_2_a", fmt.Sprintf("all_entnichepush_member_%s", staff))
+	}
+
 	if !ok {
 		return &bxsubscribe.StatusResp{ErrorCode: -1, ErrorMsg: "数据分发异常"}, nil
 	}

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

@@ -550,13 +550,13 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 			//查询数量(需要去重)
 			if len(querys) > 1 {
 				//countSql = fmt.Sprintf("select count(1) as count from %s  a STRAIGHT_JOIN %s b ON %s and a.infoid = b.infoid  %s where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, userStr, leftJoinStr, strings.Join(querys, " and "))
-				countSql = fmt.Sprintf("SELECT count(1) AS count FROM (SELECT DISTINCT matchkeys,infoid FROM %s a WHERE 1=1 %s )  a STRAIGHT_JOIN %s b ON  a.infoid = b.infoid  %s where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr, Baseinfo, leftJoinStr, strings.Join(querys, " and "))
+				countSql = fmt.Sprintf("SELECT count(1) AS count FROM (SELECT DISTINCT matchkeys,infoid FROM %s a WHERE source=2 %s )  a STRAIGHT_JOIN %s b ON  a.infoid = b.infoid  %s where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr, Baseinfo, leftJoinStr, strings.Join(querys, " and "))
 			} else {
 				//countSql = fmt.Sprintf("select count(1) as count from %s  a where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr)
-				countSql = fmt.Sprintf("SELECT count(1) AS count FROM ( SELECT DISTINCT matchkeys,infoid FROM %s a WHERE 1=1 %s ) AS data", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr)
+				countSql = fmt.Sprintf("SELECT count(1) AS count FROM ( SELECT DISTINCT matchkeys,infoid FROM %s a WHERE source=2 %s ) AS data", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr)
 			}
 			//列表查询
-			findSql = fmt.Sprintf("select a.infoid,a.matchkeys,b.isvalidfile as attachment_count from (SELECT DISTINCT matchkeys,infoid FROM %s a WHERE 1=1 %s ) a STRAIGHT_JOIN %s b ON a.infoid = b.infoid  %s where %s"+
+			findSql = fmt.Sprintf("select a.infoid,a.matchkeys,b.isvalidfile as attachment_count from (SELECT DISTINCT matchkeys,infoid FROM %s a WHERE source=2 %s ) a STRAIGHT_JOIN %s b ON a.infoid = b.infoid  %s where %s"+
 				" order by b.publishtime desc", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr, Baseinfo, leftJoinStr, strings.Join(querys, " and "))
 		} else {
 			if spqp.BuySubject == 1 {