Browse Source

浏览时间添加

WH01243 2 years ago
parent
commit
e27306bb67
2 changed files with 91 additions and 18 deletions
  1. 2 3
      jyBXSubscribe/rpc/internal/logic/setreadlogic.go
  2. 89 15
      jyBXSubscribe/rpc/model/push.go

+ 2 - 3
jyBXSubscribe/rpc/internal/logic/setreadlogic.go

@@ -31,12 +31,11 @@ func (l *SetReadLogic) SetRead(in *bxsubscribe.SetReadReq) (*bxsubscribe.StatusR
 	resp := &bxsubscribe.StatusResp{}
 	//主体处理(fType:普通用户;vType:超级订阅用户;mType:大会员用户;eType:商机管理用户)
 	if in.UserType == "vType" || in.UserType == "mType" {
-		infoCount := IC.MainMysql.CountBySql("select  count(id) from  entniche_wait_empower where  ent_id=? and  end_time>NOW() and product_type like '%超级订阅%' or product_type like '大会员' ", in.EntId)
+		infoCount := IC.MainMysql.CountBySql("select  count(id) from  entniche_wait_empower where  ent_id=? and  end_time>NOW() and (product_type like '%超级订阅%' or product_type like '%大会员%') ", in.EntId)
 		if infoCount > 0 {
 			in.UserType = "eType"
 		}
-
 	}
-	model.NewSubscribePush(in.UserType).SetRead(in.NewUserId, in.GetVsid(), in.UserId, in.EntUserId, in.EntId, in.IsEnt)
+	model.NewSubscribePush(in.UserType).SetRead(in.NewUserId, in.Vsid, in.UserId, in.EntUserId, in.EntId, in.IsEnt)
 	return resp, nil
 }

+ 89 - 15
jyBXSubscribe/rpc/model/push.go

@@ -73,6 +73,7 @@ type PushCa struct {
 	Isvip      int
 	FileExists bool
 	Source     int64
+	Title      string
 }
 
 // 查询参数
@@ -323,6 +324,11 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 	var (
 		searchSql, findSql string
 	)
