Ver código fonte

fix:动态修改

duxin 1 ano atrás
pai
commit
06b5f8633e
1 arquivos alterados com 13 adições e 27 exclusões
  1. 13 27
      entniche_new/src/entity/portrait_screen.go

+ 13 - 27
entniche_new/src/entity/portrait_screen.go

@@ -320,11 +320,11 @@ func (pwp *PortraitProjectScreen) GetBuyerListSearch() (list *[]map[string]inter
 
 func (pwp *PortraitProjectScreen) FreePortraitNews(mustQueryArr []string, isWinner bool) (data *[]map[string]interface{}, total int64, updateTime int64, err error) {
 	redisKey := fmt.Sprintf("free_portrait_list_%s", pwp.Screen.Ent)
-	var redisData map[string]interface{}
+	redisData := make(map[string]interface{})
+	var dataArr []map[string]interface{}
 	if rBytes, err := redis.GetBytes("other", redisKey); err == nil && len(*rBytes) != 0 {
 		_ = json.Unmarshal(*rBytes, &redisData)
-		dataArr, _ := redisData["data"].([]map[string]interface{})
-		data = &dataArr
+		dataArr, _ = redisData["data"].([]map[string]interface{})
 		total, _ = redisData["total"].(int64)
 		updateTime, _ = redisData["updateTime"].(int64)
 	} else {
@@ -340,35 +340,21 @@ func (pwp *PortraitProjectScreen) FreePortraitNews(mustQueryArr []string, isWinn
 		if total > 0 {
 			list := elastic.Get(biddingIndex, biddingIndex, listQuery)
 			if list != nil && len(*list) > 0 {
-				data = list
+				dataArr = *list
 			}
 		}
-	}
-	go func() {
-		redis.Put("other", redisKey, map[string]interface{}{
-			"data":       data,
-			"total":      total,
-			"updateTime": updateTime,
-		}, 24*3600*config.Config.PortraitDynamicTime)
-	}()
+		go func() {
+			redis.Put("other", redisKey, map[string]interface{}{
+				"data":       dataArr,
+				"total":      total,
+				"updateTime": updateTime,
+			}, 24*3600*config.Config.PortraitDynamicTime)
+		}()
+	}
+	data = &dataArr
 	return
 }
 
-func redisTime() float64 {
-	currentTime := time.Now()
-
-	currentWeekday := currentTime.Weekday()
-	daysUntilMonday := time.Monday - currentWeekday
-	if daysUntilMonday < 0 {
-		daysUntilMonday += 7
-	}
-	nextMonday := currentTime.AddDate(0, 0, int(daysUntilMonday))
-
-	nextMondayMidnight := time.Date(nextMonday.Year(), nextMonday.Month(), nextMonday.Day(), 0, 0, 0, 0, nextMonday.Location())
-
-	return nextMondayMidnight.Sub(currentTime).Seconds()
-}
-
 // GetBuyerList 获取采购单位采购信息数据
 // 会员展示1-4页表格数据,免费用户前三条
 func (pwp *PortraitProjectScreen) GetBuyerList() (list []map[string]interface{}, total, updateTime int64, err error) {