wcj 6 lat temu
rodzic
commit
c283884927

+ 5 - 10
src/jfw/front/swordfish.go

@@ -2454,9 +2454,12 @@ func (f *Front) HasPushHistory() {
 //历史推送
 func (f *Front) Historypush() error {
 	myopenid := util.ObjToString(f.GetSession("s_m_openid"))
-	userid := util.ObjToString(f.GetSession("userId"))
+	userId := util.ObjToString(f.GetSession("userId"))
+	if myopenid == "" || userId == "" {
+		return f.Redirect("/swordfish/share/-1")
+	}
 	// 打开推送
-	data, ok := mongodb.FindById("user", userid, nil)
+	data, ok := mongodb.FindById("user", userId, nil)
 	i_applystatus := (*data)["i_applystatus"]
 
 	var o_jy map[string]interface{}
@@ -2467,15 +2470,7 @@ func (f *Front) Historypush() error {
 		f.SetSession("a_key", a_key)
 	}
 	a_key := f.GetSession("a_key")
-	//	log.Println("a_key", a_key)
-
-	/*************/
-	if myopenid == "" || userid == "" {
-		return f.Redirect("/swordfish/share/-1")
-	}
-
 	f.T["forceShareFlag"] = public.CheckUserNeedForceShare(myopenid, public.ShareType_push)
-
 	mynickname, _ := f.Session().Get("s_nickname").(string)
 	myavatar, _ := f.Session().Get("s_avatar").(string)
 	f.T["nickname"] = mynickname

+ 27 - 26
src/jfw/modules/pushsubscribe/src/match/job/matchjob.go

@@ -188,30 +188,31 @@ func (m *MatchJob) Save(a_p, s_p *Pjob) {
 		}
 		user := (*m.users)[openid]
 		m.saveBatch = append(m.saveBatch, map[string]interface{}{
-			"s_m_openid":   user.S_m_openid,
-			"a_m_openid":   user.A_m_openid,
-			"phone":        user.Phone,
-			"jpushid":      user.Jpushid,
-			"opushid":      user.Opushid,
-			"appphonetype": user.AppPhoneType,
-			"userid":       user.Id,
-			"ratemode":     user.RateMode,
-			"wxpush":       user.WxPush,
-			"apppush":      user.AppPush,
-			"mailpush":     user.MailPush,
-			"smartset":     user.SmartSet,
-			"usertype":     user.UserType,
-			"email":        user.Email,
-			"dataexport":   user.DataExport,
-			"list":         array,
-			"size":         size,
-			"subscribe":    user.Subscribe,
-			"applystatus":  user.ApplyStatus,
-			"words":        user.OriginalKeys,
-			"modifydate":   user.ModifyDate,
-			"mergeorder":   user.MergeOrder,
-			"timestamp":    time.Now().Unix(),
-			"nickname":     user.NickName,
+			"s_m_openid":    user.S_m_openid,
+			"a_m_openid":    user.A_m_openid,
+			"phone":         user.Phone,
+			"jpushid":       user.Jpushid,
+			"opushid":       user.Opushid,
+			"appphonetype":  user.AppPhoneType,
+			"userid":        user.Id,
+			"ratemode":      user.RateMode,
+			"wxpush":        user.WxPush,
+			"apppush":       user.AppPush,
+			"mailpush":      user.MailPush,
+			"smartset":      user.SmartSet,
+			"usertype":      user.UserType,
+			"email":         user.Email,
+			"dataexport":    user.DataExport,
+			"list":          array,
+			"size":          size,
+			"subscribe":     user.Subscribe,
+			"applystatus":   user.ApplyStatus,
+			"words":         user.OriginalKeys,
+			"modifydate":    user.ModifyDate,
+			"mergeorder":    user.MergeOrder,
+			"timestamp":     time.Now().Unix(),
+			"nickname":      user.NickName,
+			"firstpushtime": user.FirstPushTime,
 		})
 		if len(m.saveBatch) == BulkSize {
 			mongodb.SaveBulk("pushspace_temp", m.saveBatch...)
@@ -318,7 +319,7 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) int {
 		"i_applystatus":   1,
 		"a_mergeorder":    1,
 		"s_nickname":      1,
-		"i_firstpushtime": 1,
+		"l_firstpushtime": 1,
 	}).Iter()
 	n := 0
 	for temp := make(map[string]interface{}); query.Next(temp); {
@@ -448,7 +449,7 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) int {
 			Subscribe:     isPush,
 			MergeOrder:    temp["a_mergeorder"],
 			NickName:      util.ObjToString(temp["s_nickname"]),
-			FirstPushTime: util.Int64All(temp["i_firstpushtime"]),
+			FirstPushTime: util.Int64All(temp["l_firstpushtime"]),
 		}
 		(*m.users)[user.Id] = user
 		m.lastUserId = user.Id

+ 0 - 9
src/jfw/modules/pushsubscribe/src/push/job/dopush.go

@@ -188,15 +188,6 @@ func (d *doPush) Do(taskType int, isSave bool, wxPush, appPush, mailPush int, k
 			logger.Info("推送任务,保存到cassandra出错", k.Id, k.S_m_openid, k.A_m_openid, k.Phone)
 			return
 		} else {
-			if k.FirstPushTime == 0 {
-				go mongodb.Update("user", map[string]interface{}{
-					"_id": bson.ObjectIdHex(k.Id),
-				}, map[string]interface{}{
-					"$set": map[string]interface{}{
-						"l_firstpushtime": time.Now().Unix(),
-					},
-				}, false, false)
-			}
 			logger.Info("推送任务,成功保存到cassandra", pushId, k.Id, k.S_m_openid, k.A_m_openid, k.Phone)
 		}
 		isSaveSuccess = true

+ 11 - 1
src/jfw/modules/pushsubscribe/src/push/job/pushjob.go

@@ -309,7 +309,17 @@ func (p *pushJob) Push(taskType int) {
 					}
 				}
 				isSaveSuccess, wxStatus, appStatus, mailStatus := DoPush.Execute(taskType, wxPush, appPush, mailPush, u, list, tempList)
