wcj 5 жил өмнө
parent
commit
804dea9b51

+ 1 - 1
src/jfw/modules/pushsubscribe/src/match/config.json

@@ -1,7 +1,7 @@
 {
 	"elasticPoolSize": 1,
 	"elasticSearch": "http://192.168.3.128:9800",
-	"redisServers": "pushcache_1=192.168.3.128:5000,other=192.168.3.128:5000",
+	"redisServers": "pushcache_1=192.168.3.128:5000,pushcache_2_a=192.168.3.128:5001",
 	"maxPushSize": 50,
 	"maxSearch": 5000,
 	"vipOneDayMaxPushSize": 2000,

+ 1 - 4
src/jfw/modules/pushsubscribe/src/match/job/freeuser.go

@@ -7,14 +7,11 @@ import (
 
 //免费用户
 type FreeUser struct {
-	Users      map[*UserInfo]bool
 	Title_Pjob *Pjob
 }
 
 func NewFreeUser() *FreeUser {
-	return &FreeUser{
-		Users: map[*UserInfo]bool{},
-	}
+	return &FreeUser{}
 }
 func (f *FreeUser) Match(info *map[string]interface{}) *map[*UserInfo]*MatchUser {
 	title, _ := (*info)["title"].(string)

+ 4 - 3
src/jfw/modules/pushsubscribe/src/match/job/matchjob.go

@@ -299,7 +299,7 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
 		"_id":             1,
 		"o_jy":            1,
 		"o_vipjy":         1,
-		"i_vipstatus":     1,
+		"i_vip_status":    1,
 		"s_m_openid":      1,
 		"a_m_openid":      1,
 		"s_phone":         1,
@@ -354,7 +354,7 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
 			}
 		}
 		applystatus := util.IntAll(temp["i_applystatus"])
-		vipStatus := util.IntAll(temp["i_vipstatus"])
+		vipStatus := util.IntAll(temp["i_vip_status"])
 		isVipUser := IsVipUser(vipStatus)
 		var o_msgset map[string]interface{}
 		if isVipUser {
@@ -374,7 +374,7 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
 		var allKeySet []*KeySet
 		var err error
 		if isVipUser {
-			if dayCount := redis.GetInt("other", DayCountKey(nowymd, userId)); dayCount >= SysConfig.VipOneDayMaxPushSize {
+			if dayCount := redis.GetInt("pushcache_2_a", DayCountKey(nowymd, userId)); dayCount >= SysConfig.VipOneDayMaxPushSize {
 				logger.Info("vip用户达到一天最大推送数量", userId, dayCount)
 				continue
 			}
@@ -556,6 +556,7 @@ 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)
 			}
+			vipUser.Users[user] = true
 		} else {
 			user.O_jy = &O_jy{
 				Area:     key_area,

+ 5 - 2
src/jfw/modules/pushsubscribe/src/match/job/vipuser.go

@@ -38,6 +38,9 @@ func NewVipUser() *VipUser {
 func (v *VipUser) Match(info *map[string]interface{}) *map[*UserInfo]*MatchUser {
 	buyerclass, _ := (*info)["buyerclass"].(string)
 	area, _ := (*info)["area"].(string)
+	if area == "全国" {
+		area = ""
+	}
 	city, _ := (*info)["city"].(string)
 	toptype, _ := (*info)["toptype"].(string)
 	title, _ := (*info)["title"].(string)
@@ -70,8 +73,8 @@ func (v *VipUser) Match(info *map[string]interface{}) *map[*UserInfo]*MatchUser
 	users := map[*UserInfo]*MatchUser{}
 	for k, _ := range v.Users {
 		if (!v.BuyerclassUsers[""][k] && !v.BuyerclassUsers[buyerclass][k]) ||
-			(!v.AreaUsers[""][k] || !v.AreaUsers[area][k] || !v.AreaUsers[city][k]) ||
-			(!v.InfoTypeUsers[""][k] || !v.InfoTypeUsers[toptype][k]) {
+			(!v.AreaUsers[""][k] && !v.AreaUsers[area][k] && !v.AreaUsers[city][k]) ||
+			(!v.InfoTypeUsers[""][k] && !v.InfoTypeUsers[toptype][k]) {
 			continue
 		}
 		var matchUser *MatchUser

+ 6 - 0
src/jfw/modules/pushsubscribe/src/public/util.go

@@ -11,6 +11,12 @@ func IsVipUser(vipStatus int) bool {
 	return false
 }
 
+//一天的推送总数
 func DayCountKey(nowymd, id string) string {
 	return fmt.Sprintf("daycount_%s_%s", nowymd, id)
 }
+
+//今天最后一次的推送总数
+func OnceCountKey(nowymd, id string) string {
+	return fmt.Sprintf("oncecount_%s_%s", nowymd, id)
+}

+ 1 - 1
src/jfw/modules/pushsubscribe/src/push/config.json

@@ -8,7 +8,7 @@
 		"size": 5,
 		"timeout": 20
 	},
-	"redisServers": "pushcache_2_a=192.168.3.128:5000,pushcache_2_b=192.168.3.128:5000,other=192.168.3.128:5000",
+	"redisServers": "pushcache_2_a=192.168.3.128:5001,pushcache_2_b=192.168.3.128:5002",
 	"mail_content": "<tr><td><num>%d</num></td><td><div class='tit'><a style='color: #000;text-decoration: none;' href='%s?mail' >%s</a></div></td><td style='float: right;' class='infos' ><span class='%s'>%s</span><span class='%s'>%s</span><span class='%s'>%s</span><span class='time'>%s</span></td></tr>",
 	"mail_html": "<body><style> *,body,html{margin:0;padding:0;font-family: tahoma, arial, 'Hiragino Sans GB', 'Microsoft YaHei', 宋体, sans-serif;font-size:16px; }#all{margin:0 auto;width:1024px;overflow:hidden;}.head{margin:5x;margin-top:20px;}.des{padding-bottom:15px;border-bottom:1px solid #e8ecee;color: #686868;}td a:hover {color: #fe7379;text-decoration: underline;} .tit{width:560px;overflow: hidden;    white-space: nowrap;text-overflow: ellipsis;}.area {background-color: #2cb7ca;border-radius: 3px;color: #fff;padding: 1px 2px;}.type {background-color: #ffba00;border-radius: 3px;color: #fff;padding: 1px 2px;margin-left:5px;}.industry {background-color: #25c78c;border-radius: 3px;color: #fff;padding: 1px 2px;margin-left:5px;}.infos span{display:inline-block;margin-left:5px;}td{padding-top:8px;padding-bottom:8px;height:20px;line-height:20px;}num{padding:0 5px 0 0; font-size:16px;color:#2cb7ca;font-weight:bolder;}.keys{color:blue;} </style><div id='all'><div class='head'><IMG width='100px' src=http://www.zhaobiao.info/images/swordfish/sf_01.png /></div><div class='head des'>根据您设置的关键词 :<span class='keys'>%s</span>,剑鱼标讯为您推送30天之内的信息。点击标题可查看详情信息</div><table cellpadding='0' cellspacing='0'>%s</table></div> </body>",
 	"mail_title": "您有新的%s信息-剑鱼标讯",

+ 10 - 5
src/jfw/modules/pushsubscribe/src/push/job/dopush.go

@@ -57,8 +57,11 @@ func (d *doPush) Do(taskType int, isSave bool, wxPush, appPush, mailPush int, k
 	TitleArray := []string{}
 	infos := []*MatchInfo{}
 	publishTitle := map[string]bool{}
-	nowymd := util.NowFormat(util.Date_yyyyMMdd)
-	//邮件附件
+	dateymd := util.NowFormat(util.Date_yyyyMMdd)
+	dayCountKey := DayCountKey(dateymd, k.Id)
+	onceCountKey := DayCountKey(dateymd, k.Id)
+	dayCount := redis.GetInt("pushcache_2_a", dayCountKey)
+	isVipUser := IsVipUser(k.VipStatus)
 	for _, ks := range *sl {
 		k2 := *ks.Info
 		title := strings.Replace(k2["title"].(string), "\n", "", -1)
@@ -137,22 +140,24 @@ func (d *doPush) Do(taskType int, isSave bool, wxPush, appPush, mailPush int, k
 			}
 			mailContent += fmt.Sprintf(SysConfig.Mail_content, i, url, otitle, classArea, area, classType, infotype, industryclass, industry, dates)
 		}
-		if IsVipUser(k.VipStatus) {
-			if redis.GetInt("other", DayCountKey(nowymd, k.Id)) >= SysConfig.VipOneDayMaxPushSize {
+		if isVipUser {
+			if dayCount >= SysConfig.VipOneDayMaxPushSize {
 				break
 			}
-			redis.Incr("other", DayCountKey(nowymd, k.Id))
 		} else {
 			//限制最大信息条数
 			if i >= SysConfig.MaxPushSize {
 				break
 			}
 		}
+		dayCount++
 	}
 	if i == 0 {
 		logger.Info("推送任务", taskType, "没有要推送的数据!", k.Id)
 		return
 	}
+	redis.Put("pushcache_2_a", dayCountKey, dayCount, 86400)
+	redis.Put("pushcache_2_a", onceCountKey, i, 86400)
 	//限制一分钟最大的推送数量
 	if d.fastigiumMinutePushPool != nil {
 		if hour := time.Now().Hour(); hour >= FastigiumStart && hour <= FastigiumEnd {

BIN
src/jfw/modules/pushsubscribe/src/push/push.exe~


+ 21 - 21
src/jfw/modules/pushsubscribe/src/push/util/util.go

@@ -173,13 +173,13 @@ func updateRedis(date int64, k *UserInfo, infos *[]*map[string]interface{}) {
 	case 0, 1:
 		pc_a.Type = 1
 		list_a = append(list_a, pc_a.Infos...)
-		if length_a > 250 {
+		if length_a > 500 {
 			if pc_b != nil {
-				list_b = append(list_b, list_a[250:]...)
+				list_b = append(list_b, list_a[500:]...)
 			}
-			list_a = list_a[:250]
-			pc_a.Count = 250
-		} else if length_a == 250 {
+			list_a = list_a[:500]
+			pc_a.Count = 500
+		} else if length_a == 500 {
 			pc_a.Count = 0
 		} else {
 			pc_a.Count = length_a
@@ -188,38 +188,38 @@ func updateRedis(date int64, k *UserInfo, infos *[]*map[string]interface{}) {
 	case 2:
 		list_a = append(list_a, pc_a.Infos...)
 		pc_a.Type = 3
-		if length_a > 250 {
+		if length_a > 500 {
 			if pc_b != nil {
-				list_b = append(list_b, list_a[250:]...)
+				list_b = append(list_b, list_a[500:]...)
 			}
-			list_a = list_a[:250]
-			pc_a.Count = 250 - len(*infos)
-		} else if length_a == 250 {
+			list_a = list_a[:500]
+			pc_a.Count = 500 - len(*infos)
+		} else if length_a == 500 {
 			pc_a.Count = len(pc_a.Infos)
 		}
 		break
 	case 3:
-		if length_a > 250 {
+		if length_a > 500 {
 			if pc_a.Count > 0 && pc_a.Count < len(pc_a.Infos) {
-				pc_a_a := pc_a.Infos[:250-pc_a.Count]
-				pc_a_b := pc_a.Infos[250-pc_a.Count:]
+				pc_a_a := pc_a.Infos[:500-pc_a.Count]
+				pc_a_b := pc_a.Infos[500-pc_a.Count:]
 				list_a = append(list_a, pc_a_a...)
-				if len(list_a) > 250 {
+				if len(list_a) > 500 {
 					pc_a.Type = 1
-					pc_a.Count = 250
+					pc_a.Count = 500
 					if pc_b != nil {
-						list_b = append(list_b, list_a[250:]...)
+						list_b = append(list_b, list_a[500:]...)
 						list_b = append(list_b, pc_a_b...)
 					}
-					list_a = list_a[:250]
-				} else if len(list_a) == 250 {
+					list_a = list_a[:500]
+				} else if len(list_a) == 500 {
 					pc_a.Type = 1
 					pc_a.Count = 0
 					if pc_b != nil {
 						list_b = append(list_b, pc_a_b...)
 					}
 				} else {
-					needLength := 250 - len(list_a)
+					needLength := 500 - len(list_a)
 					if needLength > len(pc_a_b) {
 						list_a = append(list_a, pc_a_b...)
 						pc_a.Count = len(pc_a_b)
@@ -244,8 +244,8 @@ func updateRedis(date int64, k *UserInfo, infos *[]*map[string]interface{}) {
 	jy.HistoryPush.PutPushCache_A(k.Id, pc_a)
 	if pc_b != nil {
 		list_b = append(list_b, pc_b...)
-		if len(list_b) > 1750 {
-			list_b = list_b[:1750]
+		if len(list_b) > 3500 {
+			list_b = list_b[:3500]
 		}
 		jy.HistoryPush.PutPushCache_B(k.Id, list_b)
 	}