+	codeMap, err := IC.CodeLib.CodeTransformation(context.Background(), &codeservice.Request{})
+	if codeMap.Data == nil || err != nil {
+		logx.Error("代码表获取失败")
+		return result, count
+	}
 	querys = append(querys, " 1=1 ")
 	if spqp.SelectInfoIds != nil && len(spqp.SelectInfoIds) > 0 {
 		searchSql = fmt.Sprintf(" from %s a LEFT JOIN %s b ON a.infoid = b.infoid where %s order by a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, fmt.Sprintf("a.id in ('%s')", strings.Join(spqp.SelectInfoIds, "','")))
@@ -341,11 +347,7 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 		} else {
 			userStr = fmt.Sprintf("  a.userid='%s'", common.If(s.ModuleFlag == "eType", spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
 		}
-		codeMap, err := IC.CodeLib.CodeTransformation(context.Background(), &codeservice.Request{})
-		if codeMap.Data == nil || err != nil {
-			logx.Error("代码表获取失败")
-			return result, count
-		}
+
 		//时间
 		if starttime > 0 && endtime > 0 {
 			userStr += fmt.Sprintf(" and a.date>=%d and date<=%d", starttime, endtime)
@@ -483,7 +485,8 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 		logx.Info(fmt.Sprintf("select count(a.id) " + searchSql))
 		count = spqp.BaseServiceMysql.CountBySql(fmt.Sprintf("select  /*+ HASH_JOIN(a,b)*/ count(a.id) " + searchSql))
 		logx.Info("count:", count, "---", s.ModuleFlag)
-		findSql = "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
+		findSql = "SELECT  aa.*,  bb.labelvalues as industry  FROM (select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count," +
+			"b.title,b.area_code,b.buyerclass_code,b.subtype_code,b.publishtime,b.budget,b.bidamount,b.projectname,b.buyer,b.bidopentime "
 		if s.ModuleFlag == "eType" {
 			findSql += ", IF(a.source is NULL,1,a.source) as  source "
 		}
@@ -495,12 +498,13 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 	if isLimit {
 		findSql += fmt.Sprintf(" limit %d,%d", (spqp.PageNum-1)*size, size)
 	}
+	findSql += fmt.Sprintf(") aa LEFT JOIN %s bb ON ( aa.infoid = bb.infoid )  AND bb.labelcode = 2 ", BidTags)
 	logx.Info(spqp.NewUserId, "subscribePush query sql:", findSql)
 	list := spqp.BaseServiceMysql.SelectBySql(findSql)
 	if list != nil && len(*list) > 0 {
-		pushCas := s.GetJyPushs(*list)
+		pushCas, subscribeInfo := s.GetJyPushs(*list, codeMap)
 		if !spqp.Export {
-			result = s.GetInfoByIds(spqp.Mgo_bidding, spqp.Bidding, spqp.Bidding_back, pushCas)
+			result = subscribeInfo
 		} else {
 			result = s.GetOnlyExportInfo(pushCas)
 		}
@@ -606,9 +610,36 @@ func (s *subscribePush) GetInfoByIds(Mgo_bidding mongodb.MongodbSim, bidding, bi
 }
 
 // 获取历史推送
-func (s *subscribePush) GetJyPushs(datas []map[string]interface{}) (pushCas []*PushCa) {
-	pushCas = []*PushCa{}
+func (s *subscribePush) GetJyPushs(datas []map[string]interface{}, codeMap *codeservice.Response) ([]*PushCa, []*bxsubscribe.SubscribeInfo) {
+	pushCas := []*PushCa{}
+	subscribeInfo := []*bxsubscribe.SubscribeInfo{}
+	areaMap := map[string]string{}
+	subtypeMap := map[string]string{}
+	buyerClassMap := map[string]string{}
+	industryMap := map[string]string{}
+	for k, v := range codeMap.Data.Area {
+		areaMap[v] = k
+	}
+	for k, v := range codeMap.Data.Subscopeclass {
+		industryMap[v] = k
+	}
+	for k, v := range codeMap.Data.Subtype {
+		subtypeMap[v] = k
+	}
+	for k, v := range codeMap.Data.Buyerclass {
+		buyerClassMap[v] = k
+	}
+	array := []map[string]interface{}{}
+	m := map[int64]string{}
 	for _, v := range datas {
+		id := v["id"].(int64)
+		if _, ok := m[id]; ok {
+		} else {
+			array = append(array, v)
+		}
+	}
+
+	for _, v := range array {
 		keys := []string{}
 		if matchkeys := common.ObjToString(v["matchkeys"]); matchkeys != "" {
 			keys = strings.Split(matchkeys, " ")
@@ -624,8 +655,45 @@ func (s *subscribePush) GetJyPushs(datas []map[string]interface{}) (pushCas []*P
 			FileExists: common.IntAll(v["attachment_count"]) > 0,
 			Source:     common.Int64All(v["source"]),
 		})
+		area := common.ObjToString(v["area_code"])
+		if area == "000000" {
+			area = "全国"
+		} else {
+			area = areaMap[area]
+		}
+		//采购单位类型处理buyerClass
+		buyerClass := buyerClassMap[common.ObjToString(v["buyerclass_code"])]
+		//信息类型处理subtype
+		subtype := subtypeMap[common.ObjToString(v["subtype_code"])]
+		iss := strings.Split(industryMap[common.ObjToString(v["industry"])], "_")
+		industry := ""
+		if len(iss) > 0 {
+			industry = iss[0]
+		}
+		subscribeInfo = append(subscribeInfo, &bxsubscribe.SubscribeInfo{
+			XId:          encrypt.EncodeArticleId2ByCheck(common.ObjToString(v["infoid"])),
+			Title:        common.InterfaceToStr(v["title"]),
+			Area:         area,
+			BuyerClass:   buyerClass,
+			Subtype:      subtype,
+			Industry:     industry,
+			PublishTime:  common.Int64All(v["publishtime"]),
+			CaIndex:      common.Int64All(v["id"]),
+			CaDate:       common.Int64All(v["date"]),
+			CaIsvisit:    common.Int64All(v["publishtime"]),
+			CaType:       common.Int64All(v["type"]),
+			MatchKeys:    keys,
+			Budget:       common.InterfaceToStr(v["budget"]),
+			BidAmount:    common.InterfaceToStr(v["bidamount"]),
+			Buyer:        common.InterfaceToStr(v["buyer"]),
+			ProjectName:  common.InterfaceToStr(v["projectname"]),
+			Winner:       common.InterfaceToStr(v["s_winner"]),
+			BidOpenTime:  common.Int64All(v["bidopentime"]),
+			CaFileExists: common.IntAll(v["attachment_count"]) > 0,
+			Source:       common.Int64All(v["source"]),
+		})
 	}
-	return
+	return pushCas, subscribeInfo
 }
 
 // 查看全部列表缓存
@@ -745,18 +813,24 @@ func UpdateUserPushUnread(userid string, vt string) {
 	}
 }
 func (s *subscribePush) SetRead(newUserId, id int64, userId, entUserId, entId string, isEnt bool) error {
-	if id <= 0 {
+	if id <= 0 && newUserId == 0 {
 		return nil
 	}
 	if newUserId == 0 {
 		return nil
 	}
 	if isEnt {
-		IC.BaseServiceMysql.UpdateOrDeleteBySql(fmt.Sprintf("update %s set isvisit=1 where entid=? and id=?", aboutDbMsg[s.ModuleFlag].MysqlTable), entId, id)
+		if s.ModuleFlag == "eType" {
+			IC.BaseServiceMysql.UpdateOrDeleteBySql(fmt.Sprintf("update %s set isvisit=1 ,visittime=now() where entid=? and id=?", aboutDbMsg[s.ModuleFlag].MysqlTable), entId, id)
+
+		} else {
+			IC.BaseServiceMysql.UpdateOrDeleteBySql(fmt.Sprintf("update %s set isvisit=1 where entid=? and id=?", aboutDbMsg[s.ModuleFlag].MysqlTable), entId, id)
+
+		}
 	} else {
 		if s.ModuleFlag == "eType" {
 			//商机管理
-			IC.BaseServiceMysql.UpdateOrDeleteBySql(fmt.Sprintf("update %s set isvisit=1 where userid=? and id=?", aboutDbMsg[s.ModuleFlag].MysqlTable), entUserId, id)
+			IC.BaseServiceMysql.UpdateOrDeleteBySql(fmt.Sprintf("update %s set isvisit=1,visittime=now() where userid=? and id=?", aboutDbMsg[s.ModuleFlag].MysqlTable), entUserId, id)
 		} else {
 			//其他
 			IC.BaseServiceMysql.UpdateOrDeleteBySql(fmt.Sprintf("update %s set isvisit=1 where userid=? and id=?", aboutDbMsg[s.ModuleFlag].MysqlTable), newUserId, id)
@@ -886,7 +960,7 @@ func (s *subscribePush) listManager(spqp *SubPushQueryParam, list []map[string]i
 	pushInsert := []interface{}{}
 	for i := length - 1; i >= 0; i-- {
 		v := list[i]
-		title := strings.Replace(common.ObjToString(v["title"]), "\n", "", -1)
+		title := strings.Replace(common.ObjToString(v["title"]), " ", "", -1)
 		infoid := common.InterfaceToStr(v["_id"])
 		matchkeys := getKeys(title, keyword)
 		matchkey := strings.Join(matchkeys, " ")