|
@@ -23,10 +23,22 @@ import (
|
|
|
)
|
|
|
|
|
|
var (
|
|
|
- SaveFields = []string{"_id", "area", "city", "bidamount", "bidopentime", "budget", "buyer", "buyerclass", "projectname", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "winner"}
|
|
|
+ SaveFields = []string{"_id", "area", "city", "buyerclass", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type"}
|
|
|
MailReg = regexp.MustCompile(SysConfig.MailReg)
|
|
|
)
|
|
|
|
|
|
+const (
|
|
|
+ BulkSize = 200
|
|
|
+ ShowField = `"_id","title","detail","projectscope","publishtime","toptype","subtype","type","area","href","areaval","infoformat",` +
|
|
|
+ `"projectname","buyer","winner","budget","bidamount","bidopentime","s_subscopeclass"`
|
|
|
+ SortQuery = `{"publishtime":"desc"}`
|
|
|
+ DB = "bidding"
|
|
|
+ IDRange = `{"range":{"id":{"gt":"%s","lte":"%s"}}},{"range":{"publishtime":{"gt": %d}}}`
|
|
|
+ TimeRange = `{"range":{"comeintime":{"gte":%d,"lte":%d}}}`
|
|
|
+ MaxId = `{"query":{"filtered":{"filter":{"bool":{"must":{"range":{"id":{"gt":"%s"}}}}}}},"_source":["_id","comeintime"],"sort":{"id":"desc"},"from":0,"size":1}`
|
|
|
+ DbName = "qfw"
|
|
|
+)
|
|
|
+
|
|
|
type Pjob struct {
|
|
|
InterestDfa *dfa.DFA
|
|
|
NotInterestDfa *dfa.DFA
|
|
@@ -222,7 +234,19 @@ func (m *MatchJob) LoadBidding(lastId, newId string, lastTime int64) bool {
|
|
|
var res []map[string]interface{}
|
|
|
sess := mongodb.GetMgoConn()
|
|
|
defer mongodb.DestoryMongoConn(sess)
|
|
|
- it := sess.DB(DbName).C("bidding").Find(c_query).Select(mongodb.ObjToOth(Mongodb_ShowField)).Sort("_id").Iter()
|
|
|
+ it := sess.DB(DbName).C("bidding").Find(c_query).Select(map[string]interface{}{
|
|
|
+ "title": 1,
|
|
|
+ "detail": 1,
|
|
|
+ "projectscope": 1,
|
|
|
+ "publishtime": 1,
|
|
|
+ "toptype": 1,
|
|
|
+ "subtype": 1,
|
|
|
+ "type": 1,
|
|
|
+ "area": 1,
|
|
|
+ "s_subscopeclass": 1,
|
|
|
+ "city": 1,
|
|
|
+ "buyerclass": 1,
|
|
|
+ }).Sort("_id").Iter()
|
|
|
index := 0
|
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); {
|
|
|
index++
|
|
@@ -302,7 +326,9 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
|
|
|
//免费用户
|
|
|
title_key_user := make(map[string]*[]*UserInfo)
|
|
|
title_notkey_user := make(map[string]*[]*UserInfo)
|
|
|
+ nowymd := util.NowFormat(util.Date_yyyyMMdd)
|
|
|
for temp := make(map[string]interface{}); query.Next(temp); {
|
|
|
+ userId := fmt.Sprintf("%x", string(temp["_id"].(bson.ObjectId)))
|
|
|
s_m_openid := util.ObjToString(temp["s_m_openid"])
|
|
|
a_m_openid := util.ObjToString(temp["a_m_openid"])
|
|
|
s_phone := util.ObjToString(temp["s_phone"])
|
|
@@ -314,11 +340,14 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
|
|
|
pchelperPush := 0
|
|
|
//公众号取关用户
|
|
|
if userType == 0 && isPush == 0 {
|
|
|
+ logger.Info("过滤掉,公众号取关用户", userId)
|
|
|
continue
|
|
|
} else if userType == 2 && jpushid == "" && (opushid == "" || appPhoneType == "") {
|
|
|
+ logger.Info("过滤掉,app用户没有登录", userId)
|
|
|
continue
|
|
|
} else if (userType == 1 || (userType == 5 && isPush == 0)) && jpushid == "" && (opushid == "" || appPhoneType == "") {
|
|
|
if s_phone == "" || !mutil.PcHelperIsOnLine(s_phone) {
|
|
|
+ logger.Info("过滤掉,s_phone为空或者pc助手s_phone不在线", userId)
|
|
|
continue
|
|
|
} else {
|
|
|
pchelperPush = 1
|
|
@@ -326,11 +355,12 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
|
|
|
}
|
|
|
applystatus := util.IntAll(temp["i_applystatus"])
|
|
|
vipStatus := util.IntAll(temp["i_vipstatus"])
|
|
|
+ isVipUser := IsVipUser(vipStatus)
|
|
|
var o_msgset map[string]interface{}
|
|
|
- if !IsVipUser(vipStatus) {
|
|
|
- o_msgset, _ = temp["o_jy"].(map[string]interface{})
|
|
|
- } else {
|
|
|
+ if isVipUser {
|
|
|
o_msgset, _ = temp["o_vipjy"].(map[string]interface{})
|
|
|
+ } else {
|
|
|
+ o_msgset, _ = temp["o_jy"].(map[string]interface{})
|
|
|
}
|
|
|
wxpush, apppush, mailpush := mutil.ModeTransform(userType, o_msgset)
|
|
|
email := strings.TrimSpace(util.ObjToString(o_msgset["s_email"]))
|
|
@@ -338,14 +368,16 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
|
|
|
mailpush = 0
|
|
|
}
|
|
|
if wxpush != 1 && apppush != 1 && mailpush != 1 {
|
|
|
+ logger.Info("过滤掉,wxpush apppush mailpush 都不是1", userId, wxpush, apppush, mailpush)
|
|
|
continue
|
|
|
}
|
|
|
- userId := fmt.Sprintf("%x", string(temp["_id"].(bson.ObjectId)))
|
|
|
var allKeySet []*KeySet
|
|
|
var err error
|
|
|
- if !IsVipUser(vipStatus) {
|
|
|
- allKeySet, err = m.GetKeySet(o_msgset["a_key"])
|
|
|
- } else {
|
|
|
+ if isVipUser {
|
|
|
+ if dayCount := redis.GetInt("other", DayCountKey(nowymd, userId)); dayCount >= SysConfig.VipOneDayMaxPushSize {
|
|
|
+ logger.Info("vip用户达到一天最大推送数量", userId, dayCount)
|
|
|
+ continue
|
|
|
+ }
|
|
|
vip_items, _ := o_msgset["a_items"].([]interface{})
|
|
|
for _, v := range vip_items {
|
|
|
vip_item, _ := v.(map[string]interface{})
|
|
@@ -356,6 +388,8 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
|
|
|
}
|
|
|
allKeySet = append(allKeySet, vip_keySet...)
|
|
|
}
|
|
|
+ } else {
|
|
|
+ allKeySet, err = m.GetKeySet(o_msgset["a_key"])
|
|
|
}
|
|
|
if err != nil {
|
|
|
logger.Error("获取用户关键词错误!", userId, err)
|
|
@@ -427,7 +461,8 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
|
|
|
key_infotype[upperKey][infotype] = true
|
|
|
}
|
|
|
}
|
|
|
- if !IsVipUser(vipStatus) && len(originalKeys) == 0 {
|
|
|
+ if !isVipUser && len(originalKeys) == 0 {
|
|
|
+ logger.Info("过滤掉,没有关键词", userId)
|
|
|
continue
|
|
|
}
|
|
|
modifydate := ""
|
|
@@ -465,14 +500,7 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
|
|
|
VipStatus: vipStatus,
|
|
|
}
|
|
|
/***************start*****************/
|
|
|
- if !IsVipUser(vipStatus) {
|
|
|
- user.O_jy = &O_jy{
|
|
|
- Area: key_area,
|
|
|
- Infotype: key_infotype,
|
|
|
- }
|
|
|
- m.MakeKeyUser(keys, user, &title_key_user)
|
|
|
- m.MakeKeyUser(notkeys, user, &title_notkey_user)
|
|
|
- } else {
|
|
|
+ if isVipUser {
|
|
|
//vip付费-采购单位行业
|
|
|
vip_buyerclass, _ := o_msgset["a_buyerclass"].([]interface{})
|
|
|
if len(vip_buyerclass) == 0 {
|
|
@@ -528,6 +556,13 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
|
|
|
m.MakeKeyUser(keys, user, &vip_detail_key_user)
|
|
|
m.MakeKeyUser(notkeys, user, &vip_detail_notkey_user)
|
|
|
}
|
|
|
+ } else {
|
|
|
+ user.O_jy = &O_jy{
|
|
|
+ Area: key_area,
|
|
|
+ Infotype: key_infotype,
|
|
|
+ }
|
|
|
+ m.MakeKeyUser(keys, user, &title_key_user)
|
|
|
+ m.MakeKeyUser(notkeys, user, &title_notkey_user)
|
|
|
}
|
|
|
/***************end*****************/
|
|
|
m.lastUserId = user.Id
|