12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package public
- import (
- "doFreeClueSign/db"
- "github.com/gogf/gf/v2/frame/g"
- "github.com/gogf/gf/v2/util/gconv"
- "time"
- )
- type BindMsg struct {
- MgoUserID string
- TimeStamp int64 //绑定手机号时间
- Phone string
- }
- // GetBidPhoneUser 获取绑定手机号
- func GetBidPhoneUser(st, ed time.Time) (rData []*BindMsg) {
- sess := db.MG.DB("log").GetMgoConn()
- if sess != nil {
- defer db.MG.DB("log").DestoryMongoConn(sess)
- }
- it := sess.DB("qfw").C("nsq_logs").Find(g.Map{"body.e_body.types": "bindPhone", "createtime": g.Map{"$gte": st.Unix(), "$lt": ed.Unix()}}).
- Select(g.Map{"body.e_userid": 1, "createtime": 1}).Iter()
- for _temp := make(map[string]interface{}); it.Next(&_temp); {
- var (
- userId = gconv.String(gconv.Map(_temp["body"])["e_userid"])
- timeStamp = gconv.Int64(_temp["createtime"])
- )
- if userId == "" {
- continue
- }
- phone := getPhoneByUserId(userId)
- rData = append(rData, &BindMsg{
- MgoUserID: userId,
- TimeStamp: timeStamp,
- Phone: phone,
- })
- _temp = make(map[string]interface{})
- }
- return
- }
- func getPhoneByUserId(userId string) (phone string) {
- res, _ := db.MG.DB().FindById("user", userId, `{"s_phone":1,"s_m_phone":1}`)
- if res == nil || len(*res) == 0 {
- return
- }
- if phone = gconv.String((*res)["s_phone"]); phone != "" {
- return
- }
- if phone = gconv.String((*res)["s_m_phone"]); phone != "" {
- return
- }
- return
- }
|