newestBidding.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. package model
  2. import (
  3. "app.yhyue.com/moapp/jybase/redis"
  4. "context"
  5. "encoding/json"
  6. "fmt"
  7. "jyBXBase/entity"
  8. "jyBXBase/rpc/bxbase"
  9. IC "jyBXBase/rpc/init"
  10. "jyBXBase/rpc/internal/config"
  11. "log"
  12. "sort"
  13. "strings"
  14. "time"
  15. MC "app.yhyue.com/moapp/jybase/common"
  16. ME "app.yhyue.com/moapp/jybase/encrypt"
  17. elastic "app.yhyue.com/moapp/jybase/es"
  18. "app.yhyue.com/moapp/jybase/mongodb"
  19. "app.yhyue.com/moapp/jybase/mysql"
  20. "github.com/zeromicro/go-zero/core/logx"
  21. "go.mongodb.org/mongo-driver/bson/primitive"
  22. )
  23. const (
  24. search_index = "bidding"
  25. search_type = "bidding"
  26. 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,"spidercode":1,"site":1}`
  27. query = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","spidercode","site"],"from":0,"size":%d}`
  28. multi_match = `{"multi_match": {"query": %s,"type": "phrase", "fields": ["title"]}}`
  29. query_bool_must = `{"terms":{"%s":[%s]}}`
  30. query_bool_must_and = `{"bool":{"must":[%s],"must_not":[%s]}}`
  31. search_field = `"_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","isValidFile","spidercode","site"`
  32. query_city_hkeys = `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match":%d}},"highlight": {"pre_tags": ["<a>"],"post_tags": ["</a>"],"fields": {"title": {"fragment_size": 0,"number_of_fragments": 1}}},"_source":[` + search_field + `],"sort":[{"publishtime":"desc"},{"budget":"desc"}],"from":0,"size":%d}`
  33. Pushbidding = "global_common_data.dws_f_bid_baseinfo"
  34. Province = "province"
  35. StatusCache = iota // 0 -不存缓存 本来查的就是缓存的数据
  36. StatusNoLogin // 1-未登录用户
  37. StatusLoginUser // 2-用户自己的key
  38. StatusLogin // 3-登录用户最新标讯
  39. )
  40. type NewestInfo struct {
  41. TableName string
  42. UserId string
  43. MysqlDb *mysql.Mysql
  44. NewUserId int64
  45. PushMysql *mysql.Mysql
  46. NewsLimitNum int64 // 最新标讯数量条数限制
  47. IsEnt bool
  48. }
  49. var mysqlTables = map[string]string{
  50. "f": "push.pushsubscribe",
  51. "v": "push.pushsubscribe",
  52. "m": "push.pushmember",
  53. "e": "push.pushentniche",
  54. }
  55. func GetRoleNewestInfoService(AppId, MgoUserId string, NewUserId, AccountId, EntId, EntUserId, PositionType, PositionId int64) (roleNewestInfo *NewestInfo, flag string) {
  56. powerCheck := IC.Middleground.PowerCheckCenter.Check(AppId, MgoUserId, NewUserId, AccountId, EntId, PositionType, PositionId)
  57. thisUserId := MC.If(PositionType == 1, MC.InterfaceToStr(EntUserId), MC.InterfaceToStr(NewUserId)).(string)
  58. thisNewUserId := MC.If(PositionType == 1, EntUserId, NewUserId).(int64)
  59. if powerCheck.Member.Status > 0 {
  60. // 大会员
  61. flag = "m"
  62. } else if powerCheck.Entniche.Status > 0 && powerCheck.Entniche.PowerSource != 1 && powerCheck.Entniche.IsEntPower == 1 {
  63. // 商机管理
  64. flag = "e"
  65. } else if powerCheck.Vip.Status > 0 {
  66. // 超级订阅
  67. flag = "v"
  68. } else {
  69. // 普通用户
  70. flag = "f"
  71. }
  72. thisUserType := MC.If(PositionType == 1, "e", flag).(string)
  73. return GetNewestInfo(thisUserId, thisUserType, thisNewUserId), flag
  74. }
  75. func GetNewestInfo(userId, userType string, newUserId int64) *NewestInfo {
  76. nt := &NewestInfo{
  77. UserId: userId,
  78. TableName: mysqlTables[userType],
  79. MysqlDb: IC.BaseServiceMysql,
  80. NewUserId: newUserId,
  81. NewsLimitNum: IC.C.NewsLimitNum,
  82. }
  83. return nt
  84. }
  85. // GetPushHistoryCount 缓存code 配置最新的redis code;可以感觉redis内存大小 调节redis存储;
  86. // 根据GetPushHistoryCount 返回值 作为列表缓存key中一个参数
  87. func (n *NewestInfo) GetPushHistoryCount() int64 {
  88. countKey := fmt.Sprintf(IC.C.NewsCache.Count.Key, n.TableName, n.UserId)
  89. if b := redis.GetInt("new", countKey); b != 0 {
  90. return int64(b)
  91. }
  92. countSql := "SELECT COUNT(1) FROM (SELECT 1 FROM %s WHERE userid = %d LIMIT 1) AS ph"
  93. //countSql := "select count(1) from %s a where a.userid=%d order by a.id desc"
  94. countSql = fmt.Sprintf(countSql, n.TableName, n.NewUserId)
  95. timeOut := IC.C.NewsCache.Count.Timeout
  96. c := n.MysqlDb.CountBySql(countSql)
  97. if c > 0 {
  98. timeOut = timeOut * 7
  99. } else {
  100. c = -1
  101. }
  102. redis.Put("new", countKey, c, timeOut) //过期时间走配置,比最新标讯列表缓存时间 要短1/10 尽量不超过两分钟
  103. return c
  104. }
  105. // 判断当前用户是否有最新推送信息
  106. func (n *NewestInfo) IsHasNewPushData(time int64) bool {
  107. return n.MysqlDb.CountBySql(fmt.Sprintf("SELECT COUNT(1) FROM (SELECT 1 FROM %s WHERE userid = %d AND date > %d LIMIT 1) AS ph", n.TableName, n.NewUserId, time)) > 0
  108. }
  109. // GetPushHistory
  110. func (n *NewestInfo) GetPushHistory() (res []*bxbase.NewestList) {
  111. findSQL := "select a.infoid,REPLACE(a.matchkeys,'+',' ') as matchkeys,a.attachment_count,a.budget,a.bidamount from %s a where a.userid=%d order by a.id desc limit ?"
  112. findSQL = fmt.Sprintf(findSQL, n.TableName, n.NewUserId)
  113. logx.Info(n.TableName, "-------", n.NewUserId, ",findSQL:", findSQL)
  114. t := time.Now()
  115. list := n.MysqlDb.SelectBySql(findSQL, n.NewsLimitNum)
  116. log.Println("SQL 订阅信息耗时:", time.Since(t))
  117. if len(*list) > 0 && list != nil {
  118. m := map[string]bool{}
  119. es_ids := []string{}
  120. infos := map[string]*bxbase.NewestList{}
  121. for _, v := range *list {
  122. infoId := MC.ObjToString(v["infoid"])
  123. if m[infoId] {
  124. continue
  125. }
  126. es_ids = append(es_ids, infoId)
  127. m[MC.ObjToString(v["infoid"])] = true
  128. //
  129. infos[infoId] = &bxbase.NewestList{
  130. Id: ME.EncodeArticleId2ByCheck(MC.ObjToString(v["infoid"])),
  131. Matchkeys: strings.Split(MC.ObjToString(v["matchkeys"]), " "),
  132. Budget: MC.Int64All(v["budget"]),
  133. Bidamount: MC.Int64All(v["bidamount"]),
  134. FileExists: MC.Int64All(v["attachment_count"]) > 0,
  135. }
  136. }
  137. if len(es_ids) > 0 {
  138. t = time.Now()
  139. esList := elastic.Get(search_index, search_type, fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
  140. log.Println("elastic 招标信息耗时:", time.Since(t))
  141. if esList != nil && len(*esList) > 0 {
  142. for _, v := range *esList {
  143. _id := MC.ObjToString(v["_id"])
  144. bn := infos[_id]
  145. bn.Title = MC.ObjToString(v["title"])
  146. bn.PublishTime = MC.Int64All(v["publishtime"])
  147. bn.Subtype = MC.If(v["subtype"] != nil, MC.ObjToString(v["subtype"]), MC.ObjToString(v["toptype"])).(string)
  148. bn.Area = MC.If(MC.ObjToString(v["area"]) == "A", "全国", MC.ObjToString(v["area"])).(string)
  149. bn.Buyerclass = MC.ObjToString(v["buyerclass"])
  150. bn.City = MC.ObjToString(v["city"])
  151. bn.Industry = MC.If(MC.ObjToString(v["s_subscopeclass"]) != "", strings.Split(strings.Split(MC.ObjToString(v["s_subscopeclass"]), ",")[0], "_")[0], "").(string)
  152. bn.SpiderCode = MC.ObjToString(v["spidercode"])
  153. bn.Site = MC.ObjToString(v["site"])
  154. }
  155. }
  156. }
  157. //mongodb bidding
  158. mgo_ids := []primitive.ObjectID{}
  159. for _, v := range es_ids {
  160. if infos[v].Title == "" {
  161. mgo_ids = append(mgo_ids, mongodb.StringTOBsonId(v))
  162. }
  163. }
  164. if len(mgo_ids) > 0 {
  165. t = time.Now()
  166. mgoList, ok := IC.MgoBidding.Find("bidding", map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_ids}}, nil, mongodb_fields, false, -1, -1)
  167. log.Println("mongodb bidding 招标信息耗时:", time.Since(t))
  168. if ok && *mgoList != nil && len(*mgoList) > 0 {
  169. for _, v := range *mgoList {
  170. _id := mongodb.BsonIdToSId(v["_id"])
  171. bn := infos[_id]
  172. bn.Title = MC.ObjToString(v["title"])
  173. bn.PublishTime = MC.Int64All(v["publishtime"])
  174. bn.Subtype = MC.If(v["subtype"] != nil, MC.ObjToString(v["subtype"]), MC.ObjToString(v["toptype"])).(string)
  175. bn.Area = MC.If(MC.ObjToString(v["area"]) == "A", "全国", MC.ObjToString(v["area"])).(string)
  176. bn.Buyerclass = MC.ObjToString(v["buyerclass"])
  177. bn.City = MC.ObjToString(v["city"])
  178. bn.Industry = MC.If(MC.ObjToString(v["s_subscopeclass"]) != "", strings.Split(strings.Split(MC.ObjToString(v["s_subscopeclass"]), ",")[0], "_")[0], "").(string)
  179. bn.SpiderCode = MC.ObjToString(v["spidercode"])
  180. bn.Site = MC.ObjToString(v["site"])
  181. }
  182. }
  183. }
  184. //mongodb bidding_back
  185. mgo_back_ids := []primitive.ObjectID{}
  186. for _, v := range mgo_ids {
  187. if infos[mongodb.BsonIdToSId(v)].Title == "" {
  188. mgo_back_ids = append(mgo_back_ids, v)
  189. }
  190. }
  191. if len(mgo_back_ids) > 0 {
  192. t = time.Now()
  193. mgoBKList, ok := IC.MgoBidding.Find("bidding_back", map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_back_ids}}, nil, mongodb_fields, false, -1, -1)
  194. log.Println("mongodb bidding_back 招标信息耗时:", time.Since(t))
  195. if ok && *mgoBKList != nil && len(*mgoBKList) > 0 {
  196. for _, v := range *mgoBKList {
  197. _id := mongodb.BsonIdToSId(v["_id"])
  198. bn := infos[_id]
  199. bn.Title = MC.ObjToString(v["title"])
  200. bn.PublishTime = MC.Int64All(v["publishtime"])
  201. bn.Subtype = MC.If(v["subtype"] != nil, MC.ObjToString(v["subtype"]), MC.ObjToString(v["toptype"])).(string)
  202. bn.Area = MC.If(MC.ObjToString(v["area"]) == "A", "全国", MC.ObjToString(v["area"])).(string)
  203. bn.Buyerclass = MC.ObjToString(v["buyerclass"])
  204. bn.City = MC.ObjToString(v["city"])
  205. bn.Industry = MC.If(MC.ObjToString(v["s_subscopeclass"]) != "", strings.Split(strings.Split(MC.ObjToString(v["s_subscopeclass"]), ",")[0], "_")[0], "").(string)
  206. bn.SpiderCode = MC.ObjToString(v["spidercode"])
  207. bn.Site = MC.ObjToString(v["site"])
  208. }
  209. }
  210. }
  211. //
  212. for _, v := range infos {
  213. res = append(res, v)
  214. }
  215. }
  216. return
  217. }
  218. // 根据定位或者搜索历史 查es
  219. func NewestQuery(city, keys, subtype string) (str string) {
  220. var musts, bools []string
  221. if keys != "" {
  222. for _, v := range strings.Split(keys, ",") {
  223. keys := strings.Split(v, " ") //历史搜索 空格划分
  224. must_tmp := []string{}
  225. for _, key := range keys {
  226. must_tmp = append(must_tmp, fmt.Sprintf(multi_match, "\""+key+"\""))
  227. }
  228. bools = append(bools, fmt.Sprintf(query_bool_must_and, strings.Join(must_tmp, ","), ""))
  229. }
  230. }
  231. if city != "" {
  232. musts = append(musts, fmt.Sprintf(query_bool_must, "city", `"`+city+`"`))
  233. }
  234. //未登录首页推送数据限制
  235. if subtype != "" {
  236. musts = append(musts, fmt.Sprintf(query_bool_must, "subtype", subtype))
  237. }
  238. minimum_should_match := 0
  239. if len(bools) > 0 {
  240. minimum_should_match = 1
  241. }
  242. str = fmt.Sprintf(query_city_hkeys, strings.Join(musts, ","), strings.Join(bools, ","), minimum_should_match, IC.C.NewsLimitNum)
  243. logx.Info("str:", str)
  244. return
  245. }
  246. // es查询
  247. func NewestES(doSearchStr string) (res []*bxbase.NewestList) {
  248. list := elastic.Get(search_index, search_type, doSearchStr)
  249. if list != nil && len(*list) > 0 {
  250. for _, v := range *list {
  251. _id := mongodb.BsonIdToSId(v["_id"])
  252. isValidFile, _ := v["isValidFile"].(bool)
  253. res = append(res, &bxbase.NewestList{
  254. Id: ME.EncodeArticleId2ByCheck(_id),
  255. Title: MC.ObjToString(v["title"]),
  256. Subtype: MC.If(v["subtype"] != nil, MC.ObjToString(v["subtype"]), MC.ObjToString(v["toptype"])).(string),
  257. Area: MC.If(MC.ObjToString(v["area"]) == "A", "全国", MC.ObjToString(v["area"])).(string),
  258. Buyerclass: MC.ObjToString(v["buyerclass"]),
  259. City: MC.ObjToString(v["city"]),
  260. Industry: MC.If(MC.ObjToString(v["s_subscopeclass"]) != "", strings.Split(strings.Split(MC.ObjToString(v["s_subscopeclass"]), ",")[0], "_")[0], "").(string),
  261. Budget: MC.Int64All(v["budget"]),
  262. Bidamount: MC.Int64All(v["bidamount"]),
  263. FileExists: isValidFile, //附件
  264. PublishTime: MC.Int64All(v["publishtime"]),
  265. Site: MC.ObjToString(v["site"]),
  266. SpiderCode: MC.ObjToString(v["spidercode"]),
  267. })
  268. }
  269. }
  270. return
  271. }
  272. // GetRedisKeyTimeout 获取缓存的key 和超时时间
  273. func GetRedisKeyTimeout(status int, positionId int64) config.CacheConfig {
  274. var (
  275. redisKey, cuKey string
  276. timeOut, cuTimeOut int
  277. )
  278. switch status {
  279. case StatusNoLogin:
  280. redisKey = IC.C.NewsCache.NoLogin.Key
  281. //redisKey = fmt.Sprintf(redisKey, time.Now().Year(), time.Now().Month(), time.Now().Day())
  282. redisKey = fmt.Sprintf(redisKey, time.Now().Year(), 8, 8) //最开始逻辑是每日更新---》每7天更新一次;不麻烦改配置,就改代码默认月份是8 日期是8
  283. timeOut = IC.C.NewsCache.NoLogin.Timeout
  284. cuKey = fmt.Sprintf("%s_%s", redisKey, IC.C.NewsCache.NoLogin.CacheUpdateKey)
  285. cuTimeOut = IC.C.NewsCache.NoLogin.CacheUpdateTimeout
  286. case StatusLoginUser:
  287. redisKey = IC.C.NewsCache.LoginUser.Key // 登录用户使用的缓存key
  288. //redisKey = fmt.Sprintf(redisKey, positionId, time.Now().Year(), time.Now().Month(), time.Now().Day())
  289. redisKey = fmt.Sprintf(redisKey, positionId, time.Now().Year(), 8, 8) //
  290. timeOut = IC.C.NewsCache.LoginUser.Timeout
  291. cuKey = fmt.Sprintf("%s_%s", redisKey, IC.C.NewsCache.LoginUser.CacheUpdateKey)
  292. cuTimeOut = IC.C.NewsCache.LoginUser.CacheUpdateTimeout
  293. case StatusLogin:
  294. redisKey = IC.C.NewsCache.Login.Key // 登录用户使用的最新标讯缓存key
  295. //redisKey = fmt.Sprintf(redisKey, time.Now().Year(), time.Now().Month(), time.Now().Day())
  296. redisKey = fmt.Sprintf(redisKey, time.Now().Year(), 8, 8) //
  297. timeOut = IC.C.NewsCache.Login.Timeout
  298. cuKey = fmt.Sprintf("%s_%s", redisKey, IC.C.NewsCache.Login.CacheUpdateKey)
  299. cuTimeOut = IC.C.NewsCache.Login.CacheUpdateTimeout
  300. }
  301. return config.CacheConfig{
  302. Key: redisKey,
  303. Timeout: timeOut,
  304. CacheUpdateKey: cuKey,
  305. CacheUpdateTimeout: cuTimeOut,
  306. }
  307. }
  308. // PutNewsCache 存缓存
  309. func PutNewsCache(redisKey string, redisTimeout int, list []*bxbase.NewestList) {
  310. b, err := json.Marshal(list)
  311. if err != nil {
  312. log.Printf("保存缓存 序列化异常,data:%s,err:%s\n", list, err.Error())
  313. return
  314. }
  315. if err = redis.PutBytes("new", redisKey, &b, redisTimeout); err != nil {
  316. log.Printf("保存缓存 redis 异常,key:%s,err:%s\n", redisKey, err.Error())
  317. }
  318. }
  319. // GetNewsCache 取缓存
  320. func GetNewsCache(cc config.CacheConfig) (list []*bxbase.NewestList, err error) {
  321. redisByte, err := redis.GetBytes("new", cc.Key)
  322. if err != nil || redisByte == nil || len(*redisByte) == 0 {
  323. return list, err
  324. }
  325. err = json.Unmarshal(*redisByte, &list)
  326. if err != nil {
  327. logx.Info(fmt.Sprintf("读取缓存 序列化异常,err:%s", err.Error()))
  328. return nil, err
  329. }
  330. return list, nil
  331. }
  332. type NewSet struct {
  333. Status int
  334. RedisKeyModel config.CacheConfig
  335. RedisStatus int
  336. Query string
  337. }
  338. // 排序 入缓存
  339. // status : 0 -拿到的是缓存 不用再处理也不用存缓存 1-存到未登录用户 2-存到用户自己的key 3-存到登录用户最新标讯
  340. func DataSortInRedis(r *bxbase.NewsetBiddingResp, status int, positionId int64) {
  341. //排序
  342. sort.Slice(r.Data.List, func(i, j int) bool {
  343. return r.Data.List[i].PublishTime > r.Data.List[j].PublishTime
  344. })
  345. redisKeyModel := GetRedisKeyTimeout(status, positionId)
  346. go PutNewsCache(redisKeyModel.Key, redisKeyModel.Timeout, r.Data.List)
  347. }
  348. // 延长缓存
  349. // 获取最新数据 -- 延长缓存时间7天---待调整: 1、判断是否需要更新;2、判断订阅信息是否存在,如果存在是否是最新推送,3、订阅信息查推送缓存(只有个人版有缓存:pushcache_2_a )
  350. func ExtendNewListCache(n *NewSet, in *bxbase.NewestBiddingReq, list []*bxbase.NewestList) {
  351. if flag := entity.ReqLimitInit.Limit(context.Background()); flag != 1 {
  352. if flag == -2 {
  353. log.Println("等待队列已满")
  354. } else if flag == -1 {
  355. log.Println("等待超时")
  356. }
  357. } else {
  358. defer entity.ReqLimitInit.Release()
  359. if n.RedisKeyModel.Key != "" {
  360. now := time.Now()
  361. if n.RedisKeyModel.CacheUpdateKey != "" {
  362. var (
  363. res = &bxbase.NewsetBiddingResp{
  364. Data: &bxbase.NewsetBidding{
  365. List: []*bxbase.NewestList{},
  366. },
  367. }
  368. updateTime = redis.GetInt("new", n.RedisKeyModel.CacheUpdateKey)
  369. isDoing bool
  370. )
  371. //防止穿透
  372. entity.ReqLimitLock.Lock()
  373. isDoing, _ = redis.Exists("new", fmt.Sprintf("p1_indexMessage_new_recovery_%d", in.PositionId))
  374. entity.ReqLimitLock.Unlock()
  375. if !isDoing {
  376. entity.ReqLimitLock.Lock()
  377. redis.Put("new", fmt.Sprintf("p1_indexMessage_new_recovery_%d", in.PositionId), "1", 15*time.Now().Minute()) //十五分钟
  378. entity.ReqLimitLock.Unlock()
  379. switch n.RedisStatus {
  380. case StatusLoginUser:
  381. //十五分钟内 更新过一次 不再更新
  382. if int(now.Unix())-updateTime > n.RedisKeyModel.CacheUpdateTimeout {
  383. // 登录用户
  384. roleNewestInfo, _ := GetRoleNewestInfoService(in.AppId, in.MgoUserId, in.NewUserId, in.AccountId, in.EntId, in.EntUserId, in.PositionType, in.PositionId)
  385. //当前用户有最新推送信息
  386. lastPublishTime := list[len(list)-1].PublishTime
  387. if roleNewestInfo.IsHasNewPushData(lastPublishTime) {
  388. // 查推送
  389. subscribeTime := time.Now()
  390. res.Data.List = roleNewestInfo.GetPushHistory()
  391. log.Println(in.PositionId, "获取订阅数据 存缓存 耗时:", time.Since(subscribeTime).Seconds())
  392. } else {
  393. res.Data.List = list
  394. }
  395. }
  396. default:
  397. //十五分钟内 更新过一次 不再更新
  398. if int(now.Unix())-updateTime > n.RedisKeyModel.CacheUpdateTimeout {
  399. res.Data.List = NewestES(n.Query)
  400. }
  401. }
  402. if len(res.Data.List) > 0 {
  403. //更新update time
  404. redis.Put("new", n.RedisKeyModel.CacheUpdateKey, now.Unix(), n.RedisKeyModel.CacheUpdateTimeout)
  405. go DataSortInRedis(res, n.RedisStatus, in.PositionId)
  406. }
  407. }
  408. }
  409. ////剩余时间 在 IC.C.NewsTimeOut 之内
  410. //if ttl := redis.GetTTL("new", n.RedisKeyModel.Key); ttl-IC.C.NewsTimeOut < 0 {
  411. //
  412. //}
  413. }
  414. }
  415. }