Sfoglia il codice sorgente

Merge branch 'dev2.8.5' of http://192.168.3.207:10080/qmx/jy into dev2.8.5

xuzhiheng 5 anni fa
parent
commit
40a64f07e8
27 ha cambiato i file con 168 aggiunte e 250 eliminazioni
  1. 3 2
      src/jfw/modules/app/src/app/front/login.go
  2. 0 27
      src/jfw/modules/app/src/app/jyutil/rpccall.go
  3. 0 1
      src/jfw/modules/app/src/app/pay/wxpay.go
  4. 1 1
      src/jfw/modules/pushent/src/followpush/push.go
  5. 0 27
      src/jfw/modules/pushent/src/rpccall/appPushServiceCall.go
  6. 4 18
      src/jfw/modules/pushent/src/rpccall/weixinrpc.go
  7. BIN
      src/jfw/modules/pushent/src/src
  8. 1 1
      src/jfw/modules/pushproject/src/followpush/push.go
  9. 0 27
      src/jfw/modules/pushproject/src/rpccall/appPushServiceCall.go
  10. 4 18
      src/jfw/modules/pushproject/src/rpccall/weixinrpc.go
  11. BIN
      src/jfw/modules/pushproject/src/src
  12. 3 2
      src/jfw/modules/pushsubscribe/src/match/config.json
  13. 15 14
      src/jfw/modules/pushsubscribe/src/match/config/config.go
  14. 0 13
      src/jfw/modules/pushsubscribe/src/match/job/job.go
  15. 53 18
      src/jfw/modules/pushsubscribe/src/match/job/matchjob.go
  16. 1 1
      src/jfw/modules/pushsubscribe/src/match/job/vipuser.go
  17. 1 1
      src/jfw/modules/pushsubscribe/src/match/task.json
  18. 8 0
      src/jfw/modules/pushsubscribe/src/public/util.go
  19. 2 2
      src/jfw/modules/pushsubscribe/src/push/config.json
  20. 1 1
      src/jfw/modules/pushsubscribe/src/push/config/config.go
  21. 4 5
      src/jfw/modules/pushsubscribe/src/push/job/dopush.go
  22. 5 34
      src/jfw/modules/pushsubscribe/src/push/util/rpccall.go
  23. 20 18
      src/jfw/modules/pushsubscribe/src/push/util/util.go
  24. 2 0
      src/jfw/modules/subscribepay/src/main.go
  25. 38 0
      src/jfw/modules/subscribepay/src/timetask/timetask.go
  26. 0 18
      src/jfw/public/rpccall.go
  27. 2 1
      src/jfw/timetask/followtimetask.go

+ 3 - 2
src/jfw/modules/app/src/app/front/login.go

@@ -10,6 +10,7 @@ import (
 	"log"
 	"net/http"
 	qutil "qfw/util"
+	"qfw/util/jy"
 	"qfw/util/redis"
 	"regexp"
 	"strings"
@@ -912,7 +913,7 @@ func afterLogin(user map[string]interface{}, session *httpsession.Session, rid,
 				})
 				//
 				log.Println("踢人下线", old_ponetype, userid, old_rid, old_oid)