-				if !isSaveSuccess {
+				if isSaveSuccess {
+					if u.FirstPushTime == 0 {
+						go mongodb.Update("user", map[string]interface{}{
+							"_id": bson.ObjectIdHex(u.Id),
+						}, map[string]interface{}{
+							"$set": map[string]interface{}{
+								"l_firstpushtime": time.Now().Unix(),
+							},
+						}, false, false)
+					}
+				} else {
 					return
 				}
 				//判断是否要删除数据

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

@@ -139,7 +139,7 @@ func updateRedis(date int64, k *UserInfo, infos []map[string]interface{}) {
 	if pc_a == nil {
 		return
 	}
-	list_a := pc_a.Infos[:]
+	list_a := []map[string]interface{}{}
 	list_b := []map[string]interface{}{}
 	for k, info := range infos {
 		newInfo := jy.HistoryPush.InfoFormat(&jy.PushCa{
@@ -180,9 +180,9 @@ func updateRedis(date int64, k *UserInfo, infos []map[string]interface{}) {
 		break
 	case 3:
 		if length_a > 250 {
-			if pc_a.Count < len(pc_a.Infos) {
-				pc_a_a := pc_a.Infos[:pc_a.Count]
-				pc_a_b := pc_a.Infos[pc_a.Count:]
+			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:]
 				list_a = append(list_a, pc_a_a...)
 				if len(list_a) > 250 {
 					pc_a.Type = 1

+ 2 - 2
src/jfw/modules/weixin/src/tools/searchpush.go

@@ -11,8 +11,8 @@ import (
 func PushRecordDaysOne(userid string, days int) map[string]interface{} {
 	t := time.Now()
 	for i := 0; i < days; i++ { //查询最近days天推送记录
-		dateshort := t.Format(util.Date_Short_Layout)
-		data := cassandra.SearchOne("select * from jy_push where id=? and uid=? ", dateshort, userid)
+		dateshort := t.Format(util.Date_yyyyMMdd)
+		data := cassandra.SearchOne("select * from jy_push where uid=? and dateymd=? ", dateshort, userid)
 		if len(data) > 0 {
 			return data
 		}

+ 5 - 7
src/jfw/timetask/fishindex.go

@@ -2,9 +2,9 @@ package timetask
 
 import (
 	"errors"
-	"fmt"
 	"log"
 	"qfw/util"
+	"strings"
 	"time"
 	"ucbsutil/cassandra"
 
@@ -76,9 +76,9 @@ func nowpush() {
 			}
 		*/
 		var csize = 0
-		clist := cassandra.SearchPage(10000, "select size from jy_push where id=?", d.Format(util.Date_Short_Layout))
+		clist := cassandra.SearchPage(10000, "select pushinfo from jy_push where dateymd=?", d.Format(util.Date_yyyyMMdd))
 		for _, v := range clist {
-			csize = csize + util.IntAll(fmt.Sprint(v["size"]))
+			csize += len(strings.Split(util.ObjToString(v["pushinfo"]), ","))
 		}
 		if csize > 0 {
 			mongodb.Update("swordfish_index", bson.M{"_id": (*one)["_id"].(bson.ObjectId)}, bson.M{
@@ -169,13 +169,11 @@ func othershow() error {
 		*/
 
 		var csize = 0
-		id := util.FormatDateByInt64(&lastTime, util.Date_Short_Layout)
-		clist := cassandra.SearchPage(10000, "select size from jy_push where id=?", id)
+		clist := cassandra.SearchPage(10000, "select pushinfo from jy_push where dateymd=?", util.FormatDateByInt64(&lastTime, util.Date_yyyyMMdd))
 		for _, v := range clist {
-			csize = csize + util.IntAll(fmt.Sprint(v["size"]))
+			csize += len(strings.Split(util.ObjToString(v["pushinfo"]), ","))
 		}
 		obj["i_push"] = csize + lastPushCount
-
 	} else {
 		log.Println("统计推送的信息出错:没有获取到上一次统计数据")
 		return errors.New("error")

+ 3 - 1
src/web/templates/test.html

@@ -10,6 +10,7 @@
 	var pageNum = 1;
 	var index = 0;
 	function nextPage(){
+		$("body>button").prop("disabled",true);
 		$.post("/swordfish/historypush/paging",{pageNum:pageNum},function(r){
 			if(!r.hasNextPage){
 				alert("没有下一页了!");
@@ -39,6 +40,7 @@
 				$("body>table").append(html);
 			}
 			pageNum++;
+			$("body>button").prop("disabled",false);
 		});
 	}
 	</script>
@@ -55,7 +57,7 @@
 	</style>
 </head>
 <body>
-<button onclick="nextPage()" style="position:fixed;top:10px;left:10px;">下一页</button>
+<button onclick="nextPage()" style="height: 50px;width: 150px;position:fixed;top:10px;left:10px;">下一页</button>
 <table>
 	<tr>
 		<td>index</td>