fuwencai 3 місяців тому
батько
коміт
837fe206c1
1 змінених файлів з 13 додано та 1 видалено
  1. 13 1
      back-end/service/integral/integral.go

+ 13 - 1
back-end/service/integral/integral.go

@@ -127,7 +127,7 @@ func (this *Integral) ToUpdate() {
 					user := util.GetUserBaseInfo(this.Session())
 					key := fmt.Sprintf(TaskActivityCacheKey, user.PositionId, TaskActiveId, TaskId)
 					if exist, _ := redis.Exists("other", key); !exist {
-						redis.Put("other", key, 1, TaskActivityCacheTimeout)
+						redis.Put("other", key, 1, GetTimeout(TaskActivityCacheTimeout))
 						// p718
 						platform := util.GetPlatform(this.Request)
 						nsqNode := jy.Jyweb_node2
@@ -173,6 +173,18 @@ func (this *Integral) ToUpdate() {
 	}()
 	this.ServeJson(r)
 }
+func GetTimeout(n int) int {
+	t := time.Now()
+	midnight := time.Date(t.Year(), t.Month(), t.Day()+1, 0, 0, 0, 0, t.Location())
+	if midnight.After(t) {
+		if int(midnight.Unix()-t.Unix()) > n {
+			return n
+		} else {
+			return int(midnight.Unix() - t.Unix())
+		}
+	}
+	return n
+}
 
 // 用户剑鱼币明细
 func (this *Integral) GetList() {