1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package public
- import (
- "app.yhyue.com/moapp/jybase/mongodb"
- "doFreeClueSign/db"
- "github.com/gogf/gf/v2/frame/g"
- "github.com/gogf/gf/v2/util/gconv"
- "time"
- )
- type AgainSubUserMsg struct {
- MgoUserID string
- TimeStamp int64 //关注时间
- }
- // GetAgainSubUser 再次关注用户列表
- func GetAgainSubUser(st, ed time.Time) (rData []*AgainSubUserMsg) {
- sess := db.MG.DB().GetMgoConn()
- if sess != nil {
- defer db.MG.DB().DestoryMongoConn(sess)
- }
- it := sess.DB("qfw").C("jy_subscribe").Find(g.Map{"s_event": "subscribe", "l_date": g.Map{"$gte": st.Unix(), "$lt": ed.Unix()}}).
- Select(g.Map{"s_m_openid": 1, "l_date": 1}).Iter()
- for _temp := make(map[string]interface{}); it.Next(&_temp); {
- var (
- s_m_openid = gconv.String(_temp["s_m_openid"])
- timeStamp = gconv.Int64(_temp["l_date"])
- )
- //是否有取关记录
- if count := db.MG.DB().Count("jy_subscribe", g.Map{"s_event": "unsubscribe", "$lt": st.Unix()}); count == 0 {
- continue
- }
- if mgoUserID := getUserIdByOpenid(s_m_openid); mgoUserID != "" {
- rData = append(rData, &AgainSubUserMsg{
- MgoUserID: mgoUserID,
- TimeStamp: timeStamp,
- })
- }
- _temp = make(map[string]interface{})
- }
- return nil
- }
- func getUserIdByOpenid(openId string) (userId string) {
- res, _ := db.MG.DB().FindOne("user", g.Map{"s_m_openid": openId})
- if res == nil || len(*res) == 0 {
- return
- }
- userId = mongodb.BsonIdToSId((*res)["_id"])
- return
- }
|