Browse Source

Merge branch 'feature/v1.1.64' of https://jygit.jydev.jianyu360.cn/BaseService/jyMicroservices into feature/v1.1.64

fuwencai 7 months ago
parent
commit
7da314ae63

+ 6 - 2
jyBXSubscribe/rpc/internal/logic/bidreclistlogic.go

@@ -27,8 +27,12 @@ func NewBidRecListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BidRec
 
 
 // 订阅推荐列表
 // 订阅推荐列表
 func (l *BidRecListLogic) BidRecList(in *bxsubscribe.BidRecListReq) (*bxsubscribe.SubscribeInfosResp, error) {
 func (l *BidRecListLogic) BidRecList(in *bxsubscribe.BidRecListReq) (*bxsubscribe.SubscribeInfosResp, error) {
-	var list []*bxsubscribe.SubscribeInfo
-	hasNextPage, total, list := model.NewSubscribePush("").SubRecList(common.ObjToString(common.If(in.PositionType == 0, in.UserId, in.EntUserId)), []model.ViewKeyWord{})
+	var (
+		list        []*bxsubscribe.SubscribeInfo
+		hasNextPage bool
+		total       int64
+	)
+	hasNextPage, total, list = model.NewSubscribePush("").SubRecList(common.ObjToString(common.If(in.PositionType == 0, in.UserId, in.EntUserId)), []model.ViewKeyWord{}, model.PageSize)
 	if len(list) == 0 { // 订阅更多
 	if len(list) == 0 { // 订阅更多
 		hasNextPage, total, list = model.NewSubscribePush("").GetRecListByEs()
 		hasNextPage, total, list = model.NewSubscribePush("").GetRecListByEs()
 	}
 	}

+ 1 - 1
jyBXSubscribe/rpc/internal/logic/bypushhistorylogic.go

@@ -104,7 +104,7 @@ func (l *ByPushHistoryLogic) ByPushHistory(in *bxsubscribe.SubscribeInfosReq) (*
 	if len(spqp.SelectInfoIds) > 0 {
 	if len(spqp.SelectInfoIds) > 0 {
 		ids, keyWords = spqp.ExportPushFormat()
 		ids, keyWords = spqp.ExportPushFormat()
 	} else {
 	} else {
-		_, _, list := model.NewSubscribePush(vipType).Datas(spqp, bsp)
+		_, _, list, _ := model.NewSubscribePush(vipType).Datas(spqp, bsp)
 		if list == nil || len(list) == 0 {
 		if list == nil || len(list) == 0 {
 			return &bxsubscribe.ByPushHistoryResp{
 			return &bxsubscribe.ByPushHistoryResp{
 				ErrorCode: 1,
 				ErrorCode: 1,

+ 20 - 9
jyBXSubscribe/rpc/internal/logic/getsublistlogic.go

@@ -8,6 +8,7 @@ import (
 	"bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/type/bxsubscribe"
 	"bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/type/bxsubscribe"
 	"context"
 	"context"
 	"fmt"
 	"fmt"
+	"log"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
 	"time"
 	"time"
@@ -33,6 +34,9 @@ func NewGetSubListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSub
 // GetSubList 获取订阅推送列表
 // GetSubList 获取订阅推送列表
 func (l *GetSubListLogic) GetSubList(in *bxsubscribe.SubscribeInfosReq) (*bxsubscribe.SubscribeInfosResp, error) {
 func (l *GetSubListLogic) GetSubList(in *bxsubscribe.SubscribeInfosReq) (*bxsubscribe.SubscribeInfosResp, error) {
 	start := time.Now().Unix()
 	start := time.Now().Unix()
+	if in.PageNum <= 0 {
+		in.PageNum = 1
+	}
 	//1、推送信息已读标识
 	//1、推送信息已读标识
 	//超级订阅 i_apppushunread=0
 	//超级订阅 i_apppushunread=0
 	//大会员 i_member_apppushunread=0
 	//大会员 i_member_apppushunread=0
@@ -111,38 +115,45 @@ func (l *GetSubListLogic) GetSubList(in *bxsubscribe.SubscribeInfosReq) (*bxsubs
 	if in.UserType == model.EntnicheFlag {
 	if in.UserType == model.EntnicheFlag {
 		spqp.UserId = common.InterfaceToStr(spqp.EntUserId)
 		spqp.UserId = common.InterfaceToStr(spqp.EntUserId)
 	}
 	}
-
+	var tip string
 	sp := model.NewSubscribePush(in.UserType)
 	sp := model.NewSubscribePush(in.UserType)
 	//用户信息
 	//用户信息
 	bsp := sp.GetUserInfo(spqp)
 	bsp := sp.GetUserInfo(spqp)
-	hasNextPage, total, list := model.NewSubscribePush(in.UserType).Datas(spqp, bsp)
+	hasNextPage, total, list, tipBool := model.NewSubscribePush(in.UserType).Datas(spqp, bsp)
 	start1 := time.Now().Unix()
 	start1 := time.Now().Unix()
 	logx.Info("1、查询数据用户", start1-start)
 	logx.Info("1、查询数据用户", start1-start)
 	/*
 	/*
 	 *无推送记录生成推送记录
 	 *无推送记录生成推送记录
-	 *免费用户默认推送50条
-	 *大会员、新版商机管理、超级订阅用户 默认推送1000条记录
+	 *免费用户默认推送 50 
+	 *大会员、新版商机管理、超级订阅用户 默认推送 1000 条记录
 	 */
 	 */
-	var tip string
 	isRecommend := "1" //1:老数据 2:历史(clickhouse) 3:新数据
 	isRecommend := "1" //1:老数据 2:历史(clickhouse) 3:新数据
 	if in.PageNum == 1 && spqp.IsEmpty() && (len(list) == 0 || (in.PositionType == 0 && spqp.SubPushInactive == -1)) && in.IsEnt == false {
 	if in.PageNum == 1 && spqp.IsEmpty() && (len(list) == 0 || (in.PositionType == 0 && spqp.SubPushInactive == -1)) && in.IsEnt == false {
 		hasNextPage, total, list = model.NewSubscribePush(in.UserType).DefaultDatas(spqp, bsp, in.UserType)
 		hasNextPage, total, list = model.NewSubscribePush(in.UserType).DefaultDatas(spqp, bsp, in.UserType)
 		if in.Stag == "home" {
 		if in.Stag == "home" {
 			if len(list) == 0 {
 			if len(list) == 0 {
 				isRecommend = "2"
 				isRecommend = "2"
-				hasNextPage, total, list = model.NewSubscribePush(in.UserType).SubRecList(common.ObjToString(common.If(in.PositionType == 0, spqp.UserId, spqp.EntUserId)), bsp.Keyword)
+				hasNextPage, total, list = model.NewSubscribePush(in.UserType).SubRecList(common.ObjToString(common.If(in.PositionType == 0, spqp.UserId, spqp.EntUserId)), bsp.Keyword, bsp.Size)
 			}
 			}
 			if len(list) == 0 {
 			if len(list) == 0 {
 				isRecommend = "3"
 				isRecommend = "3"
 				hasNextPage, total, list = model.NewSubscribePush(in.UserType).GetRecListByEs()
 				hasNextPage, total, list = model.NewSubscribePush(in.UserType).GetRecListByEs()
 			}
 			}
 		}
 		}
-		//P618 增加预加载数据提示:为您预加载最近15天发布的【X】商机
-		if tipBool := len(list) == bsp.Size; tipBool && len(list) > 0 {
+		if len(list) > 0 {
+			tipBool = true
+		}
+	}
+	log.Println("tip info:", spqp.PageNum, "--", tipBool, "--", total, "--", bsp.Size)
+	//P618 增加预加载数据提示:为您预加载最近15天发布的【X】商机
+	//1、首次访问;2、无推送数据;3、数据量满足免费50条,付费用户1000条
+	tipBool = spqp.PageNum == 1 && tipBool
+	if tipBool {
+		tip = fmt.Sprintf(IC.C.SubListTip, "")
+		if total >= int64(bsp.Size) {
 			tip = fmt.Sprintf(IC.C.SubListTip, fmt.Sprintf("%d条", bsp.Size))
 			tip = fmt.Sprintf(IC.C.SubListTip, fmt.Sprintf("%d条", bsp.Size))
 		}
 		}
 	}
 	}
-
 	start2 := time.Now().Unix()
 	start2 := time.Now().Unix()
 	logx.Info("2、查询数据用户", start2-start1)
 	logx.Info("2、查询数据用户", start2-start1)
 	//查询是否收藏
 	//查询是否收藏

+ 28 - 17
jyBXSubscribe/rpc/model/push.go

@@ -32,7 +32,7 @@ import (
 )
 )
 
 
 const (
 const (
-	pageSize            = 100
+	PageSize            = 100
 	AllSubPushCacheSize = 200
 	AllSubPushCacheSize = 200
 	query               = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area","city", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","spidercode","site","buyertel","buyerperson","agency","agencyperson","agencytel","winnerperson","winnertel","signendtime","bidendtime","entidlist","isValidFile","district"],"from":0,"size":%d}`
 	query               = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area","city", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","spidercode","site","buyertel","buyerperson","agency","agencyperson","agencytel","winnerperson","winnertel","signendtime","bidendtime","entidlist","isValidFile","district"],"from":0,"size":%d}`
 	query1              = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area","city", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","spidercode","site","buyertel","buyerperson","agency","agencyperson","agencytel","winnerperson","winnertel","signendtime","bidendtime","entidlist","isValidFile", "detail","district"],"from":0,"size":%d}`
 	query1              = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area","city", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","spidercode","site","buyertel","buyerperson","agency","agencyperson","agencytel","winnerperson","winnertel","signendtime","bidendtime","entidlist","isValidFile", "detail","district"],"from":0,"size":%d}`
@@ -327,17 +327,17 @@ func subStrDetail(matchKey, detail string) string {
 	}
 	}
 	return strings.TrimSpace(detail)
 	return strings.TrimSpace(detail)
 }
 }
-func (s *subscribePush) Datas(spqp *SubPushQueryParam, bsp *ViewCondition) (hasNextPage bool, total int64, result []*bxsubscribe.SubscribeInfo) {
-	logx.Info(spqp.UserId, spqp.NewUserId, s.ModuleFlag, "subscribePush query param:", "SelectTime:", spqp.SelectTime, "Area:", spqp.Area, "District:", spqp.District, "City:", spqp.City, "Subtype:", spqp.Subtype, "Subscopeclass:", spqp.Subscopeclass, "Buyerclass:", spqp.Buyerclass, "Key:", spqp.Key, "PageNum:", spqp.PageNum, "Price:", spqp.Price, "FileExists:", spqp.FileExists)
+func (s *subscribePush) Datas(spqp *SubPushQueryParam, bsp *ViewCondition) (hasNextPage bool, total int64, result []*bxsubscribe.SubscribeInfo, tipBool bool) {
+	logx.Info(spqp.UserId, spqp.NewUserId, s.ModuleFlag, "subscribePush query param:", "SelectTime:", spqp.SelectTime, "Area:", spqp.Area, "District:", spqp.District, "City:", spqp.City, "Subtype:", spqp.Subtype, "Subscopeclass:", spqp.Subscopeclass, "Buyerclass:", spqp.Buyerclass, "Key:", spqp.Key, "PageNum:", spqp.PageNum, "Price:", spqp.Price, "FileExists:", spqp.FileExists, "SubPushInactive:", spqp.SubPushInactive)
 	if spqp.UserId == "" {
 	if spqp.UserId == "" {
 		return
 		return
 	}
 	}
 	if spqp.PageNum < 1 {
 	if spqp.PageNum < 1 {
 		spqp.PageNum = 1
 		spqp.PageNum = 1
 	}
 	}
-	if spqp.PageSize < 1 || spqp.PageSize > pageSize {
+	if spqp.PageSize <= 1 || spqp.PageSize > PageSize {
 		if !spqp.Export {
 		if !spqp.Export {
-			spqp.PageSize = pageSize
+			spqp.PageSize = PageSize
 		} else { //数据导出查询20000条限制
 		} else { //数据导出查询20000条限制
 			if spqp.PageSize < 1 || spqp.PageSize > 20000 {
 			if spqp.PageSize < 1 || spqp.PageSize > 20000 {
 				spqp.PageSize = 20000
 				spqp.PageSize = 20000
@@ -364,6 +364,9 @@ func (s *subscribePush) Datas(spqp *SubPushQueryParam, bsp *ViewCondition) (hasN
 		}
 		}
 		result, total = s.inactiveQuery(spqp, bsp)
 		result, total = s.inactiveQuery(spqp, bsp)
 		hasNextPage = len(result) >= spqp.PageSize
 		hasNextPage = len(result) >= spqp.PageSize
+		if total > 0 {
+			tipBool = true
+		}
 		return
 		return
 	}
 	}
 	nowFormat := date.NowFormat(date.Date_Short_Layout)
 	nowFormat := date.NowFormat(date.Date_Short_Layout)
@@ -515,9 +518,13 @@ func (s *subscribePush) inactiveQuery(spqp *SubPushQueryParam, bsp *ViewConditio
 			starttime = time.Now().AddDate(0, 0, -15).Unix()
 			starttime = time.Now().AddDate(0, 0, -15).Unix()
 			endtime = time.Now().Unix()
 			endtime = time.Now().Unix()
 		}
 		}
-		qstr := s.getFreeDatasSQL(bsp, starttime, endtime, (spqp.PageNum-1)*spqp.PageSize, spqp.PageSize)
+		qstr := s.getFreeDatasSQL(bsp, starttime, endtime, (spqp.PageNum-1)*spqp.PageSize)
+		log.Println("inactiveQuery---:", qstr)
 		//list = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSort, bidField, 0, 4500, 0, false)
 		//list = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSort, bidField, 0, 4500, 0, false)
 		count, list = elastic.GetWithCount(INDEX, TYPE, "", qstr)
 		count, list = elastic.GetWithCount(INDEX, TYPE, "", qstr)
+		if len(*list) > spqp.PageSize {
+			*list = (*list)[:spqp.PageSize]
+		}
 	}
 	}
 	if count > 500 {
 	if count > 500 {
 		count = 500
 		count = 500
@@ -1327,7 +1334,7 @@ func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam, bsp *ViewCondition
 	if spqp.UserId == "" {
 	if spqp.UserId == "" {
 		return false, 0, nil
 		return false, 0, nil
 	}
 	}
-	logx.Info("userId:", spqp.UserId, "newUserId:", spqp.NewUserId)
+	logx.Info("---userId:", spqp.UserId, "newUserId:", spqp.NewUserId)
 	t1 := time.Now()
 	t1 := time.Now()
 	if len(bsp.Keyword) > 0 {
 	if len(bsp.Keyword) > 0 {
 		logx.Info("--bsp:", bsp)
 		logx.Info("--bsp:", bsp)
@@ -1351,8 +1358,8 @@ func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam, bsp *ViewCondition
 			logx.Info(time.Since(t1), "mlist count:", len(mlist))
 			logx.Info(time.Since(t1), "mlist count:", len(mlist))
 			total = int64(len(mlist))
 			total = int64(len(mlist))
 			result = s.listManager(spqp, mlist, bsp.Keyword)
 			result = s.listManager(spqp, mlist, bsp.Keyword)
-			if len(result) > pageSize {
-				result = result[:pageSize]
+			if len(result) > PageSize {
+				result = result[:PageSize]
 				hasNextPage = true
 				hasNextPage = true
 			}
 			}
 		}
 		}
@@ -1486,7 +1493,7 @@ func getKeys(title string, keywords []ViewKeyWord) (str []string) {
 }
 }
 
 
 // 获取查询语句
 // 获取查询语句
-func (s *subscribePush) getFreeDatasSQL(bsp *ViewCondition, startTime, endTime int64, startNumb, size int) (str string) {
+func (s *subscribePush) getFreeDatasSQL(bsp *ViewCondition, startTime, endTime int64, startNumb int) (str string) {
 	query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}},"_source":[%s],"sort": [{"publishtime": "desc"}],"from":%d,"size":%d}`
 	query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}},"_source":[%s],"sort": [{"publishtime": "desc"}],"from":%d,"size":%d}`
 	query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
 	query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
 	multi_match := `{"multi_match": {"query": %s,"type": "phrase", "fields": [%s]}}`
 	multi_match := `{"multi_match": {"query": %s,"type": "phrase", "fields": [%s]}}`
@@ -1630,7 +1637,7 @@ func (s *subscribePush) getFreeDatasSQL(bsp *ViewCondition, startTime, endTime i
 		}
 		}
 	}
 	}
 
 
-	qstr := fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(bools, ","), boolsNum, bidField, startNumb, size)
+	qstr := fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(bools, ","), boolsNum, bidField, startNumb, bsp.Size)
 	logx.Info("----", qstr)
 	logx.Info("----", qstr)
 	return qstr
 	return qstr
 }
 }
@@ -2461,8 +2468,9 @@ func (s *SubPushQueryParam) ExportPushFormat() (ids, keyWords []string) {
 // @Author jianghan
 // @Author jianghan
 // @Description	clickhouse获取推荐的列表数据
 // @Description	clickhouse获取推荐的列表数据
 // @Date 2024/3/11
 // @Date 2024/3/11
-func (s *subscribePush) SubRecList(userId string, keyword []ViewKeyWord) (hasNextPage bool, total int64, resultList []*bxsubscribe.SubscribeInfo) {
-	infos := IC.BaseServiceMysql.SelectBySql(`select autoid from push.sub_recommend_list where userid=? order by create_time desc limit ?`, userId, pageSize)
+// 根据用户身份获取数据量:免费50,付费1000
+func (s *subscribePush) SubRecList(userId string, keyword []ViewKeyWord, size int) (hasNextPage bool, total int64, resultList []*bxsubscribe.SubscribeInfo) {
+	infos := IC.BaseServiceMysql.SelectBySql(`select autoid from push.sub_recommend_list where userid=? order by create_time desc limit ?`, userId, PageSize)
 	ids := []int64{}
 	ids := []int64{}
 	if infos != nil && len(*infos) > 0 {
 	if infos != nil && len(*infos) > 0 {
 		for _, v := range *infos {
 		for _, v := range *infos {
@@ -2473,9 +2481,12 @@ func (s *subscribePush) SubRecList(userId string, keyword []ViewKeyWord) (hasNex
 		length := len(ids)
 		length := len(ids)
 		resultList = []*bxsubscribe.SubscribeInfo{}
 		resultList = []*bxsubscribe.SubscribeInfo{}
 		esq := `{"query": {"bool": {"must": [{"terms": {"autoid": [` + strings.Join(gconv.Strings(ids), ",") + ` ]}}]}}}`
 		esq := `{"query": {"bool": {"must": [{"terms": {"autoid": [` + strings.Join(gconv.Strings(ids), ",") + ` ]}}]}}}`
-		binfo := elastic.GetAllByNgram(INDEX, TYPE, esq, findfields, bidSort, bidField, 0, pageSize, length, false)
+		binfo := elastic.GetAllByNgram(INDEX, TYPE, esq, findfields, bidSort, bidField, 0, size, length, false)
 		if binfo != nil && len(*binfo) > 0 {
 		if binfo != nil && len(*binfo) > 0 {
-			for _, m := range *binfo {
+			for n, m := range *binfo {
+				if n > PageSize {
+					break
+				}
 				title := strings.Replace(common.ObjToString(m["title"]), " ", "", -1)
 				title := strings.Replace(common.ObjToString(m["title"]), " ", "", -1)
 				matchkeys := getKeys(title, keyword)
 				matchkeys := getKeys(title, keyword)
 				resultList = append(resultList, s.InfoFormat(&PushCa{
 				resultList = append(resultList, s.InfoFormat(&PushCa{
@@ -2521,8 +2532,8 @@ func (s *subscribePush) GetRecListByEs() (hasNextPage bool, total int64, resultL
 		}
 		}
 	}
 	}
 	total = int64(len(resultList))
 	total = int64(len(resultList))
-	if total > pageSize {
-		resultList = resultList[:pageSize]
+	if total > PageSize {
+		resultList = resultList[:PageSize]
 		hasNextPage = true
 		hasNextPage = true
 	}
 	}
 	return
 	return