wangchuanjin hace 5 meses
padre
commit
f2f66cb74a
Se han modificado 2 ficheros con 6 adiciones y 4 borrados
  1. 1 1
      main.go
  2. 5 3
      p/public.go

+ 1 - 1
main.go

@@ -14,5 +14,5 @@ func main() {
 		DbName:      "push",
 	}
 	mgo.InitPool()
-	log.Println(GetWxTplSurplus(mgo, 2, 7, 1000000, 100000))
+	log.Println(WxNoMsgTmplUsableNum(mgo, 2, 7, 1000000, 100000))
 }

+ 5 - 3
p/public.go

@@ -904,7 +904,7 @@ func WxNoMsgTmplUsableNum(mgo *MongodbSim, wxNodeNum, dayNum, count, retain int6
 		now = now.AddDate(0, 0, -1)
 		ymds = append(ymds, FormatDate(&now, Date_Short_Layout))
 	}
-	list, ok := mgo.Find("wxtmplsend_tj", map[string]interface{}{"type": map[string]interface{}{"$in": []string{"all", "nomsg"}}, "ymd": map[string]interface{}{"$in": ymds}}, `{"ymd":-1}`, `{"count":1,"node_type":1,"ymd":1}`, false, -1, -1)
+	list, ok := mgo.Find("wxtmplsend_tj", map[string]interface{}{"type": map[string]interface{}{"$in": []string{"all", "nomsg"}}, "ymd": map[string]interface{}{"$in": ymds}}, `{"ymd":-1}`, `{"count":1,"node":1,"ymd":1,"type":1}`, false, -1, -1)
 	if !ok || list == nil || len(*list) == 0 {
 		logger.Error("wxtmplsend_tj没有找到记录", ymds)
 		return 0
@@ -917,7 +917,7 @@ func WxNoMsgTmplUsableNum(mgo *MongodbSim, wxNodeNum, dayNum, count, retain int6
 		if all[ymd] == nil {
 			all[ymd] = map[string]int64{}
 		}
-		all[ymd][ObjToString(v["node_type"])]++
+		all[ymd][ObjToString(v["node"])]++
 		if ObjToString(v["type"]) == "all" {
 			ymdCount[ymd] += Int64All(v["count"])
 		} else {
@@ -925,6 +925,7 @@ func WxNoMsgTmplUsableNum(mgo *MongodbSim, wxNodeNum, dayNum, count, retain int6
 		}
 	}
 	var index, maxNum, maxNoMsgNum int64
+	var hitYmd string
 L:
 	for _, v := range ymds {
 		if all[v] == nil || int64(len(all[v])) != wxNodeNum+1 {
@@ -937,6 +938,7 @@ L:
 		}
 		index++
 		if maxNum < ymdCount[v] {
+			hitYmd = v
 			maxNum = ymdCount[v]
 			maxNoMsgNum = ymdNoMsgCount[v]
 		}
@@ -949,6 +951,6 @@ L:
 	if surplus < 0 {
 		return 0
 	}
-	logger.Info("微信模板消息最大量", count, ",过去", dayNum, "天内一天最大推送量", maxNum, ",保留", retain, ",剩余可用", surplus)
+	logger.Info("微信模板消息最大量", count, ",过去", dayNum, "天", hitYmd, "的推送量最大", maxNum, ",无消息提醒的推送量", maxNoMsgNum, ",保留", retain, ",剩余可用", surplus)
 	return surplus
 }