-				jyutil.AppPushServiceCall(map[string]interface{}{
+				jy.AppPush(config.Sysconfig["appPushServiceRpc"].(string), map[string]interface{}{
 					"type":        "signOut",
 					"descript":    kickedTip,
 					"jgPushId":    old_rid,
@@ -1086,7 +1087,7 @@ func checkRepeatLogin(user *map[string]interface{}, rid, oid string) {
 		//
 		go func() {
 			log.Println("踢人下线", ponetype, userid, jpushid, opushid)
-			jyutil.AppPushServiceCall(map[string]interface{}{
+			jy.AppPush(config.Sysconfig["appPushServiceRpc"].(string), map[string]interface{}{
 				"type":        "signOut",
 				"descript":    kickedTip,
 				"jgPushId":    jpushid,

+ 0 - 27
src/jfw/modules/app/src/app/jyutil/rpccall.go

@@ -1,27 +0,0 @@
-package jyutil
-
-import (
-	"encoding/json"
-	"jfw/config"
-	"log"
-	"net/rpc"
-	"qfw/util"
-)
-
-func AppPushServiceCall(m map[string]interface{}) bool {
-	defer util.Catch()
-	var repl string
-	client, err := rpc.DialHTTP("tcp", config.Sysconfig["appPushServiceRpc"].(string))
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	defer client.Close()
-	b, _ := json.Marshal(m)
-	err = client.Call("Rpc.Push", b, &repl)
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	return repl == "y"
-}

+ 0 - 1
src/jfw/modules/app/src/app/pay/wxpay.go

@@ -3,7 +3,6 @@ package pay
 import (
 	"jfw/config"
 	"jfw/public"
-	"log"
 	"qfw/util"
 )
 

+ 1 - 1
src/jfw/modules/pushent/src/followpush/push.go

@@ -403,7 +403,7 @@ func push(fid, sname, userId string, res *[]map[string]interface{}) {
 					descriptAppend = fmt.Sprintf("\n...(共%d条)", pushnum)
 					jpushtitle = fmt.Sprintf("1. %s", jpushtitle)
 				}
-				isPushOk := rpccall.AppPushServiceCall(map[string]interface{}{
+				isPushOk := jy.AppPush(Sysconfig["appPushServiceRpc"].(string), map[string]interface{}{
 					"phoneType":      phoneType,
 					"otherPushId":    opushid,
 					"jgPushId":       jpushid,

+ 0 - 27
src/jfw/modules/pushent/src/rpccall/appPushServiceCall.go

@@ -1,27 +0,0 @@
-package rpccall
-
-import (
-	"config"
-	"encoding/json"
-	"log"
-	"net/rpc"
-	"qfw/util"
-)
-
-func AppPushServiceCall(m map[string]interface{}) bool {
-	defer util.Catch()
-	var repl string
-	client, err := rpc.DialHTTP("tcp", config.Sysconfig["appPushServiceRpc"].(string))
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	defer client.Close()
-	b, _ := json.Marshal(m)
-	err = client.Call("Rpc.Push", b, &repl)
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	return repl == "y"
-}

+ 4 - 18
src/jfw/modules/pushent/src/rpccall/weixinrpc.go

@@ -2,8 +2,7 @@ package rpccall
 
 import (
 	"config"
-	"log"
-	"net/rpc"
+	"qfw/util/jy"
 	qrpc "qfw/util/rpc"
 	"strings"
 	"time"
@@ -13,26 +12,13 @@ import (
 //微信远程调用,实现模板发送消息
 func SendWinXin(p *qrpc.NotifyMsg, userId string) bool {
 	time.Sleep(10 * time.Millisecond)
-	client, err := rpc.DialHTTP("tcp", config.Sysconfig["weixinRpcServer"].(string))
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	defer client.Close()
-	var repl qrpc.RpcResult
-	err = client.Call("WeiXinRpc.SendPushMsg", p, &repl)
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	res := string(repl)
-	if strings.Contains(res, "[46004]") || strings.Contains(res, "[65302]") || strings.Contains(res, "[43004]") || strings.Contains(res, "[40003]") {
+	ok, res := jy.WxPush(config.Sysconfig["weixinRpcServer"].(string), "WeiXinRpc.SendPushMsg", p)
+	if !ok && (strings.Contains(res, "[46004]") || strings.Contains(res, "[65302]") || strings.Contains(res, "[43004]") || strings.Contains(res, "[40003]")) {
 		tools.MQFW.UpdateById("user", userId, map[string]interface{}{
 			"$set": map[string]interface{}{
 				"i_ispush": 0,
 			},
 		})
-		return false
 	}
-	return repl == "Y"
+	return ok
 }

BIN
src/jfw/modules/pushent/src/src


+ 1 - 1
src/jfw/modules/pushproject/src/followpush/push.go

@@ -511,7 +511,7 @@ func push(fid interface{}, sname, scode, title, userId string, res *[]map[string
 							descriptAppend = fmt.Sprintf("\n...(共%d条)", pushnum)
 							jpushtitle = fmt.Sprintf("1. %s", jpushtitle)
 						}
-						isPushOk := rpccall.AppPushServiceCall(map[string]interface{}{
+						isPushOk := jy.AppPush(Sysconfig["appPushServiceRpc"].(string), map[string]interface{}{
 							"phoneType":      phoneType,
 							"otherPushId":    opushid,
 							"jgPushId":       jpushid,

+ 0 - 27
src/jfw/modules/pushproject/src/rpccall/appPushServiceCall.go

@@ -1,27 +0,0 @@
-package rpccall
-
-import (
-	"config"
-	"encoding/json"
-	"log"
-	"net/rpc"
-	"qfw/util"
-)
-
-func AppPushServiceCall(m map[string]interface{}) bool {
-	defer util.Catch()
-	var repl string
-	client, err := rpc.DialHTTP("tcp", config.Sysconfig["appPushServiceRpc"].(string))
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	defer client.Close()
-	b, _ := json.Marshal(m)
-	err = client.Call("Rpc.Push", b, &repl)
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	return repl == "y"
-}

+ 4 - 18
src/jfw/modules/pushproject/src/rpccall/weixinrpc.go

@@ -2,8 +2,7 @@ package rpccall
 
 import (
 	"config"
-	"log"
-	"net/rpc"
+	"qfw/util/jy"
 	qrpc "qfw/util/rpc"
 	"strings"
 	"time"
@@ -13,26 +12,13 @@ import (
 //微信远程调用,实现模板发送消息
 func SendWinXin(p *qrpc.NotifyMsg, userId string) bool {
 	time.Sleep(10 * time.Millisecond)
-	client, err := rpc.DialHTTP("tcp", config.Sysconfig["weixinRpcServer"].(string))
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	defer client.Close()
-	var repl qrpc.RpcResult
-	err = client.Call("WeiXinRpc.SendPushMsg", p, &repl)
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	res := string(repl)
-	if strings.Contains(res, "[46004]") || strings.Contains(res, "[65302]") || strings.Contains(res, "[43004]") || strings.Contains(res, "[40003]") {
+	ok, res := jy.WxPush(config.Sysconfig["weixinRpcServer"].(string), "WeiXinRpc.SendPushMsg", p)
+	if !ok && (strings.Contains(res, "[46004]") || strings.Contains(res, "[65302]") || strings.Contains(res, "[43004]") || strings.Contains(res, "[40003]")) {
 		tools.MQFW.UpdateById("user", userId, map[string]interface{}{
 			"$set": map[string]interface{}{
 				"i_ispush": 0,
 			},
 		})
-		return false
 	}
-	return repl == "Y"
+	return ok
 }

BIN
src/jfw/modules/pushproject/src/src


+ 3 - 2
src/jfw/modules/pushsubscribe/src/match/config.json

@@ -1,12 +1,13 @@
 {
 	"elasticPoolSize": 1,
 	"elasticSearch": "http://192.168.3.128:9800",
-	"redisServers": "pushcache_1=192.168.3.128:5000",
+	"redisServers": "pushcache_1=192.168.3.128:5000,other=192.168.3.128:5000",
 	"maxPushSize": 50,
 	"maxSearch": 5000,
+	"vipOneDayMaxPushSize": 2000,
 	"mgoAddr": "192.168.3.128:27080",
 	"mgoSize": 10,
-	"testids": [],
+	"testids": ["5cee3e2a61fd002c800e2569"],
 	"filterWords":["项目","中标","公告"],
 	"matchPoolSize": 60,
 	"matchDuration": 1, 

+ 15 - 14
src/jfw/modules/pushsubscribe/src/match/config/config.go

@@ -5,20 +5,21 @@ import (
 )
 
 type sysConfig struct {
-	ElasticPoolSize int      `json:"elasticPoolSize"`
-	ElasticSearch   string   `json:"elasticSearch"`
-	RedisServers    string   `json:"redisServers"`
-	MaxPushSize     int      `json:"maxPushSize"`
-	MaxSearch       int      `json:"maxSearch"`
-	MgoAddr         string   `json:"mgoAddr"`
-	MgoSize         int      `json:"mgoSize"`
-	TestIds         []string `json:"testIds"`
-	FilterWords     []string `json:"filterWords"`
-	MatchPoolSize   int      `json:"matchPoolSize"`
-	MatchDuration   int64    `json:"matchDuration"`
-	UserBatch       int      `json:"userBatch"`
-	PcHelper        string   `json:"pcHelper"`
-	MailReg         string   `json:"mailReg"`
+	ElasticPoolSize      int      `json:"elasticPoolSize"`
+	ElasticSearch        string   `json:"elasticSearch"`
+	RedisServers         string   `json:"redisServers"`
+	MaxPushSize          int      `json:"maxPushSize"`
+	VipOneDayMaxPushSize int      `json:"vipOneDayMaxPushSize"`
+	MaxSearch            int      `json:"maxSearch"`
+	MgoAddr              string   `json:"mgoAddr"`
+	MgoSize              int      `json:"mgoSize"`
+	TestIds              []string `json:"testIds"`
+	FilterWords          []string `json:"filterWords"`
+	MatchPoolSize        int      `json:"matchPoolSize"`
+	MatchDuration        int64    `json:"matchDuration"`
+	UserBatch            int      `json:"userBatch"`
+	PcHelper             string   `json:"pcHelper"`
+	MailReg              string   `json:"mailReg"`
 }
 
 type taskConfig struct {

+ 0 - 13
src/jfw/modules/pushsubscribe/src/match/job/job.go

@@ -5,19 +5,6 @@ import (
 	"sync"
 )
 
-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}`
-	Mongodb_ShowField = `{"title":1,"detail":1,"projectscope":1,"publishtime":1,"toptype":1,"subtype":1,"type":1,"area":1,"href":1,"areaval":1,"infoformat":1,"projectname":1,"buyer":1,"winner":1,"budget":1,"bidamount":1,"bidopentime":1,"s_subscopeclass":1}`
-	DbName            = "qfw"
-)
-
 type Job interface {
 	Execute()
 }

+ 53 - 18
src/jfw/modules/pushsubscribe/src/match/job/matchjob.go

@@ -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

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

@@ -75,7 +75,7 @@ func (v *VipUser) Match(info *map[string]interface{}) *map[*UserInfo]*MatchUser
 			continue
 		}
 		var matchUser *MatchUser
-		if len(k.OriginalKeys) > 0 {
+		if len(k.Keys) > 0 {
 			matchUser = (*title_users)[k]
 			if matchUser == nil {
 				matchUser = (*detail_users)[k]

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

@@ -1 +1 @@
-{"startTime":"","lastId":"4c754b91a5cb26b9b79a0ce8"}
+{"startTime":"","lastId":"5da69c3fa5cb26b9b77bec0d"}

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

@@ -1,8 +1,16 @@
 package public
 
+import (
+	"fmt"
+)
+
 func IsVipUser(vipStatus int) bool {
 	if vipStatus == 1 || vipStatus == 2 {
 		return true
 	}
 	return false
 }
+
+func DayCountKey(nowymd, id string) string {
+	return fmt.Sprintf("daycount_%s_%s", nowymd, id)
+}

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

@@ -34,8 +34,8 @@
 	"vipOneDayMaxPushSize": 2000,
 	"mgoAddr": "192.168.3.128:27080",
 	"mgoSize": 10,
-	"testids": ["5d6e142a25ef871f08a72662"],
-	"weixinRpcServer": "127.0.0.1:8083",
+	"testids": ["5cee3e2a61fd002c800e2569"],
+	"weixinRpcServer": "192.168.20.111:8083",
 	"wxColor": "#2cb7ca",
 	"wxGroup": "招标信息",
 	"wxTitle": "根据你订阅的关键词“%s”,剑鱼标讯为你推送以下信息。如果不想继续收到此类信息,可进入招标订阅的设置页面取消订阅。",

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

@@ -33,7 +33,7 @@ type sysConfig struct {
 	OncePushTime            string      `json:"oncePushTime"`
 	OtherPushTimes          []string    `json:"otherPushTimes"`
 	WxPollSize              int         `json:"wxPollSize"`
-	VipOneDayMaxPushSize    int64       `json:"vipOneDayMaxPushSize"`
+	VipOneDayMaxPushSize    int         `json:"vipOneDayMaxPushSize"`
 	AppPollSize             int         `json:"appPollSize"`
 	MailSleep               int         `json:"mailSleep"`
 	CassandraSleep          int         `json:"cassandraSleep"`

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

@@ -55,9 +55,8 @@ func (d *doPush) Do(taskType int, isSave bool, wxPush, appPush, mailPush int, k
 	jpushtitle := ""
 	lastInfoDate := int64(0)
 	TitleArray := []string{}
-	infos := []map[string]interface{}{}
+	infos := []*MatchInfo{}
 	publishTitle := map[string]bool{}
-	pushIds := []string{}
 	nowymd := util.NowFormat(util.Date_yyyyMMdd)
 	//邮件附件
 	for _, ks := range *sl {
@@ -74,8 +73,7 @@ func (d *doPush) Do(taskType int, isSave bool, wxPush, appPush, mailPush int, k
 		}
 		publishTitle[newTitle] = true
 		i++
-		infos = append(infos, k2)
-		pushIds = append(pushIds, util.ObjToString(k2["_id"]))
+		infos = append(infos, ks)
 		TitleArray = append(TitleArray, newTitle)
 		if i == 1 {
 			jpushtitle = title
@@ -140,9 +138,10 @@ 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.Incr("other", fmt.Sprintf("daycount_%s_%s", nowymd, k.Id)) >= SysConfig.VipOneDayMaxPushSize {
+			if redis.GetInt("other", DayCountKey(nowymd, k.Id)) >= SysConfig.VipOneDayMaxPushSize {
 				break
 			}
+			redis.Incr("other", DayCountKey(nowymd, k.Id))
 		} else {
 			//限制最大信息条数
 			if i >= SysConfig.MaxPushSize {

+ 5 - 34
src/jfw/modules/pushsubscribe/src/push/util/rpccall.go

@@ -6,6 +6,7 @@ import (
 	. "public"
 	. "push/config"
 	"qfw/util"
+	"qfw/util/jy"
 	"qfw/util/mongodb"
 	qrpc "qfw/util/rpc"
 	"strconv"
@@ -25,13 +26,11 @@ var (
 func SendWeixin(k *UserInfo, remark, title string) bool {
 	wxPushPool <- true
 	defer func() {
-		util.Catch()
 		<-wxPushPool
 	}()
 	if SysConfig.WxSleep > 0 {
 		time.Sleep(time.Duration(SysConfig.WxSleep) * time.Millisecond)
 	}
-	var repl qrpc.RpcResult
 	now := time.Now()
 	p := &qrpc.NotifyMsg{
 		Openid:      k.S_m_openid,
@@ -44,53 +43,25 @@ func SendWeixin(k *UserInfo, remark, title string) bool {
 		DetailColor: SysConfig.WxDetailColor,
 		Url:         SysConfig.JianyuDomain + "/front/sess/" + Se.EncodeString(k.S_m_openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",rssset"),
 	}
-	client, err := rpc.DialHTTP("tcp", SysConfig.WeixinRpcServer)
-	if err != nil {
-		logger.Error(err.Error())
-		return false
-	}
-	defer client.Close()
-	err = client.Call("WeiXinRpc.SubscribePush", p, &repl)
-	if err != nil {
-		logger.Error(err.Error())
-	}
-	res := string(repl)
-	if strings.Contains(res, "[46004]") || strings.Contains(res, "[65302]") || strings.Contains(res, "[43004]") || strings.Contains(res, "[40003]") {
+	ok, res := jy.WxPush(SysConfig.WeixinRpcServer, "WeiXinRpc.SubscribePush", p)
+	if !ok && (strings.Contains(res, "[46004]") || strings.Contains(res, "[65302]") || strings.Contains(res, "[43004]") || strings.Contains(res, "[40003]")) {
 		mongodb.Update("user", map[string]interface{}{"_id": bson.ObjectIdHex(k.Id)}, map[string]interface{}{
 			"$set": map[string]interface{}{
 				"i_ispush": 0,
 			},
 		}, false, false)
-		return true
-	}
-	if repl == "Y" {
-		return true
 	}
-	return false
+	return ok
 }
 func SendApp(m map[string]interface{}) bool {
 	appPushPool <- true
 	defer func() {
-		util.Catch()
 		<-appPushPool
 	}()
 	if SysConfig.AppSleep > 0 {
 		time.Sleep(time.Duration(SysConfig.AppSleep) * time.Millisecond)
 	}
-	var repl string
-	client, err := rpc.DialHTTP("tcp", SysConfig.AppPushServiceRpc)
-	if err != nil {
-		logger.Error(err.Error())
-		return false
-	}
-	defer client.Close()
-	b, _ := json.Marshal(m)
-	err = client.Call("Rpc.Push", b, &repl)
-	if err != nil {
-		logger.Error(err.Error())
-		return false
-	}
-	return repl == "y"
+	return jy.AppPush(SysConfig.AppPushServiceRpc, m)
 }
 
 //

+ 20 - 18
src/jfw/modules/pushsubscribe/src/push/util/util.go

@@ -106,7 +106,7 @@ func ModeTransform(userType int, o_msgset map[string]interface{}) (int, int, int
 }
 
 //保存发送信息
-func SaveSendInfo(k *UserInfo, infos []map[string]interface{}) string {
+func SaveSendInfo(k *UserInfo, infos []*MatchInfo) string {
 	cassandraPoll <- true
 	defer func() {
 		<-cassandraPoll
@@ -123,30 +123,32 @@ func SaveSendInfo(k *UserInfo, infos []map[string]interface{}) string {
 	}
 	date := now.Unix()
 	dateymd := now.Format(util.Date_yyyyMMdd)
-	var saves []map[string]interface{}
-	for _, info := range infos {
+	var saves []*map[string]interface{}
+	for _, v := range infos {
 		wxpush := map[string]interface{}{
 			"dateymd":    dateymd,
 			"uid":        k.Id,
 			"date":       date,
-			"pushinfo":   fmt.Sprint(info["_id"]),
-			"keys":       k.Keys,
-			"area":       util.ObjToString(info["area"]),
-			"city":       util.ObjToString(info["city"]),
-			"buyerclass": util.ObjToString(info["buyerclass"]),
+			"pushinfo":   fmt.Sprint((*v.Info)["_id"]),
+			"keys":       v.Keys,
+			"area":       util.ObjToString((*v.Info)["area"]),
+			"city":       util.ObjToString((*v.Info)["city"]),
+			"buyerclass": util.ObjToString((*v.Info)["buyerclass"]),
 		}
-		if ca.Save("jy_pushsubscribe", wxpush) {
-			saves = append(saves, info)
+		time.Sleep(200 * time.Millisecond)
+		if ca.Save("jy_pushhistory", wxpush) {
+			(*v.Info)["matchkeys"] = v.Keys
+			saves = append(saves, v.Info)
 		}
 	}
 	if len(saves) > 0 {
-		updateRedis(date, k, infos)
+		updateRedis(date, k, &saves)
 		return fmt.Sprint(date)
 	}
 	return ""
 }
 
-func updateRedis(date int64, k *UserInfo, infos []map[string]interface{}) {
+func updateRedis(date int64, k *UserInfo, infos *[]*map[string]interface{}) {
 	pc_a, pc_a_err := jy.HistoryPush.GetPushCache_A(k.Id)
 	pc_b, pc_b_err := jy.HistoryPush.GetPushCache_B(k.Id)
 	if pc_a_err != nil {
@@ -158,12 +160,12 @@ func updateRedis(date int64, k *UserInfo, infos []map[string]interface{}) {
 	}
 	list_a := []map[string]interface{}{}
 	list_b := []map[string]interface{}{}
-	for k, info := range infos {
+	for k, info := range *infos {
 		newInfo := jy.HistoryPush.InfoFormat(&jy.PushCa{
 			Date:   date,
-			InfoId: util.ObjToString(info["_id"]),
+			InfoId: util.ObjToString((*info)["_id"]),
 			Index:  k + 1,
-		}, &info)
+		}, info)
 		list_a = append(list_a, newInfo)
 	}
 	length_a := len(list_a) + len(pc_a.Infos)
@@ -191,7 +193,7 @@ func updateRedis(date int64, k *UserInfo, infos []map[string]interface{}) {
 				list_b = append(list_b, list_a[250:]...)
 			}
 			list_a = list_a[:250]
-			pc_a.Count = 250 - len(infos)
+			pc_a.Count = 250 - len(*infos)
 		} else if length_a == 250 {
 			pc_a.Count = len(pc_a.Infos)
 		}
@@ -242,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) > 750 {
-			list_b = list_b[:750]
+		if len(list_b) > 1750 {
+			list_b = list_b[:1750]
 		}
 		jy.HistoryPush.PutPushCache_B(k.Id, list_b)
 	}

+ 2 - 0
src/jfw/modules/subscribepay/src/main.go

@@ -6,12 +6,14 @@ import (
 	_ "filter"
 	"net/http"
 	_ "service"
+	"timetask"
 	_ "util"
 
 	"github.com/go-xweb/xweb"
 )
 
 func main() {
+	go timetask.Run()
 	mux1 := http.NewServeMux()
 	xweb.RunBase(":"+Config.Webport, mux1)
 }

+ 38 - 0
src/jfw/modules/subscribepay/src/timetask/timetask.go

@@ -0,0 +1,38 @@
+package timetask
+
+import (
+	"time"
+)
+
+func Run() {
+	checkIsExpire()
+	expireRemind()
+}
+
+//每天0点 检查试用、vip服务是否到期
+func checkIsExpire() {
+	crontab(0, func() {
+
+	})
+}
+
+//即将到期或者已到期发推送消息
+func expireRemind() {
+	crontab(10, func() {
+
+	})
+}
+
+func crontab(hour int, f func()) {
+	go f()
+	now := time.Now()
+	t := time.Date(now.Year(), now.Month(), now.Day()+1, hour, 0, 0, 0, time.Local)
+	timer := time.NewTimer(t.Sub(now))
+	for {
+		select {
+		case <-timer.C:
+			go f()
+			timer.Reset(24 * time.Hour)
+		}
+	}
+}

+ 0 - 18
src/jfw/public/rpccall.go

@@ -166,21 +166,3 @@ func GetShareQRStr(url string) string {
 	}, func(e interface{}) {})
 	return ret
 }
-
-func AppPushServiceCall(m map[string]interface{}) bool {
-	defer util.Catch()
-	var repl string
-	client, err := rpc.DialHTTP("tcp", config.Sysconfig["appPushServiceRpc"].(string))
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	defer client.Close()
-	b, _ := json.Marshal(m)
-	err = client.Call("Rpc.Push", b, &repl)
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	return repl == "y"
-}

+ 2 - 1
src/jfw/timetask/followtimetask.go

@@ -7,6 +7,7 @@ import (
 	public "jfw/public"
 	"log"
 	"qfw/util"
+	"qfw/util/jy"
 	"qfw/util/redis"
 	rpc "qfw/util/rpc"
 	"strconv"
@@ -132,7 +133,7 @@ func tip() {
 		}
 		if jpushid != "" || opushid != "" {
 			phoneType, _ := (*userdata)["s_appponetype"].(string)
-			isPushOk := public.AppPushServiceCall(map[string]interface{}{
+			isPushOk := jy.AppPush(config.Sysconfig["appPushServiceRpc"].(string), map[string]interface{}{
 				"phoneType":   phoneType,
 				"otherPushId": opushid,
 				"jgPushId":    jpushid,