Эх сурвалжийг харах

feat:订阅列表附件文件

wangshan 3 жил өмнө
parent
commit
69c97a9b71

+ 0 - 3
jyBXSubscribe/api/internal/logic/subscribeInfoLogic.go

@@ -3,7 +3,6 @@ package logic
 import (
 	"context"
 	"jyBXSubscribe/rpc/type/bxsubscribe"
-	"log"
 	"net/http"
 
 	"jyBXSubscribe/api/internal/svc"
@@ -29,7 +28,6 @@ func NewSubscribeInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *h
 }
 
 func (l *SubscribeInfoLogic) SubscribeInfo(req types.SubscribeRequest) (*types.CommonRes, error) {
-	log.Println("--------------------", req.UserType)
 	res, err := l.svcCtx.Suscribe.GetSubInfo(l.ctx, &bxsubscribe.SubscribeInfosReq{
 		PageNum:    req.PageNum,
 		PageSize:   req.PageSize,
@@ -51,7 +49,6 @@ func (l *SubscribeInfoLogic) SubscribeInfo(req types.SubscribeRequest) (*types.C
 			Data:     nil,
 		}, nil
 	}
-	log.Println("res.data:", res)
 	return &types.CommonRes{
 		Err_code: res.ErrCode,
 		Err_msg:  res.ErrMsg,

+ 1 - 0
jyBXSubscribe/rpc/bxsubscribe.proto

@@ -51,6 +51,7 @@ message subscribeInfo {
   string winner = 18;
   string  bidOpenTime = 19;
   int64  ca_isvip = 20;
+  bool  fileExists = 21;
 }
 
 service Bxsubscribe {

+ 6 - 0
jyBXSubscribe/rpc/internal/logic/getsubinfologic.go

@@ -33,6 +33,10 @@ func (l *GetSubInfoLogic) GetSubInfo(in *bxsubscribe.SubscribeInfosReq) (*bxsubs
 	//超级订阅 i_apppushunread=0
 	//大会员 i_member_apppushunread=0
 	//商机管理 i_entniche_apppushunread=0
+
+	if in.PageNum == 1 {
+		go util.UpdateUserPushUnread(in.UserId, in.UserType)
+	}
 	spqp := &util.SubPushQueryParam{
 		Mgo_bidding:   IC.MgoBidding,                         //mongo
 		Bidding:       IC.C.MongoDB.Bidding.Collection,       //招标信息 表
@@ -56,6 +60,8 @@ func (l *GetSubInfoLogic) GetSubInfo(in *bxsubscribe.SubscribeInfosReq) (*bxsubs
 		spqp.PushMysql = IC.PushMysql
 	}
 	hasNextPage, total, list := util.NewSubscribePush(in.UserType).Datas(spqp)
+	//查询是否收藏
+	util.NewSubscribePush(in.UserType).MakeCollection(in.UserId, list)
 	return &bxsubscribe.SubscribeInfosResp{
 		Data: &bxsubscribe.SubscribeData{
 			List:        list,

+ 12 - 2
jyBXSubscribe/rpc/type/bxsubscribe/bxsubscribe.pb.go

@@ -311,6 +311,7 @@ type SubscribeInfo struct {
 	Winner      string   `protobuf:"bytes,18,opt,name=winner,proto3" json:"winner,omitempty"`
 	BidOpenTime string   `protobuf:"bytes,19,opt,name=bidOpenTime,proto3" json:"bidOpenTime,omitempty"`
 	CaIsvip     int64    `protobuf:"varint,20,opt,name=ca_isvip,json=caIsvip,proto3" json:"ca_isvip,omitempty"`
+	FileExists  bool     `protobuf:"varint,21,opt,name=fileExists,proto3" json:"fileExists,omitempty"`
 }
 
 func (x *SubscribeInfo) Reset() {
@@ -485,6 +486,13 @@ func (x *SubscribeInfo) GetCaIsvip() int64 {
 	return 0
 }
 
+func (x *SubscribeInfo) GetFileExists() bool {
+	if x != nil {
+		return x.FileExists
+	}
+	return false
+}
+
 var File_bxsubscribe_proto protoreflect.FileDescriptor
 
 var file_bxsubscribe_proto_rawDesc = []byte{
@@ -526,7 +534,7 @@ var file_bxsubscribe_proto_rawDesc = []byte{
 	0x61, 0x67, 0x65, 0x12, 0x2e, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28,
 	0x0b, 0x32, 0x1a, 0x2e, 0x62, 0x78, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x2e,
 	0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x6c,
-	0x69, 0x73, 0x74, 0x22, 0xae, 0x04, 0x0a, 0x0d, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62,
+	0x69, 0x73, 0x74, 0x22, 0xce, 0x04, 0x0a, 0x0d, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62,
 	0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
 	0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02,
 	0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x61,
@@ -561,7 +569,9 @@ var file_bxsubscribe_proto_rawDesc = []byte{
 	0x65, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x62, 0x69,
 	0x64, 0x4f, 0x70, 0x65, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x61, 0x5f,
 	0x69, 0x73, 0x76, 0x69, 0x70, 0x18, 0x14, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x63, 0x61, 0x49,
-	0x73, 0x76, 0x69, 0x70, 0x32, 0x5c, 0x0a, 0x0b, 0x42, 0x78, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72,
+	0x73, 0x76, 0x69, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x69, 0x6c, 0x65, 0x45, 0x78, 0x69, 0x73,
+	0x74, 0x73, 0x18, 0x15, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x66, 0x69, 0x6c, 0x65, 0x45, 0x78,
+	0x69, 0x73, 0x74, 0x73, 0x32, 0x5c, 0x0a, 0x0b, 0x42, 0x78, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72,
 	0x69, 0x62, 0x65, 0x12, 0x4d, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x49, 0x6e, 0x66,
 	0x6f, 0x12, 0x1e, 0x2e, 0x62, 0x78, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x2e,
 	0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x52, 0x65,

+ 25 - 9
jyBXSubscribe/rpc/util/push.go

@@ -24,7 +24,7 @@ const (
 	pageSize            = 50
 	pageSizes           = 10
 	AllSubPushCacheSize = 250
-	query               = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner"],"from":0,"size":%d}`
+	query               = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext"],"from":0,"size":%d}`
 	mongodb_fields      = `{"_id":1,"area":1,"publishtime":1,"s_subscopeclass":1,"subtype":1,"title":1,"toptype":1,"type":1, "buyerclass":1,"budget":1,"bidamount":1,"s_winner":1,"bidopentime":1,"buyer":1,"projectname":1}`
 
 	SubFreeFlag  = "fType"
@@ -129,7 +129,7 @@ func (s *subscribePush) allKey(userId string) string {
 }
 
 //历史推送记录中单条信息格式化
-func (s *subscribePush) InfoFormat(p *PushCa, info *map[string]interface{}) *bxsubscribe.SubscribeInfo {
+func (s *subscribePush) InfoFormat(p *PushCa, info *map[string]interface{}, files *map[string]bool) *bxsubscribe.SubscribeInfo {
 	area := common.ObjToString((*info)["area"])
 	if area == "A" {
 		area = "全国"
@@ -181,6 +181,7 @@ func (s *subscribePush) InfoFormat(p *PushCa, info *map[string]interface{}) *bxs
 		ProjectName: common.ObjToString((*info)["projectname"]),
 		Winner:      common.ObjToString((*info)["s_winner"]),
 		BidOpenTime: common.ObjToString((*info)["bidopentime"]),
+		FileExists:  (*files)[_id],
 	}
 }
 
@@ -263,7 +264,6 @@ func (s *subscribePush) Datas(spqp *SubPushQueryParam) (hasNextPage bool, total
 			logx.Info(spqp.UserId, "GetAllCache Error", err)
 		}
 		if err != nil || allCache == nil || allCache.Date != nowFormat || len(allCache.Datas) == 0 {
-			logx.Info("a3")
 			spqp.PageNum = 1
 			logx.Info(1111)
 			list, countSearch := s.getDatasFromMysql(spqp, starttime, endtime, AllSubPushCacheSize, true)
@@ -419,7 +419,6 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 
 	logx.Info(spqp.UserId, "subscribePush query sql:", findSql)
 	list := spqp.PushMysql.SelectBySql(findSql)
-	logx.Info("list:", list)
 	if list != nil && len(*list) > 0 {
 		pushCas := s.GetJyPushs(*list)
 		result = s.GetInfoByIds(spqp.Mgo_bidding, spqp.Bidding, spqp.Bidding_back, pushCas)
@@ -447,19 +446,21 @@ func (s *subscribePush) GetInfoByIds(Mgo_bidding mongodb.MongodbSim, bidding, bi
 	}
 	infos := map[string]map[string]interface{}{}
 	//redis
-
+	files := map[string]bool{}
 	es_ids := []string{}
 	for _, v := range ids {
+		//剑鱼程序未找到赋值 位置;猜测在推送程序中
 		info_i := redis.Get("pushcache_1", fmt.Sprintf("info_%s", v))
 		if info_i != nil {
 			info_m, _ := info_i.(map[string]interface{})
 			info_m["_id"] = v
 			infos[v] = info_m
+			logx.Info("----", info_m, "----")
+			files[v] = info_m["fileExists"] != nil
 		} else {
 			es_ids = append(es_ids, v)
 		}
 	}
-	logx.Info("es_ids:", es_ids)
 	//elasticsearch
 	if len(es_ids) > 0 {
 		list := elastic.Get("bidding", "bidding", fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
@@ -467,6 +468,7 @@ func (s *subscribePush) GetInfoByIds(Mgo_bidding mongodb.MongodbSim, bidding, bi
 			for _, v := range *list {
 				_id := common.ObjToString(v["_id"])
 				infos[_id] = v
+				files[_id] = v["filetext"] != nil
 			}
 		}
 	}
@@ -485,6 +487,7 @@ func (s *subscribePush) GetInfoByIds(Mgo_bidding mongodb.MongodbSim, bidding, bi
 				_id := mongodb.BsonIdToSId(v["_id"])
 				v["_id"] = _id
 				infos[_id] = v
+				files[_id] = v["projectinfo"] != nil
 			}
 		}
 	}
@@ -502,6 +505,7 @@ func (s *subscribePush) GetInfoByIds(Mgo_bidding mongodb.MongodbSim, bidding, bi
 				_id := mongodb.BsonIdToSId(v["_id"])
 				v["_id"] = _id
 				infos[_id] = v
+				files[_id] = v["projectinfo"] != nil
 			}
 		}
 	}
@@ -511,7 +515,7 @@ func (s *subscribePush) GetInfoByIds(Mgo_bidding mongodb.MongodbSim, bidding, bi
 		if info == nil {
 			info = map[string]interface{}{}
 		}
-		array[k] = s.InfoFormat(v, &info)
+		array[k] = s.InfoFormat(v, &info, &files)
 	}
 	return array
 }
@@ -562,7 +566,7 @@ func (s *subscribePush) GetCache(code, key string) (*SubPush, error) {
 }
 
 //是否收藏
-func (s *subscribePush) MakeCollection(userId string, m *mysql.Mysql, list []*bxsubscribe.SubscribeInfo) {
+func (s *subscribePush) MakeCollection(userId string, list []*bxsubscribe.SubscribeInfo) {
 	if list == nil || len(list) == 0 {
 		return
 	}
@@ -576,7 +580,7 @@ func (s *subscribePush) MakeCollection(userId string, m *mysql.Mysql, list []*bx
 		}
 	}
 	if len(wh) > 0 {
-		result := m.SelectBySql(`select bid from bdcollection where userid=? and bid in (`+strings.Join(wh, ",")+`)`, param...)
+		result := IC.MainMysql.SelectBySql(`select bid from bdcollection where userid=? and bid in (`+strings.Join(wh, ",")+`)`, param...)
 		bid_map := map[string]bool{}
 		if result != nil {
 			for _, v := range *result {
@@ -641,3 +645,15 @@ func InfoFormats(info map[string]interface{}, tmp map[string]interface{}) map[st
 	info["type"] = infotype
 	return info
 }
+
+//UpdateUserPushUnread 更新app未读标识为已读
+func UpdateUserPushUnread(userid string, vt string) {
+	if vt == MemberFlag {
+		IC.Mgo.UpdateById("user", userid, map[string]interface{}{"$set": map[string]interface{}{"i_member_apppushunread": 0}})
+	} else if vt == EntnicheFlag {
+		IC.Mgo.UpdateById("user", userid, map[string]interface{}{"$set": map[string]interface{}{"i_entniche_apppushunread": 0}})
+	} else {
+		IC.Mgo.UpdateById("user", userid, map[string]interface{}{"$set": map[string]interface{}{"i_apppushunread": 0}})
+
+	}
+}