|
@@ -5,13 +5,17 @@ import (
|
|
|
. "activeStartTip/rpc"
|
|
|
"log"
|
|
|
"sync"
|
|
|
+ "sync/atomic"
|
|
|
"time"
|
|
|
|
|
|
"app.yhyue.com/moapp/MessageCenter/rpc/type/message"
|
|
|
+ "app.yhyue.com/moapp/jybase/common"
|
|
|
. "app.yhyue.com/moapp/jybase/mongodb"
|
|
|
+ "go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
)
|
|
|
|
|
|
func main() {
|
|
|
+ allUser := loadAllUser()
|
|
|
pool := make(chan bool, Config.SendMsgPool)
|
|
|
wait := &sync.WaitGroup{}
|
|
|
sess := Mgo.GetMgoConn()
|
|
@@ -22,25 +26,14 @@ func main() {
|
|
|
"$in": ToObjectIds(Config.TestIds),
|
|
|
}
|
|
|
} else {
|
|
|
- unix := time.Now().AddDate(-1, 0, 0).Unix()
|
|
|
- query["$or"] = []map[string]interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "$gt": map[string]interface{}{
|
|
|
- "l_registedate": unix,
|
|
|
- },
|
|
|
- },
|
|
|
- map[string]interface{}{
|
|
|
- "$gt": map[string]interface{}{
|
|
|
- "auto_updatetime": unix,
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
+ query["i_appid"] = 2
|
|
|
}
|
|
|
log.Println("start...", query)
|
|
|
it := sess.DB("qfw").C("user").Find(query).Select(map[string]interface{}{
|
|
|
- "_id": 1,
|
|
|
- }).Iter()
|
|
|
- index := 0
|
|
|
+ "_id": 1,
|
|
|
+ "base_user_id": 1,
|
|
|
+ }).Sort("_id").Iter()
|
|
|
+ var index int64
|
|
|
for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
pool <- true
|
|
|
wait.Add(1)
|
|
@@ -49,23 +42,57 @@ func main() {
|
|
|
<-pool
|
|
|
wait.Done()
|
|
|
}()
|
|
|
+ if !allUser[common.Int64All(u["base_user_id"])] {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ rs := atomic.AddInt64(&index, 1)
|
|
|
+ rs++
|
|
|
+ if rs%5000 == 0 {
|
|
|
+ log.Println("index", rs)
|
|
|
+ }
|
|
|
_id := BsonIdToSId(u["_id"])
|
|
|
SendMsg(&message.MultipleSaveMsgReq{
|
|
|
UserIds: _id,
|
|
|
Title: "做任务赚好礼",
|
|
|
Content: "7天内完成限时任务,额外赠送超级订阅7天体验。获取更多采购项目信息,快速对接项目联系人!",
|
|
|
MsgType: 1,
|
|
|
- Link: "/home/work-bench/app/points/earn,/jy_mobile/points/earn,/jy_mobile/points/earn",
|
|
|
+ Link: "/page_workDesktop/work-bench/app/points/earn,/jy_mobile/points/earn,/jy_mobile/points/earn,/jy_mobile/points/earn",
|
|
|
Appid: "10000",
|
|
|
AppPushUrl: "/jy_mobile/points/earn",
|
|
|
IosPushUrl: "/jy_mobile/points/earn",
|
|
|
})
|
|
|
}(m)
|
|
|
- index++
|
|
|
- if index%500 == 0 {
|
|
|
- log.Println("index", index)
|
|
|
- }
|
|
|
}
|
|
|
wait.Wait()
|
|
|
log.Println("over...", index)
|
|
|
}
|
|
|
+
|
|
|
+func loadAllUser() map[int64]bool {
|
|
|
+ _id := primitive.NewObjectIDFromTimestamp(time.Now().AddDate(-1, 0, 0))
|
|
|
+ log.Println("开始加载最近一年活跃用户。。。", _id)
|
|
|
+ allUser := map[int64]bool{}
|
|
|
+ sess := Mgo_Log.GetMgoConn()
|
|
|
+ defer Mgo_Log.DestoryMongoConn(sess)
|
|
|
+ it := sess.DB("qfw").C("jy_gateway_logs").Find(map[string]interface{}{
|
|
|
+ "_id": map[string]interface{}{
|
|
|
+ "$gt": _id,
|
|
|
+ },
|
|
|
+ }).Select(map[string]interface{}{
|
|
|
+ "_id": 0,
|
|
|
+ "userid_new": 1,
|
|
|
+ }).Iter()
|
|
|
+ var index int64
|
|
|
+ for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
+ index++
|
|
|
+ if index%50000 == 0 {
|
|
|
+ log.Println("加载最近一年活跃用户", index)
|
|
|
+ }
|
|
|
+ userid_new := common.Int64All(m["userid_new"])
|
|
|
+ if userid_new <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ allUser[userid_new] = true
|
|
|
+ }
|
|
|
+ log.Println("加载最近一年活跃用户结束。。。", _id, index)
|
|
|
+ return allUser
|
|
|
+}
|