lianbingjie 6 năm trước cách đây
mục cha
commit
ca7efb3ee1
100 tập tin đã thay đổi với 1605 bổ sung6953 xóa
  1. 16 10
      src/config.json
  2. 4 13
      src/jfw/filter/logfilter.go
  3. 5 7
      src/jfw/front/follow.go
  4. 7 79
      src/jfw/front/front.go
  5. 0 19
      src/jfw/front/otherAct.go
  6. 28 30
      src/jfw/front/pchelper.go
  7. 1 1
      src/jfw/front/shorturl.go
  8. 1 2
      src/jfw/front/supsearch.go
  9. 40 260
      src/jfw/front/swordfish.go
  10. 5 13
      src/jfw/modules/app/src/app/filter/logfilter.go
  11. 68 52
      src/jfw/modules/app/src/app/followent/followent.go
  12. 9 26
      src/jfw/modules/app/src/app/followent/myfwent.go
  13. 5 6
      src/jfw/modules/app/src/app/front/follow.go
  14. 5 47
      src/jfw/modules/app/src/app/front/front.go
  15. 9 100
      src/jfw/modules/app/src/app/front/login.go
  16. 35 220
      src/jfw/modules/app/src/app/front/swordfish.go
  17. 16 10
      src/jfw/modules/app/src/config.json
  18. 11 20
      src/jfw/modules/app/src/main.go
  19. 14 1
      src/jfw/modules/app/src/web/templates/app/update.html
  20. 4 0
      src/jfw/modules/app/src/web/templates/followent/add.html
  21. 8 4
      src/jfw/modules/app/src/web/templates/followent/list.html
  22. 228 251
      src/jfw/modules/app/src/web/templates/weixin/historypush.html
  23. 2 38
      src/jfw/modules/app/src/web/templates/weixin/wxkeyset/seniorset.html
  24. 2 7
      src/jfw/modules/entsesearch/src/main.go
  25. BIN
      src/jfw/modules/entsesearch/src/src
  26. 3 7
      src/jfw/modules/followent/src/config.json
  27. 76 54
      src/jfw/modules/followent/src/followent/followent.go
  28. 9 26
      src/jfw/modules/followent/src/followent/myfwent.go
  29. 1 5
      src/jfw/modules/followent/src/main.go
  30. 1 1
      src/jfw/modules/followent/src/seo.json
  31. BIN
      src/jfw/modules/followent/src/src
  32. 0 18
      src/jfw/modules/followent/src/tools/mongo.go
  33. 11 8
      src/jfw/modules/followent/src/web/templates/weixin/add.html
  34. 3 3
      src/jfw/modules/followent/src/web/templates/weixin/list.html
  35. 0 41
      src/jfw/modules/followent/src/wx/wxjssdk.go
  36. 14 3
      src/jfw/modules/pc/server/src/push/push.go
  37. 0 84
      src/jfw/modules/push/src/config.json
  38. 0 76
      src/jfw/modules/push/src/main.go
  39. 0 53
      src/jfw/modules/push/src/qfw/push/cache.go
  40. 0 55
      src/jfw/modules/push/src/qfw/push/cf.go
  41. 0 142
      src/jfw/modules/push/src/qfw/push/dfa/interestanalysis.go
  42. 0 45
      src/jfw/modules/push/src/qfw/push/dfa/interestanalysis_test.go
  43. 0 346
      src/jfw/modules/push/src/qfw/push/dopush/dopush.go
  44. 0 1031
      src/jfw/modules/push/src/qfw/push/dopush/dopushes.go
  45. 0 93
      src/jfw/modules/push/src/qfw/push/dopush/excel.go
  46. 0 8
      src/jfw/modules/push/src/qfw/push/job.go
  47. 0 86
      src/jfw/modules/push/src/qfw/push/jobs/bidpush.go
  48. 0 43
      src/jfw/modules/push/src/qfw/push/jobs/fixpush.go
  49. 0 45
      src/jfw/modules/push/src/qfw/push/jobs/realtimepush.go
  50. 0 101
      src/jfw/modules/push/src/qfw/push/listdb/listdb.go
  51. 0 10
      src/jfw/modules/push/src/qfw/push/pushconfig.go
  52. 0 45
      src/jfw/modules/push/src/qfw/push/rpccall.go
  53. 0 122
      src/jfw/modules/push/src/qfw/push/weixincall.go
  54. 0 1
      src/jfw/modules/push/src/task.json
  55. BIN
      src/jfw/modules/push/src/xlsx/201709191346354425.xlsx
  56. 0 1
      src/jfw/modules/push/src/xlsx/readme.txt
  57. BIN
      src/jfw/modules/push/src/xlsx/temp.xlsx
  58. 0 67
      src/jfw/modules/push_v1/src/config.json
  59. 0 70
      src/jfw/modules/push_v1/src/main.go
  60. 0 150
      src/jfw/modules/push_v1/src/push/config/config.go
  61. 0 142
      src/jfw/modules/push_v1/src/push/dfa/interestanalysis.go
  62. 0 45
      src/jfw/modules/push_v1/src/push/dfa/interestanalysis_test.go
  63. 0 93
      src/jfw/modules/push_v1/src/push/dopush/excel.go
  64. 0 52
      src/jfw/modules/push_v1/src/push/dopush/job.go
  65. 0 632
      src/jfw/modules/push_v1/src/push/dopush/matchjob.go
  66. 0 782
      src/jfw/modules/push_v1/src/push/dopush/pushjob.go
  67. 0 152
      src/jfw/modules/push_v1/src/push/dopush/pushtimetask.go
  68. 0 115
      src/jfw/modules/push_v1/src/push/util/rpccall.go
  69. 0 159
      src/jfw/modules/push_v1/src/push/util/util.go
  70. 0 1
      src/jfw/modules/push_v1/src/src
  71. 0 1
      src/jfw/modules/push_v1/src/task.json
  72. 0 1
      src/jfw/modules/push_v1/src/xlsx/readme.txt
  73. BIN
      src/jfw/modules/push_v1/src/xlsx/temp.xlsx
  74. 5 5
      src/jfw/modules/pushent/src/config.json
  75. 0 1
      src/jfw/modules/pushent/src/config/config.go
  76. 5 12
      src/jfw/modules/pushent/src/followpush/push.go
  77. 10 14
      src/jfw/modules/pushent/src/main.go
  78. 0 1
      src/jfw/modules/pushproject/src/config/config.go
  79. 3 10
      src/jfw/modules/pushproject/src/followpush/push.go
  80. 10 14
      src/jfw/modules/pushproject/src/main.go
  81. 5 3
      src/jfw/modules/pushsubscribe/src/match/config.json
  82. 2 0
      src/jfw/modules/pushsubscribe/src/match/config/config.go
  83. 108 81
      src/jfw/modules/pushsubscribe/src/match/job/matchjob.go
  84. 3 2
      src/jfw/modules/pushsubscribe/src/match/job/timetask.go
  85. 2 0
      src/jfw/modules/pushsubscribe/src/match/main.go
  86. BIN
      src/jfw/modules/pushsubscribe/src/match/match
  87. 0 1
      src/jfw/modules/pushsubscribe/src/match/src
  88. 27 0
      src/jfw/modules/pushsubscribe/src/match/util/rpccall.go
  89. 4 4
      src/jfw/modules/pushsubscribe/src/match/util/util.go
  90. 31 28
      src/jfw/modules/pushsubscribe/src/public/entity.go
  91. 3 4
      src/jfw/modules/pushsubscribe/src/push/config.json
  92. 1 1
      src/jfw/modules/pushsubscribe/src/push/config/config.go
  93. 372 0
      src/jfw/modules/pushsubscribe/src/push/job/dopush.go
  94. 18 13
      src/jfw/modules/pushsubscribe/src/push/job/job.go
  95. 150 524
      src/jfw/modules/pushsubscribe/src/push/job/pushjob.go
  96. 160 0
      src/jfw/modules/pushsubscribe/src/push/job/repairjob.go
  97. 22 0
      src/jfw/modules/pushsubscribe/src/push/main.go
  98. BIN
      src/jfw/modules/pushsubscribe/src/push/push
  99. 21 0
      src/jfw/modules/pushsubscribe/src/push/rpc/rpc.go
  100. 2 4
      src/jfw/modules/pushsubscribe/src/push/util/excel.go

+ 16 - 10
src/config.json

@@ -9,15 +9,22 @@
     "strTimeNumber": 30,
     "elasticsearch": "http://192.168.3.18:9800",
     "elasticPoolSize": 30,
-    "redisaddrs": "other=192.168.3.18:3379,push=192.168.3.18:3379,pushcache=192.168.3.18:3379,sso=192.168.3.18:3379,session=192.168.3.18:3379,recovery=192.168.3.18:3379",
-    "webport": "8089",
+    "redisaddrs": "other=192.168.3.18:3379,push=192.168.3.18:3379,pushcache_1=192.168.3.18:2001,pushcache_2_a=192.168.3.18:2002,pushcache_2_b=192.168.3.18:2003,sso=192.168.3.18:3379,session=192.168.3.18:3379,recovery=192.168.3.18:3379",
+    "webport": "83",
     "webrpcport": "8084",
     "weixinrpc": "127.0.0.1:8083",
     "cacheflag": false,
-    "cassandra": [
-        "192.168.3.207"
-    ],
-    "cassandrasize": 5,
+    "cassandra": {
+		"log":{
+			"host":["192.168.3.207"],
+			"size":5,
+			"port": 9043
+		},
+		"push":{
+			"host":["192.168.3.207"],
+			"size":5
+		}
+	},
     "agreement": "https",
     "webdomain": "https://webws.qmx.top",
     "redirect": {
@@ -47,7 +54,8 @@
         "sealIndex": "/active/seal/index",
         "sealSend": "/active/seal/sealMsg",
 		"futureIndex": "/active/future/index",
-		"keysetIndex":"/wxkeyset/keyset/index?tiptext=%s"
+		"keysetIndex":"/wxkeyset/keyset/index?tiptext=%s",
+        "followEntDetail": "/jylab/followent/detail/%s"
     },
     "jy_activeset": {
         "activitystartcode": "3201000000",
@@ -284,7 +292,5 @@
 	},
 	"getpicurl":"https://res.jianyu360.com/",
 	"sealSendTime":14400,
-	"appPushServiceRpc":"127.0.0.1:5566",
-	"pushTimeout": 300,
-	"ninePushTimeout": 172800
+	"appPushServiceRpc":"127.0.0.1:5566"
 }

+ 4 - 13
src/jfw/filter/logfilter.go

@@ -17,7 +17,6 @@ import (
 	"sync"
 	"time"
 	uc "ucbsutil"
-	ca "ucbsutil/cassandra"
 
 	"github.com/go-xweb/httpsession"
 	"github.com/go-xweb/xweb"
@@ -67,7 +66,7 @@ func SaveLogTask() {
 		arr = make([]map[string]interface{}, 0)
 		for _, v := range tmp {
 			go func(v map[string]interface{}) {
-				if !ca.SaveCache("jy_flogs", v) {
+				if !public.Ca_Log.SaveCache("jy_flogs", v) {
 					public.MQFW.Save("jy_logs", v)
 				}
 			}(v)
@@ -144,22 +143,14 @@ func addLog(l *logfilter, session *httpsession.Session, req *http.Request) {
 	lock.Lock()
 	arr = append(arr, logs)
 	if len(arr) >= nc || s_url == "/sl" {
-		/*tmp := arr
-		arr = make([]map[string]interface{}, 0)
-		go func() {
-			log.Println("save..visit..log", len(tmp))
-			tools.MQFW.SaveBulk("jy_logs", tmp...)
-		}()
-		*/
-		tmp := arr
-		arr = make([]map[string]interface{}, 0)
-		for _, v := range tmp {
+		for _, v := range arr {
 			go func(v map[string]interface{}) {
-				if !ca.SaveCache("jy_flogs", v) {
+				if !public.Ca_Log.SaveCache("jy_flogs", v) {
 					public.MQFW.Save("jy_logs", v)
 				}
 			}(v)
 		}
+		arr = make([]map[string]interface{}, 0)
 	}
 	lock.Unlock()
 }

+ 5 - 7
src/jfw/front/follow.go

@@ -16,8 +16,6 @@ import (
 	"strings"
 	"time"
 
-	ca "ucbsutil/cassandra"
-
 	"github.com/go-xweb/xweb"
 	"gopkg.in/mgo.v2/bson"
 )
@@ -867,8 +865,8 @@ func (m *Follow) Notice(id, followId string) error {
 	userid := util.ObjToString(m.GetSession("userId"))
 	date := util.Int64All(id) / 1000000000
 	if date > 0 {
-		_, openid := public.GetOldOpenid(userid)
-		plog := ca.SearchOne("select * from jy_pushproject where id=? and openid=? and date=?", util.FormatDateByInt64(&date, util.Date_Short_Layout), openid, id)
+		_, openid := public.GetOldOpenId(userid)
+		plog := public.Ca_Push.SearchOne("select * from jy_pushproject where id=? and openid=? and date=?", util.FormatDateByInt64(&date, util.Date_Short_Layout), openid, id)
 		dataFromDB := plog
 		if a_relationinfo := plog["info"]; a_relationinfo != nil {
 			relationinfo := []map[string]interface{}{}
@@ -888,7 +886,7 @@ func (m *Follow) Notice(id, followId string) error {
 			}
 			if len(relationinfo) == 1 {
 				firstMap := relationinfo[0]
-				ca.CDB.Query("update jy_pushproject set visit = visit+['"+fmt.Sprint(firstMap["s_id"])+"'] where id=? and openid=? and date=? ", util.FormatDateByInt64(&date, util.Date_Short_Layout), openid, id).Exec()
+				public.Ca_Push.CDB.Query("update jy_pushproject set visit = visit+['"+fmt.Sprint(firstMap["s_id"])+"'] where id=? and openid=? and date=? ", util.FormatDateByInt64(&date, util.Date_Short_Layout), openid, id).Exec()
 				return m.Redirect("/article/content/" + util.ObjToString(firstMap["s_id"]) + ".html")
 			}
 			dataFromDB["a_relationinfo"] = relationinfo
@@ -967,8 +965,8 @@ func (m *Follow) Visited() error {
 		if util.Int64All(id) > 0 {
 			userid := util.ObjToString(m.GetSession("userId"))
 			date := util.Int64All(id) / 1000000000
-			_, openid := public.GetOldOpenid(userid)
-			ca.CDB.Query("update jy_pushproject set visit = visit+['"+sid+"'] where id=? and openid=? and date=? ", util.FormatDateByInt64(&date, util.Date_Short_Layout), openid, id).Exec()
+			_, openid := public.GetOldOpenId(userid)
+			public.Ca_Push.CDB.Query("update jy_pushproject set visit = visit+['"+sid+"'] where id=? and openid=? and date=? ", util.FormatDateByInt64(&date, util.Date_Short_Layout), openid, id).Exec()
 		} else {
 			mongodb.Update("follow_push_log", `{"_id":"`+id+`"}`, map[string]interface{}{
 				"$addToSet": map[string]interface{}{"a_visited": sid},

+ 7 - 79
src/jfw/front/front.go

@@ -23,10 +23,7 @@ import (
 	"sync"
 	"time"
 
-	ca "ucbsutil/cassandra"
-
 	"github.com/go-xweb/httpsession"
-
 	"github.com/go-xweb/xweb"
 	"gopkg.in/mgo.v2/bson"
 )
@@ -38,6 +35,8 @@ type userPool struct {
 }
 type Front struct {
 	*xweb.Action
+	test xweb.Mapper `xweb:"/front/test"`
+
 	ajaxPolling        xweb.Mapper `xweb:"/front/ajaxPolling"`      //登录轮询
 	getLoginNum        xweb.Mapper `xweb:"/front/getLoginNum/(.*)"` //
 	login              xweb.Mapper `xweb:"/front/login/(.*)"`       //登录
@@ -156,6 +155,10 @@ func init() {
 	//up.user = make(map[string]*map[string]interface{})
 }
 
+func (f *Front) Test() error {
+	return f.Render("/test.html")
+}
+
 //
 func (f *Front) Hp() error {
 
@@ -824,82 +827,7 @@ func (m *Front) Wxprotocol() error {
 
 //推送列表
 func (m *Front) WxpushListInfo(_id string) error {
-	defer util.Catch()
-	userid := util.ObjToString(m.GetSession("userId"))
-	if userid == "" {
-		m.T["isWeixin"] = 1
-		return m.Render("/weixin/about.html")
-	}
-	//打开推送列表日志
-	date := util.Int64All(_id)
-	if date > 0 {
-		go ca.SaveCache("jy_pushvisit", map[string]interface{}{
-			"openid": userid,
-			"pdate":  date,
-			"vsid":   "-1", //打开列表页,无sid默认为-1
-			"date":   time.Now(),
-			"isopen": true,
-		})
-		//获取已浏览记录
-		visited := ca.Search("select vsid from jy_pushvisit where openid=? and pdate=?", userid, date)
-		vsidList := []string{}
-		for _, v := range visited {
-			vsidList = append(vsidList, (v["vsid"]).(string))
-		}
-
-		//获取推送信息
-		_, openId := public.GetOldOpenid(userid)
-		data := ca.SearchOne("select * from jy_push where id=? and openid=? and date=?", util.FormatDateByInt64(&date, util.Date_Short_Layout), openId, _id)
-		res := make(map[string]interface{})
-		if len(data) > 0 {
-			data["visit"] = vsidList
-			res = data
-			res["bmatch"] = true
-			//更换key
-			val := public.ChangeMapKeyForCass(res)
-			m.T["data"] = val
-		}
-		/*else { //查mongodb
-			go mongodb.Update("wxpush", `{"s_m_openid":"`+openid+`","l_date":`+fmt.Sprint(date)+`}`,
-				map[string]interface{}{
-					"$set": map[string]interface{}{
-						"isopen": true,
-					}},
-				true, false)
-			tmp, ok := mongodb.FindOne("wxpush", `{"s_m_openid":"`+openid+`","l_date":`+fmt.Sprint(date)+`}`)
-			if ok {
-				(*tmp)["bmatch"] = true
-				m.T["data"] = &tmp
-			} else {
-				(*tmp)["bmatch"] = false
-				m.T["data"] = &tmp
-			}
-		}*/
-	}
-	/*else { //日志迁移,过一段时间可删除
-		go mongodb.UpdateById("wxpush", _id, map[string]interface{}{
-			"$set": map[string]interface{}{
-				"isopen": true,
-			},
-		})
-		tmp, ok := mongodb.FindById("wxpush", _id, nil)
-		if ok {
-			(*tmp)["bmatch"] = true
-			m.T["data"] = &tmp
-		} else {
-			(*tmp)["bmatch"] = false
-			m.T["data"] = &tmp
-		}
-	}*/
-	m.T["_id"] = _id
-	m.T["signature"] = wx.SignJSSDK(m.Site() + m.Url())
-	m.T["openid"] = se.EncodeString(util.ObjToString(m.GetSession("s_m_openid")))
-	mynickname, _ := m.Session().Get("s_nickname").(string)
-	myavatar, _ := m.Session().Get("s_avatar").(string)
-	m.T["nickname"] = mynickname
-	m.T["avatar"] = myavatar
-	m.T["forceShareFlag"] = public.CheckUserNeedForceShare(userid, public.ShareType_push)
-	return m.Render("/weixin/wxpush.html", &m.T)
+	return m.Redirect("/swordfish/historypush")
 }
 func (m *Front) Feedback() error {
 	defer util.Catch()

+ 0 - 19
src/jfw/front/otherAct.go

@@ -154,25 +154,6 @@ func (f *Front) Lpsubmit() error {
 				"o_log": reqPhoneInfo(f.Request),
 			}
 			_id := mongodb.Save("user", data)
-			/*下个版本删除 start*/
-			go mongodb.Save("user_bak", map[string]interface{}{
-				"i_type":        1, //手机注册
-				"i_appid":       2,
-				"s_unionid":     phoneNum,
-				"s_phone":       phoneNum,
-				"s_m_openid":    phoneNum,
-				"s_source":      "landPage",
-				"s_extcode":     s_extcode,
-				"l_registedate": time.Now().Unix(),
-				"i_ts_guide":    2,
-				"o_jy": map[string]interface{}{
-					"i_mode":       1,
-					"i_ratemode":   2,
-					"l_modifydate": time.Now().Unix(),
-				},
-				"o_log": reqPhoneInfo(f.Request),
-			})
-			/*下个版本删除 end*/
 			if _id != "" {
 				deleteIdentSession(f.Session())
 				return "y"

+ 28 - 30
src/jfw/front/pchelper.go

@@ -135,25 +135,6 @@ func (l *PcHelper) Login() error {
 							"o_log": reqPhoneInfo(l.Request),
 						}
 						_id := mongodb.Save("user", data)
-						/*下个版本删除 start*/
-						go mongodb.Save("user_bak", map[string]interface{}{
-							"i_type":        1, //手机注册
-							"i_source":      1, //pc助手注册 add 20181119
-							"i_appid":       2,
-							"s_unionid":     phone,
-							"s_phone":       phone,
-							"s_m_openid":    phone,
-							"s_password":    "",
-							"l_registedate": time.Now().Unix(),
-							"i_ts_guide":    2,
-							"o_jy": map[string]interface{}{
-								"i_mode":       1,
-								"i_ratemode":   2,
-								"l_modifydate": time.Now().Unix(),
-							},
-							"o_log": reqPhoneInfo(l.Request),
-						})
-						/*下个版本删除 end*/
 						if _id != "" {
 							deleteIdentSession_(l.Session())
 							reToken = getUToken(mac, phone)
@@ -327,7 +308,27 @@ func (l *PcHelper) ToAct(token string) error {
 
 func (l *PcHelper) ToPushView() error {
 	defer util.Catch()
-	return l.Render("/pchelper/pushView.html")
+	userid := util.ObjToString(l.GetSession("userId"))
+	if userid != "" {
+		user, _ := public.HistoryPush.UserInfo(userid)
+		var o_jy map[string]interface{}
+		if user != nil {
+			o_jy, _ = (*user)["o_jy"].(map[string]interface{})
+		}
+		keyArr := []string{}
+		if o_jy != nil || len(o_jy) == 0 {
+			a_key, _ := o_jy["a_key"].([]interface{})
+			for _, vi := range a_key {
+				v, _ := vi.(map[string]interface{})
+				keys_a := v["key"].([]interface{})
+				if thiskey := strings.TrimSpace(strings.Join(util.ObjArrToStringArr(keys_a), "+")); thiskey != "" {
+					keyArr = append(keyArr, thiskey)
+				}
+			}
+		}
+		l.T["words"] = keyArr
+	}
+	return l.Render("/pchelper/pushView.html", &l.T)
 }
 
 func (l *PcHelper) ToSearch() error {
@@ -337,19 +338,16 @@ func (l *PcHelper) ToSearch() error {
 
 func (l *PcHelper) PushView() error {
 	defer util.Catch()
-	lasttime, _ := l.GetInt("lasttime")
+	pageNum, _ := l.GetInteger("pageNum")
 	userid := util.ObjToString(l.GetSession("userId"))
-	log.Println(logPrefix, "PushView-param", "lasttime:", lasttime, "userid:", userid)
 	res := map[string]interface{}{}
-	res["success"] = false
-	if userid != "" && lasttime > 0 {
-		user, openId := public.GetOldOpenid(userid)
-		thisindex, list := public.GetHistorypush(0, user, userid, openId)
-		log.Println(logPrefix, "PushView-getHistorypush-size", len(*list))
-		if list != nil && len(*list) > 0 {
-			res["success"] = true
+	res["hasNextPage"] = false
+	if userid != "" {
+		user, firstPushTime := public.HistoryPush.UserInfo(userid)
+		if user != nil {
+			hasNextPage, list, _ := public.HistoryPush.Datas(userid, pageNum, firstPushTime)
+			res["hasNextPage"] = hasNextPage
 			res["data"] = &list
-			res["thistime"] = thisindex
 		}
 	}
 	l.ServeJson(&res)

+ 1 - 1
src/jfw/front/shorturl.go

@@ -187,7 +187,7 @@ func (s *Short) Article(stype, id string) error {
 		sid := sids[0]
 		//log.Println("sid", sid)
 		var rec = ""
-		log.Println(redis.Get("recovery", "rec-"+ssOpenid.(string)), "ssOpenid:", ssOpenid)
+		//log.Println(redis.Get("recovery", "rec-"+ssOpenid.(string)), "ssOpenid:", ssOpenid)
 		if ssOpenid != nil && ssOpenid != "" && userId != "" {
 			if stype == "content" {
 				//判断是否需要强制分享

+ 1 - 2
src/jfw/front/supsearch.go

@@ -15,7 +15,6 @@ import (
 	"strings"
 	"time"
 	uc "ucbsutil"
-	ca "ucbsutil/cassandra"
 
 	"github.com/SKatiyar/qr"
 	"github.com/go-xweb/xweb"
@@ -509,7 +508,7 @@ func SaveUserSearchLog(request *http.Request, userid string, count int64, platfo
 		}
 		data["id"] = uc.DayShortTime()
 		data["tuid"] = gocql.TimeUUID()
-		if !ca.SaveCache("jy_search", data) {
+		if !public.Ca_Log.SaveCache("jy_search", data) {
 			data := map[string]interface{}{
 				"ip":         filter.GetIp(request),
 				"count":      count,

+ 40 - 260
src/jfw/front/swordfish.go

@@ -22,8 +22,6 @@ import (
 	"sync"
 	"time"
 
-	"ucbsutil/cassandra"
-
 	"github.com/go-xweb/httpsession"
 	"github.com/go-xweb/xweb"
 	. "github.com/thinxer/go-word2vec"
@@ -1532,7 +1530,7 @@ func (m *Front) WxpushView() error {
 	if openid == "" || userid == "" {
 		return m.Redirect("/swordfish/share/-1")
 	}
-	a_key, list := getWxPushViewData(userid, "", 1)
+	a_key, list := public.PushViewDatas(userid, "", bidSearch_field, 1, wx_pageSize)
 	public.BidListConvert("", list)
 	m.T["firstPage"] = list
 	m.T["hasNextPage"] = list != nil && len(*list) == wx_pageSize
@@ -1551,7 +1549,7 @@ func (m *Front) WxpushViewPaging() {
 	var list *[]map[string]interface{}
 	pageNum, _ := m.GetInteger("pageNum")
 	if userid := m.Session().Get("userId"); userid != nil && pageNum <= wx_maxPageNum {
-		_, list = getWxPushViewData(userid.(string), "", pageNum)
+		_, list = public.PushViewDatas(userid.(string), "", bidSearch_field, pageNum, wx_pageSize)
 	}
 	public.BidListConvert("", list)
 	m.ServeJson(map[string]interface{}{
@@ -1559,44 +1557,7 @@ func (m *Front) WxpushViewPaging() {
 		"hasNextPage": list != nil && len(*list) == wx_pageSize && pageNum < wx_maxPageNum,
 	})
 }
-func getWxPushViewData(userid, allquery string, pageNum int) (keys []interface{}, list *[]map[string]interface{}) {
-	if userid == "" {
-		return
-	}
-	tmp, ok := mongodb.FindById("user", userid, `{"_id":1,"o_jy":1,"i_smartset": 1}`)
-	if !ok || tmp == nil || len(*tmp) == 0 {
-		return
-	}
-	o_jy := (*tmp)["o_jy"].(map[string]interface{})
-	a_key, _ := o_jy["a_key"].([]interface{})
-	if len(a_key) == 0 {
-		return
-	}
-	i_smartset := util.IntAll((*tmp)["i_smartset"])
-	findf := `"title"`
-	if i_smartset == 1 {
-		//开启智能订阅
-		findf = `"title","detail"`
-	}
-	for _, v := range a_key {
-		keyMap, _ := v.(map[string]interface{})
-		key, _ := keyMap["key"].([]interface{})
-		keys = append(keys, key)
-	}
-	//field := `"_id","title","publishtime","toptype","subtype","type","area","href","areaval"`
-	var allkeys []elastic.KeyConfig //用户配置
-	_bs, err := json.Marshal(a_key)
-	if err == nil {
-		json.Unmarshal(_bs, &allkeys)
-	}
-	list = elastic.GetResForJY(INDEX, TYPE, allkeys, allquery, findf, `{"publishtime":"desc"}`, bidSearch_field, (pageNum-1)*wx_pageSize, wx_pageSize)
-	if list != nil {
-		for _, v := range *list {
-			v["_id"] = util.EncodeArticleId2ByCheck(util.ObjToString(v["_id"]))
-		}
-	}
-	return
-}
+
 func (m *Front) Guide(sign string) error {
 	defer util.Catch()
 	if m.Session().Get("userId") == nil || m.Session().Get("s_m_openid") == nil {
@@ -1647,31 +1608,11 @@ func (m *Front) Share(openids string) error {
 }
 func (m *Front) WxpushAjaxReq() error {
 	defer util.Catch()
+	index, _ := m.GetInteger("index")
+	date, _ := m.GetInt("_id")
+	userid := util.ObjToString(m.GetSession("userId"))
 	vsid := m.GetString("vsid")
-	pdate := m.GetString("_id")
-	//	log.Println("vsid=", vsid)
-	//	log.Println("pdate=", pdate)
-	if util.Int64All(pdate) > 0 {
-		visit := map[string]interface{}{
-			"openid": m.Session().Get("userId"),
-			"pdate":  pdate,
-			"vsid":   vsid,
-			"date":   time.Now(),
-			"vtime":  time.Now().Unix(),
-		}
-		cassandra.Save("jy_pushvisit", visit)
-	}
-	/*else {
-		index, _ := m.GetInteger("index")
-		//		log.Println("index", index)
-		mongodb.Update("wxpush", `{"_id":"`+pdate+`"}`, map[string]interface{}{
-			"$addToSet": map[string]interface{}{"a_visitedindex": index},
-			"$set": map[string]interface{}{
-				"a_visitedtime." + fmt.Sprint(index): time.Now().Unix(),
-				//				"a_visitedindex":                     index,
-			},
-		}, false, false)
-	}*/
+	public.HistoryPush.Visit(userid, vsid, date, index)
 	return nil
 }
 
@@ -2472,63 +2413,53 @@ func classify(stp, area, industry string) (string, string, string) {
 	return tpadd, areaadd, induadd
 }
 func (f *Front) HasPushHistory() {
-	userid := util.ObjToString(f.GetSession("userId"))
-	if userid == "" {
+	userId := util.ObjToString(f.GetSession("userId"))
+	if userId == "" {
 		return
 	}
-	user, openId := public.GetOldOpenid(userid)
+	user, firstPushTime := public.HistoryPush.UserInfo(userId)
 	var o_jy map[string]interface{}
 	if user != nil {
 		o_jy, _ = (*user)["o_jy"].(map[string]interface{})
 	}
-	haskey := false
+
+	keyArr := []string{}
 	if o_jy != nil || len(o_jy) == 0 {
 		a_key, _ := o_jy["a_key"].([]interface{})
 		for _, vi := range a_key {
 			v, _ := vi.(map[string]interface{})
 			keys_a := v["key"].([]interface{})
-			if strings.TrimSpace(strings.Join(util.ObjArrToStringArr(keys_a), "")) != "" {
-				haskey = true
-				break
+			if thiskey := strings.TrimSpace(strings.Join(util.ObjArrToStringArr(keys_a), "+")); thiskey != "" {
+				keyArr = append(keyArr, thiskey)
 			}
 		}
-	} else {
-		haskey = true
 	}
-	thistime, list := public.GetHistorypush(0, user, userid, openId)
-	/*if haskey && (list == nil || len(*list) == 0) {
-		list = &[]map[string]interface{}{}
-		flag, data := makeHistoryDatas(util.BsonIdToSId((*user)["_id"]), openId, o_jy)
+	hasNextPage, list, err := public.HistoryPush.Datas(userId, 1, firstPushTime)
+	if err == nil && len(keyArr) > 0 && len(list) == 0 {
+		flag, data := public.HistoryPush.MakeHistoryDatas(userId, bidSearch_field, o_jy)
 		if flag && data != nil {
-			tmp := public.ChangeMapKeyForCass(data)
-			if ats, ok := tmp["o_pushinfo"].(map[string]interface{}); ok {
-				thistime = 0
-				tmp["count"] = len(ats)
-				*list = append(*list, tmp)
-			}
+			list = data
 		}
-	}*/
-	//
-	var success bool
-	if list != nil && len(*list) > 0 {
-		success = true
 	}
 	//
 	f.ServeJson(map[string]interface{}{
-		"haskey":      haskey,
+		"haskey":      len(keyArr) > 0,
 		"data":        list,
-		"thistime":    thistime,
-		"success":     success,
-		"isInTSguide": isInTSguide(userid),
+		"hasNextPage": hasNextPage,
+		"isInTSguide": isInTSguide(userId),
+		"keys":        keyArr,
 	})
 }
 
 //历史推送
 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{}
@@ -2539,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
@@ -2560,87 +2483,20 @@ func (f *Front) Historypush() error {
 }
 
 func (f *Front) HistorypushPaging() error {
-	lasttime, _ := f.GetInteger("lasttime")
-	userid := util.ObjToString(f.GetSession("userId"))
-	res := map[string]interface{}{}
-	res["success"] = false
-	if userid != "" && lasttime > 0 {
-		user, openId := public.GetOldOpenid(userid)
-		thisindex, list := public.GetHistorypush(lasttime, user, userid, openId)
-		if list != nil && len(*list) > 0 {
-			res["success"] = true
-			res["data"] = &list
-			res["thistime"] = thisindex
-		}
-	}
-	f.ServeJson(&res)
-	return nil
-}
-
-func getHistorypush_old(lasttime, infotime int64, userId, openId string, res []map[string]interface{}, count int, vsidList []string) (thistime int64, list *[]map[string]interface{}) {
-	if lasttime < time.Now().Unix()-60*24*60*60 { //最多查询最近60天数据
-		return lasttime, &res
-	}
-	thistime = lasttime
-	if res == nil {
-		res = make([]map[string]interface{}, 0)
-	}
-	list = &res
-	dateshort := util.FormatDateByInt64(&lasttime, util.Date_Short_Layout)
-	pinfo := cassandra.Search("select * from jy_push where id=? and openid=? and date<?", dateshort, openId, lasttime+infotime)
-	if len(pinfo) > 0 {
-		for _, info := range pinfo {
-			tmp := public.ChangeMapKeyForCass(info)
-			if ats, ok := tmp["o_pushinfo"].(map[string]interface{}); ok {
-				thistime = util.Int64All(tmp["l_date"])
-				//获取已浏览记录
-				visited := cassandra.Search("select vsid from jy_pushvisit where openid=? and pdate=?", userId, thistime)
-				if len(visited) > 0 {
-					for _, v := range visited {
-						vsidList = append(vsidList, (v["vsid"]).(string))
-					}
-					log.Println(thistime, "vsidList:", vsidList)
-				}
-				tmp["a_visitedindex"] = vsidList
-				count += len(ats)
-				tmp["count"] = len(ats)
-				res = append(res, tmp)
-				list = &res
-				if count >= wx_pageSize {
-					return
-				}
-			}
-		}
-	}
-	/*else { //日志迁移,过一段时间作废
-		tmps, ok := mongodb.Find("wxpush", &map[string]interface{}{
-			"s_m_openid": openid,
-			"l_date": map[string]interface{}{
-				"$lt": lasttime,
-			},
-		}, `{"l_date":-1}`, nil, false, 0, 1)
-		if ok && (*tmps) != nil && len(*tmps) == 1 && (*tmps)[0] != nil {
-			tmp := (*tmps)[0]
-			at := tmp["o_pushinfo"]
-			if at != nil {
-				ats := at.(map[string]interface{})
-				thistime = tmp["l_date"].(int64)
-				count += len(ats)
-				tmp["count"] = len(ats)
-				res = append(res, tmp)
-				list = &res
-				if count >= wx_pageSize {
-					return
-				}
-			}
-		}
-	}*/
-	if count < wx_pageSize {
-		t, _ := time.ParseInLocation(util.Date_Short_Layout, time.Unix(lasttime, 0).Format(util.Date_Short_Layout), time.Local)
-		thistime = t.Unix() - 24*60*60
-		infotime = 24 * 60 * 60
+	pageNum, _ := f.GetInteger("pageNum")
+	userId := util.ObjToString(f.GetSession("userId"))
+	if userId != "" {
+		user, firstPushTime := public.HistoryPush.UserInfo(userId)
+		if user == nil {
+			return nil
+		}
+		hasNextPage, list, _ := public.HistoryPush.Datas(userId, pageNum, firstPushTime)
+		f.ServeJson(map[string]interface{}{
+			"hasNextPage": hasNextPage,
+			"data":        list,
+		})
 	}
-	return getHistorypush_old(thistime, infotime, userId, openId, res, count, vsidList)
+	return nil
 }
 
 //电脑端招标订阅
@@ -2802,79 +2658,3 @@ func wxPushViewDatas(index, itype string, keys []elastic.KeyConfig, allquery, fi
 		return nil
 	}
 }
-
-//保存最近7天的数据到历史记录
-func makeHistoryDatas(userid, openid string, o_jy map[string]interface{}) (bool, map[string]interface{}) {
-	allquery := `{"range":{"publishtime":{"gt":%s}}}`
-	allquery = fmt.Sprintf(allquery, fmt.Sprint(time.Now().AddDate(0, 0, -7).Unix()))
-	//allquery := ``
-	_, list := getWxPushViewData(userid, allquery, 1)
-	if list == nil || len(*list) == 0 {
-		return true, nil
-	}
-	var allkeysTemp []elastic.KeyConfig
-	_bs, err := json.Marshal(o_jy["a_key"])
-	if err == nil {
-		json.Unmarshal(_bs, &allkeysTemp)
-	}
-	keysTemp := []string{} //原始关键词
-	for _, vs := range allkeysTemp {
-		keysTemp = append(keysTemp, strings.Join(vs.Keys, "+"))
-	}
-	o_pushinfo := map[string]map[string]interface{}{}
-	publishTitle := map[string]bool{}
-	str := fmt.Sprintf("<div>根据您设置的关键词(%s),给您推送以下信息:</div>", strings.Join(keysTemp, ";"))
-	i := 0
-	for _, v := range *list {
-		title := strings.Replace(v["title"].(string), "\n", "", -1)
-		area := util.ObjToString(v["area"])
-		if publishTitle[area+title] {
-			log.Println("重复标题", title)
-			continue
-		} else {
-			publishTitle[area+title] = true
-		}
-		infoid := util.ObjToString(v["_id"])
-		redis.PutCKV("push", "push_"+userid+"_"+infoid, 1)
-		i++
-		industry := ""
-		if v["s_subscopeclass"] != nil {
-			k2sub := strings.Split(util.ObjToString(v["s_subscopeclass"]), ",")
-			if len(k2sub) > 0 {
-				industry = k2sub[0]
-				if industry != "" {
-					ss := strings.Split(industry, "_")
-					if len(ss) > 1 {
-						industry = ss[0]
-					}
-				}
-			}
-		}
-		str += "<div class='tslist'><span class='xh'>" + fmt.Sprintf("%d", i) + ".</span><a class='bt' target='_blank' eid='" + infoid + "' href='" + util.ObjToString(v["href"]) + "'>" + title + "</a></div>"
-		o_pushinfo[strconv.Itoa(i)] = map[string]interface{}{
-			"publishtime":   v["publishtime"],
-			"stype":         util.ObjToString(v["type"]),
-			"topstype":      util.ObjToString(v["toptype"]),
-			"substype":      util.ObjToString(v["subtype"]),
-			"subscopeclass": industry,
-			"buyer":         v["buyer"],
-			"projectname":   v["projectname"],
-			"budget":        v["budget"],
-			"bidopentime":   v["bidopentime"],
-			"winner":        v["winner"],
-			"bidamount":     v["bidamount"],
-		}
-	}
-	md, _ := json.Marshal(o_pushinfo)
-	wxpush := map[string]interface{}{
-		"id":       time.Now().Format(util.Date_Short_Layout),
-		"openid":   openid,
-		"date":     time.Now().Unix(),
-		"words":    keysTemp,
-		"uid":      userid,
-		"content":  str,
-		"pushinfo": string(md),
-	}
-	flag := cassandra.SaveCacheByTimeOut("jy_push", wxpush, 10)
-	return flag, wxpush
-}

+ 5 - 13
src/jfw/modules/app/src/app/filter/logfilter.go

@@ -7,6 +7,7 @@
 package filter
 
 import (
+	"encoding/json"
 	"jfw/public"
 	"net"
 	"net/http"
@@ -15,10 +16,7 @@ import (
 	"strings"
 	"sync"
 	"time"
-
-	"encoding/json"
 	uc "ucbsutil"
-	ca "ucbsutil/cassandra"
 
 	"github.com/go-xweb/httpsession"
 	"github.com/go-xweb/xweb"
@@ -66,7 +64,7 @@ func SaveLogTask() {
 		arr = make([]map[string]interface{}, 0)
 		for _, v := range tmp {
 			go func(v map[string]interface{}) {
-				if !ca.SaveCache("jy_fapp", v) {
+				if !public.Ca_Log.SaveCache("jy_fapp", v) {
 					public.MQFW.Save("jyapp_logs", v)
 				}
 			}(v)
@@ -142,20 +140,14 @@ func addLog(l *logfilter, session *httpsession.Session, req *http.Request) {
 	lock.Lock()
 	arr = append(arr, logs)
 	if len(arr) >= nc || s_url == "/sl" {
-		tmp := arr
-		arr = make([]map[string]interface{}, 0)
-		/*go func() {
-			log.Println("save..visit..log", len(tmp))
-			public.MQFW.SaveBulk("jyapp_logs", tmp...)
-		}()*/
-
-		for _, v := range tmp {
+		for _, v := range arr {
 			go func(v map[string]interface{}) {
-				if !ca.SaveCache("jy_fapp", v) {
+				if !public.Ca_Log.SaveCache("jy_fapp", v) {
 					public.MQFW.Save("jyapp_logs", v)
 				}
 			}(v)
 		}
+		arr = make([]map[string]interface{}, 0)
 	}
 	lock.Unlock()
 }

+ 68 - 52
src/jfw/modules/app/src/app/followent/followent.go

@@ -1,18 +1,17 @@
 package followent
 
 import (
+	"app/jylabutil"
 	"jfw/config"
 	"jfw/public"
 	"qfw/util"
-	"qfw/util/elastic"
 	"qfw/util/redis"
 	"strconv"
 	"strings"
 	"time"
 
-	"app/jylabutil"
-
 	"github.com/go-xweb/xweb"
+	"gopkg.in/mgo.v2/bson"
 )
 
 var mongodb = public.MQFW
@@ -30,7 +29,7 @@ type FollowEnt struct {
 	qgFollow   xweb.Mapper `xweb:"/jyapp/followent/qgFollow"`       //取消关注
 	visited    xweb.Mapper `xweb:"/jyapp/followent/notice/visited"` //用户是否已查看
 	ajaxSearch xweb.Mapper `xweb:"/jyapp/followent/ajaxSearch"`     //用户是否关注企业
-
+	detail     xweb.Mapper `xweb:"/jyapp/followent/detail/(.*)"`    //关注详情
 }
 
 func init() {
@@ -90,7 +89,7 @@ func (f *FollowEnt) GetEntList() {
 	})
 }
 func (f *FollowEnt) AddEnt() error {
-	return f.Render("followent/add.html")
+	return f.Render("/followent/add.html")
 }
 
 func (f *FollowEnt) RecList() {
@@ -110,72 +109,86 @@ func (f *FollowEnt) RecList() {
 func (f *FollowEnt) SaveEnt() {
 	f.ServeJson(map[string]interface{}{})
 }
+func (f *FollowEnt) Detail(followId string) error {
+	defer util.Catch()
+	userId := util.ObjToString(f.GetSession("userId"))
+	if !jylabutil.IsAuthorized(userId, "i_followent") {
+		return f.Redirect("/jyapp/jylab/laboratory/gzqy")
+	}
+	followId = util.DecodeArticleId2ByCheck(followId)[0]
+	winner := ""
+	winnerId := ""
+	var a_visited interface{}
+	oneQy, ok := mongodb.FindOneByField("jylab_followent", map[string]interface{}{
+		"_id":      bson.ObjectIdHex(followId),
+		"s_userid": userId,
+	}, `{"s_entname":1,"s_id":1,"a_visited":1}`)
+	follow := "n"
+	if !ok || oneQy == nil || len(*oneQy) == 0 {
+		oneQy, ok = mongodb.FindOneByField("jylab_followent_back", map[string]interface{}{
+			"s_followid": followId,
+			"s_userid":   userId,
+		}, `{"s_entname":1,"s_id":1,"a_visited":1}`)
+		if !ok || oneQy == nil || len(*oneQy) == 0 {
+			return f.Render("_error.html")
+		}
+	} else {
+		follow = "y"
+		mongodb.UpdateById("jylab_followent", followId, map[string]interface{}{
+			"$set": map[string]interface{}{
+				"i_apppushunread": 0,
+			},
+		})
+		if (*oneQy)["a_visited"] != nil {
+			a_visited = (*oneQy)["a_visited"]
+		}
+	}
+	winner = util.ObjToString((*oneQy)["s_entname"])
+	winnerId = util.ObjToString((*oneQy)["s_id"])
+	f.T["data"] = public.GetWinnerNewestDatas(winner)
+	f.T["winner"] = winner
+	f.T["s_id"] = util.EncodeArticleId2ByCheck(winnerId)
+	f.T["_id"] = util.EncodeArticleId2ByCheck(followId)
+	f.T["follow"] = follow
+	f.T["a_visited"] = a_visited
+	return f.Render("/followent/set.html", &f.T)
+}
 
 //企业最新信息
-func (f *FollowEnt) NewInfo(winnerid string) error {
+func (f *FollowEnt) NewInfo(param string) error {
 	defer util.Catch()
-	userid := util.ObjToString(f.GetSession("userId"))
-	authStatus := jylabutil.IsAuthorized(userid, "i_followent")
-	if !authStatus {
+	userId := util.ObjToString(f.GetSession("userId"))
+	if !jylabutil.IsAuthorized(userId, "i_followent") {
 		return f.Redirect("/jyapp/jylab/laboratory/gzqy")
 	}
 	winner := ""
-	id := ""
-	if winnerid != "" {
-		winner = strings.Split(winnerid, "___")[0]
-		id = strings.Split(winnerid, "___")[1]
+	winnerId := ""
+	if param != "" {
+		winner = strings.Split(param, "___")[0]
+		winnerId = strings.Split(param, "___")[1]
 	}
-
 	var follow = "n"
 	var a_visited interface{}
-	_id := ""
-	//fields := `{"projectname":1,"bidamount":1,"title":1,"publishtime":1,"subtype":1,"toptype":1,"href":1}`
-	//data, ok := mongodb.Find("bidding", `{"winner":"`+winner+`"}`, `{"publishtime":-1}`, fields, false, -1, -1)
-	ok := true
-	fields := `"_id","projectname","bidamount","title","publishtime","subtype","toptype","href"`
-	data := elastic.GetPage("bidding", "bidding", `{"TERM_s_winner":"`+winner+`"}`, `{"publishtime":-1}`, fields, 0, 100)
-	if !ok {
-		return f.Redirect("/jyapp/free/mob/err")
-	}
-	if ok && len(*data) != 0 && data != nil && *data != nil {
-		for _, v := range *data {
-			v["_id"] = util.EncodeArticleId2ByCheck(util.BsonIdToSId(v["_id"]))
-			bidamount, _ := v["bidamount"].(float64)
-			v["bidamount"] = bidamount
-		}
-
-	}
-
 	//判断用户是否关注
-	s_id := ""
-	if id == "" {
-		s_id = createId(winner)
+	if winnerId == "" {
+		winnerId = createId(winner)
 	} else {
-		s_id = util.DecodeArticleId2ByCheck(id)[0] //企业id
+		winnerId = util.DecodeArticleId2ByCheck(winnerId)[0] //企业id
 	}
-	oneQy, ok := mongodb.FindOneByField("jylab_followent", `{"s_userid":"`+userid+`","s_id":"`+s_id+`"}`, `{"a_visited":1}`)
-	if ok && oneQy != nil {
-		mongodb.Update("jylab_followent", map[string]interface{}{
-			"s_userid": userid,
-			"s_id":     s_id,
-		}, map[string]interface{}{
-			"$set": map[string]interface{}{
-				"i_apppushunread": 0,
-			},
-		}, false, true)
+	oneQy, ok := mongodb.FindOneByField("jylab_followent", `{"s_userid":"`+userId+`","s_id":"`+winnerId+`"}`, `{"a_visited":1}`)
+	if ok && oneQy != nil && len(*oneQy) > 0 {
 		follow = "y" //已经关注此企业
 		if (*oneQy)["a_visited"] != nil {
 			a_visited = (*oneQy)["a_visited"]
 		}
-		_id = util.EncodeArticleId2ByCheck(util.BsonIdToSId((*oneQy)["_id"]))
+		f.T["_id"] = util.EncodeArticleId2ByCheck(util.BsonIdToSId((*oneQy)["_id"]))
 	}
-	f.T["data"] = data
+	f.T["data"] = public.GetWinnerNewestDatas(winner)
 	f.T["winner"] = winner
-	f.T["s_id"] = util.EncodeArticleId2ByCheck(s_id)
-	f.T["_id"] = _id
+	f.T["s_id"] = util.EncodeArticleId2ByCheck(winnerId)
 	f.T["follow"] = follow
 	f.T["a_visited"] = a_visited
-	return f.Render("followent/set.html", &f.T)
+	return f.Render("/followent/set.html", &f.T)
 }
 
 //取消企业关注
@@ -201,12 +214,15 @@ func (f *FollowEnt) Followent() error {
 	//data := elastic.GetPage("bidding", "bidding", "{}", `{"publishtime":-1}`, `"_id","title","publishtime","toptype","subtype","type","area","href"`, 0, 2)
 	redis.Put("sso", "followent", "9999999999999999999999", 60)
 	//log.Println("data:", redis.Get("sso", "followent"))
-	return f.Render("followent/index.html")
+	return f.Render("/followent/index.html")
 }
 
 //没有企业id创建企业id
 func createId(winner string) string {
 	defer util.Catch()
+	if winner == "" {
+		return ""
+	}
 	tem, ok := mongodb.FindOneByField("winner", `{"name":"`+winner+`"}`, `{"_id":1}`)
 	winnerid := ""
 	if ok && len(*tem) == 0 {

+ 9 - 26
src/jfw/modules/app/src/app/followent/myfwent.go

@@ -2,10 +2,10 @@ package followent
 
 import (
 	"jfw/config"
+	"jfw/public"
 	"log"
 	"qfw/util"
 	"qfw/util/elastic"
-	"qfw/util/redis"
 	"strings"
 	"time"
 
@@ -86,30 +86,27 @@ func Findent(entname string) string {
 //删除30无更新数据的企业
 func (m *Myfwent) DelOvertimeCompany() error {
 	defer util.Catch()
-	var ids []string
+	var ids []bson.ObjectId
 	var flag = "F"
-	var arrid = strings.Split(m.GetString("arrid"), ",")
-	if len(arrid) > 0 {
-		for _, chid := range arrid {
-			ids = append(ids, util.DecodeArticleId2ByCheck(chid)[0])
-		}
+	for _, chid := range strings.Split(m.GetString("arrid"), ",") {
+		ids = append(ids, bson.ObjectIdHex(util.DecodeArticleId2ByCheck(chid)[0]))
 	}
-	userId, ok := m.GetSession("userId").(string)
-	if !ok || userId == "" || len(ids) < 1 {
+	userId, _ := m.GetSession("userId").(string)
+	if userId == "" || len(ids) == 0 {
 		m.ServeJson(map[string]interface{}{
 			"flag": flag,
 		})
 		return nil
 	}
-	datas, ok := mongodb.Find("jylab_followent", bson.M{"s_id": bson.M{"$in": ids}, "s_userid": userId}, nil, nil, false, -1, -1)
+	datas, ok := mongodb.Find("jylab_followent", bson.M{"_id": bson.M{"$in": ids}, "s_userid": userId}, nil, nil, false, -1, -1)
 	if ok && datas != nil {
 		for _, v := range *datas {
 			delete(v, "_id")
 			mongodb.Save("jylab_followent_back", v)
-			go delRelRedis(v["s_userid"], v["a_relationinfo"]) //openid-xxxx
+			go public.DelRelRedis(v["s_userid"], v["a_relationinfo"]) //openid-xxxx
 		}
 	}
-	if mongodb.Del("jylab_followent", bson.M{"s_id": bson.M{"$in": ids}, "s_userid": userId}) {
+	if mongodb.Del("jylab_followent", bson.M{"_id": bson.M{"$in": ids}, "s_userid": userId}) {
 		flag = "T"
 	}
 	m.ServeJson(map[string]interface{}{
@@ -117,17 +114,3 @@ func (m *Myfwent) DelOvertimeCompany() error {
 	})
 	return nil
 }
-
-//删除redis相关数据
-func delRelRedis(userid interface{}, relationinfo interface{}) {
-	defer util.Catch()
-	uid, _ := userid.(string)
-	if uid == "" || relationinfo == nil {
-		return
-	}
-	array, _ := relationinfo.([]interface{})
-	for _, v := range util.ObjArrToMapArr(array) {
-		sid, _ := v["s_id"].(string)
-		redis.Del("push", "push_"+uid+"_"+sid)
-	}
-}

+ 5 - 6
src/jfw/modules/app/src/app/front/follow.go

@@ -12,7 +12,6 @@ import (
 	rpc "qfw/util/rpc"
 	"strings"
 	"time"
-	ca "ucbsutil/cassandra"
 
 	"github.com/go-xweb/xweb"
 	"gopkg.in/mgo.v2/bson"
@@ -731,8 +730,8 @@ func (m *Follow) Notice(id, followId string) error {
 	}, false, false)
 	date := util.Int64All(id)
 	date = date / 1000000000
-	_, openid := public.GetOldOpenid(util.ObjToString(m.GetSession("userId")))
-	dataFromDB := ca.SearchOne("select * from jy_pushproject where id=? and openid=? and date=?", util.FormatDateByInt64(&date, util.Date_Short_Layout), openid, id)
+	_, openid := public.GetOldOpenId(util.ObjToString(m.GetSession("userId")))
+	dataFromDB := public.Ca_Push.SearchOne("select * from jy_pushproject where id=? and openid=? and date=?", util.FormatDateByInt64(&date, util.Date_Short_Layout), openid, id)
 	if a_relationinfo := dataFromDB["info"]; a_relationinfo != nil {
 		relationinfo := []map[string]interface{}{}
 		json.Unmarshal([]byte(a_relationinfo.(string)), &relationinfo)
@@ -751,7 +750,7 @@ func (m *Follow) Notice(id, followId string) error {
 		}
 		if len(relationinfo) == 1 {
 			firstMap := relationinfo[0]
-			ca.CDB.Query("update jy_pushproject set visit = visit+['"+fmt.Sprint(firstMap["s_id"])+"'] where id=? and openid=? and date=? ", util.FormatDateByInt64(&date, util.Date_Short_Layout), openid, id).Exec()
+			public.Ca_Push.CDB.Query("update jy_pushproject set visit = visit+['"+fmt.Sprint(firstMap["s_id"])+"'] where id=? and openid=? and date=? ", util.FormatDateByInt64(&date, util.Date_Short_Layout), openid, id).Exec()
 			return m.Redirect("/jyapp/article/content/" + util.ObjToString(firstMap["s_id"]) + ".html")
 		}
 		dataFromDB["a_relationinfo"] = relationinfo
@@ -801,8 +800,8 @@ func (m *Follow) Visited() error {
 		}, false, false)
 	} else if reqType == 2 {
 		date := util.Int64All(id) / 1000000000
-		_, openid := public.GetOldOpenid(util.ObjToString(m.GetSession("userId")))
-		ca.CDB.Query("update jy_pushproject set visit = visit+['"+sid+"'] where id=? and openid=? and date=? ", util.FormatDateByInt64(&date, util.Date_Short_Layout), openid, id).Exec()
+		_, openid := public.GetOldOpenId(util.ObjToString(m.GetSession("userId")))
+		public.Ca_Push.CDB.Query("update jy_pushproject set visit = visit+['"+sid+"'] where id=? and openid=? and date=? ", util.FormatDateByInt64(&date, util.Date_Short_Layout), openid, id).Exec()
 	}
 	return nil
 }

+ 5 - 47
src/jfw/modules/app/src/app/front/front.go

@@ -6,16 +6,13 @@ import (
 	"jfw/config"
 	"jfw/public"
 	"log"
-	"net/url"
 	"qfw/util"
 	"qfw/util/elastic"
 	"regexp"
 	"strings"
 	"sync"
 	"time"
-
 	uc "ucbsutil"
-	ca "ucbsutil/cassandra"
 
 	"github.com/dchest/captcha"
 	"github.com/go-xweb/xweb"
@@ -146,7 +143,7 @@ func mesCaLog(mid, url, userId, recType string) {
 	userData, ok1 := mongodb.FindById("user", userId, `{"s_province":1,"s_city":1,"s_nickname":1}`)
 	mesData, ok2 := mongodb.FindById("message_app", mid, `{"s_title":1,"s_subtitle":1}`)
 	if ok1 && ok2 && *mesData != nil && *userData != nil {
-		ca.SaveCache("jy_message", map[string]interface{}{
+		public.Ca_Push.SaveCache("jy_message", map[string]interface{}{
 			"id":       uc.DayShortTime(),
 			"openid":   userId, //之前存的是openid,用户合并以后存的是userid
 			"mid":      mid,
@@ -328,49 +325,10 @@ var pushGetEidReg = regexp.MustCompile("eid='(.+?)'")
 
 func (m *Front) WxpushListInfo(_id string) error {
 	defer util.Catch()
-	userId, _ := m.GetSession("userId").(string)
-	date := util.Int64All(_id)
-	go ca.SaveCache("jy_pushvisit", map[string]interface{}{
-		"openid": userId, //之前存openid,用户合并以后存的userid
-		"pdate":  date,
-		"vsid":   "-1", //打开列表页,无sid默认为-1
-		"date":   time.Now(),
-		"isopen": true,
-	})
-	//获取已浏览记录
-	visited := ca.Search("select vsid from jy_pushvisit where openid=? and pdate=?", userId, date)
-	vsidList := []string{}
-	for _, v := range visited {
-		vsidList = append(vsidList, (v["vsid"]).(string))
-	}
-	_, openId := public.GetOldOpenid(userId)
-	data := ca.SearchOne("select * from jy_push where id=? and openid=? and date=?", util.FormatDateByInt64(&date, util.Date_Short_Layout), openId, _id)
-	res := make(map[string]interface{})
-	data["visit"] = vsidList
-	res = data
-	res = public.ChangeMapKeyForCass(res) //更换key
-	//如果有一条,直接跳转
-	o_pushinfo, _ := res["o_pushinfo"].(map[string]interface{})
-	if len(o_pushinfo) == 1 {
-		s_content, _ := res["s_content"].(string)
-		array := pushGetEidReg.FindStringSubmatch(s_content)
-		if len(array) == 2 {
-			eid := array[1]
-			tmps, _ := res["s_words"].([]string)
-			s_words := []interface{}{}
-			for _, v := range tmps {
-				s_words = append(s_words, v)
-			}
-			words := "subkey_" + strings.Join(util.ObjArrToStringArr(s_words), "_")
-			return m.Redirect("/jyapp/article/content/" + eid + ".html?keywords=" + url.QueryEscape(words))
-		}
-	}
-	res["bmatch"] = true
-	m.T["data"] = res
-	m.T["_id"] = _id
-	m.T["forceShareFlag"] = public.CheckUserNeedForceShare(userId, public.ShareType_push)
-	return m.Render("/weixin/wxpush.html", &m.T)
-} //
+	return m.Redirect("/jyapp/swordfish/historypush")
+}
+
+//
 func (f *Front) LimitSearchText() {
 	userId, _ := f.GetSession("userId").(string)
 	if userId == "" || !public.Lst.IsCanLogin(userId) {

+ 9 - 100
src/jfw/modules/app/src/app/front/login.go

@@ -186,27 +186,6 @@ func (l *Login) Login() error {
 						"o_log": reqPhoneInfo(l.Request),
 					}
 					_id := mongodb.Save("user", data)
-					/*下个版本删除 start*/
-					go mongodb.Save("user_bak", map[string]interface{}{
-						"i_appid":       2,
-						"s_phone":       phone,
-						"s_m_openid":    phone,
-						"s_unionid":     phone,
-						"i_type":        1,
-						"s_password":    "",
-						"l_registedate": time.Now().Unix(),
-						"s_jpushid":     rid,
-						"s_opushid":     oid,
-						"s_appponetype": phoneType,
-						"i_ts_guide":    2,
-						"o_jy": map[string]interface{}{
-							"i_mode":       1,
-							"i_ratemode":   2,
-							"l_modifydate": time.Now().Unix(),
-						},
-						"o_log": reqPhoneInfo(l.Request),
-					})
-					/*下个版本删除 end*/
 					if _id != "" {
 						deleteIdentSession(l.Session())
 						returnSign = afterLogin(data, l.Session(), rid, oid, phoneType, 1, true)
@@ -245,15 +224,18 @@ func (l *Login) Sess(ostr string) error {
 		if l.GetSession("userId") != nil {
 			hasSession = true
 		} else {
-			openid := str[0]
-			loginType := 2
-			if phoneReg.MatchString(openid) {
-				loginType = 1
+			loginType := 0
+			loginId := str[0]
+			if str[1] == "uid" {
+				loginType = 2
+				if phoneReg.MatchString(loginId) {
+					loginType = 1
+				}
 			}
-			if createSession(l.Session(), nil, openid, loginType) {
+			if createSession(l.Session(), nil, loginId, loginType) {
 				hasSession = true
 			} else {
-				log.Println("创建session失败", openid)
+				log.Println("创建session失败", loginId)
 			}
 		}
 		if hasSession {
@@ -354,27 +336,6 @@ func (l *Login) Register() error {
 				"o_log": reqPhoneInfo(l.Request),
 			}
 			_id := mongodb.Save("user", data)
-			/*下个版本删除 start*/
-			go mongodb.Save("user_bak", map[string]interface{}{
-				"i_appid":       2,
-				"i_type":        1,
-				"s_phone":       phone,
-				"s_m_openid":    phone,
-				"s_unionid":     phone,
-				"s_password":    qutil.GetMd5String(password),
-				"l_registedate": time.Now().Unix(),
-				"s_jpushid":     rid,
-				"s_opushid":     oid,
-				"s_appponetype": phoneType,
-				"i_ts_guide":    2,
-				"o_jy": map[string]interface{}{
-					"i_mode":       1,
-					"i_ratemode":   2,
-					"l_modifydate": time.Now().Unix(),
-				},
-				"o_log": reqPhoneInfo(l.Request),
-			})
-			/*下个版本删除 end*/
 			if _id != "" {
 				l.DelSession("registerStep")
 				deleteIdentSession(l.Session())
@@ -516,64 +477,12 @@ func (l *Login) WxLogin() {
 				}
 				update["$set"] = set
 				mongodb.Update("user", map[string]interface{}{"_id": (*user)["_id"]}, update, false, false)
-				/*下个版本删除 start*/
-				go mongodb.Save("user_bak", map[string]interface{}{
-					"s_jpushid":       rid,
-					"s_opushid":       oid,
-					"s_appponetype":   phoneType,
-					"s_name":          u.Nickname,
-					"i_appid":         2,
-					"i_ts_guide":      2,
-					"i_type":          2,
-					"s_m_openid":      u.OpenId,
-					"s_unionid":       u.UnionId,
-					"l_a_registedate": time.Now().Unix(),
-					"s_nickname":      u.Nickname,
-					"i_sex":           u.Sex,
-					"s_country":       u.Country,
-					"s_province":      u.Province,
-					"s_city":          u.City,
-					"s_headimageurl":  u.HeadImageUrl,
-					"o_jy": map[string]interface{}{
-						"i_mode":       1,
-						"i_ratemode":   2,
-						"l_modifydate": time.Now().Unix(),
-					},
-					"o_log": reqPhoneInfo(l.Request),
-				})
-				/*下个版本删除 end*/
 				returnSign = afterLogin(*user, l.Session(), rid, oid, phoneType, 2, true)
 				return 1
 			} else {
 				//保存用户之前,先清理rid
 				//clearRidByRid(rid)
 				//创建全新用户
-				/*下个版本删除 start*/
-				go mongodb.Save("user_bak", map[string]interface{}{
-					"s_jpushid":       rid,
-					"s_opushid":       oid,
-					"s_appponetype":   phoneType,
-					"s_name":          u.Nickname,
-					"i_appid":         2,
-					"i_ts_guide":      2,
-					"i_type":          2,
-					"s_m_openid":      u.OpenId,
-					"s_unionid":       u.UnionId,
-					"l_a_registedate": time.Now().Unix(),
-					"s_nickname":      u.Nickname,
-					"i_sex":           u.Sex,
-					"s_country":       u.Country,
-					"s_province":      u.Province,
-					"s_city":          u.City,
-					"s_headimageurl":  u.HeadImageUrl,
-					"o_jy": map[string]interface{}{
-						"i_mode":       1,
-						"i_ratemode":   2,
-						"l_modifydate": time.Now().Unix(),
-					},
-					"o_log": reqPhoneInfo(l.Request),
-				})
-				/*下个版本删除 end*/
 				newUser := map[string]interface{}{
 					"s_jpushid":      rid,
 					"s_opushid":      oid,

+ 35 - 220
src/jfw/modules/app/src/app/front/swordfish.go

@@ -3,7 +3,6 @@ package front
 import (
 	"app/filter"
 	"app/jylabutil"
-	"encoding/json"
 	"fmt"
 	"jfw/config"
 	"jfw/public"
@@ -18,7 +17,6 @@ import (
 	"sync"
 	"time"
 	uc "ucbsutil"
-	ca "ucbsutil/cassandra"
 
 	"github.com/go-xweb/httpsession"
 	"github.com/gocql/gocql"
@@ -653,7 +651,7 @@ func (m *Front) WxpushView() error {
 	if userid == "" {
 		return m.Redirect("/jyapp/login")
 	}
-	a_key, list := getWxPushViewData(userid, "", 1)
+	a_key, list := public.PushViewDatas(userid, "", bidSearch_field, 1, wx_pageSize)
 	public.BidListConvert("", list)
 	m.T["firstPage"] = list
 	m.T["hasNextPage"] = list != nil && len(*list) == wx_pageSize
@@ -666,7 +664,7 @@ func (m *Front) WxpushViewPaging() {
 	var list *[]map[string]interface{}
 	pageNum, _ := m.GetInteger("pageNum")
 	if userid := util.ObjToString(m.GetSession("userId")); userid != "" && pageNum <= wx_maxPageNum {
-		_, list = getWxPushViewData(userid, "", pageNum)
+		_, list = public.PushViewDatas(userid, "", bidSearch_field, pageNum, wx_pageSize)
 	}
 	public.BidListConvert("", list)
 	m.ServeJson(map[string]interface{}{
@@ -674,94 +672,44 @@ func (m *Front) WxpushViewPaging() {
 		"hasNextPage": list != nil && len(*list) == wx_pageSize && pageNum < wx_maxPageNum,
 	})
 }
-func getWxPushViewData(userid, allquery string, pageNum int) (keys []interface{}, list *[]map[string]interface{}) {
-	if userid == "" {
-		return
-	}
-	tmp, ok := mongodb.FindById("user", userid, `{"_id":1,"o_jy":1,"i_smartset": 1}`)
-	if !ok || tmp == nil || len(*tmp) == 0 {
-		return
-	}
-	o_jy, _ := (*tmp)["o_jy"].(map[string]interface{})
-	a_key, _ := o_jy["a_key"].([]interface{})
-	if len(a_key) == 0 {
-		return
-	}
-	i_smartset := util.IntAll((*tmp)["i_smartset"])
-	findf := `"title"`
-	if i_smartset == 1 {
-		//开启智能订阅
-		findf = `"title","detail"`
-	}
-	for _, v := range a_key {
-		keyMap, _ := v.(map[string]interface{})
-		key, _ := keyMap["key"].([]interface{})
-		keys = append(keys, key)
-	}
-	//field := `"_id","title","publishtime","toptype","subtype","type","area","href","areaval"`
-	var allkeys []elastic.KeyConfig //用户配置
-	_bs, err := json.Marshal(a_key)
-	if err == nil {
-		json.Unmarshal(_bs, &allkeys)
-	}
-	list = elastic.GetResForJY(INDEX, TYPE, allkeys, "", findf, `{"publishtime":"desc"}`, bidSearch_field, (pageNum-1)*wx_pageSize, wx_pageSize)
-	if list != nil {
-		for _, v := range *list {
-			v["_id"] = util.EncodeArticleId2ByCheck(util.ObjToString(v["_id"]))
-		}
-	}
-	return
-}
+
 func (f *Front) HasPushHistory() {
-	userid, _ := f.GetSession("userId").(string)
-	if userid == "" {
+	userId, _ := f.GetSession("userId").(string)
+	if userId == "" {
 		return
 	}
-	user, openId := public.GetOldOpenid(userid)
+	user, firstPushTime := public.HistoryPush.UserInfo(userId)
 	var o_jy map[string]interface{}
 	if user != nil {
 		o_jy, _ = (*user)["o_jy"].(map[string]interface{})
 	}
-	haskey := false
+	keyArr := []string{}
 	if o_jy != nil || len(o_jy) == 0 {
 		a_key, _ := o_jy["a_key"].([]interface{})
 		for _, vi := range a_key {
 			v, _ := vi.(map[string]interface{})
 			keys_a := v["key"].([]interface{})
-			if strings.TrimSpace(strings.Join(util.ObjArrToStringArr(keys_a), "")) != "" {
-				haskey = true
-				break
+			if thiskey := strings.TrimSpace(strings.Join(util.ObjArrToStringArr(keys_a), "+")); thiskey != "" {
+				keyArr = append(keyArr, thiskey)
 			}
 		}
-	} else {
-		haskey = true
 	}
-	thistime, list := public.GetHistorypush(0, user, userid, openId)
-	/*if haskey && (list == nil || len(*list) == 0) {
-		list = &[]map[string]interface{}{}
-		flag, data := makeHistoryDatas(userid, openId, o_jy)
+	hasNextPage, list, err := public.HistoryPush.Datas(userId, 1, firstPushTime)
+	if len(list) > 0 {
+		go updateUserApppushunread(userId)
+	} else if err == nil && len(keyArr) > 0 {
+		flag, data := public.HistoryPush.MakeHistoryDatas(userId, bidSearch_field, o_jy)
 		if flag && data != nil {
-			tmp := public.ChangeMapKeyForCass(data)
-			if ats, ok := tmp["o_pushinfo"].(map[string]interface{}); ok {
-				thistime = 0
-				tmp["count"] = len(ats)
-				*list = append(*list, tmp)
-			}
+			list = data
 		}
-	}*/
-	//
-	var success bool
-	if list != nil && len(*list) > 0 {
-		go updateUserApppushunread(userid)
-		success = true
 	}
 	//
 	f.ServeJson(map[string]interface{}{
-		"haskey":      haskey,
+		"haskey":      len(keyArr) > 0,
 		"data":        list,
-		"thistime":    thistime,
-		"success":     success,
-		"isInTSguide": isInTSguide(userid),
+		"hasNextPage": hasNextPage,
+		"isInTSguide": isInTSguide(userId),
+		"keys":        keyArr,
 	})
 }
 
@@ -770,74 +718,21 @@ func (f *Front) Historypush() error {
 	return f.Render("/weixin/historypush.html")
 }
 func (f *Front) HistorypushPaging() error {
-	lasttime, _ := f.GetInteger("lasttime")
+	pageNum, _ := f.GetInteger("pageNum")
 	userId, _ := f.GetSession("userId").(string)
-	res := map[string]interface{}{}
-	res["success"] = false
-	if userId != "" && lasttime > 0 || lasttime == -1 {
-		isFirstPage := false
-		if lasttime == -1 {
-			isFirstPage = true
-		}
-		user, openId := public.GetOldOpenid(userId)
-		thistime, list := public.GetHistorypush(lasttime, user, userId, openId)
-		if list != nil && len(*list) > 0 {
-			if isFirstPage {
-				go updateUserApppushunread(userId)
-			}
-			res["success"] = true
-			res["data"] = &list
-			res["thistime"] = thistime
-		}
+	if userId != "" {
+		if pageNum == 1 {
+			go updateUserApppushunread(userId)
+		}
+		_, firstPushTime := public.HistoryPush.UserInfo(userId)
+		hasNextPage, list, _ := public.HistoryPush.Datas(userId, pageNum, firstPushTime)
+		f.ServeJson(map[string]interface{}{
+			"hasNextPage": hasNextPage,
+			"data":        list,
+		})
 	}
-	f.ServeJson(&res)
 	return nil
 }
-func getHistorypush_old(lasttime, infotime int64, userId, openId string, res []map[string]interface{}, count int, vsidList []string) (thistime int64, list *[]map[string]interface{}) {
-	if lasttime < time.Now().Unix()-60*24*60*60 { //最多查询最近60天数据
-		return lasttime, &res
-	}
-	thistime = lasttime
-	if res == nil {
-		res = make([]map[string]interface{}, 0)
-	}
-	list = &res
-	dateshort := util.FormatDateByInt64(&lasttime, util.Date_Short_Layout)
-	pinfo := ca.Search("select * from jy_push where id=? and openid=? and date<?", dateshort, openId, lasttime+infotime)
-	for _, info := range pinfo {
-		tmp := public.ChangeMapKeyForCass(info)
-		if ats, ok := tmp["o_pushinfo"].(map[string]interface{}); ok {
-			thistime = util.Int64All(tmp["l_date"])
-			//获取已浏览记录
-			visited := ca.Search("select vsid from jy_pushvisit where openid=? and pdate=?", userId, thistime)
-			if len(visited) > 0 {
-				for _, v := range visited {
-					vsidList = append(vsidList, (v["vsid"]).(string))
-				}
-				log.Println(thistime, "vsidList:", vsidList)
-			}
-			tmp["a_visitedindex"] = vsidList
-			count += len(ats)
-			tmp["count"] = len(ats)
-			res = append(res, tmp)
-			list = &res
-			if count >= wx_pageSize {
-				return
-			}
-		}
-		if count < wx_pageSize {
-			t, _ := time.ParseInLocation(util.Date_Short_Layout, time.Unix(lasttime, 0).Format(util.Date_Short_Layout), time.Local)
-			thistime = t.Unix() - 24*60*60
-			infotime = 24 * 60 * 60
-		}
-	}
-	if count < wx_pageSize {
-		t, _ := time.ParseInLocation(util.Date_Short_Layout, time.Unix(lasttime, 0).Format(util.Date_Short_Layout), time.Local)
-		thistime = t.Unix() - 24*60*60
-		infotime = 24 * 60 * 60
-	}
-	return getHistorypush_old(thistime, infotime, userId, openId, res, count, vsidList)
-}
 
 func MFollow(userId, pname, pcode, title string) (bool, string) {
 	defer util.Catch()
@@ -946,16 +841,11 @@ func saveBehaviorRecord(sess *httpsession.Session, data bson.M) bool {
 
 func (m *Front) WxpushAjaxReq() error {
 	defer util.Catch()
+	index, _ := m.GetInteger("index")
+	pdate, _ := m.GetInt("_id")
+	userid := util.ObjToString(m.GetSession("userId"))
 	vsid := m.GetString("vsid")
-	pdate := m.GetString("_id")
-	visit := map[string]interface{}{
-		"openid": m.Session().Get("userId"), //以前存openid,用户合并以后存userId
-		"pdate":  pdate,
-		"vsid":   vsid,
-		"date":   time.Now(),
-		"vtime":  time.Now().Unix(),
-	}
-	ca.Save("jy_pushvisit", visit)
+	public.HistoryPush.Visit(userid, vsid, pdate, index)
 	return nil
 }
 func (m *Front) DelWxHistorySearch() {
@@ -1071,7 +961,7 @@ func SaveUserSearchLog(request *http.Request, userId string, count int64, platfo
 		}
 		data["id"] = uc.DayShortTime()
 		data["tuid"] = gocql.TimeUUID()
-		if !ca.SaveCache("jy_search", data) {
+		if !public.Ca_Log.SaveCache("jy_search", data) {
 			data := map[string]interface{}{
 				"ip":         filter.GetIp(request),
 				"count":      count,
@@ -1091,81 +981,6 @@ func SaveUserSearchLog(request *http.Request, userId string, count int64, platfo
 	}()
 }
 
-//保存最近7天的数据到历史记录
-func makeHistoryDatas(userid, openId string, o_jy map[string]interface{}) (bool, map[string]interface{}) {
-	allquery := `{"range":{"publishtime":{"gt":%s}}}`
-	allquery = fmt.Sprintf(allquery, fmt.Sprint(time.Now().AddDate(0, 0, -7).Unix()))
-	//allquery := ``
-	_, list := getWxPushViewData(userid, allquery, 1)
-	if list == nil || len(*list) == 0 {
-		return true, nil
-	}
-	var allkeysTemp []elastic.KeyConfig
-	_bs, err := json.Marshal(o_jy["a_key"])
-	if err == nil {
-		json.Unmarshal(_bs, &allkeysTemp)
-	}
-	keysTemp := []string{} //原始关键词
-	for _, vs := range allkeysTemp {
-		keysTemp = append(keysTemp, strings.Join(vs.Keys, "+"))
-	}
-	o_pushinfo := map[string]map[string]interface{}{}
-	publishTitle := map[string]bool{}
-	str := fmt.Sprintf("<div>根据您设置的关键词(%s),给您推送以下信息:</div>", strings.Join(keysTemp, ";"))
-	i := 0
-	for _, v := range *list {
-		title := strings.Replace(v["title"].(string), "\n", "", -1)
-		area := util.ObjToString(v["area"])
-		if publishTitle[area+title] {
-			log.Println("重复标题", title)
-			continue
-		} else {
-			publishTitle[area+title] = true
-		}
-		infoid := util.ObjToString(v["_id"])
-		redis.PutCKV("push", "push_"+userid+"_"+infoid, 1)
-		i++
-		industry := ""
-		if v["s_subscopeclass"] != nil {
-			k2sub := strings.Split(util.ObjToString(v["s_subscopeclass"]), ",")
-			if len(k2sub) > 0 {
-				industry = k2sub[0]
-				if industry != "" {
-					ss := strings.Split(industry, "_")
-					if len(ss) > 1 {
-						industry = ss[0]
-					}
-				}
-			}
-		}
-		str += "<div class='tslist'><span class='xh'>" + fmt.Sprintf("%d", i) + ".</span><a class='bt' target='_blank' eid='" + infoid + "' href='" + util.ObjToString(v["href"]) + "'>" + title + "</a></div>"
-		o_pushinfo[strconv.Itoa(i)] = map[string]interface{}{
-			"publishtime":   v["publishtime"],
-			"stype":         util.ObjToString(v["type"]),
-			"topstype":      util.ObjToString(v["toptype"]),
-			"substype":      util.ObjToString(v["subtype"]),
-			"subscopeclass": industry,
-			"buyer":         v["buyer"],
-			"projectname":   v["projectname"],
-			"budget":        v["budget"],
-			"bidopentime":   v["bidopentime"],
-			"winner":        v["winner"],
-			"bidamount":     v["bidamount"],
-		}
-	}
-	md, _ := json.Marshal(o_pushinfo)
-	wxpush := map[string]interface{}{
-		"id":       time.Now().Format(util.Date_Short_Layout),
-		"date":     time.Now().Unix(),
-		"words":    keysTemp,
-		"uid":      userid,
-		"openid":   openId,
-		"content":  str,
-		"pushinfo": string(md),
-	}
-	flag := ca.SaveCacheByTimeOut("jy_push", wxpush, 10)
-	return flag, wxpush
-}
 func updateUserApppushunread(userid string) {
 	mongodb.UpdateById("user", userid, map[string]interface{}{"$set": map[string]interface{}{"i_apppushunread": 0}})
 }

+ 16 - 10
src/jfw/modules/app/src/config.json

@@ -6,13 +6,20 @@
     "influxdb": "jy_logs",
     "elasticsearch": "http://192.168.3.18:9800",
     "elasticPoolSize": 30,
-    "redisaddrs": "other=192.168.3.18:2379,push=192.168.3.18:2379,pushcache=192.168.3.18:2379,sso=192.168.3.18:2379,session=192.168.3.18:3379",
-    "webport": "8080",
+    "redisaddrs": "other=192.168.3.18:2379,push=192.168.3.18:2379,pushcache_1=192.168.3.18:2001,pushcache_2_a=192.168.3.18:2002,pushcache_2_b=192.168.3.18:2003,sso=192.168.3.18:2379,session=192.168.3.18:3379",
+    "webport": "89",
     "weixinrpc": "127.0.0.1:8083",
-    "cassandra": [
-        "192.168.3.207"
-    ],
-    "cassandrasize": 5,
+    "cassandra": {
+		"log":{
+			"host":["192.168.3.207"],
+			"size":5,
+			"port":9043
+		},
+		"push":{
+			"host":["192.168.3.207"],
+			"size":5
+		}
+	},
     "cacheflag": false,
     "agreement": "http",
     "webdomain": "http://webws.qmx.top",
@@ -22,7 +29,8 @@
         "wxpushfollowlist": "/jyapp/follow/notice/%s/%s",
         "followset": "/jyapp/follow/set/%s/%s",
         "myfeedbacks": "/jyapp/swordfish/myFeedbacks",
-        "historypush": "/jyapp/swordfish/historypush?f=push"
+        "historypush": "/jyapp/swordfish/historypush?f=push",
+        "followEntDetail": "/jyapp/followent/detail/%s"
     },
     "followProject": 10,
     "followentlimit": "10",
@@ -94,7 +102,5 @@
     "appPushServiceRpc": "127.0.0.1:5566",
     "appPower": {
         "grayflag": true
-    },
-	"pushTimeout": 300,
-	"ninePushTimeout": 172800
+    }
 }

+ 11 - 20
src/jfw/modules/app/src/main.go

@@ -13,17 +13,12 @@ import (
 	"qfw/util/redis"
 	"strings"
 	"time"
-	ca "ucbsutil/cassandra"
 
 	"github.com/go-xweb/httpsession"
 	"github.com/go-xweb/xweb"
 )
 
 func init() {
-	//初始化cassandra
-	ca.ViewCacheLen = true
-	ca.InitCassandra("jianyu", (int)(Sysconfig["cassandrasize"].(float64)), util.ObjArrToStringArr(Sysconfig["cassandra"].([]interface{})))
-
 	initXweb()
 	redis.InitRedisBySize(Sysconfig["redisaddrs"].(string), 100, 30, 300)
 	elastic.InitElasticSize(Sysconfig["elasticsearch"].(string), util.IntAllDef(Sysconfig["elasticPoolSize"], 30))
@@ -31,21 +26,17 @@ func init() {
 
 func main() {
 	//开启web
-	go func() {
-		//限制全文检索查询
-		public.InitLimitSearchText(false)
-		//
-		mux1 := http.NewServeMux()
-		mux1.HandleFunc("/jyapp/res/", func(w http.ResponseWriter, r *http.Request) {
-			if strings.HasSuffix(r.URL.String(), ".apk") {
-				w.Header().Set("Content-Type", "application/vnd.android.package-archive")
-			}
-			http.StripPrefix("/jyapp/res/", http.FileServer(http.Dir("web/staticres/jyapp/res"))).ServeHTTP(w, r)
-		})
-		xweb.RunBase(":"+Sysconfig["webport"].(string), mux1)
-	}()
-	b := make(chan bool, 1)
-	<-b
+	//限制全文检索查询
+	public.InitLimitSearchText(false)
+	//
+	mux1 := http.NewServeMux()
+	mux1.HandleFunc("/jyapp/res/", func(w http.ResponseWriter, r *http.Request) {
+		if strings.HasSuffix(r.URL.String(), ".apk") {
+			w.Header().Set("Content-Type", "application/vnd.android.package-archive")
+		}
+		http.StripPrefix("/jyapp/res/", http.FileServer(http.Dir("web/staticres/jyapp/res"))).ServeHTTP(w, r)
+	})
+	xweb.RunBase(":"+Sysconfig["webport"].(string), mux1)
 }
 
 func initXweb() {

+ 14 - 1
src/jfw/modules/app/src/web/templates/app/update.html

@@ -40,6 +40,8 @@
 			color: #686868;
 			font-size: 15px;
 			line-height: 22px;
+			display: none;
+			padding: 0px 10px;
 		}
 		.update{
 			padding: 0px 15px;
@@ -68,18 +70,29 @@
 			<img src="/jyapp/images/logo.png">
 			<span class="line"></span>
 			<div class="title">发现新版本</div>
-			<div class="txt">
+			<div class="txt" id="txt_ios">
 				系统检测到您当前的版本过低<br>
 				为了不影响您的使用。请及时更新到<br>
 				最新版本V{{.T.update.ios_version}}
 			</div>
+			<div class="txt" id="txt_android">
+				系统检测到您当前的<span id="oldversion"></span>版本过低<br>
+				为了不影响您的使用。请到剑鱼官网(jianyu360.com)以及应用市场下载<br>
+				最新版本V{{.T.update.version}}
+			</div>
 			<div class="update">
 				<button onclick="window.location.href='https://itunes.apple.com/cn/app/id1354897149'">去更新</button>
 			</div>
 		{{if not .T.mustupdate}}</div>{{end}}
 		<script type="text/javascript">
+			try{
+				$("#oldversion").text("V"+JyObj.getVersion());
+			}catch(e){}
 			if(mySysIsIos()){
+				$("#txt_ios").show();
 				$(".update").show();
+			}else{
+				$("#txt_android").show();
 			}
 			new FastClick(document.body);
 		</script>

+ 4 - 0
src/jfw/modules/app/src/web/templates/followent/add.html

@@ -116,7 +116,11 @@
 						$("#recList").append(obj);
 					}
 					$("#recList").show();
+				}else{
+	                $("#recList").hide();
 				}
+			}else{
+                $("#recList").hide();
 			}
 			$(".rec").on("tap",function(){
                     if($(this).text()!=""){

+ 8 - 4
src/jfw/modules/app/src/web/templates/followent/list.html

@@ -71,7 +71,7 @@
 				if(frontarr[f]["i_apppushunread"]==1){
 					redSpot = '<i class="redspot"></i>';
 				}
-				fronthtml +="<li data-id='"+frontarr[f]["s_id"]+"' data-entname='"+entname+"' Sort='"+lastpushtime+"'>"
+				fronthtml +="<li data-id='"+frontarr[f]["_id"]+"' Sort='"+lastpushtime+"'>"
 	                +"<div class='jyfwlistno'>"+listno+".</div>"
 	                +"<div class='jyfwlisttitle'>"+entname+"</div>"
 	                +"<div style='clear:both;'></div>"+rem
@@ -104,7 +104,7 @@
 				if(lastarr[l]["i_apppushunread"]==1){
 					redSpot = '<i class="redspot"></i>';
 				}
-				lasthtml +="<li class='jyovertime' data-entname='"+lastarr[l]["s_entname"]+"' data-id='"+lastarr[l]["s_id"]+"'>"
+				lasthtml +="<li class='jyovertime' data-id='"+lastarr[l]["_id"]+"'>"
 				+"<div class='jyfwlistno'>"+listno+".</div>"
 				+"<div class='jyfwlisttitle'>"+lastarr[l]["s_entname"]+"</div>"
 				+"<div style='clear:both;'></div>"+rem
@@ -121,7 +121,7 @@
 	            if(sessionStorage){
 	                sessionStorage.version="0";
 	            }
-	            window.location.href = "/jyapp/followent/newInfo/"+encodeURIComponent($(this).attr("data-entname"))+"___"+$(this).attr("data-id");
+	            window.location.href = "/jyapp/followent/detail/"+$(this).attr("data-id");
 	        });
 		});
 		
@@ -163,7 +163,11 @@ function afterReceivePushMessage(type,url){
 	if(type=="entname"){
 		var array = url.split("__");
 		if(array.length > 1){
-			$("[data-entname='"+array[1]+"']").append('<i class="redspot"></i>');
+			if($("[data-id='"+encodeURIComponent(array[1])+"']").length > 0){
+				$("[data-id='"+encodeURIComponent(array[1])+"']").append('<i class="redspot"></i>');	
+			}else if($("[data-id='"+array[1]+"']").length > 0){
+				$("[data-id='"+array[1]+"']").append('<i class="redspot"></i>');	
+			}
 		}
 	}
 }

+ 228 - 251
src/jfw/modules/app/src/web/templates/weixin/historypush.html

@@ -11,14 +11,13 @@
 <script>
 var firstPage = null;
 var scrollTop = 0;
-//var listCache = "";
-//var tableCache = "";
 var dataCache = new Array();
 var lasttime = 0;
-var success = false;
-var noMore = "false";
 var count = 0;
 var wxflag = "";
+var hasNextPage=false;
+var words=[];
+var pageIndex=1;
 //
 if(getUrlParam("f")=="push"){
 	removeSessionStorage();
@@ -64,34 +63,19 @@ function initpage(){
 	}
 	//
 	if(sessionStorage && sessionStorage.historypushScrollTop && sessionStorage.historypushDataCache){
-		success = true;
-		lasttime = sessionStorage.historypushLasttimeCache;
-		//listCache = sessionStorage.historypushListCache;
-		noMore = sessionStorage.historypushNoMoreCache;
-		// count = sessionStorage.historypushCount;
-		//tableCache = sessionStorage.historypushTableCache;
+		pageIndex = sessionStorage.historypushPageIndexCache;
+		hasNextPage = sessionStorage.historypushHasNextPage=="true"?true:false;
 		scrollTop = sessionStorage.historypushScrollTop;
+		if(sessionStorage.historypushWords){
+			words = sessionStorage.historypushWords.split(",");
+		}
 		dataCache = JSON.parse(sessionStorage.historypushDataCache);
 		$("#list>*").remove();
 		$("#mytable>*").remove();
 		$(".showType").css("display","flex");
 		$(".showType_bg").show();
-		for(var i=0;i<dataCache.length;i++){
-			structureHtml(dataCache[i]);
-		}
+		structureHtml(dataCache);
 		// appendList($(listCache),$(tableCache));
-		if(noMore == "true"){
-			wxflag = $('.listcontent').dropload({
-		        scrollArea : window,
-				loadUpFn : function(me){
-					loadDatas(me,-1);
-				},
-		        loadDownFn : function(me){
-					loadDatas(me,lasttime);
-		        }
-		    });
-			noMoreData(wxflag,1);
-		}
 		$(window).scrollTop(scrollTop);
 		removeSessionStorage();
 	}else{
@@ -102,10 +86,12 @@ function initpage(){
 			async: false,
 			dataType: 'json',
 			success: function(data){
-				success = data.success;
+				pageIndex=2;
 				lasttime = data.thistime;
 				firstPage = data.data;
-				if(!success && !data.haskey){
+				hasNextPage=data.hasNextPage;
+				words=data.keys;
+				if(!firstPage.length>0 && !data.haskey){
 					if(sessionStorage&&(sessionStorage.keysetindexToHistory=="1"||sessionStorage.keysetindexToHistory=="2"||sessionStorage.keysetindexToHistory=="3")){
 						sessionStorage.removeItem("keysetindexToHistory");
 					}else{
@@ -125,7 +111,7 @@ function initpage(){
 				hasNoData();
 			}
 		});
-		if(!success){
+		if(firstPage.length==0){
 			hasNoData();
 			return;
 		}else{
@@ -134,26 +120,36 @@ function initpage(){
 		}
 		$("#list").css("visibility","hidden");
 		dataCache = dataCache.concat(firstPage);
-		for(var i=0;i<firstPage.length;i++){
-			structureHtml(firstPage[i]);
-		}
+		structureHtml(firstPage);
 		setTimeout(function(){
 			$(window).scrollTop(0);
 			$("#list").css("visibility","visible");
 		},300);
 	}
-	if(noMore != "true"){
+	if(hasNextPage){
 		setTimeout(function(){
 			wxflag = $('.listcontent').dropload({
 		        scrollArea : window,
 				loadUpFn : function(me){
-					loadDatas(me,-1);
+					//loadDatas(me,-1);
+          reloadFirstPage(me);//下拉刷新更新订阅词
 				},
 		        loadDownFn : function(me){
 					loadDatas(me,lasttime);
 		        }
 		    });
 		},1000);
+	}else{
+		wxflag = $('.listcontent').dropload({
+	        scrollArea : window,
+			loadUpFn : function(me){
+				loadDatas(me,-1);
+			},
+	        loadDownFn : function(me){
+				loadDatas(me,lasttime);
+	        }
+	    });
+		noMoreData(wxflag);
 	}
 	
 	//展示
@@ -186,50 +182,99 @@ function initpage(){
 		})
 	});
 }
+//下拉刷新
+function reloadFirstPage(me){
+  $.ajax({
+			type: 'post',
+			url: '/jyapp/front/hasPushHistory?t='+new Date().getTime(),
+			data: {},
+			async: false,
+			dataType: 'json',
+			success: function(data){
+				pageIndex=1;
+				lasttime = data.thistime;
+				firstPage = data.data;
+				hasNextPage=data.hasNextPage;
+				words=data.keys;
+        
+        count=0;
+				dataCache = new Array();
+				$("#list>*").remove();
+				$("#mytable>*").remove();
+				hasNextPage = true;
+		    me.$domDown.html(me.opts.domDown.domLoad);
+				me.isData = true;
+				me.isLockUp = false;
+        me.isLockDown = false;
+				JyObj.hideRedSpotOnMenu("subscribe");        
+        
+        if(data.data.length==0){
+  				noMoreData(me);
+  			}else{
+  				pageIndex++;
+  				lasttime = data["thistime"];
+  				dataCache = dataCache.concat(data["data"]);
+  				structureHtml(data["data"]);
+  				if(data.hasNextPage){
+  					// 每次数据插入,必须重置
+  					me.resetload();
+  				}else{
+  					noMoreData(me);
+  				}
+  			}   
+			},
+			error: function(xhr, type){
+				hasNoData(me);
+			}
+		});
+}
 function loadDatas(me,le){
 	wxflag = me;
 	$.ajax({
 		type: 'post',
 		url: '/jyapp/swordfish/historypush/paging',
-		data: {"lasttime": le},
+		data: {"pageNum": pageIndex},
 		dataType: 'json',
 		success: function(data){
-			if(le==-1){
+			/*if(le==-1){
 				count=0;
 				dataCache = new Array();
 				$("#list>*").remove();
 				$("#mytable>*").remove();
-				noMore = "false";
+				hasNextPage = true;
 		        me.$domDown.html(me.opts.domDown.domLoad);
 				me.isData = true;
 				me.isLockUp = false;
         		me.isLockDown = false;
 				JyObj.hideRedSpotOnMenu("subscribe");
-			}
+			}*/
 			//没有数据
-			if(!data["success"]){
-				noMoreData(me,2);
+			if(data.data.length==0){
+				noMoreData(me);
 			}else{
+				pageIndex++;
 				lasttime = data["thistime"];
 				dataCache = dataCache.concat(data["data"]);
-				for(var i=0;i<data["data"].length;i++){
-					structureHtml(data["data"][i]);
+				structureHtml(data["data"]);
+				if(data.hasNextPage){
+					// 每次数据插入,必须重置
+					me.resetload();
+				}else{
+					noMoreData(me);
 				}
-				// 每次数据插入,必须重置
-				me.resetload();
 			}
 		},
 		error: function(xhr, type){
-			noMoreData(me,3);
+			noMoreData(me);
 		}
 	});
 }
-function noMoreData(me,f){
+function noMoreData(me){
 	if(me == null){
 		return;
 	}
 	wxflag = me;
-	noMore = "true";
+	hasNextPage = false;
 	// 锁定
 	me.lock();
 	// 无数据
@@ -245,205 +290,131 @@ function hasNoData(){
 }
 function structureHtml(object){
 	var tablehtml = '';
-	var words = object["s_words"];
-	a_visitedindex = object["a_visitedindex"];
-	var content = $("<div>"+object["s_content"]+"</div>");
-	content.children("div:first").remove();
-	content.children(".tslist").each(function(i){
+	var listhtml='';
+	for(let obj of object){
 		count++;
-		var info = object["o_pushinfo"][i+1];
-		var l_date = object["l_date"];
-		if(words){
-			$(this).attr("words",words.join("_"));
-		}
-		$(this).find(".xh").html(count+".").wrap('<div class="resnumb"><div class="one"></div></div>');
-		$(this).find("a.bt").attr("s",function(){
-			return $(this).attr("href");
-		})
-		.attr("href","javascript:void(0);")
-		.wrap(function(){
-			var paddingLeft = 20;
-			var countLength = count.toString().length;
-			if(countLength > 1){
-				paddingLeft = (countLength+1)*9;
-			}
-			return '<div class="two bt-parent" style="padding-left: '+paddingLeft+'px;"></div>';
-		});
-		$(this).find(".two").appendTo($(this).find(".resnumb"));
-		$(this).append('<div style="clear:both;"></div>');
-		$(this).append(function(){
-			var tdf = info.publishtime;
-			//
-			var area = $(this).find(".area").text();
-			var html = $(this).find(".bt").html().replace("[<span class=\"area\">"+area,"").replace("</span>]","");
-			if(words){
-				for(var n=0;n<words.length;n++){
-					var keysTemp = words[n].split("+");
-					var isReplace = true;
-					var htmlTemp = html;
-					for(var m=0;m<keysTemp.length;m++){
-						var _htmlTemp = keyWordHighlight(htmlTemp,keysTemp[m],'<font class="keyword">$1</font>');
-						if(htmlTemp == _htmlTemp){
-							isReplace = false;
-							break;
-						}
-						htmlTemp = _htmlTemp;
-					}
-					if(isReplace){
-						html = htmlTemp;
-					}
-				}
-				$(this).find("a.bt").html(html);
-			}
-			$(this).find(".bt").html(html);
-			$(this).find(".area").remove();
-			$(this).find(".bt").attr("push_date",l_date);
-			if(!area){
-				area = "";
-			}else{
-				area = $.trim(area);
-				area = area=="A"?"全国":area;
-			}
-			if(area != ""){
-				area = '<span class="location">'+area+'</span>';
-			}
-			//
-			if(tdf){
-				tdf = timeDiff(new Date(Number(tdf+"000")));
-				if(tdf != null){
-					tdf='<span><i class="glyphicon bofangjilu" style="color:#7a7a7a;margin-right:2px;"></i>'+tdf+'</span>'
-				}
-			}else{
-				tdf = '';
-			}
-			//
-			var datatype = "";
-			if(info.substype){
-				datatype='<span class="type">'+info.substype+'</span>'
-			}else if(info.topstype){
-				datatype='<span class="type">'+info.topstype+'</span>'
-			}else if(info.type){
-				if(info.type == "tender"){
-					datatype='<span class="type">招标</span>'
-				}else if(info.type == "bid"){
-					datatype='<span class="type">中标</span>'
-				}
-			}
-		    var	industryname = ""
-			if(info.subscopeclass!=null&&info.subscopeclass!=""){
-				industryname='<span class="industry">'+info.subscopeclass+'</span>'
-			}else{
-				industryname='';
-			}
-			return '<div class="restime time-diff">'+area+datatype+industryname+tdf+'</div>';
-		});
-		$(this).append('<div style="clear:both;"></div>');
-
-		var tableVisit = "";
-		// 已读未读
-		var $list = $(this).find(".bt").attr("eid");
-		if (typeof (a_visitedindex) != "undefined") {
-			var xh = $(this).find(".xh").text().replace(".", "");
-			// console.log(xh);
-			for (var i = 0; i < a_visitedindex.length; i++) {
-				if (xh == a_visitedindex[i]) {
-					tableVisit="visited";
-					$(this).find("a.bt").addClass("visited");
-					$(this).find(".xh").addClass("visited");
-				}
-			}
-		}
-		if (typeof (a_visitedindex) != "undefined") {
-			for (var i = 0; i < a_visitedindex.length; i++) {
-				if ($list == a_visitedindex[i]) {
-					tableVisit="visited";
-					$(this).find("a.bt").addClass("visited");
-					$(this).find(".xh").addClass("visited");
-				}
-			}
-		}
-		//
-		tablehtml +='<tr onClick="tablejump(\''+$(this).find("a.bt").attr("eid")+'\',\''+$(this).find("a.bt").attr("s")+'\',\''+words.join("_")+'\',$(this))" class="'+tableVisit+'" push_date="'+l_date+'">'+
-				'<td>'+count+'</td>'
-		if(typeof(info.projectname) != "undefined"&&info.projectname != ""){
-			var pn = info.projectname;
+		//标题(需要高亮)
+		var title=obj.title;
+		var mWords="";
+		if(words.length>0){
 			for(var n=0;n<words.length;n++){
 				var keysTemp = words[n].split("+");
-				var isReplace = true;
-				var pnTemp = pn;
 				for(var m=0;m<keysTemp.length;m++){
-					var _pnTemp = keyWordHighlight(pnTemp,keysTemp[m],'<font class="keyword">$1</font>');
-					if(pnTemp == _pnTemp){
-						isReplace = false;
-						break;
-					}
-					pnTemp = _pnTemp;
-				}
-				if(isReplace){
-					pn = pnTemp;
+					 title = keyWordHighlight(title,keysTemp[m],'<font class="keyword">$1</font>');
 				}
 			}
-			tablehtml +='<td>'+pn+'</td>'
-		}else{
-			tablehtml +='<td>'+$(this).find("a.bt").html()+'</td>'
+			mWords=words.join("_");
 		}
-		if(info.substype){
-			tablehtml +='<td>'+info.substype+'公告</td>'
-		}else if(info.topstype){
-			tablehtml +='<td>'+info.topstype+'公告</td>'
-		}else{
-			tablehtml +='<td></td>'
+		//地区
+		var area=obj.area;
+		var areaList="";
+		if(area != ""){
+			area = $.trim(area);
+			area = area=="A"?"全国":area;
+			areaList = '<span class="location">'+area+'</span>';
 		}
-		
-		if(typeof(info.budget) != "undefined" && info.budget != null && info.budget != ""){
-			var budgetone =parseInt(info.budget)/10000
-			if(budgetone.toString().length>6){
-				if(budgetone.toString().indexOf(".")==5){
-					budgetone=budgetone.toString().substr(0,7)
-				}else{
-					budgetone=budgetone.toString().substr(0,6)
-				}
-			}
-			tablehtml += '<td>'+budgetone+'</td>';
-		}else{
-			tablehtml += '<td></td>';
+		//类型
+		var datatype = obj.type;
+		var datatypeList="";
+		var datatypeTable="";
+		if (datatype!=""){
+			datatypeList='<span class="type">'+datatype+'</span>'
+			datatypeTable=datatype+"公告"
 		}
-		if(info.buyer!=undefined&&info.buyer!=""){
-			tablehtml += '<td>'+info.buyer+'</td>'
-		}else{
-			tablehtml += '<td></td>'
+		//行业
+		var	industryname = "";
+		var industryListname ="";
+		if(obj.s_subscopeclass!=null&&obj.s_subscopeclass!=""){
+			industryname=obj.s_subscopeclass
+			industryListname='<span class="industry">'+industryname+'</span>';
 		}
-		if(typeof(info.bidopentime) != "undefined" && info.bidopentime != null && info.bidopentime != ""){
-			var diff = formatDate(Number(info.bidopentime),"l");
-			tablehtml += '<td><div>'+diff+'</div></td>';
-		}else{
-			tablehtml += '<td><div></div></td>';
+		//时间
+		var showdateList=""
+		var showdateTable=""
+		if(obj.publishtime){
+			showdateList = timeDiff(new Date(Number(obj.publishtime+"000")));
+			showdateTable=formatDate(obj.publishtime)
+			if(showdateList != null){
+				showdateList='<span><i class="glyphicon bofangjilu" style="color:#7a7a7a;margin-right:2px;"></i>'+showdateList+'</span>'
+			}
 		}
-		if(typeof(info.winner) != "undefined" && info.winner != null && info.winner != ""){
-			tablehtml += '<td class="tt-l"><div>'+info.winner+'</div></td>';
-		}else{
-			tablehtml += '<td class="tt-l"><div></div></td>';
+		//预算
+		var budgetTable="";
+		if(typeof(obj.budget) != "undefined" && obj.budget != null && obj.budget != ""){
+			budgetTable=parseInt(obj.budget)/10000
+			if(budgetTable.toString().length>6){
+				if(budgetTable.toString().indexOf(".")==5){
+					budgetTable=budgetTable.toString().substr(0,7)
+				}else{
+					budgetTable=budgetTable.toString().substr(0,6)
+				}
+			}
 		}
-		if(typeof(info.bidamount) != "undefined" && info.bidamount != null && info.bidamount != ""){
-			var bidamountone = parseInt(info.bidamount)/10000
-			if(bidamountone.toString().length>6){
-				if(bidamountone.toString().indexOf(".")==5){
-					bidamountone=bidamountone.toString().substr(0,7)
+		//中标金额
+		var bidamountTable="";
+		if(typeof(obj.bidamount) != "undefined" && obj.bidamount != null && obj.bidamount != ""){
+			bidamountTable = parseInt(obj.bidamount)/10000
+			if(bidamountTable.toString().length>6){
+				if(bidamountTable.toString().indexOf(".")==5){
+					bidamountTable=bidamountTable.toString().substr(0,7)
 				}else{
-					bidamountone=bidamountone.toString().substr(0,6)
+					bidamountTable=bidamountTable.toString().substr(0,6)
 				}
 			}
-			tablehtml += '<td class="tt-r"><div>'+bidamountone+'</div></td>';
-		}else{
-			tablehtml += '<td class="tt-r"><div></div></td>';
 		}
-		var tabletime = formatDate(info.publishtime);
-		tablehtml +='<td>'+tabletime+'</td></tr>'
-
-	});
-	//listCache += content.prop("outerHTML");
-	//tableCache += tablehtml;
-	appendList(content,tablehtml);
+		//招标单位
+		var buyerTable=obj.buyer==undefined?"":obj.buyer;
+		//中标单位
+		var winnerTable=obj.winner==undefined?"":obj.winner;
+		//开标时间
+		var opentimeTable=""
+		if(typeof(obj.bidopentime) != "undefined" && obj.bidopentime != null && obj.bidopentime != ""){
+			opentimeTable = formatDate(Number(obj.bidopentime),"l");
+		}
+		//序号位置
+		var paddingLeft=20
+		var countLength = count.toString().length;
+		if(countLength>1){
+			paddingLeft = (countLength+1)*9;
+		}
+		//是否浏览过
+		var visited="";
+		if(obj.ca_visit==1){
+			visited="visited"
+		}
+		listhtml+=`<div class="tslist" words="`+mWords+`">
+						<div class="resnumb">
+							<div class="one">
+								<span class="xh `+visited+`">`+count+`.</span>
+							</div>
+							<div class="two bt-parent" style="padding-left:`+paddingLeft+`px;">
+								<a class="bt `+visited+`" target="_blank" eid="`+obj["_id"]+`" href="javascript:void(0);"  push_date="`+obj["ca_date"]+`" openlist_index="`+obj["ca_openlist_index"]+`">
+								`+title+`
+								</a>
+							</div>
+						</div>
+						<div style="clear:both;">
+						</div>
+						<div class="restime time-diff">
+						`+areaList+datatypeList+industryListname+showdateList+`
+						</div>
+						<div style="clear:both;"></div>
+					</div>`
+					
+		tablehtml+=`<tr class="`+visited+`" onclick="tablejump('`+obj["_id"]+`','','`+mWords+`',$(this))" push_date="`+obj["ca_date"]+`" openlist_index="`+obj["ca_openlist_index"]+`">
+						<td>`+count+`</td>
+						<td>`+title+`</td>
+						<td>`+datatypeTable+`</td>
+						<td>`+budgetTable+`</td>
+						<td>`+buyerTable+`</td>
+						<td><div>`+opentimeTable+`</div></td>
+						<td class="tt-l"><div>`+winnerTable+`</div></td>
+						<td class="tt-r"><div>`+bidamountTable+`</div></td>
+						<td>`+showdateTable+`</td>
+					</tr>`
+		
+	}
+	appendList($("<div>"+listhtml+"</div>"),tablehtml);
 }
 //
 function formatDate(date,sl)   { 
@@ -475,42 +446,49 @@ function formatDate(date,sl)   {
 //
 function appendList(content,tablehtml){
 	content.children(".tslist").on("click", function(event){
+		var isv=$(this).find("a.bt").hasClass("visited");//是否为已读
 		setVisitedIndex($(this),"");
 		var sds = $(this).attr("words");
 		var h = $(this).find("a.bt").attr("s");
 		var eid = $(this).find("a.bt").attr("eid");
-		beforeJump(eid,h,sds);
+		var index=$(this).find("a.bt").attr("openlist_index");
+		var pdate=$(this).find("a.bt").attr("push_date");
+		beforeJump(eid,h,sds,index,pdate,isv);
 	});
 	$("#list").append(content);
-	//
 	$("#mytable").append(tablehtml);
 	$(".findnull").hide();
 	$(".listcontent").show();
 }
 
 function tablejump(eid,h,sds,t){
+	var index = t.attr("openlist_index");//序列
+	var pdate =t.attr("push_date");//日期id
+	var isv=obj.hasClass("visited");//是否为已读
 	setVisitedIndex(t,eid);
-	beforeJump(eid,h,sds);
+	beforeJump(eid,h,sds,index,pdate,isv);
 }
 
-function beforeJump(eid,h,sds){
-	for(var i=0;i<dataCache.length;i++){
-		if(JSON.stringify(dataCache[i].a_visitedindex).indexOf(eid)<0){
-			dataCache[i].a_visitedindex.push(eid);
+function beforeJump(eid,h,sds,index,pd,vis){
+	if(!vis){
+		for(var i=0;i<dataCache.length;i++){
+			if(dataCache[i].ca_openlist_index==index&&dataCache[i].ca_date==pd){
+				dataCache[i].ca_visit=1;
+				break
+			}
 		}
 	}
 	setSessionStorage();
 	newredirect("",h,eid,"subkey_"+sds);
 }
 function setSessionStorage(){
-	if(sessionStorage&&success){
+	if(sessionStorage){
 		sessionStorage.historypushScrollTop = scrollTop;
-		//sessionStorage.historypushListCache = listCache;
-		//sessionStorage.historypushTableCache = tableCache;
-		sessionStorage.historypushLasttimeCache = lasttime;
 		sessionStorage.historypushDataCache = JSON.stringify(dataCache);
-		sessionStorage.historypushNoMoreCache = noMore;
+		sessionStorage.historypushPageIndexCache = pageIndex;
+		sessionStorage.historypushHasNextPage = hasNextPage;
 		sessionStorage.historypushCount = count;
+		sessionStorage.historypushWords = words;
 		if($(".showType .showTable").hasClass("on")){
 			sessionStorage.setItem("listortable","T");
 		}
@@ -519,34 +497,33 @@ function setSessionStorage(){
 
 function removeSessionStorage(){
 	sessionStorage.removeItem("historypushDataCache");
-	//sessionStorage.removeItem("historypushListCache");
-	//sessionStorage.removeItem("historypushTableCache");
-	sessionStorage.removeItem("historypushLasttimeCache");
+	sessionStorage.removeItem("historypushPageIndexCache");
 	sessionStorage.removeItem("historypushScrollTop");
-	sessionStorage.removeItem("historypushNoMoreCache");
+	sessionStorage.removeItem("historypushHasNextPage");
 	sessionStorage.removeItem("historypushCount");
 	sessionStorage.removeItem("listortable");
+	sessionStorage.removeItem("historypushWords");
 }
 
 function setVisitedIndex(obj,eid){
-	// console.log(obj.hasClass("visited")+"--------");
 	if(obj.find("a.bt").hasClass("visited")||obj.hasClass("visited")){
 		return;
 	}
 	obj.find("a.bt").addClass("visited");
 	obj.find("span.xh").addClass("visited");
 	var _id = obj.find("a.bt").attr("push_date");
-	var index = obj.find(".one span").text();
-	if(index.indexOf(".")>0){
-		index = index.substring(0,index.length-1)
-	}
+	var index = obj.find("a.bt").attr("openlist_index");
 	var vsid=obj.find("a.bt").attr("eid");
 	if (eid != ""){
 		obj.addClass("visited");
 		vsid = eid;
 		_id = obj.attr("push_date");
+		index = obj.attr("openlist_index");
 	}
-	$.post("/jyapp/wxpush/bid/ajaxReq",{_id:_id,vsid:vsid,index:index});
+	if(index&&_id&&vsid){
+		$.post("/jyapp/wxpush/bid/ajaxReq",{_id:_id,index:parseInt(index),vsid:vsid});
+	}
+	
 }
 </script>
 <style type="text/css">

+ 2 - 38
src/jfw/modules/app/src/web/templates/weixin/wxkeyset/seniorset.html

@@ -254,25 +254,9 @@ function numScroller(){
 }
 //
 function init(r){
-	this.ratemode = 1;
-	this.mode = 1;
-	if(r){
-		if(r["i_ratemode"]){
-			this.ratemode = r["i_ratemode"];
-		}
-		if(r["i_mode"]){
-			this.mode = r["i_mode"];
-		}
-		/*if(r["i_rmstart"]){
-			def1 = r["i_rmstart"]
-		}
-		if(r["i_rmend"]){
-			def2 = r["i_rmend"]
-		}*/
-	}
-	if(this.ratemode == 2){
+	if(r["i_ratemode"] == 2){
 		$("#pushfrequency li:eq(2)").addClass("checked");
-	}else if(this.ratemode == 1){
+	}else if(r["i_ratemode"] == 1){
 		$("#pushfrequency li:eq(1)").addClass("checked");
 	}
 	/*else {
@@ -286,23 +270,6 @@ function init(r){
 	numScroller();
 	//接收方式:i_mode 1--app 2--邮件 3--app+邮件
 	var hasOneOpen = false;
-	/*if(this.mode == 1 || this.mode == 3){
-		hasOneOpen = true
-		$("#apptip").addClass("on");
-		$("#apptip>img.turn-on").show();
-	}else{
-		$("#apptip>img.turn-off").show();
-	}
-	if(this.mode == 2 || this.mode == 3){
-		hasOneOpen = true
-		if(email != ""){
-			$(".emailset").show();
-		}
-		$("#emailtip").addClass("on");
-		$("#emailtip>img.turn-on").show();
-	}else{
-		$("#emailtip>img.turn-off").show();
-	}*/
 	if(r["i_mode"]==1){
 		r["i_apppush"] = 1;
 	}else if(r["i_mode"]==2){
@@ -310,8 +277,6 @@ function init(r){
 	}else if(r["i_mode"]==3){
 		r["i_apppush"] = 1;
 		r["i_mailpush"] = 1;
-	}else{
-		r["i_apppush"] = 1;
 	}
 	if(r["i_mailpush"]==1&& email!=""){
 		hasOneOpen=true;
@@ -347,7 +312,6 @@ function saveData(){
 		"ratemode": 1,
 		"wxpush":0,
 		"mailpush":0,
-		//"mode": 1,
 		"email": $("#email").val(),
 	};
 	if($("#pushfrequency li:eq(2)").hasClass("checked")){

+ 2 - 7
src/jfw/modules/entsesearch/src/main.go

@@ -18,18 +18,13 @@ func init() {
 	initXweb()
 	//初始化cassandra
 	ca.ViewCacheLen = true
-	ca.InitCassandra("jianyu", (int)(config.Sysconfig["cassandrasize"].(float64)), util.ObjArrToStringArr(config.Sysconfig["cassandra"].([]interface{})))
+	ca.InitCassandra("jianyu", util.IntAll(config.Sysconfig["cassandrasize"]), util.ObjArrToStringArr(config.Sysconfig["cassandra"].([]interface{})))
 	redis.InitRedisBySize(config.Sysconfig["redisaddrs"].(string), 100, 30, 300)
 	elastic.InitElasticSize(config.Sysconfig["elasticsearch"].(string), util.IntAllDef(config.Sysconfig["elasticPoolSize"], 30))
 }
 
 func main() {
-
-	go func() {
-		xweb.Run(":" + config.Sysconfig["webport"].(string))
-	}()
-	b := make(chan bool, 1)
-	<-b
+	xweb.Run(":" + config.Sysconfig["webport"].(string))
 }
 
 func initXweb() {

BIN
src/jfw/modules/entsesearch/src/src


+ 3 - 7
src/jfw/modules/followent/src/config.json

@@ -2,17 +2,13 @@
     "mongodbServers": "192.168.3.18:27080",
     "mongodbPoolSize": "5",
     "mongodbName": "qfw",
-    "influxaddr": "http://192.168.3.207:8086",
-    "influxdb": "jy_logs",
     "elasticsearch": "http://192.168.3.18:9800",
     "elasticPoolSize": 30,
-    "redisaddrs": "other=192.168.3.18:2379,push=192.168.3.18:2379,sso=192.168.3.18:2379,session=192.168.3.18:2379,recovery=192.168.3.18:2379",
-    "webport": "8091",
-    "webrpcport": "84",
-    "weixinrpc": "127.0.0.1:83",
+    "redisaddrs": "other=192.168.3.18:3379,push=192.168.3.18:3379,sso=192.168.3.18:3379,session=192.168.3.18:3379,recovery=192.168.3.18:3379",
+    "webport": "81",
+    "weixinrpc": "127.0.0.1:8083",
     "cacheflag": false,
     "agreement": "https",
 	"followentlimit":"10",
-    "followPushRpc": "127.0.0.1:8759",
     "recommendEntLimit":"50"
 }

+ 76 - 54
src/jfw/modules/followent/src/followent/followent.go

@@ -2,21 +2,20 @@ package followent
 
 import (
 	"config"
+	"jfw/jylabutil"
+	"jfw/public"
 	"jfw/wx"
 	"qfw/util"
-	"qfw/util/elastic"
 	"qfw/util/redis"
 	"strconv"
 	"strings"
 	"time"
-	"tools"
-
-	"jfw/jylabutil"
 
 	"github.com/go-xweb/xweb"
+	"gopkg.in/mgo.v2/bson"
 )
 
-var mongodb = tools.MQFW
+var mongodb = public.MQFW
 var se = util.SE
 
 type FollowEnt struct {
@@ -30,7 +29,7 @@ type FollowEnt struct {
 	qgFollow   xweb.Mapper `xweb:"/jylab/followent/qgFollow"`       //取消关注
 	visited    xweb.Mapper `xweb:"/jylab/followent/notice/visited"` //用户是否已查看
 	ajaxSearch xweb.Mapper `xweb:"/jylab/followent/ajaxSearch"`     //用户是否关注企业
-
+	detail     xweb.Mapper `xweb:"/jylab/followent/detail/(.*)"`    //关注详情
 }
 
 func init() {
@@ -122,74 +121,93 @@ func (f *FollowEnt) RecList() {
 func (f *FollowEnt) SaveEnt() {
 	f.ServeJson(map[string]interface{}{})
 }
-
-//企业最新信息
-func (f *FollowEnt) NewInfo(winnerid string) error {
+func (f *FollowEnt) Detail(followId string) error {
 	defer util.Catch()
-	userid := util.ObjToString(f.GetSession("userId"))
-	if userid == "" {
+	userId := util.ObjToString(f.GetSession("userId"))
+	if userId == "" {
 		return f.Redirect("/swordfish/about")
 	}
-	authStatus := jylabutil.IsAuthorized(userid, "i_followent")
-	if !authStatus {
+	if !jylabutil.IsAuthorized(userId, "i_followent") {
 		return f.Redirect("/jylab/laboratory/gzqy")
 	}
-
+	followId = util.DecodeArticleId2ByCheck(followId)[0]
 	winner := ""
-	id := ""
-	if winnerid != "" {
-		winner = strings.Split(winnerid, "___")[0]
-		id = strings.Split(winnerid, "___")[1]
-	}
-	userId := f.GetSession("userId").(string) //用户id
-	var follow = "n"
+	winnerId := ""
 	var a_visited interface{}
-	_id := ""
-	//fields := `{"projectname":1,"bidamount":1,"title":1,"publishtime":1,"subtype":1,"toptype":1,"href":1}`
-	//data, ok := mongodb.Find("bidding", `{"winner":"`+winner+`"}`, `{"publishtime":-1}`, fields, false, -1, -1)
-	ok := true
-	fields := `"_id","projectname","bidamount","title","publishtime","subtype","toptype","href"`
-	data := elastic.GetPage("bidding", "bidding", `{"TERM_s_winner":"`+winner+`"}`, `{"publishtime":-1}`, fields, 0, 100)
-	if !ok {
-		return f.Render("_error.html")
-	}
-	if ok && len(*data) != 0 && data != nil && *data != nil {
-		for _, v := range *data {
-			v["_id"] = util.EncodeArticleId2ByCheck(util.BsonIdToSId(v["_id"]))
-			bidamount, _ := v["bidamount"].(float64)
-			v["bidamount"] = bidamount
+	oneQy, ok := mongodb.FindOneByField("jylab_followent", map[string]interface{}{
+		"_id":      bson.ObjectIdHex(followId),
+		"s_userid": userId,
+	}, `{"s_entname":1,"s_id":1,"a_visited":1}`)
+	follow := "n"
+	if !ok || oneQy == nil || len(*oneQy) == 0 {
+		oneQy, ok = mongodb.FindOneByField("jylab_followent_back", map[string]interface{}{
+			"s_followid": followId,
+			"s_userid":   userId,
+		}, `{"s_entname":1,"s_id":1,"a_visited":1}`)
+		if !ok || oneQy == nil || len(*oneQy) == 0 {
+			return f.Render("_error.html")
 		}
-
+	} else {
+		if (*oneQy)["a_visited"] != nil {
+			a_visited = (*oneQy)["a_visited"]
+		}
+		follow = "y"
 	}
+	winner = util.ObjToString((*oneQy)["s_entname"])
+	winnerId = util.ObjToString((*oneQy)["s_id"])
+	f.T["data"] = public.GetWinnerNewestDatas(winner)
+	f.T["winner"] = winner
+	f.T["s_id"] = util.EncodeArticleId2ByCheck(winnerId)
+	f.T["_id"] = util.EncodeArticleId2ByCheck(followId)
+	f.T["follow"] = follow
+	f.T["a_visited"] = a_visited
+	f.T["signature"] = wx.SignJSSDK(f.Site() + f.Url())
+	f.T["openid"] = se.EncodeString(util.ObjToString(f.GetSession("s_m_openid")))
+	f.T["nickname"], _ = f.Session().Get("s_nickname").(string)
+	f.T["avatar"], _ = f.Session().Get("s_avatar").(string)
+	return f.Render("/weixin/set.html", &f.T)
+}
 
-	//判断用户是否关注
-	s_id := ""
-	if id == "" {
-		s_id = createId(winner)
+//企业最新信息
+func (f *FollowEnt) NewInfo(param string) error {
+	defer util.Catch()
+	userId := util.ObjToString(f.GetSession("userId"))
+	if userId == "" {
+		return f.Redirect("/swordfish/about")
+	}
+	if !jylabutil.IsAuthorized(userId, "i_followent") {
+		return f.Redirect("/jylab/laboratory/gzqy")
+	}
+	winner := ""
+	winnerId := ""
+	if param != "" {
+		winner = strings.Split(param, "___")[0]
+		winnerId = strings.Split(param, "___")[1]
+	}
+	if winnerId == "" {
+		winnerId = createId(winner)
 	} else {
-		s_id = util.DecodeArticleId2ByCheck(id)[0] //企业id
+		winnerId = util.DecodeArticleId2ByCheck(winnerId)[0] //企业id
 	}
-	oneQy, ok := mongodb.FindOneByField("jylab_followent", `{"s_userid":"`+userId+`","s_id":"`+s_id+`"}`, `{"a_visited":1}`)
-	if ok && len(*oneQy) != 0 && oneQy != nil && *oneQy != nil {
+	var follow = "n"
+	var a_visited interface{}
+	oneQy, ok := mongodb.FindOneByField("jylab_followent", `{"s_userid":"`+userId+`","s_id":"`+winnerId+`"}`, `{"a_visited":1}`)
+	if ok && oneQy != nil && len(*oneQy) > 0 {
 		follow = "y" //已经关注此企业
 		if (*oneQy)["a_visited"] != nil {
 			a_visited = (*oneQy)["a_visited"]
 		}
-		_id = util.EncodeArticleId2ByCheck(util.BsonIdToSId((*oneQy)["_id"]))
+		f.T["_id"] = util.EncodeArticleId2ByCheck(util.BsonIdToSId((*oneQy)["_id"]))
 	}
-	f.T["data"] = data
+	f.T["data"] = public.GetWinnerNewestDatas(winner)
 	f.T["winner"] = winner
-	f.T["s_id"] = util.EncodeArticleId2ByCheck(s_id)
-	f.T["_id"] = _id
+	f.T["s_id"] = util.EncodeArticleId2ByCheck(winnerId)
 	f.T["follow"] = follow
 	f.T["a_visited"] = a_visited
-
 	f.T["signature"] = wx.SignJSSDK(f.Site() + f.Url())
 	f.T["openid"] = se.EncodeString(util.ObjToString(f.GetSession("s_m_openid")))
-	mynickname, _ := f.Session().Get("s_nickname").(string)
-	myavatar, _ := f.Session().Get("s_avatar").(string)
-	f.T["nickname"] = mynickname
-	f.T["avatar"] = myavatar
+	f.T["nickname"], _ = f.Session().Get("s_nickname").(string)
+	f.T["avatar"], _ = f.Session().Get("s_avatar").(string)
 	return f.Render("/weixin/set.html", &f.T)
 }
 
@@ -203,8 +221,12 @@ func (f *FollowEnt) QgFollow() error {
 	status := "n"
 	id := f.GetString("id")
 	s_id := util.DecodeArticleId2ByCheck(id)[0]
-	ok := mongodb.Del("jylab_followent", `{"s_userid":"`+userid+`","s_id":"`+s_id+`"}`)
-	if ok {
+	data, ok := mongodb.FindOne("jylab_followent", `{"s_userid":"`+userid+`","s_id":"`+s_id+`"}`)
+	if mongodb.Del("jylab_followent", `{"s_userid":"`+userid+`","s_id":"`+s_id+`"}`) {
+		if ok && data != nil && len(*data) > 0 {
+			(*data)["s_followid"] = util.BsonIdToSId((*data)["_id"])
+			mongodb.Save("jylab_followent_back", data)
+		}
 		status = "y"
 	}
 	f.ServeJson(map[string]interface{}{

+ 9 - 26
src/jfw/modules/followent/src/followent/myfwent.go

@@ -2,10 +2,10 @@ package followent
 
 import (
 	"config"
+	"jfw/public"
 	"log"
 	"qfw/util"
 	"qfw/util/elastic"
-	"qfw/util/redis"
 	"strings"
 	"time"
 
@@ -93,30 +93,27 @@ func Findent(entname string) string {
 //删除30无更新数据的企业
 func (m *Myfwent) DelOvertimeCompany() error {
 	defer util.Catch()
-	var ids []string
+	var ids []bson.ObjectId
 	var flag = "F"
-	var arrid = strings.Split(m.GetString("arrid"), ",")
-	if len(arrid) > 0 {
-		for _, chid := range arrid {
-			ids = append(ids, util.DecodeArticleId2ByCheck(chid)[0])
-		}
+	for _, chid := range strings.Split(m.GetString("arrid"), ",") {
+		ids = append(ids, bson.ObjectIdHex(util.DecodeArticleId2ByCheck(chid)[0]))
 	}
-	userId, ok := m.GetSession("userId").(string)
-	if !ok || userId == "" || len(ids) < 1 {
+	userId, _ := m.GetSession("userId").(string)
+	if userId == "" || len(ids) == 0 {
 		m.ServeJson(map[string]interface{}{
 			"flag": flag,
 		})
 		return nil
 	}
-	datas, ok := mongodb.Find("jylab_followent", bson.M{"s_id": bson.M{"$in": ids}, "s_userid": userId}, nil, nil, false, -1, -1)
+	datas, ok := mongodb.Find("jylab_followent", bson.M{"_id": bson.M{"$in": ids}, "s_userid": userId}, nil, nil, false, -1, -1)
 	if ok && datas != nil {
 		for _, v := range *datas {
 			delete(v, "_id")
 			mongodb.Save("jylab_followent_back", v)
-			go delRelRedis(v["s_userid"], v["a_relationinfo"])
+			go public.DelRelRedis(v["s_userid"], v["a_relationinfo"])
 		}
 	}
-	if mongodb.Del("jylab_followent", bson.M{"s_id": bson.M{"$in": ids}, "s_userid": userId}) {
+	if mongodb.Del("jylab_followent", bson.M{"_id": bson.M{"$in": ids}, "s_userid": userId}) {
 		flag = "T"
 	}
 	m.ServeJson(map[string]interface{}{
@@ -124,17 +121,3 @@ func (m *Myfwent) DelOvertimeCompany() error {
 	})
 	return nil
 }
-
-//删除redis相关数据
-func delRelRedis(userid interface{}, relationinfo interface{}) {
-	defer util.Catch()
-	uid, _ := userid.(string)
-	if uid == "" || relationinfo == nil {
-		return
-	}
-	array, _ := relationinfo.([]interface{})
-	for _, v := range util.ObjArrToMapArr(array) {
-		sid, _ := v["s_id"].(string)
-		redis.Del("push", "push_"+uid+"_"+sid)
-	}
-}

+ 1 - 5
src/jfw/modules/followent/src/main.go

@@ -20,11 +20,7 @@ func init() {
 }
 
 func main() {
-	go func() {
-		xweb.Run(":" + config.Sysconfig["webport"].(string))
-	}()
-	b := make(chan bool, 1)
-	<-b
+	xweb.Run(":" + config.Sysconfig["webport"].(string))
 }
 
 func initXweb() {

+ 1 - 1
src/jfw/modules/followent/src/seo.json

@@ -265,7 +265,7 @@
 	},
 	"jyadd":"http://127.0.0.1",
 	"limitcount":20,
-	"ZBADDRESS":"http://webwcj.qmx.top",
+	"ZBADDRESS":"https://web-jydev-wcj.jianyu360.cn",
 	"jysy":"10",
 	"jydyy":"11",
 	"jysslby":"12",

BIN
src/jfw/modules/followent/src/src


+ 0 - 18
src/jfw/modules/followent/src/tools/mongo.go

@@ -1,18 +0,0 @@
-package tools
-
-import (
-	"config"
-	"qfw/util"
-	"qfw/util/mongodb"
-)
-
-var MQFW mongodb.MongodbSim
-
-func init() {
-	MQFW = mongodb.MongodbSim{
-		MongodbAddr: util.ObjToString(config.Sysconfig["mongodbServers"]),
-		Size:        util.IntAll(config.Sysconfig["mongodbPoolSize"]),
-		DbName:      util.ObjToString(config.Sysconfig["mongodbName"]),
-	}
-	MQFW.InitPool()
-}

+ 11 - 8
src/jfw/modules/followent/src/web/templates/weixin/add.html

@@ -107,7 +107,7 @@
 		$("#recList").html("");
 		$.post("/jylab/followent/recList",{entName:entName_key},function(r){
 			if(r){
-				if(typeof (r.recList)!="undefined"){
+				if(typeof(r.recList)!="undefined" && r.recList != null && r.recList.length > 0){
 					var recList = r.recList;
 					for(var i=0;i<recList.length;i++){
 					    var entName = recList[i].name;
@@ -118,16 +118,19 @@
 						var obj=$("<div class='rec' data-id='"+id+"'>"+entName.replace(entName_key,"<span class='highLight'>"+entName_key+"</span>")+"</div>");
 						$("#recList").append(obj);
 					}
+					$("#recList").show();
+				}else{
+	                $("#recList").hide();
 				}
+			}else{
+                $("#recList").hide();
 			}
-			$("#recList").show();
-
 			$(".rec").click(function(){
-                    if($(this).text()!=""){
-                        $("input").val($(this).text());
-                        winner_id = $(this).attr("data-id");
-                        $("#recList").hide();
-                    }
+                if($(this).text()!=""){
+                    $("input").val($(this).text());
+                    winner_id = $(this).attr("data-id");
+                    $("#recList").hide();
+                }
 			});
 		});
 	}

+ 3 - 3
src/jfw/modules/followent/src/web/templates/weixin/list.html

@@ -77,7 +77,7 @@ initShare({{.T.signature}},{{.T.openid}},2,"jy_extend",{{.T.nickname}},{{.T.avat
             if(typeof (entname)=="undefined"){
                 entname = "";
 			}
-			fronthtml +="<li data-id='"+frontarr[f]["s_id"]+"' data-entname='"+entname+"' Sort='"+lastpushtime+"'>"
+			fronthtml +="<li data-id='"+frontarr[f]["_id"]+"' Sort='"+lastpushtime+"'>"
                 +"<div class='jyfwlistno'>"+listno+".</div>"
                 +"<div class='jyfwlisttitle'>"+entname+"</div>"
                 +"<div style='clear:both;'></div>"+rem
@@ -105,7 +105,7 @@ initShare({{.T.signature}},{{.T.openid}},2,"jy_extend",{{.T.nickname}},{{.T.avat
             }
 			
 			var listno = parseInt(l)+parseInt(1)+jyno;
-			lasthtml +="<li class='jyovertime' data-entname='"+lastarr[l]["s_entname"]+"' data-id='"+lastarr[l]["s_id"]+"'>"
+			lasthtml +="<li class='jyovertime' data-id='"+lastarr[l]["_id"]+"'>"
 			+"<div class='jyfwlistno'>"+listno+".</div>"
 			+"<div class='jyfwlisttitle'>"+lastarr[l]["s_entname"]+"</div>"
 			+"<div style='clear:both;'></div>"+rem
@@ -123,7 +123,7 @@ initShare({{.T.signature}},{{.T.openid}},2,"jy_extend",{{.T.nickname}},{{.T.avat
             if(sessionStorage){
                 sessionStorage.version="0";
             }
-            window.location.href = "/jylab/followent/newInfo/"+encodeURIComponent($(this).attr("data-entname"))+"___"+$(this).attr("data-id");
+            window.location.href = "/jylab/followent/detail/"+$(this).attr("data-id");
         });
 
         var flag = {{.T.flag}};

+ 0 - 41
src/jfw/modules/followent/src/wx/wxjssdk.go

@@ -1,41 +0,0 @@
-package wx
-
-import (
-	"config"
-	"encoding/json"
-	"log"
-	"net/rpc"
-	"qfw/util"
-	"qfw/util/redis"
-)
-
-func SignJSSDK(url string) []string {
-	util.Catch()
-	var signature []string
-	var key = "wxsignature_" + url
-	if ret := redis.Get("other", key); ret != nil {
-		if d, err := json.Marshal(ret); err == nil {
-			json.Unmarshal(d, &signature)
-		}
-	}
-	if signature == nil || len(signature) == 0 {
-		util.Try(func() {
-			client, err := rpc.DialHTTP("tcp", util.ObjToString(config.Sysconfig["weixinrpc"]))
-			defer client.Close()
-			if err != nil {
-				log.Println(err.Error())
-				return
-			}
-			err = client.Call("WeiXinRpc.GetJSInterfaceParam", url, &signature)
-			if err != nil {
-				log.Println(err.Error())
-			}
-		}, func(e interface{}) {})
-		if signature == nil || len(signature) != 4 || signature[3] == "" {
-			signature = []string{"", "", "", ""}
-		} else {
-			redis.Put("other", key, signature, 90*60)
-		}
-	}
-	return signature
-}

+ 14 - 3
src/jfw/modules/pc/server/src/push/push.go

@@ -4,10 +4,10 @@
 package push
 
 import (
-	"errors"
-	"net/rpc"
 	"encoding/json"
+	"errors"
 	"log"
+	"net/rpc"
 )
 
 func push(code string, json interface{}) bool {
@@ -20,7 +20,7 @@ func pushVersion(json interface{}) {
 
 //服务
 type (
-	Service string
+	Service     string
 	PushRequest struct {
 		ClientCode string
 		Title      string
@@ -34,6 +34,17 @@ type (
 	}
 )
 
+func (s *Service) IsOnLine(request *string, repl *string) error {
+	lock.Lock()
+	defer lock.Unlock()
+	//断开老连接
+	if _, ok := mapping[*request]; ok {
+		*repl = "y"
+	} else {
+		*repl = "n"
+	}
+	return nil
+}
 func (s *Service) PushMsg(request *[]byte, repl *string) error {
 	ps := &PushRequest{}
 	err := json.Unmarshal(*request, &ps)

+ 0 - 84
src/jfw/modules/push/src/config.json

@@ -1,84 +0,0 @@
-{
-	"bidViewDomain": "http://webwcj.qmx.top",
-	"cassandra": {
-		"cachesize": 10000,
-		"host": ["192.168.3.207"],
-		"open": true,
-		"size": 5,
-		"timeout": 20
-	},
-	"durationMinutes": 1,
-	"elasticPoolSize": 10,
-	"elasticsearch": "http://192.168.3.18:9800",
-	"pushPoolSize": 60,
-	"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信息-剑鱼标讯",
-	"mails": [{
-		"addr": "smtp.exmail.qq.com",
-		"port": 465,
-		"pwd": "ue9Rg9Sf4CVtdm5a",
-		"user": "public03@topnet.net.cn"
-	}],
-	"maxPushSize": 50,
-	"maxSearch": 500,
-	"messyCodeEmailReg": "(@(126|163)\\.com)$",
-	"mgoAddr": "192.168.3.18:27080",
-	"mgoSize": 10,
-	"province": {
-		"上海": 9,
-		"云南": 25,
-		"内蒙古": 5,
-		"北京": 1,
-		"台湾": 32,
-		"吉林": 7,
-		"四川": 13,
-		"天津": 2,
-		"宁夏": 30,
-		"安徽": 12,
-		"山东": 15,
-		"山西": 4,
-		"广东": 19,
-		"广西": 20,
-		"新疆": 31,
-		"江苏": 10,
-		"江西": 14,
-		"河北": 3,
-		"河南": 16,
-		"浙江": 11,
-		"海南": 21,
-		"湖北": 17,
-		"湖南": 18,
-		"澳门": 34,
-		"甘肃": 28,
-		"福建": 23,
-		"西藏": 26,
-		"贵州": 24,
-		"辽宁": 6,
-		"重庆": 22,
-		"陕西": 27,
-		"青海": 29,
-		"香港": 33,
-		"黑龙江": 8
-	},
-	"redisServers": "push=192.168.3.18:1379",
-	"rpcPort": "8766",
-	"testids": ["15037870765"],
-	"weixinRpcServer": "127.0.0.1:8083",
-	"wxcolor": "#2cb7ca",
-	"wxcontent": "剑鱼标讯推送",
-	"wxgroup": "招标信息",
-	"wxtitle": "根据你订阅的关键词“%s”,剑鱼标讯为你推送以下信息。如果不想继续收到此类信息,可进入招标订阅的设置页面取消订阅。",
-	"wxdetailcolor":"#686868",
-	"appPushServiceRpc":"127.0.0.1:5566",
-	"pcPushHelper":"192.168.20.129:8082",
-	"filterWords":["项目","中标","公告"],
-	"startpushtime":"08:00",
-	"endpushtime":"20:00",
-	"oncepushtime": "9:00",
-	"otherpushtimes":[
-		"14:00",
-		"18:00"
-	],
-	"mailPollSize": 20
-}

+ 0 - 76
src/jfw/modules/push/src/main.go

@@ -1,76 +0,0 @@
-/**
- *推送服务
- */
-package main
-
-import (
-	"flag"
-	"log"
-	_ "net/http/pprof"
-	"qfw/push"
-	"qfw/push/dopush"
-	"qfw/push/jobs"
-	"qfw/util"
-	"qfw/util/elastic"
-	"qfw/util/mongodb"
-	"qfw/util/redis"
-	"regexp"
-	ca "ucbsutil/cassandra"
-)
-
-//初始化
-func init() {
-	util.ReadConfig(&push.PushConfig)
-	util.ReadConfig("./task.json", &push.TaskConfig)
-	push.Inits()
-	push.City = make(map[string]uint)
-	pushCite := push.PushConfig["province"].(map[string]interface{})
-	for k, v := range pushCite {
-		push.City[k] = uint(v.(float64))
-	}
-	jobs.MaxPushSize = util.IntAllDef(push.PushConfig["maxPushSize"], 50)
-	dopush.MaxSearch = util.IntAllDef(push.PushConfig["maxSearch"], 20000)
-	push.WeixinRpcServer = push.PushConfig["weixinRpcServer"].(string)
-	dopush.PushPool = make(chan bool, util.IntAllDef(push.PushConfig["pushPoolSize"], 20))
-	mongodb.InitMongodbPool(util.IntAllDef(push.PushConfig["mgoSize"], 50), push.PushConfig["mgoAddr"].(string), "qfw")
-	redis.InitRedis(push.PushConfig["redisServers"].(string))
-	elastic.InitElasticSize(push.PushConfig["elasticsearch"].(string), util.IntAllDef(push.PushConfig["elasticPoolSize"], 20))
-	dopush.MessyCodeEmailReg = regexp.MustCompile(push.PushConfig["messyCodeEmailReg"].(string))
-	dopush.FilterWords = util.ObjArrToStringArr(push.PushConfig["filterWords"].([]interface{}))
-
-	//初始化cassandra
-	if cassandra, ok := push.PushConfig["cassandra"].(map[string]interface{}); ok {
-		if open, _ := cassandra["open"].(bool); open {
-			ca.ViewCacheLen = true
-			ca.InitCassandra("jianyu",
-				(int)(cassandra["size"].(float64)),
-				util.ObjArrToStringArr(cassandra["host"].([]interface{})),
-				map[string]int{
-					"cachesize": (int)(cassandra["cachesize"].(float64)),
-					"timeout":   (int)(cassandra["timeout"].(float64)),
-				},
-			)
-			push.CassandraOpen = open
-		}
-	}
-}
-
-//主应用,定时任务
-func main() {
-	modle := flag.Int("m", 0, "默认:0;1 先匹配数据后实时推送 2 不匹配数据直接实时推送 3 九点推送")
-	flag.Parse()
-	if *modle == 1 {
-		go dopush.PushInfo(jobs.MaxPushSize, true)
-	} else if *modle == 2 {
-		go dopush.PushOtherUsers(jobs.MaxPushSize, true)
-	} else if *modle == 3 {
-		go dopush.PushOtherUsers(jobs.MaxPushSize, false)
-	} else {
-		go (&jobs.NinePushJob{}).Execute(true)
-		go (&jobs.RealTimePushJob{}).Execute(true)
-		go (&jobs.BidPushJob{}).Execute(true)
-	}
-	log.Println("启动推送系统")
-	flag := make(chan bool)
-	<-flag
-}

+ 0 - 53
src/jfw/modules/push/src/qfw/push/cache.go

@@ -1,53 +0,0 @@
-/**
- * 缓存
- * 主要缓存用户,用户标识、用户兴趣词,用户所在位置,
- */
-package push
-
-import (
-	"qfw/util/elastic"
-)
-
-type MemberInterest struct {
-	Id           string                     //mongoid
-	Province     string                     //省份
-	Key_notkey   map[string]map[string]bool //关键词-排除词
-	Key_area     map[string]map[string]bool //关键词-信息范围
-	Key_infotype map[string]map[string]bool //关键词-信息类型
-	Infotypes    []string                   //信息类型
-	ProvinceVal  uint64                     //可选多个省份的处理
-	Interest     []string                   //用户兴趣
-	NotInterest  []string                   //用户不感兴趣
-	S_m_openid   string                     //公众号openid
-	A_m_openid   string                     //app微信登录openid
-	Phone        string                     //app手机号登录
-	Jpushid      string
-	Opushid      string
-	InterestDate int64
-	WxPush       int
-	AppPush      int
-	MailPush     int
-	Ratemode     int
-	Smartset     int //智能订阅 1开启 0关闭
-	Rmstart      int
-	Rmend        int
-	Email        string
-	Dataexport   int //是否导出数据 1开启 0关闭
-	AllKeys      []elastic.KeyConfig
-	ModifyDate   string
-	AppPoneType  string
-	ApplyStatus  int
-	Subscribe    int
-	UserType     int
-}
-
-//各省份排序,最终会占某个2进制位
-//根据传入参数,计算选择代码
-func GetChoiceCode(choice ...string) (ret uint64) {
-	for _, v := range choice {
-		if tmp, ok := City[v]; ok {
-			ret += 1 << (tmp - 1)
-		}
-	}
-	return
-}

+ 0 - 55
src/jfw/modules/push/src/qfw/push/cf.go

@@ -1,55 +0,0 @@
-package push
-
-import (
-	"qfw/util"
-	"qfw/util/mail"
-	"regexp"
-)
-
-var wxsendpool = make(chan bool, 50)
-var Se util.SimpleEncrypt
-var Re *regexp.Regexp
-var MAXLen = 200
-var ContentLen int
-var WxTitle, WxContent, WxColor, WxGroup, WxDetailColor string
-var GmailMap *mail.GmailAuth
-var Domain = ""
-var (
-	Mail_html    = ""
-	Mail_content = ""
-	Mail_title   = ""
-)
-
-//初始化推送信息
-func Inits() {
-	//推送标题
-	Mail_title = util.ObjToString(PushConfig["mail_title"])
-	Mail_html = util.ObjToString(PushConfig["mail_html"])
-	Mail_content = util.ObjToString(PushConfig["mail_content"])
-
-	WxTitle = util.ObjToString(PushConfig["wxtitle"])
-	//正文
-	WxContent = util.ObjToString(PushConfig["wxcontent"])
-	WxColor = util.ObjToString(PushConfig["wxcolor"])
-	WxDetailColor = util.ObjToString(PushConfig["wxdetailcolor"])
-	//信息类型
-	WxGroup = util.ObjToString(PushConfig["wxgroup"])
-	Se = util.SimpleEncrypt{Key: "topnet"}
-	//html过滤
-	Re, _ = regexp.Compile("<[^>]+>([^<]+)?<[^>]+>")
-	//长度计算
-	ContentLen = len([]rune(WxContent))
-
-	//初始化服务邮箱
-	arrMap := util.ObjArrToMapArr(PushConfig["mails"].([]interface{}))
-	for i := 0; i < len(arrMap); i++ {
-		GmailMap = &mail.GmailAuth{
-			SmtpHost: util.ObjToString(arrMap[i]["addr"]),
-			SmtpPort: util.IntAll(arrMap[i]["port"]),
-			User:     util.ObjToString(arrMap[i]["user"]),
-			Pwd:      util.ObjToString(arrMap[i]["pwd"]),
-			PoolSize: util.IntAll(PushConfig["mailPollSize"]),
-		}
-	}
-	Domain = PushConfig["bidViewDomain"].(string)
-}

+ 0 - 142
src/jfw/modules/push/src/qfw/push/dfa/interestanalysis.go

@@ -1,142 +0,0 @@
-/**
- *兴趣分析
- *
- */
-package dfa
-
-import (
-	"log"
-	"strings"
-)
-
-//DFA实现
-type DFA struct {
-	link        map[string]interface{} //存放or
-	linkAnd     map[string]int         //存放and
-	linkAndWord map[string]interface{} //存放and中的拆分词
-
-}
-
-//添加词组,用于初始化,该方法是可以调用多次的
-func (d *DFA) AddWord(words ...string) {
-	if d.link == nil {
-		d.link = make(map[string]interface{})
-		d.linkAnd = make(map[string]int)
-		d.linkAndWord = make(map[string]interface{})
-	}
-	var nowMap *map[string]interface{}
-	for _, key := range words {
-		keys := strings.Split(key, "+")
-		lenkeys := len(keys)
-		if lenkeys > 1 {
-			d.linkAnd[key] = lenkeys
-			for k := 0; k < lenkeys; k++ {
-				minKey := keys[k]
-				nowMap = &d.linkAndWord
-				for i := 0; i < len(minKey); i++ {
-					kc := minKey[i : i+1]
-					if v, ok := (*nowMap)[kc]; ok {
-						nowMap, _ = v.(*map[string]interface{})
-					} else {
-						newMap := map[string]interface{}{}
-						newMap["YN"] = "N"
-						(*nowMap)[kc] = &newMap
-						nowMap = &newMap
-					}
-					if i == len(minKey)-1 {
-						(*nowMap)["YN"] = "Y"
-						if (*nowMap)["key"] == nil {
-							(*nowMap)["key"] = make(map[string]int)
-						}
-						(*nowMap)["key"].(map[string]int)[key] = k
-					}
-				}
-			}
-		} else {
-			nowMap = &d.link
-			for i := 0; i < len(key); i++ {
-				kc := key[i : i+1]
-				if v, ok := (*nowMap)[kc]; ok {
-					nowMap, _ = v.(*map[string]interface{})
-				} else {
-					newMap := map[string]interface{}{}
-					newMap["YN"] = "N"
-					(*nowMap)[kc] = &newMap
-					nowMap = &newMap
-				}
-
-				if i == len(key)-1 {
-					(*nowMap)["YN"] = "Y"
-				}
-			}
-		}
-	}
-}
-func (d *DFA) Clear() {
-	d.link = nil
-}
-
-//从给定的内容中找出匹配上的关键词
-func (d *DFA) Analy(src string) []string {
-	if d.link == nil {
-		log.Println("请先添加词组")
-		return []string{}
-	}
-	keywords := []string{}
-	tempMap := make(map[string][]bool)
-	for i := 0; i < len(src); i++ {
-		nowMap := &d.link
-		length := 0 // 匹配标识数默认为0
-		//flag := false // 敏感词结束标识位:用于敏感词只有1位的情况
-		for j := i; j < len(src); j++ {
-			word := src[j : j+1]
-			nowMap, _ = (*nowMap)[word].(*map[string]interface{})
-			if nowMap != nil {
-				length = length + 1
-				tag, _ := (*nowMap)["YN"].(string)
-				if "Y" == tag {
-					//flag = true
-					keywords = append(keywords, src[i:i+length])
-				}
-			} else {
-				break
-			}
-		}
-		nowMap = &d.linkAndWord
-		length = 0
-		for j := i; j < len(src); j++ {
-			word := src[j : j+1]
-			nowMap, _ = (*nowMap)[word].(*map[string]interface{})
-			if nowMap != nil {
-				length = length + 1
-				tag, _ := (*nowMap)["YN"].(string)
-				if "Y" == tag {
-					mkeys := (*nowMap)["key"].(map[string]int)
-					for k, v := range mkeys {
-						tempBool := tempMap[k]
-						if tempBool == nil {
-							tempBool = make([]bool, d.linkAnd[k])
-							tempMap[k] = tempBool
-						}
-						tempBool[v] = true
-					}
-				}
-			} else {
-				break
-			}
-		}
-	}
-	for k, v := range tempMap {
-		ball := true
-		for _, m := range v {
-			if !m {
-				ball = false
-				break
-			}
-		}
-		if ball {
-			keywords = append(keywords, k)
-		}
-	}
-	return keywords
-}

+ 0 - 45
src/jfw/modules/push/src/qfw/push/dfa/interestanalysis_test.go

@@ -1,45 +0,0 @@
-package dfa
-
-import (
-	"log"
-	"strings"
-	"testing"
-	"time"
-)
-
-var d *DFA = &DFA{}
-
-func copyMap(m map[string]int) (m2 map[string]int) {
-	m2 = make(map[string]int)
-	for k, v := range m {
-		m2[k] = v
-	}
-	return m2
-}
-
-func TestAnaly(t *testing.T) {
-	d.AddWord("办公", "办+楼", "河+省", "完+你们8")
-	log.Println(strings.Split("河+南+", "+")[2])
-	t1 := time.Now()
-	log.Println(d.Analy("这胡省锦河涛写给江泽民的信我们你们于办公楼上你完就是啊。"), "=====")
-	log.Println(time.Now().Sub(t1).Seconds())
-	d.Clear()
-	//log.Println(d.Analy("这是胡锦涛写给江泽民的信啊。"))
-
-}
-
-func Test_Label(t *testing.T) {
-	log.Println("000----")
-
-	for _, v := range []int{1, 2, 3, 4, 5} {
-		log.Println(v)
-	L1:
-		for _, vv := range []string{"a", "b", "c", "d"} {
-			log.Println(vv)
-			if vv == "add" {
-				break L1
-			}
-		}
-	}
-	log.Println("111----")
-}

+ 0 - 346
src/jfw/modules/push/src/qfw/push/dopush/dopush.go

@@ -1,346 +0,0 @@
-package dopush
-
-import (
-	"container/list"
-	"fmt"
-	"log"
-	"os"
-	"qfw/push"
-	"qfw/util"
-	"qfw/util/mail"
-	"qfw/util/mongodb"
-	"sort"
-	"strconv"
-	"strings"
-	"time"
-
-	"gopkg.in/mgo.v2/bson"
-)
-
-type sortList []*MatchInfo
-
-func (s sortList) Len() int {
-	return len(s)
-}
-
-func (s sortList) Less(i, j int) bool {
-	defer util.Catch()
-	return util.Int64All((*s[i].Info)["publishtime"]) > util.Int64All((*s[j].Info)["publishtime"])
-}
-
-func (s sortList) Swap(i, j int) {
-	defer util.Catch()
-	s[i], s[j] = s[j], s[i]
-}
-
-//推送模式i_mode: 1--微信 2--邮件 3--微信+邮件 4--app 5--app+邮件 6--app+微信 7--app+微信+邮箱
-func DealSend(k *push.MemberInterest, l *list.List, now time.Time, MaxPushSize int, ratemode int, isPushWxTpl bool) {
-	defer util.Catch()
-	//没有需要推送的数据
-	if l == nil || l.Len() == 0 {
-		return
-	}
-	//排序
-	sl := make(sortList, 0)
-	for ks := l.Front(); ks != nil; ks = ks.Next() {
-		k2 := *(ks.Value.(*MatchInfo))
-		sl = append(sl, &k2)
-	}
-	sort.Sort(sl)
-	bmail := false
-	if k.MailPush == 1 && k.Email != "" {
-		if k.UserType == 0 && k.Subscribe == 0 {
-			bmail = false
-		} else if (k.UserType == 1 || k.UserType == 2) && k.Jpushid == "" {
-			bmail = false
-		} else if k.UserType == 3 && k.Subscribe == 0 && k.Jpushid == "" {
-			bmail = false
-		} else {
-			bmail = true
-		}
-	}
-	str := fmt.Sprintf("<div>根据您设置的关键词(%s),给您推送以下信息:</div>", strings.Join(k.Interest, ";"))
-	mailContent := ""
-	//发送内容组合
-	i := 0
-	jpushtitle := ""
-	lastInfoDate := int64(0)
-	TitleArray := []string{}
-	o_pushinfo := map[string]map[string]interface{}{}
-	matchKey_infoIndex := map[string]string{}
-	publishTitle := map[string]bool{}
-	//邮件附件
-	var fmdatas = []map[string]interface{}{}
-	for _, ks := range sl {
-		k2 := *ks.Info
-		title := strings.Replace(k2["title"].(string), "\n", "", -1)
-		if !publishTitle[title] {
-			publishTitle[title] = true
-			TitleArray = append(TitleArray, push.Re.ReplaceAllString(title, "$1"))
-			i++
-			if i == 1 {
-				jpushtitle = strings.Replace(k2["otitle"].(string), "\n", "", -1)
-				lastInfoDate = util.Int64All(k2["publishtime"])
-			}
-			//_sid := util.EncodeArticleId(util.BsonIdToSId(k2["_id"]))
-			//url := fmt.Sprintf("%s/pcdetail/%s.html", Domain, _sid)
-			_sid := util.EncodeArticleId2ByCheck(util.BsonIdToSId(k2["_id"]))
-			//增加行业的处理
-			industry := ""
-			industryclass := "industry"
-			if k2["s_subscopeclass"] != nil {
-				k2sub := strings.Split(util.ObjToString(k2["s_subscopeclass"]), ",")
-				if len(k2sub) > 0 {
-					industry = k2sub[0]
-					if industry != "" {
-						ss := strings.Split(industry, "_")
-						if len(ss) > 1 {
-							industry = ss[0]
-						}
-					}
-				}
-			}
-			if bmail { //关于邮件的处理
-				mailSid := util.CommonEncodeArticle("mailprivate", util.BsonIdToSId(k2["_id"]))
-				url := fmt.Sprintf("%s/article/mailprivate/%s.html", push.Domain, mailSid)
-				classArea := "area"
-				area := util.ObjToString(k2["area"])
-				if area == "A" {
-					area = "全国"
-				}
-				classType := "type"
-				types := util.ObjToString(k2["subtype"])
-				if types == "" {
-					types = util.ObjToString(k2["toptype"])
-					if types == "" {
-						types = "其他"
-					}
-				}
-				dates := util.LongToDate(k2["publishtime"], false)
-				//标题替换
-				otitle := util.ObjToString(k2["otitle"])
-				for _, kw := range k.Interest {
-					kws := strings.Split(kw, "+")
-					n := 0
-					otitle2 := otitle
-					for _, kwn := range kws {
-						ot := strings.Replace(otitle2, kwn, "<span class='keys'>"+kwn+"</span>", 1)
-						if ot != otitle {
-							n++
-							otitle2 = ot
-						} else {
-							break
-						}
-					}
-					if n == len(kws) {
-						otitle = otitle2
-						break
-					}
-				}
-				if industry == "" {
-					industryclass = ""
-				}
-				mailContent += fmt.Sprintf(push.Mail_content, i, url, otitle, classArea, area, classType, types, industryclass, industry, dates)
-			}
-			//str += "<div class='tslist'><span class='xh'>" + fmt.Sprintf("%d", i) + ".</span><a class='bt' target='_blank' sid='" + _sid + "' href='" + util.ObjToString(k2["href"]) + "'>" + title + "</a></div>"
-			str += "<div class='tslist'><span class='xh'>" + fmt.Sprintf("%d", i) + ".</span><a class='bt' target='_blank' eid='" + _sid + "' href='" + util.ObjToString(k2["href"]) + "'>" + title + "</a></div>"
-			o_pushinfo[strconv.Itoa(i)] = map[string]interface{}{
-				"publishtime":   k2["publishtime"],
-				"stype":         util.ObjToString(k2["type"]),
-				"topstype":      util.ObjToString(k2["toptype"]),
-				"substype":      util.ObjToString(k2["subtype"]),
-				"subscopeclass": industry,
-				"buyer":         k2["buyer"],
-				"projectname":   k2["projectname"],
-				"budget":        k2["budget"],
-				"bidopentime":   k2["bidopentime"],
-				"winner":        k2["winner"],
-				"bidamount":     k2["bidamount"],
-			}
-			if k2["highlight"] != nil {
-				o_pushinfo[strconv.Itoa(i)]["highlight"] = k2["highlight"]
-			}
-			//附件数据
-			fmdata := map[string]interface{}{
-				"publishtime": k2["publishtime"],
-				"subtype":     k2["subtype"],
-				"buyer":       k2["buyer"],
-				"projectname": k2["projectname"],
-				"budget":      k2["budget"],
-				"bidopentime": k2["bidopentime"],
-				"winner":      k2["winner"],
-				"bidamount":   k2["bidamount"],
-			}
-			fmdatas = append(fmdatas, fmdata)
-			//匹配到的关键词
-			for _, key := range (*ks).Keys {
-				if matchKey_infoIndex[key] != "" {
-					matchKey_infoIndex[key] = matchKey_infoIndex[key] + ","
-				}
-				matchKey_infoIndex[key] = matchKey_infoIndex[key] + strconv.Itoa(i)
-			}
-			if i >= MaxPushSize {
-				//限制最大信息条数
-				break
-			}
-		}
-	}
-	if i == 0 {
-		log.Println("没有要推送的数据!", k.S_m_openid, k.A_m_openid, k.Phone)
-		return
-	}
-	///-----------------长度计算-----------------
-	TmpTip := ""
-	minute := now.Unix() - lastInfoDate
-	if minute > -1 && minute < 61 {
-		TmpTip = fmt.Sprintf("%d秒前发布的", minute)
-	} else {
-		minute = minute / 60
-		if minute < 121 {
-			if minute < 1 {
-				minute = 1
-			}
-			TmpTip = fmt.Sprintf("%d分钟前发布的", minute)
-		}
-	}
-	//推送记录id
-	pushid := push.SaveSendInfo(k, time.Now(), str, o_pushinfo, ratemode, matchKey_infoIndex)
-	if pushid == "" {
-		log.Println("保存到cassandra出错", k.S_m_openid, k.A_m_openid, k.Phone)
-		return
-	}
-	//发送微信:1,3
-	if k.S_m_openid != "" && k.WxPush == 1 {
-		log.Println("微信推送", k.Ratemode, "-----", k.S_m_openid, "-----", k.ApplyStatus)
-		if k.ApplyStatus == 1 {
-			Tip1 := util.If(TmpTip == "", "", TmpTip+":\n").(string)
-			LastTip := ""
-			if i > 1 {
-				LastTip = fmt.Sprintf("...(共%d条)", i)
-			}
-			LastTipLen := len([]rune(LastTip))
-			wxTitleKeys := strings.Join(k.Interest, ";")
-			if len([]rune(wxTitleKeys)) > 8 {
-				wxTitleKeys = string([]rune(wxTitleKeys)[:8]) + "..."
-			}
-			wxtitle := fmt.Sprintf(push.WxTitle, wxTitleKeys)
-			TitleLen := len([]rune(wxtitle))
-			GroupLen := len([]rune(k.ModifyDate))
-			reLen := push.MAXLen - TitleLen - GroupLen - push.ContentLen - len([]rune(Tip1))
-			//if infoType == 2 {
-			//	reLen = reLen - 4
-			//}
-			WXTitle := ""
-			bshow := false
-			for n := 1; n < len(TitleArray)+1; n++ {
-				curTitle := TitleArray[n-1]
-				tmptitle := WXTitle + fmt.Sprintf("%d %s\n", n, curTitle)
-				ch := reLen - len([]rune(tmptitle))
-				if ch < LastTipLen { //加上后大于后辍,则没有完全显示
-					if ch == 0 && n == len(TitleArray) {
-						WXTitle = tmptitle
-						bshow = true
-					} else {
-						ch_1 := reLen - len([]rune(WXTitle)) - LastTipLen
-						if ch_1 > 8 {
-							curLen := len([]rune(curTitle))
-							if ch_1 > curLen {
-								ch_1 = curLen
-							}
-							WXTitle += fmt.Sprintf("%d %s\n", n, string([]rune(curTitle)[:ch_1-3]))
-						}
-					}
-				} else if ch == LastTipLen {
-					WXTitle = tmptitle
-					if n == len(TitleArray) {
-						bshow = true
-					}
-				} else {
-					WXTitle = tmptitle
-					if n == len(TitleArray) {
-						bshow = true
-					}
-				}
-			}
-			if bshow {
-				LastTip = ""
-			}
-			SendWeixin(k, pushid, str, now, Tip1+WXTitle+LastTip, o_pushinfo, ratemode, matchKey_infoIndex, wxtitle)
-		}
-	}
-	if (k.Jpushid != "" || k.Opushid != "") && k.AppPush == 1 {
-		if len([]rune(jpushtitle)) > 80 {
-			jpushtitle = string([]rune(jpushtitle)[:80]) + "..."
-		}
-		if i > 1 {
-			jpushtitle = fmt.Sprintf("1. %s\n...(共%d条)", jpushtitle, i)
-		}
-		go mongodb.Update("user", map[string]interface{}{
-			"_id": bson.ObjectIdHex(k.Id),
-		}, map[string]interface{}{
-			"$inc": map[string]interface{}{
-				"i_apppushunread": 1,
-			},
-		}, false, false)
-		openid := k.S_m_openid
-		if openid == "" {
-			openid = k.A_m_openid
-		}
-		if openid == "" {
-			openid = k.Phone
-		}
-		isPushOk := push.AppPushServiceCall(map[string]interface{}{
-			"phoneType": k.AppPoneType,
-			"descript":  jpushtitle,
-			"type":      "bid",
-			"userId":    k.Id,
-			"url":       "/jyapp/free/sess/" + push.Se.EncodeString(openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",historypush"),
-			//"url":         "/jyapp/free/sess/" + push.Se.EncodeString(k.Openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",wxpushlist") + "__" + pushid,
-			"otherPushId": k.Opushid,
-			"jgPushId":    k.Jpushid, //极光-推送id
-		})
-		log.Println("app推送", k.AppPoneType, isPushOk, k.Ratemode, k.S_m_openid, k.Phone, k.A_m_openid, k.Jpushid)
-	}
-	//发送邮件
-	if bmail {
-		log.Println("发送邮件", k.S_m_openid, k.Phone, k.A_m_openid, "-----", k.Email, "-----", k.Dataexport)
-		html := fmt.Sprintf(push.Mail_html, strings.Replace(strings.Join(k.Interest, ";"), "+", " ", -1), mailContent)
-		subject := fmt.Sprintf(push.Mail_title, "招标")
-		SendFmail(k.Email, subject, html, k.Dataexport, fmdatas)
-	}
-	//pc端助手推送
-	go func() {
-		openid := k.S_m_openid
-		if openid == "" {
-			openid = k.Phone
-		}
-		if openid != "" {
-			push.PcZhushou(map[string]interface{}{"clientCode": openid})
-		}
-	}()
-}
-
-//推送邮件(含附件)
-func SendFmail(email, subject, html string, dataexport int, fmdatas []map[string]interface{}) {
-	defer util.Catch()
-	//生成附件
-	var fnamepath, rename string
-	if dataexport == 1 { //开启导出
-		fnamepath, rename = GetBidInfoXlsx(fmdatas)
-		if MessyCodeEmailReg.MatchString(email) {
-			rename = time.Now().Format("2006-01-02") + ".xlsx"
-		}
-	}
-	b := mail.GSendMail("剑鱼标讯", email, "", "", subject, html, fnamepath, rename, push.GmailMap)
-	if !b {
-		log.Println(email, "邮件发送失败")
-	}
-	if fnamepath != "" {
-		os.Remove(fnamepath)
-	}
-}
-
-//推送微信
-func SendWeixin(k *push.MemberInterest, wid, str string, now time.Time, Remarks string, o_pushinfo map[string]map[string]interface{}, ratemode int, matchKey_infoIndex map[string]string, wxtitle string) {
-	push.SendWeiXinNew(k, wid, str, Remarks, o_pushinfo, ratemode, matchKey_infoIndex, wxtitle)
-}

+ 0 - 1031
src/jfw/modules/push/src/qfw/push/dopush/dopushes.go

@@ -1,1031 +0,0 @@
-package dopush
-
-import (
-	"container/list"
-	"encoding/json"
-	"fmt"
-	"log"
-	"net/http"
-	"net/url"
-	"qfw/push"
-	"qfw/push/dfa"
-	"qfw/util"
-	"qfw/util/elastic"
-	"qfw/util/mongodb"
-	"regexp"
-	"sort"
-	"strings"
-	"sync"
-	"time"
-
-	"gopkg.in/mgo.v2/bson"
-)
-
-const (
-	ShowField = `"_id","title","detail","projectscope","publishtime","toptype","subtype","type","area","href","areaval","infoformat",` +
-		`"projectname","buyer","winner","budget","bidamount","bidopentime","s_subscopeclass"`
-	FindField      = `"title"`
-	SmartFindField = `"title","projectscope"`
-	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}`
-	PushTitle      = `[<span class='area'>%s</span>]%s`
-	Infoformat     = `{"term":{"infoformat":%d}}`
-	FilterQuery    = `{"query":{"filtered":{"filter":{"bool":{"must":[%s]}}}}}`
-	//
-	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}`
-)
-
-var (
-	searchPool        = make(chan bool, 8)
-	PushPool          chan bool
-	eachPool          = make(chan bool, 100)
-	searchWaitGroup   = &sync.WaitGroup{}
-	eachInfoWaitGroup = &sync.WaitGroup{}
-	userMapLock       = &sync.Mutex{}
-	pushLock          = &sync.Mutex{}
-	biddingDatas      *[]map[string]interface{}        //所有数据
-	allUsers          *map[string]*push.MemberInterest //所有用户
-	MaxSearch         = 20000                          //缓存中总共加载这么多条
-	userCollection    = "user"
-	MessyCodeEmailReg *regexp.Regexp
-	FilterWords       = []string{}
-)
-
-type Pjob struct {
-	InterestDfa    *dfa.DFA
-	NotInterestDfa *dfa.DFA
-	Key_user       *map[string]*[]*push.MemberInterest
-	Notkey_user    *map[string]*[]*push.MemberInterest
-}
-
-type MatchInfo struct {
-	Info *map[string]interface{}
-	Keys []string
-}
-
-type MatchUser struct {
-	User *push.MemberInterest
-	Keys []string
-}
-
-//所有用户的关键词和排除词
-func (p *Pjob) CreateDaf() {
-	//关键词
-	p.InterestDfa = &dfa.DFA{}
-	interestWords := make([]string, 0)
-	for k, _ := range *p.Key_user {
-		interestWords = append(interestWords, k)
-	}
-	p.InterestDfa.AddWord(interestWords...)
-	//排除关键词
-	p.NotInterestDfa = &dfa.DFA{}
-	notInterestWords := make([]string, 0)
-	for k, _ := range *p.Notkey_user {
-		notInterestWords = append(notInterestWords, k)
-	}
-	p.NotInterestDfa.AddWord(notInterestWords...)
-}
-
-func PushInfo(MaxPushSize int, isPushWxTpl bool) bool {
-	defer util.Catch()
-	pushLock.Lock()
-	defer pushLock.Unlock()
-	st, _ := time.ParseInLocation(util.Date_Full_Layout, util.ObjToString(push.TaskConfig["startTime"]), time.Local)
-	lastTime := st.Unix()
-	_id := util.ObjToString(push.TaskConfig["lastId"])
-	log.Println("实时推送,开始执行任务-id-lasttime-PushPoolLength", _id, lastTime, len(PushPool))
-	Now := time.Now()
-	//获取本次查询的最大id
-	idQuery := ""
-	if _id == "" {
-		idQuery = strings.Replace(fmt.Sprintf(MaxId, _id), `"gt"`, `"gte"`, -1)
-	} else {
-		idQuery = fmt.Sprintf(MaxId, _id)
-	}
-	resId := elastic.Get(DB, DB, idQuery)
-	lastid := ""
-	var comeintime interface{}
-	if resId != nil && *resId != nil && len(*resId) == 1 {
-		lastid = util.ObjToString((*resId)[0]["_id"])
-		comeintime = (*resId)[0]["comeintime"]
-	} else {
-		log.Println("实时推送,获取本次查询的最大id的时候,未查找到数据!", idQuery)
-		return false
-	}
-	a_p, s_p := InitUserCache()
-	if a_p == nil {
-		log.Println("实时推送,未查找到需要推送的用户!")
-		return false
-	}
-	if !InitBiddingCache(_id, lastid, lastTime) {
-		log.Println("实时推送,加载数据到内存中的时候,未查找到数据!")
-		return false
-	}
-	//
-	DoPush(a_p, s_p, MaxPushSize, Now, isPushWxTpl)
-	log.Println("实时推送,推送结束-lastid-comeintime", lastid, comeintime)
-	biddingDatas = nil
-	allUsers = nil
-	push.TaskConfig["startTime"] = util.FormatDateWithObj(&comeintime, util.Date_Full_Layout)
-	push.TaskConfig["lastId"] = lastid
-	util.WriteSysConfig("./task.json", push.TaskConfig)
-	return true
-}
-
-//定点推送的用户
-func PushOtherUsers(MaxPushSize int, isWxFixPushJob bool) bool {
-	defer util.Catch()
-	pushLock.Lock()
-	defer pushLock.Unlock()
-	jobType := "九点推送"
-	if isWxFixPushJob {
-		jobType = "微信定点实时推送"
-	}
-	log.Println(jobType, "开始执行任务-PushPoolLength", len(PushPool))
-	session := mongodb.GetMgoConn()
-	defer mongodb.DestoryMongoConn(session)
-	user_query := map[string]interface{}{}
-	if isWxFixPushJob {
-		user_query = map[string]interface{}{
-			"i_appid":         2,
-			"o_jy.i_ratemode": 1,
-			"i_type": map[string]interface{}{
-				"$exists": 0,
-			},
-			"i_applystatus": 1,
-		}
-	} else {
-		user_query = map[string]interface{}{
-			"i_appid":         2,
-			"o_jy.i_ratemode": 2,
-		}
-	}
-	testids := util.ObjArrToStringArr(push.PushConfig["testids"].([]interface{}))
-	if len(testids) > 0 {
-		user_query["s_m_openid"] = map[string]interface{}{
-			"$in": testids,
-		}
-	}
-	log.Println("testids", testids)
-	user_result := session.DB("qfw").C(userCollection).Find(&user_query).Select(&map[string]interface{}{
-		"_id":           1,
-		"o_jy":          1,
-		"s_m_openid":    1,
-		"a_m_openid":    1,
-		"s_phone":       1,
-		"s_jpushid":     1,
-		"s_opushid":     1,
-		"i_ispush":      1,
-		"i_type":        1,
-		"i_dataexport":  1,
-		"i_smartset":    1,
-		"i_supersearch": 1,
-		"s_appponetype": 1,
-		"i_applystatus": 1,
-	}).Iter()
-	nineUsers := map[string]*push.MemberInterest{}
-	u_n := 0
-	for tmp := make(map[string]interface{}); user_result.Next(tmp); u_n++ {
-		s_m_openid := util.ObjToString(tmp["s_m_openid"])
-		a_m_openid := util.ObjToString(tmp["a_m_openid"])
-		s_phone := util.ObjToString(tmp["s_phone"])
-		userType := GetUserType(s_m_openid, a_m_openid, s_phone, util.IntAllDef(tmp["i_type"], 0))
-		isPush := util.IntAllDef(tmp["i_ispush"], 1)
-		//公众号取关用户,后面还有pc助手推送,暂时不过滤app用户
-		if userType == 0 && isPush == 0 {
-			continue
-		}
-		applystatus := util.IntAll(tmp["i_applystatus"])
-		jpushid := util.ObjToString(tmp["s_jpushid"])
-		opushid := util.ObjToString(tmp["s_opushid"])
-		o_msgset, _ := tmp["o_jy"].(map[string]interface{})
-		wxpush, apppush, mailpush := ModeTransform(userType, o_msgset)
-		log.Println(jobType, "s_m_openid", s_m_openid, "a_m_openid", a_m_openid, "s_phone", s_phone, "wxpush", wxpush, "apppush", apppush, "mailpush", mailpush, "jpushid", jpushid, "opushid", opushid, "applystatus", applystatus)
-		util.Try(func() {
-			var allkeys []elastic.KeyConfig
-			_bs, err := json.Marshal(o_msgset["a_key"])
-			if err == nil {
-				json.Unmarshal(_bs, &allkeys)
-			}
-			////////////////
-			if len(allkeys) > 0 {
-				keys := []string{} //关键词
-				for _, vs := range allkeys {
-					keys = append(keys, strings.Join(vs.Keys, "+"))
-				}
-				modifydate := ""
-				md, _ := o_msgset["l_modifydate"].(int64)
-				if md > 0 {
-					modifydate = util.FormatDateByInt64(&md, util.Date_Short_Layout)
-				}
-				if modifydate == "" {
-					now := time.Now()
-					modifydate = util.FormatDate(&now, util.Date_Short_Layout)
-				}
-				user := &push.MemberInterest{
-					Id:          fmt.Sprintf("%x", string(tmp["_id"].(bson.ObjectId))),
-					Interest:    keys,
-					WxPush:      wxpush,
-					AppPush:     apppush,
-					MailPush:    mailpush,
-					Email:       util.ObjToString(o_msgset["s_email"]),
-					S_m_openid:  s_m_openid,
-					A_m_openid:  a_m_openid,
-					Phone:       s_phone,
-					UserType:    userType,
-					Jpushid:     jpushid,
-					Opushid:     opushid,
-					Ratemode:    util.IntAllDef(o_msgset["i_ratemode"], 1),
-					Rmstart:     util.IntAllDef(o_msgset["i_rmstart"], 1),
-					Rmend:       util.IntAllDef(o_msgset["i_rmend"], 1),
-					Smartset:    util.IntAllDef(tmp["i_smartset"], 0),
-					Dataexport:  util.IntAllDef(tmp["i_dataexport"], 0),
-					ModifyDate:  modifydate,
-					AppPoneType: util.ObjToString(tmp["s_appponetype"]),
-					ApplyStatus: applystatus,
-					Subscribe:   isPush,
-				}
-				nineUsers[user.Id] = user
-			}
-		}, func(e interface{}) {
-			log.Println(e)
-		})
-		tmp = make(map[string]interface{})
-	}
-	if u_n == 0 {
-		log.Println(jobType, "未查找到需要推送的用户!")
-		return false
-	}
-	log.Println(jobType, "查询到用户总数", u_n)
-	//查询所有临时表中的数据
-	isLoadAllTemPush := false
-	if u_n > 20000 {
-		isLoadAllTemPush = true
-	}
-	var tempushMap map[string]*list.List
-	if isLoadAllTemPush {
-		tempushMap = GetAllTemPush()
-	}
-	Now := time.Now()
-	for k, v := range nineUsers {
-		PushPool <- true
-		go func(userId string, user *push.MemberInterest) {
-			defer func() {
-				<-PushPool
-			}()
-			//从临时表中匹配到九点推送用户的数据
-			var listInfos *list.List
-			if isLoadAllTemPush {
-				listInfos = tempushMap[userId]
-			} else {
-				listInfos = list.New()
-				tempush := mongodb.FindOneByField("tempush", map[string]interface{}{
-					"userid": userId,
-				}, `{"userid": 1,"tmpinfos": 1}`)
-				if tempush == nil {
-					return
-				}
-				if (*tempush)["tmpinfos"] == nil {
-					return
-				}
-				tmpinfos, _ := (*tempush)["tmpinfos"].([]interface{})
-				if len(tmpinfos) > 0 {
-					for _, tif := range tmpinfos {
-						tifMap, _ := tif.(map[string]interface{})
-						delete(tifMap, "projectscope")
-						delete(tifMap, "detail")
-						if tifMap["info"] != nil && tifMap["keys"] != nil {
-							info, _ := tifMap["info"].(map[string]interface{})
-							delete(tifMap, "projectscope")
-							delete(tifMap, "detail")
-							interface_keys, _ := tifMap["keys"].([]interface{})
-							keys := util.ObjArrToStringArr(interface_keys)
-							listInfos.PushBack(&MatchInfo{
-								Info: &info,
-								Keys: keys,
-							})
-						} else {
-							listInfos.PushBack(&MatchInfo{
-								Info: &tifMap,
-								Keys: []string{},
-							})
-						}
-					}
-				}
-			}
-			mongodb.Del("tempush", &bson.M{"userid": userId})
-			DealSend(user, listInfos, Now, MaxPushSize, user.Ratemode, isWxFixPushJob)
-		}(k, v)
-	}
-	log.Println(jobType, "推送结束!")
-	return true
-}
-
-//初始化用户缓存
-func InitUserCache() (*Pjob, *Pjob) {
-	defer util.Catch()
-	//遍历用户
-	q := map[string]interface{}{
-		"i_appid": 2,
-	}
-	testids := util.ObjArrToStringArr(push.PushConfig["testids"].([]interface{}))
-	if len(testids) > 0 {
-		q["s_m_openid"] = map[string]interface{}{
-			"$in": testids,
-		}
-	}
-	log.Println("testids", testids)
-	//18 o8-2pwHj1s_tv3nnRxrH9cD2ngkk
-	//14 ouCYjwzKpn-3orDpb0CA3Po1RLHw
-	//	q = map[string]interface{}{
-	//		"i_appid": 2,
-	//		"s_m_openid": map[string]interface{}{
-	//			"$in": []string{"o8-2pwHj1s_tv3nnRxrH9cD2ngkk"},
-	//		},
-	//	}
-	session := mongodb.GetMgoConn()
-	defer mongodb.DestoryMongoConn(session)
-	query := session.DB("qfw").C(userCollection).Find(&q).Select(&map[string]interface{}{
-		"_id":           1,
-		"o_jy":          1,
-		"s_m_openid":    1,
-		"a_m_openid":    1,
-		"s_phone":       1,
-		"s_jpushid":     1,
-		"s_opushid":     1,
-		"i_ispush":      1,
-		"i_dataexport":  1,
-		"i_type":        1,
-		"i_smartset":    1,
-		"i_supersearch": 1,
-		"s_appponetype": 1,
-		"i_applystatus": 1,
-	}).Iter()
-	//所有用户
-	allUsers = &map[string]*push.MemberInterest{}
-	//遍历所有用户放到数组
-	a_key_user := make(map[string]*[]*push.MemberInterest)
-	a_notkey_user := make(map[string]*[]*push.MemberInterest)
-	//开启智能订阅的用户
-	s_key_user := make(map[string]*[]*push.MemberInterest)
-	s_notkey_user := make(map[string]*[]*push.MemberInterest)
-	//遍历用户数组
-	n := 0
-	for tmp := make(map[string]interface{}); query.Next(tmp); {
-		s_m_openid := util.ObjToString(tmp["s_m_openid"])
-		a_m_openid := util.ObjToString(tmp["a_m_openid"])
-		s_phone := util.ObjToString(tmp["s_phone"])
-		userType := GetUserType(s_m_openid, a_m_openid, s_phone, util.IntAllDef(tmp["i_type"], 0))
-		isPush := util.IntAllDef(tmp["i_ispush"], 1)
-		//公众号取关用户,后面还有pc助手推送,暂时不过滤app用户
-		if userType == 0 && isPush == 0 {
-			continue
-		}
-		applystatus := util.IntAll(tmp["i_applystatus"])
-		o_msgset, _ := tmp["o_jy"].(map[string]interface{})
-		wxpush, apppush, mailpush := ModeTransform(userType, o_msgset)
-		jpushid := util.ObjToString(tmp["s_jpushid"])
-		opushid := util.ObjToString(tmp["s_opushid"])
-		log.Println("实时推送,s_m_openid", s_m_openid, "a_m_openid", a_m_openid, "s_phone", s_phone, "jpushid", jpushid, "opushid", opushid, "applystatus", applystatus)
-		n++
-		util.Try(func() {
-			var allkeysTemp []elastic.KeyConfig
-			_bs, err := json.Marshal(o_msgset["a_key"])
-			if err == nil {
-				json.Unmarshal(_bs, &allkeysTemp)
-			}
-			allkeys := []elastic.KeyConfig{}
-			if len(allkeysTemp) > 0 {
-				//一个字或者配置文件中的词,不推送
-				for _, vs := range allkeysTemp {
-					isFilter := false
-					vskey := strings.Replace(strings.Join(vs.Keys, ""), " ", "", -1)
-					if len([]rune(vskey)) == 1 {
-						continue
-					}
-					for _, fv := range FilterWords {
-						if fv == vskey {
-							isFilter = true
-							break
-						}
-					}
-					if !isFilter {
-						allkeys = append(allkeys, vs)
-					}
-				}
-			}
-			////////////////
-			if len(allkeys) > 0 {
-				keys := []string{}                           //过滤后的关键词
-				notkeys := []string{}                        //排除词
-				key_notkey := map[string]map[string]bool{}   //关键词所对应的排除词
-				key_area := map[string]map[string]bool{}     //关键词所对应的信息范围
-				key_infotype := map[string]map[string]bool{} //关键词所对应的信息类型
-				for _, vs := range allkeys {
-					key := strings.Join(vs.Keys, "+")
-					keys = append(keys, key)
-					notkeys = append(notkeys, vs.NotKeys...)
-					//转大写
-					keyTemp := strings.ToUpper(key)
-					//建立与排除词的对应关系
-					for _, notkey := range vs.NotKeys {
-						notkeyTemp := strings.ToUpper(notkey)
-						if key_notkey[keyTemp] == nil {
-							key_notkey[keyTemp] = map[string]bool{}
-						}
-						key_notkey[keyTemp][notkeyTemp] = true
-					}
-					//建立与信息范围的对应关系
-					for _, area := range vs.Areas {
-						if key_area[keyTemp] == nil {
-							key_area[keyTemp] = map[string]bool{}
-						}
-						key_area[keyTemp][area] = true
-					}
-					//建立与信息类型的对应关系
-					for _, infotype := range vs.InfoTypes {
-						if key_infotype[keyTemp] == nil {
-							key_infotype[keyTemp] = map[string]bool{}
-						}
-						key_infotype[keyTemp][infotype] = true
-					}
-				}
-				//
-				keysTemp := []string{} //原始关键词
-				for _, vs := range allkeysTemp {
-					keysTemp = append(keysTemp, strings.Join(vs.Keys, "+"))
-				}
-				smartset := util.IntAllDef(tmp["i_smartset"], 0)
-				modifydate := ""
-				md, _ := o_msgset["l_modifydate"].(int64)
-				if md > 0 {
-					modifydate = util.FormatDateByInt64(&md, util.Date_Short_Layout)
-				}
-				if modifydate == "" {
-					now := time.Now()
-					modifydate = util.FormatDate(&now, util.Date_Short_Layout)
-				}
-				user := &push.MemberInterest{
-					Id:           fmt.Sprintf("%x", string(tmp["_id"].(bson.ObjectId))),
-					Interest:     keysTemp, //原始关键词
-					NotInterest:  notkeys,
-					Key_notkey:   key_notkey,
-					Key_area:     key_area,
-					Key_infotype: key_infotype,
-					WxPush:       wxpush,
-					AppPush:      apppush,
-					MailPush:     mailpush,
-					Email:        util.ObjToString(o_msgset["s_email"]),
-					S_m_openid:   s_m_openid,
-					A_m_openid:   a_m_openid,
-					Phone:        s_phone,
-					Jpushid:      util.ObjToString(tmp["s_jpushid"]),
-					Opushid:      util.ObjToString(tmp["s_opushid"]),
-					UserType:     userType,
-					Ratemode:     util.IntAllDef(o_msgset["i_ratemode"], 1),
-					Rmstart:      util.IntAllDef(o_msgset["i_rmstart"], 1),
-					Rmend:        util.IntAllDef(o_msgset["i_rmend"], 1),
-					AllKeys:      allkeysTemp, //原始关键词
-					Smartset:     smartset,
-					Dataexport:   util.IntAllDef(tmp["i_dataexport"], 0),
-					ModifyDate:   modifydate,
-					AppPoneType:  util.ObjToString(tmp["s_appponetype"]),
-					ApplyStatus:  applystatus,
-					Subscribe:    isPush,
-				}
-				(*allUsers)[user.Id] = user
-				MakeKeyUser(keys, user, &a_key_user)
-				MakeKeyUser(notkeys, user, &a_notkey_user)
-				if smartset == 1 {
-					MakeKeyUser(keys, user, &s_key_user)
-					MakeKeyUser(notkeys, user, &s_notkey_user)
-				}
-			}
-		}, func(e interface{}) {
-			log.Println(e)
-		})
-		tmp = make(map[string]interface{})
-	}
-	log.Println("实时推送,查询到用户总数", n)
-	if len(*allUsers) == 0 {
-		return nil, nil
-	}
-	a_p := &Pjob{
-		Key_user:    &a_key_user,
-		Notkey_user: &a_notkey_user,
-	}
-	a_p.CreateDaf()
-	//
-	s_p := &Pjob{
-		Key_user:    &s_key_user,
-		Notkey_user: &s_notkey_user,
-	}
-	s_p.CreateDaf()
-	return a_p, s_p
-}
-
-//把用户挂在词下面
-func MakeKeyUser(keys []string, user *push.MemberInterest, key_user *map[string]*[]*push.MemberInterest) {
-	m := map[string]bool{}
-	for _, key := range keys {
-		v := strings.ToUpper(key)
-		if v == "" || m[v] {
-			continue
-		}
-		m[v] = true
-		var arr *[]*push.MemberInterest
-		if nil == (*key_user)[v] {
-			arr = &[]*push.MemberInterest{}
-			(*key_user)[v] = arr
-		} else {
-			arr = (*key_user)[v]
-			(*key_user)[v] = arr
-		}
-		*arr = append(*arr, user)
-	}
-}
-
-//加载数据到内存中
-func InitBiddingCache(_id, lastid string, lastTime int64) bool {
-	defer util.Catch()
-	c_query := map[string]interface{}{
-		"publishtime": map[string]interface{}{
-			"$gt": lastTime - 7*86400,
-		},
-		"extracttype": 1,
-	}
-	idQuery := map[string]interface{}{}
-	if _id != "" {
-		idQuery["$gt"] = bson.ObjectIdHex(_id)
-	}
-	if lastid != "" {
-		idQuery["$lte"] = bson.ObjectIdHex(lastid)
-	}
-	if len(idQuery) > 0 {
-		c_query["_id"] = idQuery
-	}
-	log.Println("mongodb query:", c_query)
-	count := mongodb.Count("bidding", c_query)
-	log.Println("本次推送共查到数据", count, "条")
-	if count == 0 {
-		return false
-	}
-	if count > MaxSearch {
-		count = MaxSearch
-		log.Println("目前数据多于", MaxSearch, ",只加载了", MaxSearch, "条!")
-	}
-	var res []map[string]interface{}
-	sess := mongodb.GetMgoConn()
-	defer mongodb.DestoryMongoConn(sess)
-	it := sess.DB("qfw").C("bidding").Find(c_query).Select(mongodb.ObjToOth(Mongodb_ShowField)).Sort("_id").Iter()
-	index := 0
-	for tmp := make(map[string]interface{}); it.Next(&tmp); {
-		index++
-		tmp["_id"] = util.BsonIdToSId(tmp["_id"])
-		res = append(res, tmp)
-		if index%200 == 0 {
-			log.Println("当前加载数据:", index)
-		}
-		tmp = make(map[string]interface{})
-		if index >= count {
-			break
-		}
-	}
-	biddingDatas = &res
-	log.Println(count, "条数据已经加载完成!")
-	return true
-}
-
-/*func InitBiddingCache(_id, lastid string, lastTime int64) bool {
-	defer util.Catch()
-	//filter全局查询
-	c_query := fmt.Sprintf(FilterQuery, fmt.Sprintf(IDRange, _id, lastid, lastTime-7*86400))
-	log.Println("es query:", c_query)
-	//testquery := `{"terms":{"_id":["596f21935d11e1c7455ddc77"]}}`
-	//testquery := ``
-	//c_query = fmt.Sprintf(FilterQuery, testquery)
-	count := int(elastic.Count(DB, DB, c_query))
-	log.Println("本次推送共查到数据", count, "条")
-	if count == 0 {
-		return false
-	}
-	if count > MaxSearch {
-		count = MaxSearch
-		log.Println("目前数据多于", MaxSearch, ",只加载了", MaxSearch, "条!")
-	}
-	onceSize := 400 //ES一次查询这么多条
-	if onceSize > count {
-		onceSize = count
-	}
-	var res []map[string]interface{}
-	totalPage := int((count + onceSize - 1) / onceSize)
-	log.Println("数据一共", totalPage, "页!")
-	//如果res长度和cout相差5条,重试
-	for t := 1; t <= 3; t++ {
-		res = []map[string]interface{}{}
-		for i := 0; i < totalPage; i++ {
-			searchPool <- true
-			searchWaitGroup.Add(1)
-			go func(start int) {
-				defer func() {
-					searchWaitGroup.Done()
-					<-searchPool
-				}()
-				size := onceSize
-				if start == totalPage-1 && count%onceSize != 0 {
-					size = count % onceSize
-				}
-				r := elastic.GetAllByNgram(DB, DB, c_query, "", SortQuery, ShowField, start*onceSize, size, 0, false)
-				if r != nil {
-					res = append(res, *r...)
-					log.Println("第", start+1, "页数据加载完成!")
-				}
-			}(i)
-		}
-		searchWaitGroup.Wait()
-		if len(res) >= count-5 {
-			break
-		}
-		log.Println("第", t, "次加载数据完成,数据总数", len(res), ",由于数据量不够,重新加载!")
-	}
-	resLenght := len(res)
-	if resLenght == 0 {
-		return false
-	}
-	biddingDatas = &res
-	log.Println(resLenght, "条数据已经加载完成!")
-	return true
-}*/
-
-//开始推送
-func DoPush(a_p *Pjob, s_p *Pjob, MaxPushSize int, Now time.Time, isPushWxTpl bool) {
-	defer util.Catch()
-	//获取本次推送匹配到数据的用户
-	userMap := EachAllBidInfo(a_p, s_p)
-	//临时表中所有的数据
-	tempushMap := GetAllTemPush()
-	//遍历所有用户
-	for _, v := range *allUsers {
-		select {
-		case <-time.After(time.Minute):
-			http.Get("http://123.56.236.148:19281/_send/_mail?program=testgo2&to=renzheng@topnet.net.cn,wangchuanjin@topnet.net.cn&title=push_剑鱼标讯平台报警&body=" + url.QueryEscape(v.Id+",并发池PushPool一分钟写入超时,PushPoolLength"+fmt.Sprint(len(PushPool))))
-			PushPool <- true
-		case PushPool <- true:
-		}
-		go func(u *push.MemberInterest) {
-			defer func() {
-				<-PushPool
-			}()
-			isPush := false
-			listInfos := list.New() //最终推送给用户的数据
-			if u.Ratemode == 1 {
-				if u.UserType == 0 {
-					if isPushWxTpl || u.ApplyStatus == 0 {
-						isPush = true
-					}
-				} else if u.UserType == 1 {
-					isPush = true
-				} else if u.UserType == 2 {
-					isPush = true
-				} else if u.UserType == 3 {
-					if isPushWxTpl || u.ApplyStatus == 0 {
-						isPush = true
-					}
-				}
-			}
-			//本次推送匹配到的数据
-			u_listInfos := (*userMap)[u.Id]
-			if u_listInfos != nil && u_listInfos.Len() > 0 {
-				listInfos.PushBackList(u_listInfos)
-			}
-			//临时表数据
-			t_listInfos := tempushMap[u.Id]
-			if isPush && t_listInfos != nil {
-				if t_listInfos.Len() > 0 {
-					listInfos.PushBackList(t_listInfos)
-				}
-				//删除临时表的数据
-				mongodb.Del("tempush", &bson.M{"userid": u.Id})
-			}
-			//推送
-			if isPush {
-				DealSend(u, listInfos, Now, MaxPushSize, u.Ratemode, isPushWxTpl)
-			}
-			//暂存数据库tempush中
-			if u.Ratemode != 1 || (!isPushWxTpl && u.ApplyStatus == 1) || u.MailPush == 1 {
-				if u_listInfos == nil || u_listInfos.Len() == 0 {
-					return
-				}
-				var pushArray = make(sortList, 0)
-				for e := u_listInfos.Front(); e != nil; e = e.Next() {
-					k2 := *(e.Value.(*MatchInfo))
-					pushArray = append(pushArray, &k2)
-				}
-				//取最新50条
-				sort.Sort(pushArray)
-				if len(pushArray) > MaxPushSize {
-					pushArray = pushArray[:MaxPushSize]
-				}
-				//临时表的数据
-				var infos = make(sortList, 0)
-				if t_listInfos != nil && t_listInfos.Len() > 0 {
-					for e := t_listInfos.Front(); e != nil; e = e.Next() {
-						k2 := *(e.Value.(*MatchInfo))
-						infos = append(infos, &k2)
-					}
-				}
-				//
-				pLength := len(pushArray)
-				upSet := new(bson.M)
-				//直接替换
-				if len(infos) == 0 {
-					upSet = &bson.M{"$set": &bson.M{"tmpinfos": &pushArray, "apppush": u.AppPush}}
-				} else { //保留最新的50条
-					rLength := len(infos)
-					if rLength > 0 && rLength+pLength > MaxPushSize {
-						start := rLength + pLength - MaxPushSize
-						var relationinfoTemp = make(sortList, 0)
-						if start < rLength {
-							relationinfoTemp = append(relationinfoTemp, infos[start:]...)
-						}
-						relationinfoTemp = append(relationinfoTemp, pushArray...)
-						upSet = &bson.M{"$set": &bson.M{"tmpinfos": &relationinfoTemp, "apppush": u.AppPush}}
-					} else { //追加
-						upSet = &bson.M{"$set": &bson.M{"apppush": u.AppPush}, "$pushAll": &bson.M{"tmpinfos": &pushArray}}
-					}
-				}
-				mongodb.Update("tempush", &bson.M{"userid": u.Id}, upSet, true, false)
-			}
-		}(v)
-	}
-}
-
-//遍历数据并执行推送操作
-func EachAllBidInfo(a_p *Pjob, s_p *Pjob) *map[string]*list.List {
-	defer util.Catch()
-	log.Println("开始遍历数据。。。")
-	userMap := &map[string]*list.List{}
-	var count int
-	for _, temp := range *biddingDatas {
-		eachPool <- true
-		eachInfoWaitGroup.Add(1)
-		count++
-		go func(info map[string]interface{}) {
-			defer func() {
-				eachInfoWaitGroup.Done()
-				<-eachPool
-			}()
-			title := util.ObjToString(info["title"])
-			if title == "" {
-				return
-			}
-			titleTemp := strings.ToUpper(title)
-			area := util.ObjToString(info["area"])
-			toptype := util.ObjToString(info["toptype"])
-			//订阅词
-			keys := a_p.InterestDfa.Analy(titleTemp)
-			//排除词
-			notkeys := a_p.NotInterestDfa.Analy(titleTemp)
-			users := GetFinalUser(keys, notkeys, a_p.Key_user, area, toptype, true)
-			//开启智能匹配的用户,匹配projectscope
-			if s_p != nil {
-				projectscope := util.ObjToString(info["projectscope"])
-				if projectscope == "" {
-					projectscope = util.ObjToString(info["detail"])
-				}
-				if projectscope != "" {
-					projectscopeTemp := strings.ToUpper(projectscope)
-					keys = s_p.InterestDfa.Analy(projectscopeTemp)
-					notkeys = s_p.NotInterestDfa.Analy(projectscopeTemp)
-					s_users := GetFinalUser(keys, notkeys, s_p.Key_user, area, toptype, false)
-					for _, s_u := range *s_users {
-						if (*users)[s_u.User.Id] != nil {
-							continue
-						}
-						(*users)[s_u.User.Id] = s_u
-					}
-				}
-			}
-			if len(*users) > 0 {
-				delete(info, "projectscope")
-				delete(info, "detail")
-				province := util.ObjToString(info["area"])
-				info["otitle"] = info["title"]
-				if "A" != province {
-					info["title"] = fmt.Sprintf(PushTitle, province, info["title"])
-				}
-				EachInfoToUser(users, &info, userMap)
-			}
-		}(temp)
-		if count%500 == 0 {
-			log.Println("当前信息索引:", count)
-		}
-	}
-	eachInfoWaitGroup.Wait()
-	log.Println("数据遍历完成!")
-	return userMap
-}
-
-//获取最终的用户,排除词、信息范围、信息类型之后的
-//返回匹配上的用户和没有匹配到的用户
-func GetFinalUser(keys, notkeys []string, key_user *map[string]*[]*push.MemberInterest, area, toptype string, flag bool) *map[string]*MatchUser {
-	keyMap := map[string]bool{}
-	for _, v := range keys {
-		keyMap[v] = true
-	}
-	y_users := map[string]*MatchUser{} //匹配到用户
-	//遍历所有用户
-	for k, us := range *key_user {
-		if !keyMap[k] { //改关键词没有匹配到的用户
-			continue
-		}
-		for _, u := range *us {
-			//获取该词下面所有的用户
-			//遍历我的排除词,如果存在的话,排除自己
-			isContinue := false
-			for _, notkey := range notkeys {
-				if u.Key_notkey[k][notkey] {
-					isContinue = true
-					break
-				}
-			}
-			if isContinue {
-				continue
-			}
-			//遍历我的信息范围,看该信息是不是在我的信息范围中
-			if len(u.Key_area[k]) > 0 && !u.Key_area[k][area] {
-				continue
-			}
-			//遍历我的信息类型,看该信息是不是在我的信息类型中
-			if len(u.Key_infotype[k]) > 0 && !u.Key_infotype[k][toptype] {
-				continue
-			}
-			matchUser := y_users[u.Id]
-			if matchUser == nil {
-				matchUser = &MatchUser{
-					User: u,
-					Keys: []string{},
-				}
-			}
-			matchUser.Keys = append(matchUser.Keys, k)
-			y_users[u.Id] = matchUser
-		}
-	}
-	//获取最终没有匹配到的用户,进行正文或者范围匹配
-	users := map[string]*MatchUser{}
-	for k, v := range *allUsers {
-		if y_users[k] == nil {
-			continue
-		}
-		users[v.Id] = &MatchUser{
-			User: v,
-			Keys: y_users[k].Keys,
-		}
-	}
-	return &users
-}
-
-//遍历用户加入到此条信息上
-func EachInfoToUser(users *map[string]*MatchUser, info *map[string]interface{}, userMap *map[string]*list.List) {
-	defer userMapLock.Unlock()
-	userMapLock.Lock()
-	for k, v := range *users {
-		l := (*userMap)[k]
-		if l == nil {
-			l = list.New()
-		}
-		l.PushBack(&MatchInfo{
-			Info: info,
-			Keys: v.Keys,
-		})
-		(*userMap)[k] = l
-	}
-}
-
-//查询所有临时表中的数据
-func GetAllTemPush() map[string]*list.List {
-	defer util.Catch()
-	session := mongodb.GetMgoConn()
-	defer mongodb.DestoryMongoConn(session)
-	log.Println("开始获取临时表中的数据。。。")
-	result := session.DB("qfw").C("tempush").Find(nil).Select(&map[string]interface{}{
-		"userid":   1,
-		"tmpinfos": 1,
-	}).Iter()
-	//遍历用户数组
-	tempushMap := map[string]*list.List{}
-	n := 0
-	for tmp := make(map[string]interface{}); result.Next(tmp); {
-		util.Try(func() {
-			userId, _ := tmp["userid"].(string)
-			if userId == "" {
-				return
-			}
-			listInfos := list.New()
-			if tmp["tmpinfos"] != nil {
-				tmpinfos, _ := tmp["tmpinfos"].([]interface{})
-				if len(tmpinfos) > 0 {
-					for _, tif := range tmpinfos {
-						tifMap, _ := tif.(map[string]interface{})
-						delete(tifMap, "projectscope")
-						delete(tifMap, "detail")
-						if tifMap["info"] != nil && tifMap["keys"] != nil {
-							info, _ := tifMap["info"].(map[string]interface{})
-							delete(info, "projectscope")
-							delete(info, "detail")
-							interface_keys, _ := tifMap["keys"].([]interface{})
-							keys := util.ObjArrToStringArr(interface_keys)
-							listInfos.PushBack(&MatchInfo{
-								Info: &info,
-								Keys: keys,
-							})
-						} else {
-							listInfos.PushBack(&MatchInfo{
-								Info: &tifMap,
-								Keys: []string{},
-							})
-						}
-					}
-				}
-			}
-			tempushMap[userId] = listInfos
-			n++
-			if n%500 == 0 {
-				log.Println("当前索引:", n)
-			}
-		}, func(e interface{}) {
-			log.Println(e)
-		})
-		tmp = make(map[string]interface{})
-		if n >= 100000 {
-			break
-		}
-	}
-	log.Println("临时表中的数据加载完成!", n)
-	return tempushMap
-}
-
-//重新设置用户类型
-func GetUserType(s_m_openid, a_m_openid, phone string, userType int) int {
-	if userType == 0 {
-		if s_m_openid == "" && phone != "" {
-			userType = 1 //app手机号
-		} else if s_m_openid == "" && a_m_openid != "" {
-			userType = 2 //app微信
-		} else if s_m_openid != "" && a_m_openid == "" && phone == "" {
-			userType = 0 //公众号
-		} else {
-			userType = 3 //用户合并以后
-		}
-	}
-	return userType
-}
-
-//推送方式转换
-func ModeTransform(userType int, o_msgset map[string]interface{}) (int, int, int) {
-	mode := util.IntAllDef(o_msgset["i_mode"], 0)
-	wxpush := util.IntAllDef(o_msgset["i_wxpush"], 0)
-	apppush := util.IntAllDef(o_msgset["i_apppush"], 0)
-	mailpush := util.IntAllDef(o_msgset["i_mailpush"], 0)
-	if mode == 0 || (wxpush == 1 || apppush == 1 || mailpush == 1) {
-		return wxpush, apppush, mailpush
-	}
-	//老的app用户
-	if userType == 1 || userType == 2 {
-		switch mode {
-		case 1:
-			apppush = 1
-			break
-		case 2:
-			mailpush = 1
-			break
-		case 3:
-			apppush = 1
-			mailpush = 1
-			break
-		}
-		if apppush == 0 && mailpush == 0 {
-			apppush = 1
-		}
-	} else if userType == 0 {
-		switch mode {
-		case 1:
-			wxpush = 1
-			break
-		case 2:
-			mailpush = 1
-			break
-		case 3:
-			wxpush = 1
-			mailpush = 1
-			break
-		}
-		if wxpush == 0 && mailpush == 0 {
-			wxpush = 1
-		}
-	}
-	return wxpush, apppush, mailpush
-}

+ 0 - 93
src/jfw/modules/push/src/qfw/push/dopush/excel.go

@@ -1,93 +0,0 @@
-package dopush
-
-import (
-	"fmt"
-	"log"
-	"math/rand"
-	"os"
-	qu "qfw/util"
-	"time"
-
-	"github.com/tealeg/xlsx"
-)
-
-var Sheets = map[int]xlsx.Sheet{}
-
-func init() {
-	fx, err := xlsx.OpenFile("./xlsx/temp.xlsx")
-	if err != nil {
-		log.Println(err.Error())
-		os.Exit(0)
-	}
-	for k, st := range fx.Sheets {
-		Sheets[k] = *st
-	}
-}
-func GetBidInfoXlsx(data []map[string]interface{}) (fnamepath, rename string) {
-	fx := xlsx.NewFile()
-	sheet := Sheets[0]
-	style := xlsx.NewStyle()
-	style.Alignment.WrapText = true
-	//信息
-	for _, v := range data {
-		row := sheet.AddRow()
-
-		projectname := qu.ObjToString(v["projectname"])
-		if projectname == "" {
-			projectname = qu.ObjToString(v["title"])
-		}
-		cell := row.AddCell()
-		cell.SetValue(projectname)
-		cell.SetStyle(style)
-
-		cell = row.AddCell()
-		cell.SetValue(v["subtype"])
-
-		budget := qu.Float64All(v["budget"]) / float64(10000)
-		cell = row.AddCell()
-		if budget != 0 {
-			cell.SetValue(budget)
-		} else {
-			cell.SetValue("")
-		}
-
-		cell = row.AddCell()
-		cell.SetValue(v["buyer"])
-		cell.SetStyle(style)
-
-		bpt := v["bidopentime"]
-		bidopentime := qu.FormatDateWithObj(&bpt, "2006-01-02 15:04")
-		cell = row.AddCell()
-		cell.SetValue(bidopentime)
-
-		cell = row.AddCell()
-		cell.SetValue(v["winner"])
-		cell.SetStyle(style)
-
-		bidamount := qu.Float64All(v["bidamount"]) / float64(10000)
-		cell = row.AddCell()
-		if bidamount != 0 {
-			cell.SetValue(bidamount)
-		} else {
-			cell.SetValue("")
-		}
-
-		pt := v["publishtime"]
-		publishtime := qu.FormatDateWithObj(&pt, qu.Date_Short_Layout)
-		cell = row.AddCell()
-		cell.SetValue(publishtime)
-	}
-	fx.AppendSheet(sheet, "剑鱼标讯")
-
-	t := time.Now()
-	rename = "剑鱼标讯_" + t.Format("2006-01-02") + "_推送信息表.xlsx"
-	fnamepath = "./xlsx/" + t.Format("20060102150405") + fmt.Sprint(rand.Intn(10000)) + ".xlsx"
-
-	err := fx.Save(fnamepath)
-	//log.Println("err", err)
-	if err != nil {
-		return "", ""
-	} else {
-		return fnamepath, rename
-	}
-}

+ 0 - 8
src/jfw/modules/push/src/qfw/push/job.go

@@ -1,8 +0,0 @@
-//消息推送
-package push
-
-//推送任务接口
-type PushJobFace interface {
-	//执行动作
-	Execute(isPushTpl bool) bool
-}

+ 0 - 86
src/jfw/modules/push/src/qfw/push/jobs/bidpush.go

@@ -1,86 +0,0 @@
-/**
- *招标,中标公告的推送消息,在兴趣词分析上,存在一定的难度
- *现在采用DFA算法分析,兴趣词会构造Map结构,前期应该不会出问题。
- *后期需要改进(用户量达到5千以上)
- *可行策略:每日产生的新数据有限,大概不超过5000条,可以把标题全加到内存
- *        用户兴趣词分批次加入,每次加入3000个左右的用户的兴趣词,过滤
- *        今日产生的招标、中标数据,并完成推送,第二批载入后3000个用户的数据
- */
-package jobs
-
-import (
-	"log"
-	"qfw/push"
-	"qfw/push/dopush"
-	"qfw/util"
-	"strings"
-	"time"
-)
-
-type BidPushJob struct {
-}
-
-//最大推送条数
-var MaxPushSize int
-
-//推送模式 mgo为数据库模式,es为elastic模式 var PushMode string
-
-//执行日常招标的消息推送
-func (b *BidPushJob) Execute(isPushWxTpl bool) {
-	startpushtime, _ := push.PushConfig["startpushtime"].(string)
-	s_h_m := strings.Split(startpushtime, ":")
-	if len(s_h_m) != 2 {
-		log.Fatalln("error:startpushtime", startpushtime)
-	}
-	now := time.Now()
-	start := time.Date(now.Year(), now.Month(), now.Day(), util.IntAll(s_h_m[0]), util.IntAll(s_h_m[1]), 0, 0, time.Local)
-	//程序启动在开始时间之前
-	if now.Before(start) {
-		sub := start.Sub(now)
-		log.Println("start", startpushtime, "push after", sub)
-		time.AfterFunc(sub, func() {
-			go b.run(true)
-			ticker := time.NewTicker(time.Hour * 24)
-			for {
-				select {
-				case <-ticker.C:
-					go b.run(true)
-				}
-			}
-		})
-	} else {
-		go b.run(false)
-		start = start.AddDate(0, 0, 1)
-		sub := start.Sub(now)
-		log.Println("start", startpushtime, "push after", sub)
-		timer := time.NewTimer(sub)
-		for {
-			select {
-			case <-timer.C:
-				timer.Reset(time.Hour * 24)
-				go b.run(true)
-			}
-		}
-	}
-}
-func (b *BidPushJob) run(isPushWxTpl bool) {
-	endpushtime, _ := push.PushConfig["endpushtime"].(string)
-	e_h_m := strings.Split(endpushtime, ":")
-	if len(e_h_m) != 2 {
-		log.Fatalln("endpushtime", endpushtime)
-	}
-	now := time.Now()
-	end := time.Date(now.Year(), now.Month(), now.Day(), util.IntAll(e_h_m[0]), util.IntAll(e_h_m[1]), 0, 0, time.Local)
-	if now.Before(end) {
-		dopush.PushInfo(MaxPushSize, isPushWxTpl)
-	}
-	//隔天的话,不继续
-	//判断下一轮是否还需要继续
-	if now.Day() != time.Now().Day() || time.Now().After(end) {
-		return
-	}
-	log.Println("start push after", push.PushConfig["durationMinutes"], "m")
-	time.AfterFunc(time.Duration(util.IntAll(push.PushConfig["durationMinutes"]))*time.Minute, func() {
-		b.run(false)
-	})
-}

+ 0 - 43
src/jfw/modules/push/src/qfw/push/jobs/fixpush.go

@@ -1,43 +0,0 @@
-package jobs
-
-/*
-*每天推送一次
- */
-
-import (
-	"log"
-	"qfw/push"
-	"qfw/push/dopush"
-	"qfw/util"
-	"strings"
-	"time"
-)
-
-type NinePushJob struct {
-}
-
-func (b *NinePushJob) Execute(isPushWxTpl bool) {
-	oncepushtime, _ := push.PushConfig["oncepushtime"].(string)
-	h_m := strings.Split(oncepushtime, ":")
-	if len(h_m) == 2 {
-		now := time.Now()
-		newDate := time.Date(now.Year(), now.Month(), now.Day(), util.IntAll(h_m[0]), util.IntAll(h_m[1]), 0, 0, time.Local)
-		if newDate.Before(now) {
-			newDate = newDate.AddDate(0, 0, 1)
-		}
-		sub := newDate.Sub(now)
-		log.Println("start", oncepushtime, "push after", sub)
-		time.AfterFunc(sub, func() {
-			go dopush.PushOtherUsers(MaxPushSize, false)
-			ticker := time.NewTicker(time.Hour * 24)
-			for {
-				select {
-				case <-ticker.C:
-					go dopush.PushOtherUsers(MaxPushSize, false)
-				}
-			}
-		})
-	} else {
-		log.Fatalln("error:oncepushtime", oncepushtime)
-	}
-}

+ 0 - 45
src/jfw/modules/push/src/qfw/push/jobs/realtimepush.go

@@ -1,45 +0,0 @@
-package jobs
-
-/*
-*每天推送一次
- */
-
-import (
-	"log"
-	"qfw/push"
-	"qfw/push/dopush"
-	"qfw/util"
-	"strings"
-	"time"
-)
-
-type RealTimePushJob struct {
-}
-
-func (b *RealTimePushJob) Execute(isPushWxTpl bool) {
-	otherpushtimes := util.ObjArrToStringArr(push.PushConfig["otherpushtimes"].([]interface{}))
-	for _, otherpushtime := range otherpushtimes {
-		h_m := strings.Split(otherpushtime, ":")
-		if len(h_m) != 2 {
-			log.Fatalln("error:otherpushtimes", otherpushtime)
-			return
-		}
-		now := time.Now()
-		newDate := time.Date(now.Year(), now.Month(), now.Day(), util.IntAll(h_m[0]), util.IntAll(h_m[1]), 0, 0, time.Local)
-		if newDate.Before(now) {
-			newDate = newDate.AddDate(0, 0, 1)
-		}
-		sub := newDate.Sub(now)
-		log.Println("start", otherpushtime, "push after", sub)
-		time.AfterFunc(sub, func() {
-			go dopush.PushOtherUsers(MaxPushSize, true)
-			ticker := time.NewTicker(time.Hour * 24)
-			for {
-				select {
-				case <-ticker.C:
-					go dopush.PushOtherUsers(MaxPushSize, true)
-				}
-			}
-		})
-	}
-}

+ 0 - 101
src/jfw/modules/push/src/qfw/push/listdb/listdb.go

@@ -1,101 +0,0 @@
-package listdb
-
-import (
-	"log"
-	"qfw/util"
-	"qfw/util/mongodb"
-	"sort"
-	"strings"
-	"sync"
-	"time"
-
-	"gopkg.in/mgo.v2/bson"
-)
-
-type arr []*map[string]interface{}
-
-func (a *arr) Len() int {
-	return len(*a)
-}
-func (a *arr) Less(i, j int) bool {
-	return util.Int64All((*(*a)[i])["publishtime"]) < util.Int64All((*(*a)[j])["publishtime"])
-}
-func (a *arr) Swap(i, j int) {
-	tmp := (*a)[i]
-	(*a)[i] = (*a)[j]
-	(*a)[j] = tmp
-}
-
-type ListDB struct {
-	Lock      *sync.Mutex
-	DB        *arr
-	Stype     string
-	timestamp int64
-	lastid    bson.ObjectId
-}
-
-var fields map[string]interface{} = map[string]interface{}{
-	"type":        1,
-	"toptype":     1,
-	"subtype":     1,
-	"comeintime":  1,
-	"publishtime": 1,
-	"title":       1,
-	"area":        1,
-	"href":        1,
-	"areaval":     1,
-}
-
-var Bid *ListDB
-
-//---废弃
-func __Inits() {
-	Bid = &ListDB{
-		Lock:      new(sync.Mutex),
-		DB:        &arr{},
-		timestamp: 0,
-	}
-	go Bid.update()
-}
-
-func (l *ListDB) update() {
-	l.Lock.Lock()
-	util.Try(func() {
-		var q map[string]interface{}
-		if l.lastid.Valid() {
-			q = map[string]interface{}{
-				"_id": map[string]interface{}{
-					"$gt": l.lastid,
-				},
-			}
-		}
-		session := mongodb.GetMgoConn()
-		defer mongodb.DestoryMongoConn(session)
-		//此处不排序,谁查谁排序(不索引会造成发布时间乱序)
-		query := session.DB("qfw").C("bidding").Find(q).Select(fields).Sort("publishtime").Iter()
-		for tmp := new(map[string]interface{}); query.Next(tmp); {
-			province := util.ObjToString((*tmp)["area"])
-			if strings.TrimSpace(province) == "" {
-				province = "A"
-			}
-			if "A" != province {
-				title := util.ObjToString((*tmp)["title"])
-				(*tmp)["title"] = `[<span class='area'>` + province + `</span>]` + title
-			}
-			*l.DB = append(*l.DB, tmp)
-			last := (*tmp)["_id"].(bson.ObjectId)
-			if !l.lastid.Valid() || l.lastid.Hex() < last.Hex() {
-				l.lastid = last
-			}
-			if l.DB.Len() > 400000 {
-				*l.DB = (*l.DB)[l.DB.Len()-400000:]
-			}
-			tmp = new(map[string]interface{})
-		}
-	}, func(e interface{}) {
-		log.Println(e)
-	})
-	sort.Sort(l.DB)
-	l.Lock.Unlock()
-	time.AfterFunc(10*time.Minute, l.update)
-}

+ 0 - 10
src/jfw/modules/push/src/qfw/push/pushconfig.go

@@ -1,10 +0,0 @@
-//
-package push
-
-//配置
-var (
-	PushConfig    map[string]interface{}
-	TaskConfig    map[string]interface{}
-	City          map[string]uint
-	CassandraOpen bool
-)

+ 0 - 45
src/jfw/modules/push/src/qfw/push/rpccall.go

@@ -1,45 +0,0 @@
-package push
-
-import (
-	"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", PushConfig["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"
-}
-
-//
-func PcZhushou(m map[string]interface{}) bool {
-	defer util.Catch()
-	var repl string
-	client, err := rpc.DialHTTP("tcp", PushConfig["pcPushHelper"].(string))
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	defer client.Close()
-	b, _ := json.Marshal(m)
-	err = client.Call("Service.PushMsg", b, &repl)
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	return repl == "y"
-}

+ 0 - 122
src/jfw/modules/push/src/qfw/push/weixincall.go

@@ -1,122 +0,0 @@
-//微信调用
-package push
-
-import (
-	"encoding/json"
-	"fmt"
-	"log"
-	"net/rpc"
-	"qfw/util"
-	"qfw/util/mongodb"
-	qrpc "qfw/util/rpc"
-	"strconv"
-	//"strconv"
-	"strings"
-	"time"
-	ca "ucbsutil/cassandra"
-)
-
-var WeixinRpcServer string
-
-//微信远程调用,实现模板发送消息
-func SendWeiXinNew(k *MemberInterest, wid, str string, Remarks string, o_pushinfo map[string]map[string]interface{}, ratemode int, matchKey_infoIndex map[string]string, wxtitle string) {
-	now := time.Now()
-	util.Try(func() {
-		p := &qrpc.NotifyMsg{
-			Openid:      k.S_m_openid,
-			Title:       wxtitle,
-			Remark:      Remarks,
-			Detail:      WxGroup,
-			Date:        "",
-			Service:     util.FormatDate(&now, util.Date_Short_Layout),
-			Color:       WxColor,
-			DetailColor: WxDetailColor,
-			Url:         Domain + "/front/sess/" + Se.EncodeString(k.S_m_openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",wxpushlist") + "__" + wid,
-		}
-		client, err := rpc.DialHTTP("tcp", WeixinRpcServer)
-		defer client.Close()
-		if err != nil {
-			log.Println(err.Error())
-			return
-		}
-		var repl qrpc.RpcResult
-		err = client.Call("WeiXinRpc.SubscribePush", p, &repl)
-		if err != nil {
-			log.Println(err.Error())
-		}
-		res := string(repl)
-		if strings.Contains(res, "[46004]") || strings.Contains(res, "[65302]") || strings.Contains(res, "[43004]") || strings.Contains(res, "[40003]") {
-			updateIsPush(p.Openid, 0)
-		}
-	}, func(e interface{}) {})
-	time.Sleep(5 * time.Millisecond)
-}
-
-func SendWinXin(p *qrpc.NotifyMsg) {
-	util.Try(func() {
-		client, err := rpc.DialHTTP("tcp", WeixinRpcServer)
-		defer client.Close()
-		if err != nil {
-			log.Println(err.Error())
-			return
-		}
-		var repl qrpc.RpcResult
-		err = client.Call("WeiXinRpc.SendPushMsg", p, &repl)
-		if err != nil {
-			log.Println(err.Error())
-		}
-		res := string(repl)
-		if strings.Contains(res, "[46004]") || strings.Contains(res, "[65302]") || strings.Contains(res, "[43004]") || strings.Contains(res, "[40003]") {
-			updateIsPush(p.Openid, 0)
-		}
-	}, func(e interface{}) {})
-	time.Sleep(5 * time.Millisecond)
-}
-
-//修改是否推送的状态
-func updateIsPush(openid string, status int) {
-	mongodb.Update("user", map[string]interface{}{"s_m_openid": openid}, map[string]interface{}{
-		"$set": map[string]interface{}{
-			"i_ispush": status,
-		},
-	}, false, false)
-	mongodb.Update("follow_project", map[string]interface{}{"s_openid": openid}, map[string]interface{}{
-		"$set": map[string]interface{}{
-			"i_ispush": status,
-		},
-	}, false, true)
-}
-
-//保存发送信息
-func SaveSendInfo(k *MemberInterest, now time.Time, str string, o_pushinfo map[string]map[string]interface{}, ratemode int, matchKey_infoIndex map[string]string) string {
-	pushid := now.Unix()
-	md, _ := json.Marshal(o_pushinfo)
-	openid := k.S_m_openid
-	if openid == "" {
-		openid = k.A_m_openid
-	}
-	if openid == "" {
-		openid = k.Phone
-	}
-	wxpush := map[string]interface{}{
-		"id":       time.Now().Format(util.Date_Short_Layout),
-		"openid":   openid,
-		"date":     pushid,
-		"words":    k.Interest,
-		"uid":      k.Id,
-		"province": k.Province,
-		"interest": k.Interest,
-		"content":  str,
-		"pushinfo": string(md),
-		"size":     len(o_pushinfo),
-		"appid":    2,
-		"ratemode": ratemode,
-		"sendmode": 9000 + k.WxPush*100 + k.AppPush*10 + k.MailPush,
-		"smartset": k.Smartset,
-		"matchki":  matchKey_infoIndex,
-	}
-	if ca.SaveCacheByTimeOut("jy_push", wxpush, 10) {
-		return fmt.Sprint(pushid)
-	}
-	return ""
-}

+ 0 - 1
src/jfw/modules/push/src/task.json

@@ -1 +0,0 @@
-{"lastId":"5bd0392d2757344954cc71ab","startTime":"2017-07-17 09:07:25"}

BIN
src/jfw/modules/push/src/xlsx/201709191346354425.xlsx


+ 0 - 1
src/jfw/modules/push/src/xlsx/readme.txt

@@ -1 +0,0 @@
-excel数据导出临时目录

BIN
src/jfw/modules/push/src/xlsx/temp.xlsx


+ 0 - 67
src/jfw/modules/push_v1/src/config.json

@@ -1,67 +0,0 @@
-{
-	"jianyuDomain": "https://web-jydev-wcj.jianyu360.cn",
-	"cassandra": {
-		"cachesize": 10000,
-		"host": ["192.168.3.207"],
-		"open": true,
-		"size": 5,
-		"timeout": 20
-	},
-	"redisServers": "push=192.168.3.18:1379,pushcache=192.168.3.18:1379",
-	"elasticPoolSize": 10,
-	"elasticSearch": "http://192.168.3.18:9800",
-	"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信息-剑鱼标讯",
-	"mails": [{
-		"addr": "smtp.exmail.qq.com",
-		"port": 465,
-		"pwd": "ue9Rg9Sf4CVtdm5a",
-		"user": "public03@topnet.net.cn"
-	}],
-	"maxPushSize": 50,
-	"maxSearch": 500,
-	"messyCodeEmailReg": "(@(126|163)\\.com)$",
-	"mgoAddr": "192.168.3.18:27080",
-	"mgoSize": 10,
-	"testids": ["5ba4aded25ef871eec5dedf4"],
-	"weixinRpcServer": "127.0.0.1:8083",
-	"wxColor": "#2cb7ca",
-	"wxContent": "剑鱼标讯推送",
-	"wxGroup": "招标信息",
-	"wxTitle": "根据你订阅的关键词“%s”,剑鱼标讯为你推送以下信息。如果不想继续收到此类信息,可进入招标订阅的设置页面取消订阅。",
-	"wxDetailColor":"#686868",
-	"appPushServiceRpc":"127.0.0.1:5566",
-	"pcHelper":"192.168.20.129:8082",
-	"filterWords":["项目","中标","公告"],
-	"startPushTime":"08:00",
-	"endPushTime":"20:00",
-	"oncePushTime": "9:00",
-	"otherPushTimes":[
-		"14:00",
-		"18:00"
-	],
-	"cassandraPollSize":10,
-	"matchPoolSize": 60,
-	"pushPoolSize": 60,
-	"minutePushSize": 300,
-	"fastigiumMinutePushSize": 100,
-	"fastigiumTime":"9-11",
-	"mailPollSize": 20,
-	"wxPollSize": 40,
-	"appPollSize": 50,
-	"pushDuration": 2,
-	"matchDuration": 1, 
-	"retry": 3,
-	"mailReTry":2,
-	"mailSleep":200,
-	"cassandraSleep":200,
-	"appSleep":5,
-	"wxSleep":5,
-	"pcHelperSleep":5,
-	"isPushMail":true,
-	"inactivityPushHour": 10,
-	"userBatch":2,
-	"pushBatch":2,
-	"ninePushRedisTimeout": 172800
-}

+ 0 - 70
src/jfw/modules/push_v1/src/main.go

@@ -1,70 +0,0 @@
-/**
- *订阅推送服务
- */
-package main
-
-import (
-	"flag"
-	"log"
-	. "push/config"
-	"push/dopush"
-	"qfw/util/elastic"
-	"qfw/util/mongodb"
-	"qfw/util/redis"
-	"time"
-	ca "ucbsutil/cassandra"
-
-	"github.com/donnie4w/go-logger/logger"
-)
-
-//主应用,定时任务
-func main() {
-	//dopush.Jobs.Match.Execute(0)
-	//dopush.Jobs.Push.Execute(2)
-	//return
-	sleep := flag.Int("s", 0, "程序启动完以后,实时推送休眠s分钟再开始")
-	modle := flag.Int("m", 0, "默认:0;1 匹配数据,2 推送数据,3 匹配+推送,4 先执行-t的任务后定时任务运行")
-	taskType := flag.Int("t", 1, "默认:1实时推送;2 实时推送+一天三次的八点推送,3 一天三次推送,4 九点推送")
-	moveDatas := flag.String("v", "y", "默认:y,是否迁移数据")
-	flag.Parse()
-	logger.SetConsole(false)
-	logger.SetRollingDaily("./logs", "push.log")
-	mongodb.InitMongodbPool(SysConfig.MgoSize, SysConfig.MgoAddr, "qfw")
-	redis.InitRedis(SysConfig.RedisServers)
-	elastic.InitElasticSize(SysConfig.ElasticSearch, SysConfig.ElasticPoolSize)
-	//初始化cassandra
-	ca.ViewCacheLen = true
-	ca.InitCassandra("jianyu",
-		SysConfig.Cassandra.Size,
-		SysConfig.Cassandra.Host,
-		map[string]int{
-			"cachesize": SysConfig.Cassandra.Cachesize,
-			"timeout":   SysConfig.Cassandra.Timeout,
-		},
-	)
-	log.Println("订阅推送程序启动")
-	isMoveDatas := *moveDatas == "y"
-	if *modle == 1 {
-		dopush.Jobs.Match.Execute(0, false)
-	} else if *modle == 2 {
-		dopush.Jobs.Push.Execute(*taskType, isMoveDatas)
-	} else if *modle == 3 {
-		dopush.Jobs.Match.Execute(0, true)
-		dopush.Jobs.Push.Execute(*taskType, isMoveDatas)
-	} else {
-		if *modle == 4 {
-			dopush.Jobs.Push.Execute(*taskType, isMoveDatas)
-		}
-		go dopush.Task.Match.Execute()
-		go dopush.Task.OtherPush.Execute()
-		go dopush.Task.NinePush.Execute()
-		if *sleep > 0 {
-			log.Println("实时推送先休眠", *sleep, "m")
-			time.AfterFunc(time.Duration(*sleep)*time.Minute, dopush.Task.RealPush.Execute)
-		} else {
-			go dopush.Task.RealPush.Execute()
-		}
-		flag := make(chan bool)
-		<-flag
-	}
-}

+ 0 - 150
src/jfw/modules/push_v1/src/push/config/config.go

@@ -1,150 +0,0 @@
-package config
-
-import (
-	"qfw/util"
-	"qfw/util/elastic"
-	"qfw/util/mail"
-	"regexp"
-)
-
-type sysConfig struct {
-	JianyuDomain            string      `json:"jianyuDomain"`
-	Cassandra               *cassandra  `json:"cassandra"`
-	RedisServers            string      `json:"redisServers"`
-	ElasticPoolSize         int         `json:"elasticPoolSize"`
-	ElasticSearch           string      `json:"elasticSearch"`
-	MatchPoolSize           int         `json:"matchPoolSize"`
-	PushPoolSize            int         `json:"pushPoolSize"`
-	Mail_content            string      `json:"mail_content"`
-	Mail_html               string      `json:"mail_html"`
-	Mail_title              string      `json:"mail_title"`
-	Mails                   []*pushMail `json:"mails"`
-	MaxPushSize             int         `json:"maxPushSize"`
-	MaxSearch               int         `json:"maxSearch"`
-	MessyCodeEmailReg       string      `json:"messyCodeEmailReg"`
-	MgoAddr                 string      `json:"mgoAddr"`
-	MgoSize                 int         `json:"mgoSize"`
-	TestIds                 []string    `json:"testIds"`
-	WeixinRpcServer         string      `json:"weixinRpcServer"`
-	WxColor                 string      `json:"wxColor"`
-	WxGroup                 string      `json:"wxGroup"`
-	WxContent               string      `json:"wxContent"`
-	WxTitle                 string      `json:"wxTitle"`
-	WxDetailColor           string      `json:"wxDetailColor"`
-	AppPushServiceRpc       string      `json:"appPushServiceRpc"`
-	PcHelper                string      `json:"pcHelper"`
-	FilterWords             []string    `json:"filterWords"`
-	PushDuration            int64       `json:"pushDuration"`
-	MatchDuration           int64       `json:"matchDuration"`
-	Retry                   int         `json:"retry"`
-	InactivityPushHour      int         `json:"inactivityPushHour"`
-	UserBatch               int         `json:"userBatch"`
-	PushBatch               int         `json:"pushBatch"`
-	StartPushTime           string      `json:"startPushTime"`
-	EndPushTime             string      `json:"endPushTime"`
-	OncePushTime            string      `json:"oncePushTime"`
-	OtherPushTimes          []string    `json:"otherPushTimes"`
-	MailPollSize            int         `json:"mailPollSize"`
-	WxPollSize              int         `json:"wxPollSize"`
-	AppPollSize             int         `json:"appPollSize"`
-	MailReTry               int         `json:"mailReTry"`
-	MailSleep               int         `json:"mailSleep"`
-	CassandraSleep          int         `json:"cassandraSleep"`
-	AppSleep                int         `json:"appSleep"`
-	WxSleep                 int         `json:"wxSleep"`
-	PcHelperSleep           int         `json:"pcHelperSleep"`
-	IsPushMail              bool        `json:"isPushMail"`
-	CassandraPollSize       int         `json:"cassandraPollSize"`
-	MinutePushSize          int         `json:"minutePushSize"`
-	FastigiumMinutePushSize int         `json:"fastigiumMinutePushSize"`
-	FastigiumTime           string      `json:"fastigiumTime"`
-	NinePushRedisTimeout    int         `json:"ninePushRedisTimeout"`
-}
-type pushMail struct {
-	Addr string `json:"addr"`
-	Port int    `json:"port"`
-	Pwd  string `json:"pwd"`
-	User string `json:"user"`
-}
-type cassandra struct {
-	Cachesize int      `json:"cachesize"`
-	Host      []string `json:"host"`
-	Open      bool     `json:"open"`
-	Size      int      `json:"size"`
-	Timeout   int      `json:"timeout"`
-}
-
-type MemberInterest struct {
-	Id           string                     //mongoid
-	Province     string                     //省份
-	Key_notkey   map[string]map[string]bool //关键词-排除词
-	Key_area     map[string]map[string]bool //关键词-信息范围
-	Key_infotype map[string]map[string]bool //关键词-信息类型
-	OriginalKeys []string                   //用户兴趣
-	Keys         []string                   //用户兴趣
-	NotKeys      []string                   //用户不感兴趣
-	S_m_openid   string                     //公众号openid
-	A_m_openid   string                     //app微信登录openid
-	Phone        string                     //app手机号登录
-	Jpushid      string
-	Opushid      string
-	InterestDate int64
-	WxPush       int
-	AppPush      int
-	MailPush     int
-	RateMode     int
-	SmartSet     int //智能订阅 1开启 0关闭
-	Email        string
-	DataExport   int //是否导出数据 1开启 0关闭
-	AllKeys      []elastic.KeyConfig
-	ModifyDate   string
-	AppPhoneType string
-	ApplyStatus  int
-	Subscribe    int
-	UserType     int
-	MergeOrder   interface{}
-	//
-	//Active int
-	//Fail   *Fail //失败重试
-}
-
-type Fail struct {
-	Wx    int
-	App   int
-	Email int
-}
-
-type taskConfig struct {
-	StartTime string `json:"startTime"`
-	LastId    string `json:"lastId"`
-}
-
-var (
-	Gmails       chan *mail.GmailAuth
-	Gmail        *mail.GmailAuth
-	Se           = util.SimpleEncrypt{Key: "topnet"}
-	Re           = regexp.MustCompile("<[^>]+>([^<]+)?<[^>]+>")
-	SysConfig    *sysConfig
-	TaskConfig   *taskConfig
-	WxContentLen int
-)
-
-func init() {
-	//html过滤
-	util.ReadConfig("./config.json", &SysConfig)
-	util.ReadConfig("./task.json", &TaskConfig)
-	//
-	WxContentLen = len([]rune(SysConfig.WxContent))
-	//Gmails = make(chan *mail.GmailAuth, len(SysConfig.Mails))
-	for _, v := range SysConfig.Mails {
-		Gmail = &mail.GmailAuth{
-			SmtpHost: v.Addr,
-			SmtpPort: v.Port,
-			User:     v.User,
-			Pwd:      v.Pwd,
-			PoolSize: SysConfig.MailPollSize,
-			ReTry:    SysConfig.MailReTry,
-		}
-		break
-	}
-}

+ 0 - 142
src/jfw/modules/push_v1/src/push/dfa/interestanalysis.go

@@ -1,142 +0,0 @@
-/**
- *兴趣分析
- *
- */
-package dfa
-
-import (
-	"log"
-	"strings"
-)
-
-//DFA实现
-type DFA struct {
-	link        map[string]interface{} //存放or
-	linkAnd     map[string]int         //存放and
-	linkAndWord map[string]interface{} //存放and中的拆分词
-
-}
-
-//添加词组,用于初始化,该方法是可以调用多次的
-func (d *DFA) AddWord(words ...string) {
-	if d.link == nil {
-		d.link = make(map[string]interface{})
-		d.linkAnd = make(map[string]int)
-		d.linkAndWord = make(map[string]interface{})
-	}
-	var nowMap *map[string]interface{}
-	for _, key := range words {
-		keys := strings.Split(key, "+")
-		lenkeys := len(keys)
-		if lenkeys > 1 {
-			d.linkAnd[key] = lenkeys
-			for k := 0; k < lenkeys; k++ {
-				minKey := keys[k]
-				nowMap = &d.linkAndWord
-				for i := 0; i < len(minKey); i++ {
-					kc := minKey[i : i+1]
-					if v, ok := (*nowMap)[kc]; ok {
-						nowMap, _ = v.(*map[string]interface{})
-					} else {
-						newMap := map[string]interface{}{}
-						newMap["YN"] = "N"
-						(*nowMap)[kc] = &newMap
-						nowMap = &newMap
-					}
-					if i == len(minKey)-1 {
-						(*nowMap)["YN"] = "Y"
-						if (*nowMap)["key"] == nil {
-							(*nowMap)["key"] = make(map[string]int)
-						}
-						(*nowMap)["key"].(map[string]int)[key] = k
-					}
-				}
-			}
-		} else {
-			nowMap = &d.link
-			for i := 0; i < len(key); i++ {
-				kc := key[i : i+1]
-				if v, ok := (*nowMap)[kc]; ok {
-					nowMap, _ = v.(*map[string]interface{})
-				} else {
-					newMap := map[string]interface{}{}
-					newMap["YN"] = "N"
-					(*nowMap)[kc] = &newMap
-					nowMap = &newMap
-				}
-
-				if i == len(key)-1 {
-					(*nowMap)["YN"] = "Y"
-				}
-			}
-		}
-	}
-}
-func (d *DFA) Clear() {
-	d.link = nil
-}
-
-//从给定的内容中找出匹配上的关键词
-func (d *DFA) Analy(src string) []string {
-	if d.link == nil {
-		log.Println("请先添加词组")
-		return []string{}
-	}
-	keywords := []string{}
-	tempMap := make(map[string][]bool)
-	for i := 0; i < len(src); i++ {
-		nowMap := &d.link
-		length := 0 // 匹配标识数默认为0
-		//flag := false // 敏感词结束标识位:用于敏感词只有1位的情况
-		for j := i; j < len(src); j++ {
-			word := src[j : j+1]
-			nowMap, _ = (*nowMap)[word].(*map[string]interface{})
-			if nowMap != nil {
-				length = length + 1
-				tag, _ := (*nowMap)["YN"].(string)
-				if "Y" == tag {
-					//flag = true
-					keywords = append(keywords, src[i:i+length])
-				}
-			} else {
-				break
-			}
-		}
-		nowMap = &d.linkAndWord
-		length = 0
-		for j := i; j < len(src); j++ {
-			word := src[j : j+1]
-			nowMap, _ = (*nowMap)[word].(*map[string]interface{})
-			if nowMap != nil {
-				length = length + 1
-				tag, _ := (*nowMap)["YN"].(string)
-				if "Y" == tag {
-					mkeys := (*nowMap)["key"].(map[string]int)
-					for k, v := range mkeys {
-						tempBool := tempMap[k]
-						if tempBool == nil {
-							tempBool = make([]bool, d.linkAnd[k])
-							tempMap[k] = tempBool
-						}
-						tempBool[v] = true
-					}
-				}
-			} else {
-				break
-			}
-		}
-	}
-	for k, v := range tempMap {
-		ball := true
-		for _, m := range v {
-			if !m {
-				ball = false
-				break
-			}
-		}
-		if ball {
-			keywords = append(keywords, k)
-		}
-	}
-	return keywords
-}

+ 0 - 45
src/jfw/modules/push_v1/src/push/dfa/interestanalysis_test.go

@@ -1,45 +0,0 @@
-package dfa
-
-import (
-	"log"
-	"strings"
-	"testing"
-	"time"
-)
-
-var d *DFA = &DFA{}
-
-func copyMap(m map[string]int) (m2 map[string]int) {
-	m2 = make(map[string]int)
-	for k, v := range m {
-		m2[k] = v
-	}
-	return m2
-}
-
-func TestAnaly(t *testing.T) {
-	d.AddWord("办公", "办+楼", "河+省", "完+你们8")
-	log.Println(strings.Split("河+南+", "+")[2])
-	t1 := time.Now()
-	log.Println(d.Analy("这胡省锦河涛写给江泽民的信我们你们于办公楼上你完就是啊。"), "=====")
-	log.Println(time.Now().Sub(t1).Seconds())
-	d.Clear()
-	//log.Println(d.Analy("这是胡锦涛写给江泽民的信啊。"))
-
-}
-
-func Test_Label(t *testing.T) {
-	log.Println("000----")
-
-	for _, v := range []int{1, 2, 3, 4, 5} {
-		log.Println(v)
-	L1:
-		for _, vv := range []string{"a", "b", "c", "d"} {
-			log.Println(vv)
-			if vv == "add" {
-				break L1
-			}
-		}
-	}
-	log.Println("111----")
-}

+ 0 - 93
src/jfw/modules/push_v1/src/push/dopush/excel.go

@@ -1,93 +0,0 @@
-package dopush
-
-import (
-	"fmt"
-	"log"
-	"math/rand"
-	"os"
-	qu "qfw/util"
-	"time"
-
-	"github.com/tealeg/xlsx"
-)
-
-var Sheets = map[int]xlsx.Sheet{}
-
-func init() {
-	fx, err := xlsx.OpenFile("./xlsx/temp.xlsx")
-	if err != nil {
-		log.Println(err.Error())
-		os.Exit(0)
-	}
-	for k, st := range fx.Sheets {
-		Sheets[k] = *st
-	}
-}
-func GetBidInfoXlsx(data []map[string]interface{}) (fnamepath, rename string) {
-	fx := xlsx.NewFile()
-	sheet := Sheets[0]
-	style := xlsx.NewStyle()
-	style.Alignment.WrapText = true
-	//信息
-	for _, v := range data {
-		row := sheet.AddRow()
-
-		projectname := qu.ObjToString(v["projectname"])
-		if projectname == "" {
-			projectname = qu.ObjToString(v["title"])
-		}
-		cell := row.AddCell()
-		cell.SetValue(projectname)
-		cell.SetStyle(style)
-
-		cell = row.AddCell()
-		cell.SetValue(v["subtype"])
-
-		budget := qu.Float64All(v["budget"]) / float64(10000)
-		cell = row.AddCell()
-		if budget != 0 {
-			cell.SetValue(budget)
-		} else {
-			cell.SetValue("")
-		}
-
-		cell = row.AddCell()
-		cell.SetValue(v["buyer"])
-		cell.SetStyle(style)
-
-		bpt := v["bidopentime"]
-		bidopentime := qu.FormatDateWithObj(&bpt, "2006-01-02 15:04")
-		cell = row.AddCell()
-		cell.SetValue(bidopentime)
-
-		cell = row.AddCell()
-		cell.SetValue(v["winner"])
-		cell.SetStyle(style)
-
-		bidamount := qu.Float64All(v["bidamount"]) / float64(10000)
-		cell = row.AddCell()
-		if bidamount != 0 {
-			cell.SetValue(bidamount)
-		} else {
-			cell.SetValue("")
-		}
-
-		pt := v["publishtime"]
-		publishtime := qu.FormatDateWithObj(&pt, qu.Date_Short_Layout)
-		cell = row.AddCell()
-		cell.SetValue(publishtime)
-	}
-	fx.AppendSheet(sheet, "剑鱼标讯")
-
-	t := time.Now()
-	rename = "剑鱼标讯_" + t.Format("2006-01-02") + "_推送信息表.xlsx"
-	fnamepath = "./xlsx/" + t.Format("20060102150405") + fmt.Sprint(rand.Intn(10000)) + ".xlsx"
-
-	err := fx.Save(fnamepath)
-	//log.Println("err", err)
-	if err != nil {
-		return "", ""
-	} else {
-		return fnamepath, rename
-	}
-}

+ 0 - 52
src/jfw/modules/push_v1/src/push/dopush/job.go

@@ -1,52 +0,0 @@
-package dopush
-
-import (
-	"push/config"
-	"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"`
-	FindField      = `"title"`
-	SmartFindField = `"title","projectscope"`
-	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}`
-	Infoformat     = `{"term":{"infoformat":%d}}`
-	FilterQuery    = `{"query":{"filtered":{"filter":{"bool":{"must":[%s]}}}}}`
-	//
-	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 {
-	MySelf() interface{}
-	Execute(taskType int, isMove bool)
-}
-
-type jobs struct {
-	Match Job
-	Nine  Job
-	Push  Job
-}
-
-var Jobs = &jobs{
-	Push: &PushJob{
-		pushPool:    make(chan bool, config.SysConfig.PushPoolSize),
-		pushWait:    &sync.WaitGroup{},
-		pushJobLock: &sync.Mutex{},
-	},
-	Match: &MatchJob{
-		datas:             &[]map[string]interface{}{},
-		users:             &map[string]*config.MemberInterest{},
-		matchPool:         make(chan bool, config.SysConfig.MatchPoolSize),
-		eachInfoWaitGroup: &sync.WaitGroup{},
-		saveWaitGroup:     &sync.WaitGroup{},
-		userMapLock:       &sync.Mutex{},
-		saveBatch:         []map[string]interface{}{},
-	},
-}

+ 0 - 632
src/jfw/modules/push_v1/src/push/dopush/matchjob.go

@@ -1,632 +0,0 @@
-package dopush
-
-import (
-	"container/list"
-	"encoding/json"
-	"fmt"
-	. "push/config"
-	"push/dfa"
-	putil "push/util"
-	"qfw/util"
-	"qfw/util/elastic"
-	"qfw/util/mongodb"
-	"regexp"
-	"sort"
-	"strings"
-	"sync"
-	"time"
-
-	"github.com/donnie4w/go-logger/logger"
-	"gopkg.in/mgo.v2/bson"
-)
-
-var (
-	SaveFields        = []string{"_id", "area", "bidamount", "bidopentime", "budget", "buyer", "otitle", "projectname", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "winner"}
-	MoveLock          = &sync.Mutex{}
-	messyCodeEmailReg = regexp.MustCompile(SysConfig.MessyCodeEmailReg)
-)
-
-type sortList []*MatchInfo
-
-func (s sortList) Len() int {
-	return len(s)
-}
-
-func (s sortList) Less(i, j int) bool {
-	defer util.Catch()
-	return util.Int64All((*s[i].Info)["publishtime"]) > util.Int64All((*s[j].Info)["publishtime"])
-}
-
-func (s sortList) Swap(i, j int) {
-	defer util.Catch()
-	s[i], s[j] = s[j], s[i]
-}
-
-type Pjob struct {
-	InterestDfa    *dfa.DFA
-	NotInterestDfa *dfa.DFA
-	Key_user       *map[string]*[]*MemberInterest
-	Notkey_user    *map[string]*[]*MemberInterest
-}
-
-//所有用户的关键词和排除词
-func (p *Pjob) CreateDaf() {
-	//关键词
-	p.InterestDfa = &dfa.DFA{}
-	interestWords := make([]string, 0)
-	for k, _ := range *p.Key_user {
-		interestWords = append(interestWords, k)
-	}
-	p.InterestDfa.AddWord(interestWords...)
-	//排除关键词
-	p.NotInterestDfa = &dfa.DFA{}
-	notInterestWords := make([]string, 0)
-	for k, _ := range *p.Notkey_user {
-		notInterestWords = append(notInterestWords, k)
-	}
-	p.NotInterestDfa.AddWord(notInterestWords...)
-}
-
-type MatchInfo struct {
-	Info *map[string]interface{}
-	Keys []string
-}
-
-type MatchUser struct {
-	User *MemberInterest
-	Keys []string
-}
-type MatchJob struct {
-	datas             *[]map[string]interface{}   //本次加载的数据
-	users             *map[string]*MemberInterest //所有用户
-	matchPool         chan bool
-	eachInfoWaitGroup *sync.WaitGroup
-	saveWaitGroup     *sync.WaitGroup
-	userMapLock       *sync.Mutex
-	lastUserId        string
-	saveBatch         []map[string]interface{}
-}
-
-func (m *MatchJob) MySelf() interface{} {
-	return m
-}
-
-//定时任务,匹配数据,存库
-func (m *MatchJob) Execute(taskType int, flag bool) {
-	defer util.Catch()
-	st, _ := time.ParseInLocation(util.Date_Full_Layout, TaskConfig.StartTime, time.Local)
-	lastTime := st.Unix()
-	_id := util.ObjToString(TaskConfig.LastId)
-	logger.Info("开始匹配数据任务。。。", _id, lastTime)
-	//获取本次查询的最大id
-	idQuery := ""
-	if _id == "" {
-		idQuery = strings.Replace(fmt.Sprintf(MaxId, _id), `"gt"`, `"gte"`, -1)
-	} else {
-		idQuery = fmt.Sprintf(MaxId, _id)
-	}
-	resId := elastic.Get(DB, DB, idQuery)
-	lastid := ""
-	var comeintime interface{}
-	if resId != nil && *resId != nil && len(*resId) == 1 {
-		lastid = util.ObjToString((*resId)[0]["_id"])
-		comeintime = (*resId)[0]["comeintime"]
-	} else {
-		logger.Info("匹配数据,获取本次查询的最大id的时候,未查找到数据!", idQuery)
-		return
-	}
-	if !m.LoadBidding(_id, lastid, lastTime) {
-		logger.Info("匹配数据,加载数据到内存中的时候,未查找到数据!")
-		return
-	}
-	MoveLock.Lock()
-	defer MoveLock.Unlock()
-	m.lastUserId = ""
-	user_batch_index := 0
-	for {
-		user_batch_index++
-		user_batch_size := m.OnceUserBatch(user_batch_index)
-		if user_batch_size == 0 {
-			break
-		}
-		a_key_user := make(map[string]*[]*MemberInterest)
-		a_notkey_user := make(map[string]*[]*MemberInterest)
-		//开启智能订阅的用户
-		s_key_user := make(map[string]*[]*MemberInterest)
-		s_notkey_user := make(map[string]*[]*MemberInterest)
-		for _, v := range *m.users {
-			m.MakeKeyUser(v.Keys, v, &a_key_user)
-			m.MakeKeyUser(v.NotKeys, v, &a_notkey_user)
-			if v.SmartSet == 1 {
-				m.MakeKeyUser(v.Keys, v, &s_key_user)
-				m.MakeKeyUser(v.NotKeys, v, &s_notkey_user)
-			}
-		}
-		m.ToMatch(user_batch_index, a_key_user, a_notkey_user, s_key_user, s_notkey_user)
-		if user_batch_size < SysConfig.UserBatch {
-			break
-		}
-	}
-	//
-	logger.Info("匹配数据任务结束。。。", lastid, comeintime)
-	//
-	TaskConfig.LastId = lastid
-	TaskConfig.StartTime = util.FormatDateWithObj(&comeintime, util.Date_Full_Layout)
-	m.datas = &[]map[string]interface{}{}
-	m.users = &map[string]*MemberInterest{}
-}
-func (m *MatchJob) ToMatch(batchIndex int, a_key_user, a_notkey_user, s_key_user, s_notkey_user map[string]*[]*MemberInterest) {
-	logger.Info("匹配数据任务,开始匹配第", batchIndex, "批用户")
-	a_p := &Pjob{
-		Key_user:    &a_key_user,
-		Notkey_user: &a_notkey_user,
-	}
-	a_p.CreateDaf()
-	//
-	s_p := &Pjob{
-		Key_user:    &s_key_user,
-		Notkey_user: &s_notkey_user,
-	}
-	s_p.CreateDaf()
-	m.Save(a_p, s_p)
-	a_key_user = make(map[string]*[]*MemberInterest)
-	a_notkey_user = make(map[string]*[]*MemberInterest)
-	//开启智能订阅的用户
-	s_key_user = make(map[string]*[]*MemberInterest)
-	s_notkey_user = make(map[string]*[]*MemberInterest)
-	logger.Info("匹配数据任务,第", batchIndex, "批用户匹配结束")
-}
-func (m *MatchJob) Save(a_p, s_p *Pjob) {
-	logger.Info("匹配数据任务,开始保存到pushmail_temp表")
-	userMap := m.EachAllBidInfo(a_p, s_p)
-	//加锁,保存数据和转移数据不能同时进行
-	index := 0
-	for openid, listInfos := range *userMap {
-		var pushArray = make(sortList, 0)
-		for e := listInfos.Front(); e != nil; e = e.Next() {
-			matchInfo := *(e.Value.(*MatchInfo))
-			pushArray = append(pushArray, &matchInfo)
-		}
-		//取最新50条
-		sort.Sort(pushArray)
-		var array []*MatchInfo
-		size := 0
-		for _, v2 := range pushArray {
-			size++
-			info := map[string]interface{}{}
-			for _, field := range SaveFields {
-				if (*v2.Info)[field] == nil {
-					continue
-				}
-				info[field] = (*v2.Info)[field]
-			}
-			array = append(array, &MatchInfo{
-				Info: &info,
-				Keys: v2.Keys,
-			})
-			if len(array) == SysConfig.MaxPushSize {
-				break
-			}
-		}
-		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(),
-		})
-		if len(m.saveBatch) == BulkSize {
-			mongodb.SaveBulk("pushspace_temp", m.saveBatch...)
-			m.saveBatch = []map[string]interface{}{}
-		}
-		index++
-		if index%500 == 0 {
-			logger.Info("匹配数据任务,保存到pushmail_temp表", index)
-		}
-	}
-	if len(m.saveBatch) > 0 {
-		mongodb.SaveBulk("pushspace_temp", m.saveBatch...)
-		m.saveBatch = []map[string]interface{}{}
-	}
-	logger.Info("匹配数据任务,保存到pushmail_temp表结束", index)
-}
-
-//加载数据到内存中
-func (m *MatchJob) LoadBidding(_id, lastid string, lastTime int64) bool {
-	defer util.Catch()
-	c_query := map[string]interface{}{
-		"publishtime": map[string]interface{}{
-			"$gt": lastTime - 7*86400,
-		},
-		"extracttype": 1,
-	}
-	idQuery := map[string]interface{}{}
-	if _id != "" {
-		idQuery["$gt"] = bson.ObjectIdHex(_id)
-	}
-	if lastid != "" {
-		idQuery["$lte"] = bson.ObjectIdHex(lastid)
-	}
-	if len(idQuery) > 0 {
-		c_query["_id"] = idQuery
-	}
-	logger.Info("匹配数据任务,mongodb query:", c_query)
-	count := mongodb.Count("bidding", c_query)
-	logger.Info("匹配数据任务,本次数据共", count, "条")
-	if count == 0 {
-		return false
-	}
-	if count > SysConfig.MaxSearch {
-		count = SysConfig.MaxSearch
-		logger.Info("匹配数据任务,目前数据多于", SysConfig.MaxSearch, ",只加载了", SysConfig.MaxSearch, "条!")
-	}
-	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()
-	index := 0
-	for tmp := make(map[string]interface{}); it.Next(&tmp); {
-		index++
-		tmp["_id"] = util.BsonIdToSId(tmp["_id"])
-		res = append(res, tmp)
-		if index%500 == 0 {
-			logger.Info("匹配数据任务,当前加载数据:", index)
-		}
-		tmp = make(map[string]interface{})
-		if index >= count {
-			break
-		}
-	}
-	m.datas = &res
-	logger.Info("匹配数据任务,", count, "条数据已经加载完成!")
-	return true
-}
-
-//初始化用户缓存
-func (m *MatchJob) OnceUserBatch(user_batch_index int) int {
-	defer util.Catch()
-	m.users = &map[string]*MemberInterest{}
-	//遍历用户
-	q := map[string]interface{}{
-		"i_appid": 2,
-	}
-	_idq := map[string]interface{}{}
-	if len(SysConfig.TestIds) > 0 {
-		_idq["$in"] = putil.ToObjectIds(SysConfig.TestIds)
-	}
-	if m.lastUserId != "" {
-		_idq["$gt"] = bson.ObjectIdHex(m.lastUserId)
-	}
-	if len(_idq) > 0 {
-		q["_id"] = _idq
-	}
-	logger.Info("匹配数据任务,开始加载第", user_batch_index, "批用户", q)
-	session := mongodb.GetMgoConn()
-	defer mongodb.DestoryMongoConn(session)
-	query := session.DB(DbName).C("user").Find(&q).Select(&map[string]interface{}{
-		"_id":           1,
-		"o_jy":          1,
-		"s_m_openid":    1,
-		"a_m_openid":    1,
-		"s_phone":       1,
-		"s_jpushid":     1,
-		"s_opushid":     1,
-		"i_ispush":      1,
-		"i_dataexport":  1,
-		"i_type":        1,
-		"i_smartset":    1,
-		"i_supersearch": 1,
-		"s_appponetype": 1,
-		"i_applystatus": 1,
-		"a_mergeorder":  1,
-	}).Iter()
-	n := 0
-	for temp := make(map[string]interface{}); query.Next(temp); {
-		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"])
-		userType := putil.GetUserType(s_m_openid, a_m_openid, s_phone, util.IntAllDef(temp["i_type"], 0))
-		isPush := util.IntAllDef(temp["i_ispush"], 1)
-		//公众号取关用户,后面还有pc助手推送,暂时不过滤app用户
-		if userType == 0 && isPush == 0 {
-			continue
-		}
-		applystatus := util.IntAll(temp["i_applystatus"])
-		o_msgset, _ := temp["o_jy"].(map[string]interface{})
-		wxpush, apppush, mailpush := putil.ModeTransform(userType, o_msgset)
-		jpushid := util.ObjToString(temp["s_jpushid"])
-		opushid := util.ObjToString(temp["s_opushid"])
-		var allkeysTemp []elastic.KeyConfig
-		_bs, err := json.Marshal(o_msgset["a_key"])
-		if err == nil {
-			json.Unmarshal(_bs, &allkeysTemp)
-		}
-		allkeys := []elastic.KeyConfig{}
-		if len(allkeysTemp) > 0 {
-			//一个字或者配置文件中的词,不推送
-			for _, vs := range allkeysTemp {
-				isFilter := false
-				vskey := strings.Replace(strings.Join(vs.Keys, ""), " ", "", -1)
-				if len([]rune(vskey)) == 1 {
-					continue
-				}
-				for _, fv := range SysConfig.FilterWords {
-					if fv == vskey {
-						isFilter = true
-						break
-					}
-				}
-				if !isFilter {
-					allkeys = append(allkeys, vs)
-				}
-			}
-		}
-		////////////////
-		if len(allkeys) == 0 {
-			continue
-		}
-		userId := fmt.Sprintf("%x", string(temp["_id"].(bson.ObjectId)))
-		logger.Info("匹配数据任务,第", user_batch_index, "批用户,userid", userId, "s_m_openid", s_m_openid, "a_m_openid", a_m_openid, "s_phone", s_phone, "jpushid", jpushid, "opushid", opushid, "applystatus", applystatus)
-		keys := []string{}                           //过滤后的关键词
-		notkeys := []string{}                        //排除词
-		key_notkey := map[string]map[string]bool{}   //关键词所对应的排除词
-		key_area := map[string]map[string]bool{}     //关键词所对应的信息范围
-		key_infotype := map[string]map[string]bool{} //关键词所对应的信息类型
-		for _, vs := range allkeys {
-			key := strings.Join(vs.Keys, "+")
-			keys = append(keys, key)
-			notkeys = append(notkeys, vs.NotKeys...)
-			//转大写
-			keyTemp := strings.ToUpper(key)
-			//建立与排除词的对应关系
-			for _, notkey := range vs.NotKeys {
-				notkeyTemp := strings.ToUpper(notkey)
-				if key_notkey[keyTemp] == nil {
-					key_notkey[keyTemp] = map[string]bool{}
-				}
-				key_notkey[keyTemp][notkeyTemp] = true
-			}
-			//建立与信息范围的对应关系
-			for _, area := range vs.Areas {
-				if key_area[keyTemp] == nil {
-					key_area[keyTemp] = map[string]bool{}
-				}
-				key_area[keyTemp][area] = true
-			}
-			//建立与信息类型的对应关系
-			for _, infotype := range vs.InfoTypes {
-				if key_infotype[keyTemp] == nil {
-					key_infotype[keyTemp] = map[string]bool{}
-				}
-				key_infotype[keyTemp][infotype] = true
-			}
-		}
-		//
-		keysTemp := []string{} //原始关键词
-		for _, vs := range allkeysTemp {
-			keysTemp = append(keysTemp, strings.Join(vs.Keys, "+"))
-		}
-		smartset := util.IntAllDef(temp["i_smartset"], 0)
-		modifydate := ""
-		md, _ := o_msgset["l_modifydate"].(int64)
-		if md > 0 {
-			modifydate = util.FormatDateByInt64(&md, util.Date_Short_Layout)
-		}
-		if modifydate == "" {
-			now := time.Now()
-			modifydate = util.FormatDate(&now, util.Date_Short_Layout)
-		}
-		user := &MemberInterest{
-			Id:           userId,
-			OriginalKeys: keysTemp,
-			Keys:         keys, //原始关键词
-			NotKeys:      notkeys,
-			Key_notkey:   key_notkey,
-			Key_area:     key_area,
-			Key_infotype: key_infotype,
-			WxPush:       wxpush,
-			AppPush:      apppush,
-			MailPush:     mailpush,
-			Email:        util.ObjToString(o_msgset["s_email"]),
-			S_m_openid:   s_m_openid,
-			A_m_openid:   a_m_openid,
-			Phone:        s_phone,
-			Jpushid:      jpushid,
-			Opushid:      opushid,
-			UserType:     userType,
-			RateMode:     util.IntAllDef(o_msgset["i_ratemode"], 2),
-			AllKeys:      allkeysTemp, //原始关键词
-			SmartSet:     smartset,
-			DataExport:   util.IntAllDef(temp["i_dataexport"], 0),
-			ModifyDate:   modifydate,
-			AppPhoneType: util.ObjToString(temp["s_appponetype"]),
-			ApplyStatus:  applystatus,
-			Subscribe:    isPush,
-			MergeOrder:   temp["a_mergeorder"],
-		}
-		(*m.users)[user.Id] = user
-		m.lastUserId = user.Id
-		temp = make(map[string]interface{})
-		n++
-		if n == SysConfig.UserBatch {
-			break
-		}
-	}
-	logger.Info("匹配数据任务,第", user_batch_index, "批用户加载结束", n)
-	return n
-}
-
-//把用户挂在词下面
-func (m *MatchJob) MakeKeyUser(keys []string, user *MemberInterest, key_user *map[string]*[]*MemberInterest) {
-	mp := map[string]bool{}
-	for _, key := range keys {
-		v := strings.ToUpper(key)
-		if v == "" || mp[v] {
-			continue
-		}
-		mp[v] = true
-		var arr *[]*MemberInterest
-		if nil == (*key_user)[v] {
-			arr = &[]*MemberInterest{}
-			(*key_user)[v] = arr
-		} else {
-			arr = (*key_user)[v]
-			(*key_user)[v] = arr
-		}
-		*arr = append(*arr, user)
-	}
-}
-
-//遍历数据并执行推送操作
-func (m *MatchJob) EachAllBidInfo(a_p *Pjob, s_p *Pjob) *map[string]*list.List {
-	defer util.Catch()
-	logger.Info("匹配数据任务,开始遍历数据。。。")
-	userMap := &map[string]*list.List{}
-	var count int
-	for _, temp := range *m.datas {
-		m.matchPool <- true
-		m.eachInfoWaitGroup.Add(1)
-		count++
-		go func(info map[string]interface{}) {
-			defer func() {
-				m.eachInfoWaitGroup.Done()
-				<-m.matchPool
-			}()
-			title := util.ObjToString(info["title"])
-			if title == "" {
-				return
-			}
-			titleTemp := strings.ToUpper(title)
-			area := util.ObjToString(info["area"])
-			toptype := util.ObjToString(info["toptype"])
-			//订阅词
-			keys := a_p.InterestDfa.Analy(titleTemp)
-			//排除词
-			notkeys := a_p.NotInterestDfa.Analy(titleTemp)
-			users := m.GetFinalUser(keys, notkeys, a_p.Key_user, area, toptype, true)
-			//开启智能匹配的用户,匹配projectscope
-			if s_p != nil {
-				projectscope := util.ObjToString(info["projectscope"])
-				if projectscope == "" {
-					projectscope = util.ObjToString(info["detail"])
-				}
-				if projectscope != "" {
-					projectscopeTemp := strings.ToUpper(projectscope)
-					keys = s_p.InterestDfa.Analy(projectscopeTemp)
-					notkeys = s_p.NotInterestDfa.Analy(projectscopeTemp)
-					s_users := m.GetFinalUser(keys, notkeys, s_p.Key_user, area, toptype, false)
-					for _, s_u := range *s_users {
-						if (*users)[s_u.User.Id] != nil {
-							continue
-						}
-						(*users)[s_u.User.Id] = s_u
-					}
-				}
-			}
-			if len(*users) > 0 {
-				m.EachInfoToUser(users, &info, userMap)
-			}
-		}(temp)
-		if count%500 == 0 {
-			logger.Info("匹配数据任务,当前信息索引:", count)
-		}
-	}
-	m.eachInfoWaitGroup.Wait()
-	logger.Info("匹配数据任务,数据遍历完成!")
-	return userMap
-}
-
-//获取最终的用户,排除词、信息范围、信息类型之后的
-//返回匹配上的用户和没有匹配到的用户
-func (m *MatchJob) GetFinalUser(keys, notkeys []string, key_user *map[string]*[]*MemberInterest, area, toptype string, flag bool) *map[string]*MatchUser {
-	keyMap := map[string]bool{}
-	for _, v := range keys {
-		keyMap[v] = true
-	}
-	y_users := map[string]*MatchUser{} //匹配到用户
-	//遍历所有用户
-	for k, us := range *key_user {
-		if !keyMap[k] { //改关键词没有匹配到的用户
-			continue
-		}
-		for _, u := range *us {
-			//获取该词下面所有的用户
-			//遍历我的排除词,如果存在的话,排除自己
-			isContinue := false
-			for _, notkey := range notkeys {
-				if u.Key_notkey[k][notkey] {
-					isContinue = true
-					break
-				}
-			}
-			if isContinue {
-				continue
-			}
-			//遍历我的信息范围,看该信息是不是在我的信息范围中
-			if len(u.Key_area[k]) > 0 && !u.Key_area[k][area] {
-				continue
-			}
-			//遍历我的信息类型,看该信息是不是在我的信息类型中
-			if len(u.Key_infotype[k]) > 0 && !u.Key_infotype[k][toptype] {
-				continue
-			}
-			matchUser := y_users[u.Id]
-			if matchUser == nil {
-				matchUser = &MatchUser{
-					User: u,
-					Keys: []string{},
-				}
-			}
-			matchUser.Keys = append(matchUser.Keys, k)
-			y_users[u.Id] = matchUser
-		}
-	}
-	//获取最终没有匹配到的用户,进行正文或者范围匹配
-	users := map[string]*MatchUser{}
-	for k, v := range *m.users {
-		if y_users[k] == nil {
-			continue
-		}
-		users[v.Id] = &MatchUser{
-			User: v,
-			Keys: y_users[k].Keys,
-		}
-	}
-	return &users
-}
-
-//遍历用户加入到此条信息上
-func (m *MatchJob) EachInfoToUser(users *map[string]*MatchUser, info *map[string]interface{}, userMap *map[string]*list.List) {
-	defer m.userMapLock.Unlock()
-	m.userMapLock.Lock()
-	for k, v := range *users {
-		l := (*userMap)[k]
-		if l == nil {
-			l = list.New()
-		}
-		l.PushBack(&MatchInfo{
-			Info: info,
-			Keys: v.Keys,
-		})
-		(*userMap)[k] = l
-	}
-}

+ 0 - 782
src/jfw/modules/push_v1/src/push/dopush/pushjob.go

@@ -1,782 +0,0 @@
-package dopush
-
-import (
-	"encoding/json"
-	"fmt"
-	"os"
-	. "push/config"
-	putil "push/util"
-	"qfw/util"
-	"qfw/util/mail"
-	"qfw/util/mongodb"
-	"sort"
-	"strconv"
-	"strings"
-	"sync"
-	"time"
-
-	"github.com/donnie4w/go-logger/logger"
-	mgo "gopkg.in/mgo.v2"
-	"gopkg.in/mgo.v2/bson"
-)
-
-var (
-	MoveFields = []string{"s_m_openid", "a_m_openid", "phone", "usertype", "jpushid", "opushid", "words", "ratemode", "wxpush", "apppush", "mailpush", "smartset", "timestamp", "subscribe", "applystatus", "appphonetype", "email", "size", "modifydate", "mergeorder"}
-)
-
-func init() {
-	mySelf := Jobs.Push.MySelf().(*PushJob)
-	//推送1分钟限制
-	mySelf.minutePushPool = make(chan bool, SysConfig.MinutePushSize)
-	mySelf.fastigiumMinutePushPool = make(chan bool, SysConfig.FastigiumMinutePushSize)
-	for i := 0; i < SysConfig.MinutePushSize; i++ {
-		mySelf.minutePushPool <- true
-	}
-	for i := 0; i < SysConfig.FastigiumMinutePushSize; i++ {
-		mySelf.fastigiumMinutePushPool <- true
-	}
-	go func() {
-		t := time.NewTicker(time.Minute)
-		for {
-			select {
-			case <-t.C:
-				for i := 0; i < SysConfig.MinutePushSize-len(mySelf.minutePushPool); i++ {
-					mySelf.minutePushPool <- true
-				}
-				for i := 0; i < SysConfig.FastigiumMinutePushSize-len(mySelf.fastigiumMinutePushPool); i++ {
-					mySelf.fastigiumMinutePushPool <- true
-				}
-			}
-		}
-	}()
-}
-
-type PushJob struct {
-	pushPool                chan bool
-	minutePushPool          chan bool
-	fastigiumMinutePushPool chan bool
-	pushWait                *sync.WaitGroup
-	pushJobLock             *sync.Mutex
-	lastId                  string
-	pushDatas               *[]map[string]interface{}
-}
-
-func (p *PushJob) MySelf() interface{} {
-	return p
-}
-
-//taskType 1--实时推送 2--实时推送+一天三次的8点推送 3--一天三次推送 4--九点推送
-func (p *PushJob) Execute(taskType int, isMoveDatas bool) {
-	p.pushJobLock.Lock()
-	defer p.pushJobLock.Unlock()
-	logger.Info("开始推送任务。。。", taskType)
-	if isMoveDatas {
-		p.Move()
-	}
-	p.Push(taskType)
-}
-func (p *PushJob) Move() {
-	logger.Info("推送任务,开始迁移数据。。。")
-	MoveLock.Lock()
-	defer MoveLock.Unlock()
-	sess := mongodb.GetMgoConn()
-	defer mongodb.DestoryMongoConn(sess)
-	it := sess.DB(DbName).C("pushspace_temp").Find(nil).Sort("_id").Iter()
-	_index := 0
-	pushspace_temp := map[string]map[string]interface{}{}
-	logger.Info("推送任务,开始把pushspace_temp表的数据加载到内存中")
-	for _temp := make(map[string]interface{}); it.Next(&_temp); {
-		userId := util.ObjToString(_temp["userid"])
-		if pushspace_temp[userId] != nil {
-			oldList, _ := pushspace_temp[userId]["list"].([]interface{})
-			newList, _ := _temp["list"].([]interface{})
-			oldList = append(oldList, newList...)
-			if len(oldList) > SysConfig.MaxPushSize {
-				_temp["list"] = oldList[:SysConfig.MaxPushSize]
-			}
-		}
-		pushspace_temp[userId] = _temp
-		_temp = make(map[string]interface{})
-		_index++
-		if _index%500 == 0 {
-			logger.Info("推送任务,pushspace_temp表的数据加载到内存中:", index)
-		}
-	}
-	logger.Info("推送任务,pushspace_temp表的数据加载完成")
-	index := 0
-	saveArray := []map[string]interface{}{}
-	updateArray_d := []map[string]interface{}{}
-	updateArray_q := []map[string]interface{}{}
-	updateArray_s := []map[string]interface{}{}
-	for userId, temp := range pushspace_temp {
-		var data map[string]interface{}
-		sess.DB(DbName).C("pushspace").Find(map[string]interface{}{"userid": userId}).Select(map[string]interface{}{"list": 1, "templist": 1}).One(&data)
-		if data == nil { //批量新增
-			saveArray = append(saveArray, temp)
-			if len(saveArray) == BulkSize {
-				p.SaveBulk(sess, &saveArray)
-			}
-		} else { //批量更新
-			setMap := map[string]interface{}{}
-			for _, field := range MoveFields {
-				if temp[field] == nil {
-					continue
-				}
-				setMap[field] = temp[field]
-			}
-			//
-			list_temp, _ := temp["list"].([]interface{})
-			pLength := len(list_temp)
-			pushAll := make(map[string]interface{})
-			for _, v := range []string{"", "temp"} {
-				list, _ := data[v+"list"].([]interface{})
-				rLength := len(list)
-				if v == "temp" && rLength == 0 {
-					continue
-				}
-				if rLength > 0 && rLength+pLength > SysConfig.MaxPushSize {
-					relationinfoTemp := []interface{}{}
-					relationinfoTemp = append(relationinfoTemp, list_temp...)
-					relationinfoTemp = append(relationinfoTemp, list...)
-					if len(relationinfoTemp) > SysConfig.MaxPushSize {
-						relationinfoTemp = relationinfoTemp[:]
-					}
-					setMap[v+"list"] = relationinfoTemp
-					setMap[v+"size"] = SysConfig.MaxPushSize
-				} else { //追加
-					setMap[v+"size"] = rLength + pLength
-					pushAll[v+"list"] = &list_temp
-				}
-			}
-			upSet := map[string]interface{}{
-				"$set": setMap,
-			}
-			if len(pushAll) > 0 {
-				upSet["$pushAll"] = pushAll
-			}
-			updateArray_d = append(updateArray_d, map[string]interface{}{"userid": temp["userid"]})
-			updateArray_q = append(updateArray_q, map[string]interface{}{"_id": data["_id"]})
-			updateArray_s = append(updateArray_s, upSet)
-			if len(updateArray_q) == BulkSize {
-				p.UpdateBulk(sess, &updateArray_d, &updateArray_q, &updateArray_s)
-			}
-		}
-		index++
-		if index%500 == 0 {
-			logger.Info("推送任务,迁移数据:", index)
-		}
-	}
-	if len(saveArray) > 0 {
-		p.SaveBulk(sess, &saveArray)
-	}
-	if len(updateArray_q) > 0 {
-		p.UpdateBulk(sess, &updateArray_d, &updateArray_q, &updateArray_s)
-	}
-	logger.Info("推送任务,迁移数据结束。。。", index)
-}
-func (p *PushJob) SaveBulk(sess *mgo.Session, array *[]map[string]interface{}) {
-	coll := sess.DB(DbName).C("pushspace")
-	bulk := coll.Bulk()
-	for _, v := range *array {
-		bulk.Insert(v)
-	}
-	_, err := bulk.Run()
-	if nil != err {
-		logger.Info("推送任务,BulkError", err)
-	} else {
-		p.DelBulk(sess, array)
-	}
-	*array = []map[string]interface{}{}
-}
-func (p *PushJob) UpdateBulk(sess *mgo.Session, array_d, array_q, array_s *[]map[string]interface{}) {
-	coll := sess.DB(DbName).C("pushspace")
-	bulk := coll.Bulk()
-	for k, v := range *array_q {
-		bulk.Update(v, (*array_s)[k])
-	}
-	_, err := bulk.Run()
-	if nil != err {
-		logger.Info("推送任务,UpdateBulkError", err)
-	} else {
-		p.DelBulk(sess, array_d)
-	}
-	*array_d = []map[string]interface{}{}
-	*array_q = []map[string]interface{}{}
-	*array_s = []map[string]interface{}{}
-}
-func (p *PushJob) DelBulk(sess *mgo.Session, array *[]map[string]interface{}) {
-	coll := sess.DB(DbName).C("pushspace_temp")
-	bulk := coll.Bulk()
-	for _, v := range *array {
-		bulk.RemoveAll(map[string]interface{}{
-			"userid": v["userid"],
-		})
-	}
-	_, err := bulk.Run()
-	if nil != err {
-		logger.Info("推送任务,DelBulkError", err)
-	}
-}
-func (p *PushJob) Push(taskType int) {
-	logger.Info("推送任务,开始推送。。。")
-	p.lastId = ""
-	batch_index := 0
-	for {
-		batch_index++
-		batch_size := p.OncePushBatch(batch_index, taskType)
-		for _, temp := range *p.pushDatas {
-			p.pushPool <- true
-			p.pushWait.Add(1)
-			go func(v map[string]interface{}) {
-				defer func() {
-					<-p.pushPool
-					p.pushWait.Done()
-				}()
-				words, _ := v["words"].([]interface{})
-				u := &MemberInterest{
-					Id:           util.ObjToString(v["userid"]),
-					OriginalKeys: util.ObjArrToStringArr(words),
-					WxPush:       util.IntAll(v["wxpush"]),
-					AppPush:      util.IntAll(v["apppush"]),
-					MailPush:     util.IntAll(v["mailpush"]),
-					Email:        util.ObjToString(v["email"]),
-					S_m_openid:   util.ObjToString(v["s_m_openid"]),
-					A_m_openid:   util.ObjToString(v["a_m_openid"]),
-					Phone:        util.ObjToString(v["phone"]),
-					Jpushid:      util.ObjToString(v["jpushid"]),
-					Opushid:      util.ObjToString(v["opushid"]),
-					UserType:     util.IntAll(v["usertype"]),
-					RateMode:     util.IntAllDef(v["ratemode"], 1),
-					SmartSet:     util.IntAllDef(v["smartset"], 1),
-					DataExport:   util.IntAll(v["dataexport"]),
-					AppPhoneType: util.ObjToString(v["appphonetype"]),
-					ApplyStatus:  util.IntAll(v["applystatus"]),
-					Subscribe:    util.IntAllDef(v["subscribe"], 1),
-					ModifyDate:   util.ObjToString(v["modifydate"]),
-					MergeOrder:   v["mergeorder"],
-				}
-				logger.Info("推送任务,开始推送用户,userid", u.Id, "s_m_openid", u.S_m_openid, "a_m_openid", u.A_m_openid, "phone", u.Phone, "jpushid", u.Jpushid, "opushid", u.Opushid, "applystatus", u.ApplyStatus)
-				wxPush, appPush, mailPush := 0, 0, 0
-				list := p.ToSortList(v["list"], u.Id)
-				templist := p.ToSortList(v["templist"], u.Id)
-				if taskType == 1 {
-					if u.WxPush == 1 {
-						if u.ApplyStatus == 1 {
-							wxPush = -1
-						} else {
-							wxPush = 1
-						}
-					}
-					if u.AppPush == 1 {
-						appPush = 1
-					}
-					if u.MailPush == 1 {
-						mailPush = -1
-					}
-				} else if taskType == 2 || taskType == 4 {
-					if u.WxPush == 1 {
-						wxPush = 1
-					}
-					if u.AppPush == 1 {
-						appPush = 1
-					}
-					if u.MailPush == 1 {
-						mailPush = 1
-					}
-				} else if taskType == 3 {
-					if u.WxPush == 1 && u.ApplyStatus == 1 {
-						wxPush = 1
-					}
-					if u.MailPush == 1 {
-						mailPush = 1
-					}
-				} else if taskType == 4 {
-					if u.WxPush == 1 {
-						wxPush = 1
-					}
-					if u.AppPush == 1 {
-						appPush = 1
-					}
-					if u.MailPush == 1 {
-						mailPush = 1
-					}
-				}
-				//再对取消关注以及app没有登录的用户进行过滤
-				if u.Subscribe == 0 {
-					wxPush = 0
-				}
-				if u.Jpushid == "" && u.Opushid == "" {
-					appPush = 0
-				}
-				if mailPush != 0 {
-					if (u.UserType == 0 || u.UserType == 3) && u.Subscribe == 0 {
-						mailPush = 0
-					} else if (u.UserType == 1 || u.UserType == 2 || u.UserType == 4) && u.Jpushid == "" && u.Opushid == "" {
-						mailPush = 0
-					} else if u.UserType == 5 && u.Subscribe == 0 && u.Jpushid == "" && u.Opushid == "" {
-						mailPush = 0
-					}
-				}
-				t_wxpush, t_mailpush := util.IntAll(v["tempwxpush"]), util.IntAll(v["tempmailpush"])
-				if templist != nil {
-					if wxPush == 1 && t_wxpush == 0 {
-						wxPush = 0
-					}
-					if mailPush == 1 && t_mailpush == 0 {
-						mailPush = 0
-					}
-				}
-				logger.Info("推送任务,本次推送任务类型", taskType, "用户的接收方式", u.Id, wxPush, appPush, mailPush, t_wxpush, t_mailpush)
-				if wxPush == 1 || appPush == 1 || mailPush == 1 {
-					isSaveSuccess := false
-					//wxPushStatus, appPushStatus, mailPushStatus := 0, 0, 0
-					//开通订阅推送或邮箱推送的用户,由实时推送修改成九点推送,app推送用list字段,微信和邮箱推送用templist字段
-					if list != nil && templist != nil {
-						isSaveSuccess, _, _, _ = p.DealSend(taskType, true, 0, appPush, 0, u, &list)
-						if !isSaveSuccess {
-							return
-						}
-						p.DealSend(taskType, false, wxPush, 0, mailPush, u, &templist)
-					} else if list != nil {
-						isSaveSuccess, _, _, _ = p.DealSend(taskType, true, wxPush, appPush, mailPush, u, &list)
-						if !isSaveSuccess {
-							return
-						}
-					} else if templist != nil {
-						p.DealSend(taskType, false, wxPush, 0, mailPush, u, &templist)
-					}
-					/*if wxPush == 1 {
-						if wxPushStatus == -1 {
-							wxPush = -1
-						} else {
-							wxPush = 0
-						}
-					}
-					if mailPush == 1 {
-						if mailPushStatus == -1 {
-							mailPush = -1
-						} else {
-							mailPush = 0
-						}
-					}*/
-					//判断是否要删除数据
-					_sess := mongodb.GetMgoConn()
-					defer mongodb.DestoryMongoConn(_sess)
-					if wxPush == -1 || mailPush == -1 {
-						//如果该用户还有微信或者邮箱推送,把list字段的值挪到templist
-						update := map[string]interface{}{}
-						set := map[string]interface{}{
-							"tempwxpush":   wxPush,
-							"tempmailpush": mailPush,
-						}
-						if templist == nil {
-							update["$rename"] = map[string]interface{}{"list": "templist"}
-						} else {
-							update["$unset"] = map[string]interface{}{"list": ""}
-						}
-						update["$set"] = set
-						_sess.DB(DbName).C("pushspace").UpdateId(v["_id"], update)
-					} else {
-						_sess.DB(DbName).C("pushspace").RemoveId(v["_id"])
-					}
-				}
-			}(temp)
-		}
-		if batch_size < SysConfig.PushBatch {
-			break
-		}
-	}
-	p.pushWait.Wait()
-	logger.Info("推送任务结束。。。", taskType)
-}
-func (p *PushJob) DealSend(taskType int, isSave bool, wxPush, appPush, mailPush int, k *MemberInterest, sl *sortList) (isSaveSuccess bool, wxPushStatus, appPushStatus, mailPushStatus int) {
-	defer util.Catch()
-	str := fmt.Sprintf("<div>根据您设置的关键词(%s),给您推送以下信息:</div>", strings.Join(k.OriginalKeys, ";"))
-	mailContent := ""
-	//发送内容组合
-	i := 0
-	jpushtitle := ""
-	lastInfoDate := int64(0)
-	TitleArray := []string{}
-	o_pushinfo := map[string]map[string]interface{}{}
-	matchKey_infoIndex := map[string]string{}
-	publishTitle := map[string]bool{}
-	//邮件附件
-	var fmdatas = []map[string]interface{}{}
-	for _, ks := range *sl {
-		k2 := *ks.Info
-		title := strings.Replace(k2["title"].(string), "\n", "", -1)
-		area := util.ObjToString(k2["area"])
-		if area == "A" {
-			area = "全国"
-		}
-		newTitle := fmt.Sprintf("[%s]%s", area, title)
-		if publishTitle[newTitle] {
-			continue
-		}
-		publishTitle[title] = true
-		i++
-		TitleArray = append(TitleArray, Re.ReplaceAllString(newTitle, "$1"))
-		if i == 1 {
-			jpushtitle = title
-			lastInfoDate = util.Int64All(k2["publishtime"])
-		}
-		//_sid := util.EncodeArticleId(util.BsonIdToSId(k2["_id"]))
-		//url := fmt.Sprintf("%s/pcdetail/%s.html", Domain, _sid)
-		_sid := util.EncodeArticleId2ByCheck(util.ObjToString(k2["_id"]))
-		//增加行业的处理
-		industry := ""
-		industryclass := "industry"
-		if k2["s_subscopeclass"] != nil {
-			k2sub := strings.Split(util.ObjToString(k2["s_subscopeclass"]), ",")
-			if len(k2sub) > 0 {
-				industry = k2sub[0]
-				if industry != "" {
-					ss := strings.Split(industry, "_")
-					if len(ss) > 1 {
-						industry = ss[0]
-					}
-				}
-			}
-		}
-		if mailPush == 1 { //关于邮件的处理
-			mailSid := util.CommonEncodeArticle("mailprivate", util.ObjToString(k2["_id"]))
-			url := fmt.Sprintf("%s/article/mailprivate/%s.html", SysConfig.JianyuDomain, mailSid)
-			classArea := "area"
-			classType := "type"
-			types := util.ObjToString(k2["subtype"])
-			if types == "" {
-				types = util.ObjToString(k2["toptype"])
-				if types == "" {
-					types = "其他"
-				}
-			}
-			dates := util.LongToDate(k2["publishtime"], false)
-			//标题替换
-			otitle := title
-			for _, kw := range k.OriginalKeys {
-				kws := strings.Split(kw, "+")
-				n := 0
-				otitle2 := otitle
-				for _, kwn := range kws {
-					ot := strings.Replace(otitle2, kwn, "<span class='keys'>"+kwn+"</span>", 1)
-					if ot != otitle {
-						n++
-						otitle2 = ot
-					} else {
-						break
-					}
-				}
-				if n == len(kws) {
-					otitle = otitle2
-					break
-				}
-			}
-			if industry == "" {
-				industryclass = ""
-			}
-			mailContent += fmt.Sprintf(SysConfig.Mail_content, i, url, otitle, classArea, area, classType, types, industryclass, industry, dates)
-		}
-		str += "<div class='tslist'><span class='xh'>" + fmt.Sprintf("%d", i) + ".</span><a class='bt' target='_blank' eid='" + _sid + "' href='" + util.ObjToString(k2["href"]) + "'>[<span class='area'>" + area + "</span>]" + title + "</a></div>"
-		o_pushinfo[strconv.Itoa(i)] = map[string]interface{}{
-			"publishtime":   k2["publishtime"],
-			"stype":         util.ObjToString(k2["type"]),
-			"topstype":      util.ObjToString(k2["toptype"]),
-			"substype":      util.ObjToString(k2["subtype"]),
-			"subscopeclass": industry,
-			"buyer":         k2["buyer"],
-			"projectname":   k2["projectname"],
-			"budget":        k2["budget"],
-			"bidopentime":   k2["bidopentime"],
-			"winner":        k2["winner"],
-			"bidamount":     k2["bidamount"],
-		}
-		//附件数据
-		fmdata := map[string]interface{}{
-			"publishtime": k2["publishtime"],
-			"subtype":     k2["subtype"],
-			"buyer":       k2["buyer"],
-			"projectname": k2["projectname"],
-			"budget":      k2["budget"],
-			"bidopentime": k2["bidopentime"],
-			"winner":      k2["winner"],
-			"bidamount":   k2["bidamount"],
-		}
-		fmdatas = append(fmdatas, fmdata)
-		//匹配到的关键词
-		for _, key := range (*ks).Keys {
-			if matchKey_infoIndex[key] != "" {
-				matchKey_infoIndex[key] = matchKey_infoIndex[key] + ","
-			}
-			matchKey_infoIndex[key] = matchKey_infoIndex[key] + strconv.Itoa(i)
-		}
-		if i >= SysConfig.MaxPushSize {
-			//限制最大信息条数
-			break
-		}
-	}
-	if i == 0 {
-		logger.Info("推送任务,没有要推送的数据!", k.S_m_openid, k.A_m_openid, k.Phone)
-		return
-	}
-	if isSave {
-		//推送记录id
-		pushId := putil.SaveSendInfo(taskType, k, str, o_pushinfo, matchKey_infoIndex)
-		if pushId == "" {
-			logger.Info("推送任务,保存到cassandra出错", k.Id, k.S_m_openid, k.A_m_openid, k.Phone)
-			return
-		} else {
-			logger.Info("推送任务,成功保存到cassandra", pushId, k.Id, k.S_m_openid, k.A_m_openid, k.Phone)
-		}
-		isSaveSuccess = true
-	}
-	//九点推送的时候,限制一分钟最大的推送数量
-	if taskType == 4 && (wxPush == 1 || appPush == 1) {
-		hour := time.Now().Hour()
-		fastigiumStart, fastigiumEnd := 0, 0
-		fastigiumTimes := strings.Split(SysConfig.FastigiumTime, "-")
-		if len(fastigiumTimes) == 2 {
-			fastigiumStart = util.IntAll(fastigiumTimes[0])
-			fastigiumEnd = util.IntAll(fastigiumTimes[1])
-		}
-		if hour >= fastigiumStart && hour <= fastigiumEnd {
-			<-p.fastigiumMinutePushPool //高峰期
-		} else {
-			<-p.minutePushPool //正常期
-		}
-	}
-	if wxPush == 1 {
-		isPushOk := true
-		if k.ApplyStatus == 1 {
-			TmpTip := ""
-			minute := time.Now().Unix() - lastInfoDate
-			if minute > -1 && minute < 61 {
-				TmpTip = fmt.Sprintf("%d秒前发布的", minute)
-			} else {
-				minute = minute / 60
-				if minute < 121 {
-					if minute < 1 {
-						minute = 1
-					}
-					TmpTip = fmt.Sprintf("%d分钟前发布的", minute)
-				}
-			}
-			Tip1 := util.If(TmpTip == "", "", TmpTip+":\n").(string)
-			LastTip := ""
-			if i > 1 {
-				LastTip = fmt.Sprintf("...(共%d条)", i)
-			}
-			LastTipLen := len([]rune(LastTip))
-			wxTitleKeys := strings.Join(k.OriginalKeys, ";")
-			if len([]rune(wxTitleKeys)) > 8 {
-				wxTitleKeys = string([]rune(wxTitleKeys)[:8]) + "..."
-			}
-			wxtitle := fmt.Sprintf(SysConfig.WxTitle, wxTitleKeys)
-			TitleLen := len([]rune(wxtitle))
-			GroupLen := len([]rune(k.ModifyDate))
-			reLen := 200 - TitleLen - GroupLen - WxContentLen - len([]rune(Tip1))
-			//if infoType == 2 {
-			//	reLen = reLen - 4
-			//}
-			WXTitle := ""
-			bshow := false
-			for n := 1; n < len(TitleArray)+1; n++ {
-				curTitle := TitleArray[n-1]
-				tmptitle := WXTitle + fmt.Sprintf("%d %s\n", n, curTitle)
-				ch := reLen - len([]rune(tmptitle))
-				if ch < LastTipLen { //加上后大于后辍,则没有完全显示
-					if ch == 0 && n == len(TitleArray) {
-						WXTitle = tmptitle
-						bshow = true
-					} else {
-						ch_1 := reLen - len([]rune(WXTitle)) - LastTipLen
-						if ch_1 > 8 {
-							curLen := len([]rune(curTitle))
-							if ch_1 > curLen {
-								ch_1 = curLen
-							}
-							WXTitle += fmt.Sprintf("%d %s\n", n, string([]rune(curTitle)[:ch_1-3]))
-						}
-					}
-				} else if ch == LastTipLen {
-					WXTitle = tmptitle
-					if n == len(TitleArray) {
-						bshow = true
-					}
-				} else {
-					WXTitle = tmptitle
-					if n == len(TitleArray) {
-						bshow = true
-					}
-				}
-			}
-			if bshow {
-				LastTip = ""
-			}
-			//推送微信
-			isPushOk = putil.SendWeixin(k, Tip1+WXTitle+LastTip, o_pushinfo, matchKey_infoIndex, wxtitle)
-			if isPushOk {
-				wxPushStatus = 1
-			} else {
-				wxPushStatus = -1
-			}
-		}
-		logger.Info("推送任务,微信推送", isPushOk, k.Id, k.S_m_openid, k.RateMode, k.ApplyStatus)
-	}
-	if appPush == 1 {
-		if len([]rune(jpushtitle)) > 80 {
-			jpushtitle = string([]rune(jpushtitle)[:80]) + "..."
-		}
-		if i > 1 {
-			jpushtitle = fmt.Sprintf("1. %s\n...(共%d条)", jpushtitle, i)
-		}
-		go mongodb.Update("user", map[string]interface{}{
-			"_id": bson.ObjectIdHex(k.Id),
-		}, map[string]interface{}{
-			"$inc": map[string]interface{}{
-				"i_apppushunread": 1,
-			},
-		}, false, false)
-		sess_openid := k.A_m_openid
-		if sess_openid == "" {
-			sess_openid = k.Phone
-		}
-		if sess_openid == "" {
-			sess_openid = k.S_m_openid
-		}
-		isPushOk := putil.SendApp(map[string]interface{}{
-			"phoneType": k.AppPhoneType,
-			"descript":  jpushtitle,
-			"type":      "bid",
-			"userId":    k.Id,
-			"openId":    sess_openid,
-			"url":       "/jyapp/free/sess/" + Se.EncodeString(sess_openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",historypush"),
-			//"url":         "/jyapp/free/sess/" + push.Se.EncodeString(k.Openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",wxpushlist") + "__" + pushid,
-			"otherPushId": k.Opushid,
-			"jgPushId":    k.Jpushid, //极光-推送id
-		})
-		if isPushOk {
-			appPushStatus = 1
-		} else {
-			appPushStatus = -1
-		}
-		logger.Info("推送任务,app推送", isPushOk, k.Id, k.S_m_openid, k.A_m_openid, k.Phone, k.AppPhoneType, k.Jpushid, k.Opushid, k.RateMode)
-	}
-	//发送邮件
-	if mailPush == 1 {
-		html := fmt.Sprintf(SysConfig.Mail_html, strings.Replace(strings.Join(k.OriginalKeys, ";"), "+", " ", -1), mailContent)
-		subject := fmt.Sprintf(SysConfig.Mail_title, "招标")
-		isPushOk := p.SendMail(k.Email, subject, html, fmdatas)
-		if isPushOk {
-			mailPushStatus = 1
-		} else {
-			mailPushStatus = -1
-		}
-		logger.Info("推送任务,发送邮件", isPushOk, k.Id, k.S_m_openid, k.A_m_openid, k.Phone, k.Email, k.DataExport)
-	}
-	if wxPush == 1 || appPush == 1 || (mailPush == 1 && wxPush == 0 && appPush == 0) {
-		//pc端助手推送
-		openid := k.S_m_openid
-		if openid == "" {
-			openid = k.Phone
-		}
-		if openid != "" {
-			putil.SendPcHelper(map[string]interface{}{"clientCode": openid})
-		}
-	}
-	return
-}
-
-//推送邮件(含附件)
-func (p *PushJob) SendMail(email, subject, html string, fmdatas []map[string]interface{}) bool {
-	if !SysConfig.IsPushMail {
-		return true
-	}
-	defer util.Catch()
-	//生成附件
-	var fnamepath, rename string
-	if len(fmdatas) > 0 { //开启导出
-		fnamepath, rename = GetBidInfoXlsx(fmdatas)
-		if messyCodeEmailReg.MatchString(email) {
-			rename = time.Now().Format("2006-01-02") + ".xlsx"
-		}
-	}
-	//gmail := <-Gmails
-	//defer func() {
-	//Gmails <- gmail
-	//}()
-	status := mail.GSendMail("剑鱼标讯", email, "", "", subject, html, fnamepath, rename, Gmail)
-	if fnamepath != "" {
-		os.Remove(fnamepath)
-	}
-	if SysConfig.MailSleep > 0 {
-		time.Sleep(time.Duration(SysConfig.MailSleep) * time.Millisecond)
-	}
-	return status
-}
-
-/************************************************/
-func (p *PushJob) OncePushBatch(batch_index, taskType int) int {
-	p.pushDatas = &[]map[string]interface{}{}
-	i := 0
-	sess := mongodb.GetMgoConn()
-	defer mongodb.DestoryMongoConn(sess)
-	var query map[string]interface{}
-	//实时推送,只查找ratemode==1的用户
-	if taskType == 1 || taskType == 2 {
-		query = map[string]interface{}{
-			"ratemode": 1,
-		}
-	} else if taskType == 3 {
-		query = map[string]interface{}{
-			"ratemode":    1,
-			"applystatus": 1,
-		}
-	} else if taskType == 4 {
-		query = map[string]interface{}{
-			"ratemode": 2,
-		}
-	} else {
-		logger.Error("taskType error", taskType)
-		return i
-	}
-	if len(SysConfig.TestIds) > 0 {
-		query["userid"] = map[string]interface{}{
-			"$in": SysConfig.TestIds,
-		}
-	}
-	if p.lastId != "" {
-		query["_id"] = map[string]interface{}{
-			"$gt": bson.ObjectIdHex(p.lastId),
-		}
-	}
-	logger.Info("推送任务,开始加载第", batch_index, "批用户", query)
-	it := sess.DB(DbName).C("pushspace").Find(query).Sort("_id").Iter()
-	for temp := make(map[string]interface{}); it.Next(&temp); {
-		i++
-		p.lastId = util.BsonIdToSId(temp["_id"])
-		*p.pushDatas = append(*p.pushDatas, temp)
-		temp = make(map[string]interface{})
-		if i == SysConfig.PushBatch {
-			break
-		}
-	}
-	logger.Info("推送任务,第", batch_index, "批用户加载结束", p.lastId)
-	return i
-}
-func (p *PushJob) ToSortList(list interface{}, userId string) sortList {
-	sl := make(sortList, 0)
-	if list == nil {
-		return nil
-	}
-	b, err := json.Marshal(list)
-	if err != nil {
-		return nil
-	}
-	err = json.Unmarshal(b, &sl)
-	if err != nil {
-		return nil
-	}
-	sort.Sort(sl)
-	return sl
-}

+ 0 - 152
src/jfw/modules/push_v1/src/push/dopush/pushtimetask.go

@@ -1,152 +0,0 @@
-package dopush
-
-import (
-	"log"
-	. "push/config"
-	"qfw/util"
-	"strings"
-	"time"
-)
-
-type timeTask struct {
-	RealPush  *RealPushTimeTask  //实时推送
-	NinePush  *NinePushTimeTask  //九点推送
-	OtherPush *OtherPushTimeTask //一天三次
-	Match     *MatchTimeTask     //匹配数据
-}
-
-var Task = &timeTask{
-	RealPush:  &RealPushTimeTask{},  //实时推送
-	NinePush:  &NinePushTimeTask{},  //九点推送
-	OtherPush: &OtherPushTimeTask{}, //一天三次
-	Match:     &MatchTimeTask{},
-}
-
-type MatchTimeTask struct {
-}
-
-func (m *MatchTimeTask) Execute() {
-	Jobs.Match.Execute(0, true)
-	util.WriteSysConfig("./task.json", &TaskConfig)
-	time.AfterFunc(time.Duration(SysConfig.MatchDuration)*time.Minute, func() {
-		m.Execute()
-	})
-}
-
-type RealPushTimeTask struct {
-}
-
-func (r *RealPushTimeTask) Execute() {
-	s_h_m := strings.Split(SysConfig.StartPushTime, ":")
-	if len(s_h_m) != 2 {
-		log.Fatalln("error:startpushtime", SysConfig.StartPushTime)
-	}
-	now := time.Now()
-	start := time.Date(now.Year(), now.Month(), now.Day(), util.IntAll(s_h_m[0]), util.IntAll(s_h_m[1]), 0, 0, time.Local)
-	//程序启动在开始时间之前
-	if now.Before(start) {
-		sub := start.Sub(now)
-		log.Println("start", SysConfig.StartPushTime, "pushjob after", sub)
-		time.AfterFunc(sub, func() {
-			go r.run(2)
-			ticker := time.NewTicker(time.Hour * 24)
-			for {
-				select {
-				case <-ticker.C:
-					go r.run(2)
-				}
-			}
-		})
-	} else {
-		go r.run(1)
-		start = start.AddDate(0, 0, 1)
-		sub := start.Sub(now)
-		log.Println("start", SysConfig.StartPushTime, "pushjob after", sub)
-		timer := time.NewTimer(sub)
-		for {
-			select {
-			case <-timer.C:
-				timer.Reset(time.Hour * 24)
-				go r.run(2)
-			}
-		}
-	}
-}
-func (r *RealPushTimeTask) run(taskType int) {
-	e_h_m := strings.Split(SysConfig.EndPushTime, ":")
-	if len(e_h_m) != 2 {
-		log.Fatalln("endpushtime", SysConfig.EndPushTime)
-	}
-	now := time.Now()
-	end := time.Date(now.Year(), now.Month(), now.Day(), util.IntAll(e_h_m[0]), util.IntAll(e_h_m[1]), 0, 0, time.Local)
-	if now.Before(end) {
-		Jobs.Push.Execute(taskType, true)
-	}
-	//隔天的话,不继续
-	//判断下一轮是否还需要继续
-	if now.Day() != time.Now().Day() || time.Now().After(end) {
-		return
-	}
-	log.Println("start pushjob after", SysConfig.PushDuration, "m")
-	time.AfterFunc(time.Duration(SysConfig.PushDuration)*time.Minute, func() {
-		r.run(1)
-	})
-}
-
-type OtherPushTimeTask struct {
-}
-
-func (o *OtherPushTimeTask) Execute() {
-	for _, otherpushtime := range SysConfig.OtherPushTimes {
-		h_m := strings.Split(otherpushtime, ":")
-		if len(h_m) != 2 {
-			log.Fatalln("error:otherpushtimes", otherpushtime)
-			return
-		}
-		now := time.Now()
-		newDate := time.Date(now.Year(), now.Month(), now.Day(), util.IntAll(h_m[0]), util.IntAll(h_m[1]), 0, 0, time.Local)
-		if newDate.Before(now) {
-			newDate = newDate.AddDate(0, 0, 1)
-		}
-		sub := newDate.Sub(now)
-		log.Println("start", otherpushtime, "pushjob after", sub)
-		time.AfterFunc(sub, func() {
-			go Jobs.Push.Execute(3, true)
-			ticker := time.NewTicker(time.Hour * 24)
-			for {
-				select {
-				case <-ticker.C:
-					go Jobs.Push.Execute(3, true)
-				}
-			}
-		})
-	}
-}
-
-type NinePushTimeTask struct {
-}
-
-func (n *NinePushTimeTask) Execute() {
-	h_m := strings.Split(SysConfig.OncePushTime, ":")
-	if len(h_m) == 2 {
-		now := time.Now()
-		newDate := time.Date(now.Year(), now.Month(), now.Day(), util.IntAll(h_m[0]), util.IntAll(h_m[1]), 0, 0, time.Local)
-		if newDate.Before(now) {
-			newDate = newDate.AddDate(0, 0, 1)
-		}
-		sub := newDate.Sub(now)
-		log.Println("start", SysConfig.OncePushTime, "pushjob after", sub)
-		time.AfterFunc(sub, func() {
-			go Jobs.Push.Execute(4, true)
-			ticker := time.NewTicker(time.Hour * 24)
-			for {
-				select {
-				case <-ticker.C:
-					go Jobs.Push.Execute(4, true)
-				}
-			}
-		})
-	} else {
-		log.Fatalln("error:oncepushtime", SysConfig.OtherPushTimes)
-	}
-}

+ 0 - 115
src/jfw/modules/push_v1/src/push/util/rpccall.go

@@ -1,115 +0,0 @@
-package util
-
-import (
-	"encoding/json"
-	"net/rpc"
-	. "push/config"
-	"qfw/util"
-	"qfw/util/mongodb"
-	qrpc "qfw/util/rpc"
-	"strconv"
-	"strings"
-	"time"
-
-	"github.com/donnie4w/go-logger/logger"
-	"gopkg.in/mgo.v2/bson"
-)
-
-var (
-	wxPushPool  = make(chan bool, SysConfig.WxPollSize)
-	appPushPool = make(chan bool, SysConfig.AppPollSize)
-)
-
-//微信远程调用,实现模板发送消息
-func SendWeixin(k *MemberInterest, Remarks string, o_pushinfo map[string]map[string]interface{}, matchKey_infoIndex map[string]string, wxtitle 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,
-		Title:       wxtitle,
-		Remark:      Remarks,
-		Detail:      SysConfig.WxGroup,
-		Date:        "",
-		Service:     util.FormatDate(&now, util.Date_Short_Layout),
-		Color:       SysConfig.WxColor,
-		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]") {
-		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
-}
-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"
-}
-
-//
-func SendPcHelper(m map[string]interface{}) bool {
-	defer util.Catch()
-	if SysConfig.PcHelperSleep > 0 {
-		time.Sleep(time.Duration(SysConfig.PcHelperSleep) * time.Millisecond)
-	}
-	var repl string
-	client, err := rpc.DialHTTP("tcp", SysConfig.PcHelper)
-	if err != nil {
-		logger.Error(err.Error())
-		return false
-	}
-	defer client.Close()
-	b, _ := json.Marshal(m)
-	err = client.Call("Service.PushMsg", b, &repl)
-	if err != nil {
-		logger.Error(err.Error())
-		return false
-	}
-	return repl == "y"
-}

+ 0 - 159
src/jfw/modules/push_v1/src/push/util/util.go

@@ -1,159 +0,0 @@
-package util
-
-import (
-	"encoding/json"
-	"fmt"
-	. "push/config"
-	"qfw/util"
-	"qfw/util/redis"
-	"time"
-	ca "ucbsutil/cassandra"
-
-	"gopkg.in/mgo.v2/bson"
-)
-
-var cassandraPoll = make(chan bool, SysConfig.CassandraPollSize)
-
-//重新设置用户类型
-func GetUserType(s_m_openid, a_m_openid, phone string, userType int) int {
-	if userType == 0 {
-		if s_m_openid != "" && a_m_openid == "" && phone == "" {
-			userType = 0 //公众号
-		} else if s_m_openid == "" && phone != "" {
-			userType = 1 //app手机号
-		} else if s_m_openid == "" && a_m_openid != "" {
-			userType = 2 //app微信
-		} else if s_m_openid != "" && a_m_openid == "" && phone == "" {
-			userType = 3 //用户合并以后只有微信用户
-		} else if s_m_openid == "" && (a_m_openid != "" || phone != "") {
-			userType = 4 //用户合并以后只有app用户
-		} else if s_m_openid != "" && (a_m_openid != "" || phone != "") {
-			userType = 5 //用户合并以后公众号和app用户都有
-		} else {
-			userType = -1
-		}
-	}
-	return userType
-}
-
-//推送方式转换
-func ModeTransform(userType int, o_msgset map[string]interface{}) (int, int, int) {
-	mode := util.IntAll(o_msgset["i_mode"])
-	wxpush := util.IntAll(o_msgset["i_wxpush"])
-	apppush := util.IntAll(o_msgset["i_apppush"])
-	mailpush := util.IntAll(o_msgset["i_mailpush"])
-	if wxpush == 1 || apppush == 1 || mailpush == 1 {
-		return wxpush, apppush, mailpush
-	}
-	//老的app用户
-	if userType == 1 || userType == 2 {
-		switch mode {
-		case 0, 1:
-			apppush = 1
-			break
-		case 2:
-			mailpush = 1
-			break
-		case 3:
-			apppush = 1
-			mailpush = 1
-			break
-		}
-		if apppush == 0 && mailpush == 0 {
-			apppush = 1
-		}
-	} else if userType == 0 {
-		switch mode {
-		case 0, 1:
-			wxpush = 1
-			break
-		case 2:
-			mailpush = 1
-			break
-		case 3:
-			wxpush = 1
-			mailpush = 1
-			break
-		}
-		if wxpush == 0 && mailpush == 0 {
-			wxpush = 1
-		}
-	} else {
-		switch mode {
-		case 0, 1, 3:
-			if userType == 3 {
-				wxpush = 1
-			} else if userType == 4 {
-				apppush = 1
-			} else if userType == 5 {
-				wxpush = 1
-				apppush = 1
-			}
-			if mode == 3 {
-				mailpush = 1
-			}
-			break
-		case 2:
-			mailpush = 1
-			break
-		}
-	}
-	return wxpush, apppush, mailpush
-}
-
-//保存发送信息
-func SaveSendInfo(taskType int, k *MemberInterest, str string, o_pushinfo map[string]map[string]interface{}, matchKey_infoIndex map[string]string) string {
-	cassandraPoll <- true
-	defer func() {
-		<-cassandraPoll
-	}()
-	if SysConfig.CassandraSleep > 0 {
-		time.Sleep(time.Duration(SysConfig.CassandraSleep) * time.Millisecond)
-	}
-	pushid := time.Now().Unix()
-	md, _ := json.Marshal(o_pushinfo)
-	openid := util.GetOldOpenid(k.S_m_openid, k.A_m_openid, k.Phone, k.MergeOrder)
-	wxpush := map[string]interface{}{
-		"id":       time.Now().Format(util.Date_Short_Layout),
-		"openid":   openid,
-		"date":     pushid,
-		"words":    k.OriginalKeys,
-		"uid":      k.Id,
-		"province": k.Province,
-		"interest": k.OriginalKeys,
-		"content":  str,
-		"pushinfo": string(md),
-		"size":     len(o_pushinfo),
-		"appid":    2,
-		"ratemode": k.RateMode,
-		"sendmode": 9000 + k.WxPush*100 + k.AppPush*10 + k.MailPush,
-		"smartset": k.SmartSet,
-		"matchki":  matchKey_infoIndex,
-	}
-	if ca.SaveCacheByTimeOut("jy_push", wxpush, 10) {
-		redisKey := "pushsubscribe_" + k.Id
-		if taskType == 4 {
-			redisDatas := redis.Get("pushcache", redisKey)
-			if redisDatas != nil {
-				list := []interface{}{wxpush}
-				redisList, _ := redisDatas.([]interface{})
-				list = append(list, redisList...)
-				if len(list) > 500 {
-					list = list[:500]
-				}
-				redis.Put("pushcache", redisKey, list, SysConfig.NinePushRedisTimeout)
-			}
-		} else {
-			redis.Del("pushcache", redisKey)
-		}
-		return fmt.Sprint(pushid)
-	}
-	return ""
-}
-func ToObjectIds(ids []string) []bson.ObjectId {
-	_ids := []bson.ObjectId{}
-	for _, v := range ids {
-		_ids = append(_ids, bson.ObjectIdHex(v))
-	}
-	return _ids
-}

+ 0 - 1
src/jfw/modules/push_v1/src/src

@@ -1 +0,0 @@
-ELF剑鱼标讯

+ 0 - 1
src/jfw/modules/push_v1/src/task.json

@@ -1 +0,0 @@
-{"startTime":"","lastId":"596f20265d11e1c7455dc5bc"}

+ 0 - 1
src/jfw/modules/push_v1/src/xlsx/readme.txt

@@ -1 +0,0 @@
-excel数据导出临时目录

BIN
src/jfw/modules/push_v1/src/xlsx/temp.xlsx


+ 5 - 5
src/jfw/modules/pushent/src/config.json

@@ -8,17 +8,17 @@
         "cachesize": 5000,
         "timeout": 20
     },
-    "durationMinutes": "3",
+    "durationMinutes": "30",
     "elasticPoolSize": 30,
     "elasticsearch": "http://192.168.3.18:9800",
     "lastid": "596f20265d11e1c7455dc5bc",
-    "maxSearch": 30000,
+    "maxSearch": 10000,
     "mongodbName": "qfw",
     "mongodbPoolSize": "20",
     "mongodbServers": "192.168.3.18:27080",
-    "redisServers": "sso=192.168.3.18:1379,other=192.168.3.18:1379,push=192.168.3.18:1379",
+    "redisServers": "sso=192.168.3.18:2379,other=192.168.3.18:2379,push=192.168.3.18:2379",
     "rpcPort": "8759",
-    "viewDomain": "http://webwcj.qmx.top",
+    "viewDomain": "https://web-jydev-wcj.jianyu360.cn",
     "weixinRpcServer": "127.0.0.1:8083",
     "wxcolor": "#25c78c",
     "wxcontent": "剑鱼标讯推送",
@@ -26,5 +26,5 @@
     "wxtitle": "您关注的企业“%s”有新的公告信息!如果不想继续收到此类信息,可进入发现-我关注的企业进行取消。",
 	"wxdetailcolor":"#686868",
 	"appPushServiceRpc":"127.0.0.1:5566",
-	"testids":["ocXeA0jceF8KRunDkwf9egT4bKI8","15838235928","13603456869"]
+	"testids":["5cb7e94c25ef871e6463e074"]
 }

+ 0 - 1
src/jfw/modules/pushent/src/config/config.go

@@ -5,7 +5,6 @@ import (
 )
 
 var Sysconfig map[string]interface{}
-var CassandraOpen = false
 
 func init() {
 	util.ReadConfig(&Sysconfig)

+ 5 - 12
src/jfw/modules/pushent/src/followpush/push.go

@@ -7,6 +7,7 @@ import (
 	"log"
 	"qfw/util"
 	"qfw/util/elastic"
+	"qfw/util/jy"
 	"qfw/util/mongodb"
 	"qfw/util/redis"
 	qrpc "qfw/util/rpc"
@@ -76,7 +77,7 @@ func pushByEs(_id string, lastTime int64) bool {
 	testids_i, _ := Sysconfig["testids"].([]interface{})
 	testids := util.ObjArrToStringArr(testids_i)
 	if len(testids) > 0 {
-		q["s_openid"] = map[string]interface{}{
+		q["s_userid"] = map[string]interface{}{
 			"$in": testids,
 		}
 	}
@@ -379,7 +380,7 @@ func push(fid, sname, title, userId string, res *[]map[string]interface{}) *Arr
 						md, _ := json.Marshal(pushArray)
 						isSaveOk := cassandra.SaveCache("jy_pushent", bson.M{
 							"id":      time.Now().Format(util.Date_Short_Layout),
-							"openid":  util.GetOldOpenid(s_m_openid, a_m_openid, s_phone, a_mergeorder),
+							"openid":  jy.GetOldOpenid(s_m_openid, a_m_openid, s_phone, a_mergeorder),
 							"date":    time.Now().UnixNano(),
 							"jpushid": jpushid,
 							"info":    string(md),
@@ -453,7 +454,7 @@ func push(fid, sname, title, userId string, res *[]map[string]interface{}) *Arr
 								Service:     lastcreatetime,
 								Color:       WxColor,
 								DetailColor: WxDetailColor,
-								Url:         ViewDomain + "/front/sess/" + se.EncodeString(s_m_openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",newInfoFollow") + "__" + sname + "__",
+								Url:         ViewDomain + "/front/sess/" + se.EncodeString(s_m_openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",followEntDetail") + "__" + util.EncodeArticleId2ByCheck(fid),
 							}, userId)
 						}
 						if jpushid != "" || opushid != "" {
@@ -464,22 +465,14 @@ func push(fid, sname, title, userId string, res *[]map[string]interface{}) *Arr
 							if pushnum > 1 {
 								jpushtitle = fmt.Sprintf("1. %s\n...(共%d条)", jpushtitle, pushnum)
 							}
-							sess_openid := a_m_openid
-							if sess_openid == "" {
-								sess_openid = s_phone
-							}
-							if sess_openid == "" {
-								sess_openid = s_m_openid
-							}
 							isPushOk := rpccall.AppPushServiceCall(map[string]interface{}{
 								"phoneType":   phoneType,
 								"otherPushId": opushid,
 								"jgPushId":    jpushid,
 								"descript":    jpushtitle,
 								"type":        "entname",
-								"openId":      sess_openid,
 								"userId":      userId,
-								"url":         "/jyapp/free/sess/" + se.EncodeString(sess_openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",newInfoFollow") + "__" + sname + "__",
+								"url":         "/jyapp/free/sess/" + se.EncodeString(userId+",_id,"+strconv.Itoa(int(time.Now().Unix()))+",followEntDetail") + "__" + util.EncodeArticleId2ByCheck(fid),
 							})
 							log.Println("app推送", userId, s_m_openid, a_m_openid, s_phone, phoneType, jpushid, opushid, isPushOk, pushnum, tit)
 						}

+ 10 - 14
src/jfw/modules/pushent/src/main.go

@@ -22,20 +22,16 @@ func init() {
 	rpccall.WeixinRpcServer = config.Sysconfig["weixinRpcServer"].(string)
 
 	//初始化cassandra
-	if cassandra, ok := config.Sysconfig["cassandra"].(map[string]interface{}); ok {
-		if open, _ := cassandra["open"].(bool); open {
-			ca.ViewCacheLen = true
-			ca.InitCassandra("jianyu",
-				(int)(cassandra["size"].(float64)),
-				util.ObjArrToStringArr(cassandra["host"].([]interface{})),
-				map[string]int{
-					"cachesize": (int)(cassandra["cachesize"].(float64)),
-					"timeout":   (int)(cassandra["timeout"].(float64)),
-				},
-			)
-			config.CassandraOpen = open
-		}
-	}
+	cassandra := config.Sysconfig["cassandra"].(map[string]interface{})
+	ca.ViewCacheLen = true
+	ca.InitCassandra("jianyu",
+		util.IntAll(cassandra["size"]),
+		util.ObjArrToStringArr(cassandra["host"].([]interface{})),
+		map[string]int{
+			"cachesize": util.IntAll(cassandra["cachesize"]),
+			"timeout":   util.IntAll(cassandra["timeout"]),
+		},
+	)
 }
 
 func main() {

+ 0 - 1
src/jfw/modules/pushproject/src/config/config.go

@@ -5,7 +5,6 @@ import (
 )
 
 var Sysconfig map[string]interface{}
-var CassandraOpen = false
 
 func init() {
 	util.ReadConfig(&Sysconfig)

+ 3 - 10
src/jfw/modules/pushproject/src/followpush/push.go

@@ -7,6 +7,7 @@ import (
 	"log"
 	"qfw/util"
 	"qfw/util/elastic"
+	"qfw/util/jy"
 	"qfw/util/mongodb"
 	"qfw/util/redis"
 	qrpc "qfw/util/rpc"
@@ -456,7 +457,7 @@ func push(fid interface{}, sname, scode, title, userId string, res *[]map[string
 							tmpid := fmt.Sprint(time.Now().UnixNano())
 							isSaveOk := cassandra.SaveCache("jy_pushproject", bson.M{
 								"id":     time.Now().Format(util.Date_Short_Layout),
-								"openid": util.GetOldOpenid(s_m_openid, a_m_openid, s_phone, a_mergeorder),
+								"openid": jy.GetOldOpenid(s_m_openid, a_m_openid, s_phone, a_mergeorder),
 								"date":   tmpid,
 								"info":   string(md),
 								"title":  title,
@@ -541,22 +542,14 @@ func push(fid interface{}, sname, scode, title, userId string, res *[]map[string
 								if pushnum > 1 {
 									jpushtitle = fmt.Sprintf("1. %s\n...(共%d条)", jpushtitle, pushnum)
 								}
-								sess_openid := a_m_openid
-								if sess_openid == "" {
-									sess_openid = s_phone
-								}
-								if sess_openid == "" {
-									sess_openid = s_m_openid
-								}
 								isPushOk := rpccall.AppPushServiceCall(map[string]interface{}{
 									"phoneType":   phoneType,
 									"otherPushId": opushid,
 									"jgPushId":    jpushid,
 									"descript":    jpushtitle,
 									"type":        "project",
-									"openId":      sess_openid,
 									"userId":      userId,
-									"url":         "/jyapp/free/sess/" + se.EncodeString(sess_openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",wxpushfollowlist") + "__" + tmpid + "__" + followid,
+									"url":         "/jyapp/free/sess/" + se.EncodeString(userId+",_id,"+strconv.Itoa(int(time.Now().Unix()))+",wxpushfollowlist") + "__" + tmpid + "__" + followid,
 								})
 								log.Println("app推送", userId, s_m_openid, a_m_openid, s_phone, phoneType, jpushid, opushid, isPushOk, pushnum, tit)
 							}

+ 10 - 14
src/jfw/modules/pushproject/src/main.go

@@ -25,20 +25,16 @@ func init() {
 	rpccall.WeixinRpcServer = config.Sysconfig["weixinRpcServer"].(string)
 
 	//初始化cassandra
-	if cassandra, ok := config.Sysconfig["cassandra"].(map[string]interface{}); ok {
-		if open, _ := cassandra["open"].(bool); open {
-			ca.ViewCacheLen = true
-			ca.InitCassandra("jianyu",
-				(int)(cassandra["size"].(float64)),
-				util.ObjArrToStringArr(cassandra["host"].([]interface{})),
-				map[string]int{
-					"cachesize": (int)(cassandra["cachesize"].(float64)),
-					"timeout":   (int)(cassandra["timeout"].(float64)),
-				},
-			)
-			config.CassandraOpen = open
-		}
-	}
+	cassandra := config.Sysconfig["cassandra"].(map[string]interface{})
+	ca.ViewCacheLen = true
+	ca.InitCassandra("jianyu",
+		util.IntAll(cassandra["size"]),
+		util.ObjArrToStringArr(cassandra["host"].([]interface{})),
+		map[string]int{
+			"cachesize": util.IntAll(cassandra["cachesize"]),
+			"timeout":   util.IntAll(cassandra["timeout"]),
+		},
+	)
 }
 
 func main() {

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

@@ -1,13 +1,15 @@
 {
-	"elasticPoolSize": 10,
+	"elasticPoolSize": 1,
 	"elasticSearch": "http://192.168.3.18:9800",
+	"redisServers": "pushcache_1=192.168.3.18:2001",
 	"maxPushSize": 50,
 	"maxSearch": 5000,
 	"mgoAddr": "192.168.3.18:27080",
 	"mgoSize": 10,
-	"testids": ["5c8f4f4325ef8723d0bc1082"],
+	"testids": ["5ca5a56e25ef8723d82b8cb5"],
 	"filterWords":["项目","中标","公告"],
 	"matchPoolSize": 60,
 	"matchDuration": 1, 
-	"userBatch":2
+	"userBatch":2,
+	"pcHelper":"127.0.0.1:8082"
 }

+ 2 - 0
src/jfw/modules/pushsubscribe/src/match/config/config.go

@@ -7,6 +7,7 @@ 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"`
@@ -16,6 +17,7 @@ type sysConfig struct {
 	MatchPoolSize   int      `json:"matchPoolSize"`
 	MatchDuration   int64    `json:"matchDuration"`
 	UserBatch       int      `json:"userBatch"`
+	PcHelper        string   `json:"pcHelper"`
 }
 
 type taskConfig struct {

+ 108 - 81
src/jfw/modules/pushsubscribe/src/match/job/matchjob.go

@@ -6,11 +6,12 @@ import (
 	"fmt"
 	. "match/config"
 	"match/dfa"
-	putil "match/util"
+	mutil "match/util"
 	. "public"
 	"qfw/util"
 	"qfw/util/elastic"
 	"qfw/util/mongodb"
+	"qfw/util/redis"
 	"sort"
 	"strings"
 	"sync"
@@ -69,27 +70,27 @@ func (m *MatchJob) Execute() {
 	defer util.Catch()
 	st, _ := time.ParseInLocation(util.Date_Full_Layout, TaskConfig.StartTime, time.Local)
 	lastTime := st.Unix()
-	_id := util.ObjToString(TaskConfig.LastId)
-	logger.Info("开始匹配数据任务。。。", _id, lastTime)
+	lastId := util.ObjToString(TaskConfig.LastId)
+	logger.Info("开始匹配数据任务。。。", lastId, lastTime)
 	//获取本次查询的最大id
 	idQuery := ""
-	if _id == "" {
-		idQuery = strings.Replace(fmt.Sprintf(MaxId, _id), `"gt"`, `"gte"`, -1)
+	if lastId == "" {
+		idQuery = strings.Replace(fmt.Sprintf(MaxId, lastId), `"gt"`, `"gte"`, -1)
 	} else {
-		idQuery = fmt.Sprintf(MaxId, _id)
+		idQuery = fmt.Sprintf(MaxId, lastId)
 	}
 	resId := elastic.Get(DB, DB, idQuery)
-	lastid := ""
+	newId := ""
 	var comeintime interface{}
 	if resId != nil && *resId != nil && len(*resId) == 1 {
-		lastid = util.ObjToString((*resId)[0]["_id"])
+		newId = util.ObjToString((*resId)[0]["_id"])
 		comeintime = (*resId)[0]["comeintime"]
 	} else {
-		logger.Info("匹配数据,获取本次查询的最大id的时候,未查找到数据!", idQuery)
+		logger.Info("获取本次查询的最大id的时候,未查找到数据!", idQuery)
 		return
 	}
-	if !m.LoadBidding(_id, lastid, lastTime) {
-		logger.Info("匹配数据,加载数据到内存中的时候,未查找到数据!")
+	if !m.LoadBidding(lastId, newId, lastTime) {
+		logger.Info("加载数据到内存中的时候,未查找到数据!")
 		return
 	}
 	m.lastUserId = ""
@@ -119,15 +120,15 @@ func (m *MatchJob) Execute() {
 		}
 	}
 	//
-	logger.Info("匹配数据任务结束。。。", lastid, comeintime)
+	logger.Info("匹配数据任务结束。。。", newId, comeintime)
 	//
-	TaskConfig.LastId = lastid
+	TaskConfig.LastId = newId
 	TaskConfig.StartTime = util.FormatDateWithObj(&comeintime, util.Date_Full_Layout)
 	m.datas = &[]map[string]interface{}{}
 	m.users = &map[string]*UserInfo{}
 }
 func (m *MatchJob) ToMatch(batchIndex int, a_key_user, a_notkey_user, s_key_user, s_notkey_user map[string]*[]*UserInfo) {
-	logger.Info("匹配数据任务,开始匹配第", batchIndex, "批用户")
+	logger.Info("开始匹配第", batchIndex, "批用户")
 	a_p := &Pjob{
 		Key_user:    &a_key_user,
 		Notkey_user: &a_notkey_user,
@@ -145,10 +146,10 @@ func (m *MatchJob) ToMatch(batchIndex int, a_key_user, a_notkey_user, s_key_user
 	//开启智能订阅的用户
 	s_key_user = make(map[string]*[]*UserInfo)
 	s_notkey_user = make(map[string]*[]*UserInfo)
-	logger.Info("匹配数据任务,第", batchIndex, "批用户匹配结束")
+	logger.Info("第", batchIndex, "批用户匹配结束")
 }
 func (m *MatchJob) Save(a_p, s_p *Pjob) {
-	logger.Info("匹配数据任务,开始保存到pushmail_temp表")
+	logger.Info("开始保存到pushmail_temp表")
 	userMap := m.EachAllBidInfo(a_p, s_p)
 	//加锁,保存数据和转移数据不能同时进行
 	index := 0
@@ -181,29 +182,32 @@ 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(),
+			"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,
+			"pchelperpush":  user.PchelperPush,
+			"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...)
@@ -211,18 +215,18 @@ func (m *MatchJob) Save(a_p, s_p *Pjob) {
 		}
 		index++
 		if index%500 == 0 {
-			logger.Info("匹配数据任务,保存到pushmail_temp表", index)
+			logger.Info("保存到pushmail_temp表", index)
 		}
 	}
 	if len(m.saveBatch) > 0 {
 		mongodb.SaveBulk("pushspace_temp", m.saveBatch...)
 		m.saveBatch = []map[string]interface{}{}
 	}
-	logger.Info("匹配数据任务,保存到pushmail_temp表结束", index)
+	logger.Info("保存到pushmail_temp表结束", index)
 }
 
 //加载数据到内存中
-func (m *MatchJob) LoadBidding(_id, lastid string, lastTime int64) bool {
+func (m *MatchJob) LoadBidding(lastId, newId string, lastTime int64) bool {
 	defer util.Catch()
 	c_query := map[string]interface{}{
 		"publishtime": map[string]interface{}{
@@ -231,24 +235,24 @@ func (m *MatchJob) LoadBidding(_id, lastid string, lastTime int64) bool {
 		"extracttype": 1,
 	}
 	idQuery := map[string]interface{}{}
-	if _id != "" {
-		idQuery["$gt"] = bson.ObjectIdHex(_id)
+	if lastId != "" {
+		idQuery["$gt"] = bson.ObjectIdHex(lastId)
 	}
-	if lastid != "" {
-		idQuery["$lte"] = bson.ObjectIdHex(lastid)
+	if newId != "" {
+		idQuery["$lte"] = bson.ObjectIdHex(newId)
 	}
 	if len(idQuery) > 0 {
 		c_query["_id"] = idQuery
 	}
-	logger.Info("匹配数据任务,mongodb query:", c_query)
+	logger.Info("mongodb query:", c_query)
 	count := mongodb.Count("bidding", c_query)
-	logger.Info("匹配数据任务,本次数据共", count, "条")
+	logger.Info("本次数据共", count, "条")
 	if count == 0 {
 		return false
 	}
 	if count > SysConfig.MaxSearch {
 		count = SysConfig.MaxSearch
-		logger.Info("匹配数据任务,目前数据多于", SysConfig.MaxSearch, ",只加载了", SysConfig.MaxSearch, "条!")
+		logger.Info("目前数据多于", SysConfig.MaxSearch, ",只加载了", SysConfig.MaxSearch, "条!")
 	}
 	var res []map[string]interface{}
 	sess := mongodb.GetMgoConn()
@@ -257,10 +261,20 @@ func (m *MatchJob) LoadBidding(_id, lastid string, lastTime int64) bool {
 	index := 0
 	for tmp := make(map[string]interface{}); it.Next(&tmp); {
 		index++
-		tmp["_id"] = util.BsonIdToSId(tmp["_id"])
+		_id := util.BsonIdToSId(tmp["_id"])
+		tmp["_id"] = _id
 		res = append(res, tmp)
+		//信息缓存3天
+		info := map[string]interface{}{}
+		for _, v := range SaveFields {
+			if v == "_id" || tmp[v] == nil {
+				continue
+			}
+			info[v] = tmp[v]
+		}
+		redis.Put("pushcache_1", "info_"+_id, info, 259200)
 		if index%500 == 0 {
-			logger.Info("匹配数据任务,当前加载数据:", index)
+			logger.Info("当前加载数据:", index)
 		}
 		tmp = make(map[string]interface{})
 		if index >= count {
@@ -268,7 +282,7 @@ func (m *MatchJob) LoadBidding(_id, lastid string, lastTime int64) bool {
 		}
 	}
 	m.datas = &res
-	logger.Info("匹配数据任务,", count, "条数据已经加载完成!")
+	logger.Info(count, "条数据已经加载完成!")
 	return true
 }
 
@@ -282,7 +296,7 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) int {
 	}
 	_idq := map[string]interface{}{}
 	if len(SysConfig.TestIds) > 0 {
-		_idq["$in"] = putil.ToObjectIds(SysConfig.TestIds)
+		_idq["$in"] = mutil.ToObjectIds(SysConfig.TestIds)
 	}
 	if m.lastUserId != "" {
 		_idq["$gt"] = bson.ObjectIdHex(m.lastUserId)
@@ -290,42 +304,53 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) int {
 	if len(_idq) > 0 {
 		q["_id"] = _idq
 	}
-	logger.Info("匹配数据任务,开始加载第", user_batch_index, "批用户", q)
+	logger.Info("开始加载第", user_batch_index, "批用户", q)
 	session := mongodb.GetMgoConn()
 	defer mongodb.DestoryMongoConn(session)
 	query := session.DB(DbName).C("user").Find(&q).Select(&map[string]interface{}{
-		"_id":           1,
-		"o_jy":          1,
-		"s_m_openid":    1,
-		"a_m_openid":    1,
-		"s_phone":       1,
-		"s_jpushid":     1,
-		"s_opushid":     1,
-		"i_ispush":      1,
-		"i_dataexport":  1,
-		"i_type":        1,
-		"i_smartset":    1,
-		"i_supersearch": 1,
-		"s_appponetype": 1,
-		"i_applystatus": 1,
-		"a_mergeorder":  1,
+		"_id":             1,
+		"o_jy":            1,
+		"s_m_openid":      1,
+		"a_m_openid":      1,
+		"s_phone":         1,
+		"s_jpushid":       1,
+		"s_opushid":       1,
+		"i_ispush":        1,
+		"i_dataexport":    1,
+		"i_type":          1,
+		"i_smartset":      1,
+		"i_supersearch":   1,
+		"s_appponetype":   1,
+		"i_applystatus":   1,
+		"a_mergeorder":    1,
+		"s_nickname":      1,
+		"l_firstpushtime": 1,
 	}).Iter()
 	n := 0
 	for temp := make(map[string]interface{}); query.Next(temp); {
 		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"])
-		userType := putil.GetUserType(s_m_openid, a_m_openid, s_phone, util.IntAllDef(temp["i_type"], 0))
+		userType := mutil.GetUserType(s_m_openid, a_m_openid, s_phone, util.IntAll(temp["i_type"]))
 		isPush := util.IntAllDef(temp["i_ispush"], 1)
-		//公众号取关用户,后面还有pc助手推送,暂时不过滤app用户
+		jpushid := util.ObjToString(temp["s_jpushid"])
+		opushid := util.ObjToString(temp["s_opushid"])
+		pchelperPush := 0
+		//公众号取关用户
 		if userType == 0 && isPush == 0 {
 			continue
+		} else if userType == 2 && jpushid == "" && opushid == "" {
+			continue
+		} else if (userType == 1 || (userType == 5 && isPush == 0)) && jpushid == "" && opushid == "" {
+			if s_phone == "" || !mutil.PcHelperIsOnLine(s_phone) {
+				continue
+			} else {
+				pchelperPush = 1
+			}
 		}
 		applystatus := util.IntAll(temp["i_applystatus"])
 		o_msgset, _ := temp["o_jy"].(map[string]interface{})
-		wxpush, apppush, mailpush := putil.ModeTransform(userType, o_msgset)
-		jpushid := util.ObjToString(temp["s_jpushid"])
-		opushid := util.ObjToString(temp["s_opushid"])
+		wxpush, apppush, mailpush := mutil.ModeTransform(userType, o_msgset)
 		var allkeysTemp []elastic.KeyConfig
 		_bs, err := json.Marshal(o_msgset["a_key"])
 		if err == nil {
@@ -356,7 +381,8 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) int {
 			continue
 		}
 		userId := fmt.Sprintf("%x", string(temp["_id"].(bson.ObjectId)))
-		logger.Info("匹配数据任务,第", user_batch_index, "批用户,userid", userId, "s_m_openid", s_m_openid, "a_m_openid", a_m_openid, "s_phone", s_phone, "jpushid", jpushid, "opushid", opushid, "applystatus", applystatus)
+		smartset := util.IntAll(temp["i_smartset"])
+		logger.Info("第", user_batch_index, "批用户,userid", userId, "s_m_openid", s_m_openid, "a_m_openid", a_m_openid, "s_phone", s_phone, "jpushid", jpushid, "opushid", opushid, "applystatus", applystatus, "smartset", smartset)
 		keys := []string{}                           //过滤后的关键词
 		notkeys := []string{}                        //排除词
 		key_notkey := map[string]map[string]bool{}   //关键词所对应的排除词
@@ -396,7 +422,6 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) int {
 		for _, vs := range allkeysTemp {
 			keysTemp = append(keysTemp, strings.Join(vs.Keys, "+"))
 		}
-		smartset := util.IntAllDef(temp["i_smartset"], 0)
 		modifydate := ""
 		md, _ := o_msgset["l_modifydate"].(int64)
 		if md > 0 {
@@ -417,6 +442,7 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) int {
 			WxPush:       wxpush,
 			AppPush:      apppush,
 			MailPush:     mailpush,
+			PchelperPush: pchelperPush,
 			Email:        util.ObjToString(o_msgset["s_email"]),
 			S_m_openid:   s_m_openid,
 			A_m_openid:   a_m_openid,
@@ -427,12 +453,13 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) int {
 			RateMode:     util.IntAllDef(o_msgset["i_ratemode"], 2),
 			AllKeys:      allkeysTemp, //原始关键词
 			SmartSet:     smartset,
-			DataExport:   util.IntAllDef(temp["i_dataexport"], 0),
+			DataExport:   util.IntAll(temp["i_dataexport"]),
 			ModifyDate:   modifydate,
 			AppPhoneType: util.ObjToString(temp["s_appponetype"]),
 			ApplyStatus:  applystatus,
 			Subscribe:    isPush,
 			MergeOrder:   temp["a_mergeorder"],
+			NickName:     util.ObjToString(temp["s_nickname"]),
 		}
 		(*m.users)[user.Id] = user
 		m.lastUserId = user.Id
@@ -442,7 +469,7 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) int {
 			break
 		}
 	}
-	logger.Info("匹配数据任务,第", user_batch_index, "批用户加载结束", n)
+	logger.Info("第", user_batch_index, "批用户加载结束", n)
 	return n
 }
 
@@ -470,7 +497,7 @@ func (m *MatchJob) MakeKeyUser(keys []string, user *UserInfo, key_user *map[stri
 //遍历数据并执行推送操作
 func (m *MatchJob) EachAllBidInfo(a_p *Pjob, s_p *Pjob) *map[string]*list.List {
 	defer util.Catch()
-	logger.Info("匹配数据任务,开始遍历数据。。。")
+	logger.Info("开始遍历数据。。。")
 	userMap := &map[string]*list.List{}
 	var count int
 	for _, temp := range *m.datas {
@@ -518,11 +545,11 @@ func (m *MatchJob) EachAllBidInfo(a_p *Pjob, s_p *Pjob) *map[string]*list.List {
 			}
 		}(temp)
 		if count%500 == 0 {
-			logger.Info("匹配数据任务,当前信息索引:", count)
+			logger.Info("当前信息索引:", count)
 		}
 	}
 	m.eachInfoWaitGroup.Wait()
-	logger.Info("匹配数据任务,数据遍历完成!")
+	logger.Info("数据遍历完成!")
 	return userMap
 }
 

+ 3 - 2
src/jfw/modules/pushsubscribe/src/match/job/timetask.go

@@ -1,10 +1,11 @@
 package job
 
 import (
-	"log"
 	. "match/config"
 	"qfw/util"
 	"time"
+
+	"github.com/donnie4w/go-logger/logger"
 )
 
 type timeTask struct {
@@ -22,6 +23,6 @@ func (m *MatchTimeTask) Execute() {
 	Jobs.Match.Execute()
 	util.WriteSysConfig("./task.json", &TaskConfig)
 	t := time.Duration(SysConfig.MatchDuration) * time.Minute
-	log.Println("start match job after", t)
+	logger.Info("start match job after", t)
 	time.AfterFunc(t, m.Execute)
 }

+ 2 - 0
src/jfw/modules/pushsubscribe/src/match/main.go

@@ -8,6 +8,7 @@ import (
 	"match/job"
 	"qfw/util/elastic"
 	"qfw/util/mongodb"
+	"qfw/util/redis"
 
 	"github.com/donnie4w/go-logger/logger"
 )
@@ -18,6 +19,7 @@ func main() {
 	logger.SetConsole(false)
 	logger.SetRollingDaily("./logs", "match.log")
 	mongodb.InitMongodbPool(SysConfig.MgoSize, SysConfig.MgoAddr, "qfw")
+	redis.InitRedis(SysConfig.RedisServers)
 	elastic.InitElasticSize(SysConfig.ElasticSearch, SysConfig.ElasticPoolSize)
 	log.Println("订阅推送-匹配数据程序启动。。。")
 	if *modle == 1 {

BIN
src/jfw/modules/pushsubscribe/src/match/match


+ 0 - 1
src/jfw/modules/pushsubscribe/src/match/src

@@ -1 +0,0 @@
-ELF剑鱼标讯

+ 27 - 0
src/jfw/modules/pushsubscribe/src/match/util/rpccall.go

@@ -0,0 +1,27 @@
+package util
+
+import (
+	"net/rpc"
+	. "push/config"
+	"qfw/util"
+
+	"github.com/donnie4w/go-logger/logger"
+)
+
+//
+func PcHelperIsOnLine(phone string) bool {
+	defer util.Catch()
+	var repl string
+	client, err := rpc.DialHTTP("tcp", SysConfig.PcHelper)
+	if err != nil {
+		logger.Error(err.Error())
+		return false
+	}
+	defer client.Close()
+	err = client.Call("Service.IsOnLine", phone, &repl)
+	if err != nil {
+		logger.Error(err.Error())
+		return false
+	}
+	return repl == "y"
+}

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

@@ -15,10 +15,10 @@ func GetUserType(s_m_openid, a_m_openid, phone string, userType int) int {
 			userType = 1 //app手机号
 		} else if s_m_openid == "" && a_m_openid != "" {
 			userType = 2 //app微信
-		} else if s_m_openid != "" && a_m_openid == "" && phone == "" {
-			userType = 3 //用户合并以后只有微信用户
-		} else if s_m_openid == "" && (a_m_openid != "" || phone != "") {
-			userType = 4 //用户合并以后只有app用户
+			//} else if s_m_openid != "" && a_m_openid == "" && phone == "" {
+			//userType = 3 //用户合并以后只有微信用户
+			//} else if s_m_openid == "" && (a_m_openid != "" || phone != "") {
+			//userType = 4 //用户合并以后只有app用户
 		} else if s_m_openid != "" && (a_m_openid != "" || phone != "") {
 			userType = 5 //用户合并以后公众号和app用户都有
 		} else {

+ 31 - 28
src/jfw/modules/pushsubscribe/src/public/entity.go

@@ -6,34 +6,37 @@ import (
 )
 
 type UserInfo struct {
-	Id           string                     //mongoid
-	Province     string                     //省份
-	Key_notkey   map[string]map[string]bool //关键词-排除词
-	Key_area     map[string]map[string]bool //关键词-信息范围
-	Key_infotype map[string]map[string]bool //关键词-信息类型
-	OriginalKeys []string                   //用户兴趣
-	Keys         []string                   //用户兴趣
-	NotKeys      []string                   //用户不感兴趣
-	S_m_openid   string                     //公众号openid
-	A_m_openid   string                     //app微信登录openid
-	Phone        string                     //app手机号登录
-	Jpushid      string
-	Opushid      string
-	InterestDate int64
-	WxPush       int
-	AppPush      int
-	MailPush     int
-	RateMode     int
-	SmartSet     int //智能订阅 1开启 0关闭
-	Email        string
-	DataExport   int //是否导出数据 1开启 0关闭
-	AllKeys      []elastic.KeyConfig
-	ModifyDate   string
-	AppPhoneType string
-	ApplyStatus  int
-	Subscribe    int
-	UserType     int
-	MergeOrder   interface{}
+	Id            string                     //mongoid
+	Province      string                     //省份
+	Key_notkey    map[string]map[string]bool //关键词-排除词
+	Key_area      map[string]map[string]bool //关键词-信息范围
+	Key_infotype  map[string]map[string]bool //关键词-信息类型
+	OriginalKeys  []string                   //用户兴趣
+	Keys          []string                   //用户兴趣
+	NotKeys       []string                   //用户不感兴趣
+	S_m_openid    string                     //公众号openid
+	A_m_openid    string                     //app微信登录openid
+	Phone         string                     //app手机号登录
+	Jpushid       string
+	Opushid       string
+	InterestDate  int64
+	WxPush        int
+	AppPush       int
+	MailPush      int
+	PchelperPush  int
+	RateMode      int
+	SmartSet      int //智能订阅 1开启 0关闭
+	Email         string
+	DataExport    int //是否导出数据 1开启 0关闭
+	AllKeys       []elastic.KeyConfig
+	ModifyDate    string
+	AppPhoneType  string
+	ApplyStatus   int
+	Subscribe     int
+	UserType      int
+	MergeOrder    interface{}
+	NickName      string
+	FirstPushTime int64
 	//
 	//Active int
 	//Fail   *Fail //失败重试

+ 3 - 4
src/jfw/modules/pushsubscribe/src/push/config.json

@@ -1,4 +1,5 @@
 {
+	"rpcPort":"1122",
 	"jianyuDomain": "https://web-jydev-wcj.jianyu360.cn",
 	"cassandra": {
 		"cachesize": 10000,
@@ -7,7 +8,7 @@
 		"size": 5,
 		"timeout": 20
 	},
-	"redisServers": "pushcache=192.168.3.18:3379",
+	"redisServers": "pushcache_2_a=192.168.3.18:2002,pushcache_2_b=192.168.3.18:2003",
 	"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信息-剑鱼标讯",
@@ -30,7 +31,6 @@
 		}
 	],
 	"maxPushSize": 50,
-	"messyCodeEmailReg": "(@(126|163)\\.com)$",
 	"mgoAddr": "192.168.3.18:27080",
 	"mgoSize": 10,
 	"testids": ["5c8f4f4325ef8723d0bc1082"],
@@ -64,6 +64,5 @@
 	"pcHelperSleep":5,
 	"isPushMail":true,
 	"pushBatch":2,
-	"moveBatch":1000,
-	"ninePushRedisTimeout": 172800
+	"moveBatch":1000
 }

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

@@ -16,7 +16,6 @@ type sysConfig struct {
 	Mail_title              string      `json:"mail_title"`
 	Mails                   []*pushMail `json:"mails"`
 	MaxPushSize             int         `json:"maxPushSize"`
-	MessyCodeEmailReg       string      `json:"messyCodeEmailReg"`
 	MgoAddr                 string      `json:"mgoAddr"`
 	MgoSize                 int         `json:"mgoSize"`
 	TestIds                 []string    `json:"testIds"`
@@ -47,6 +46,7 @@ type sysConfig struct {
 	FastigiumMinutePushSize int         `json:"fastigiumMinutePushSize"`
 	FastigiumTime           string      `json:"fastigiumTime"`
 	NinePushRedisTimeout    int         `json:"ninePushRedisTimeout"`
+	RpcPort                 string      `json:"rpcPort"`
 	MoveBatch               int         `json:"moveBatch"`
 }
 type pushMail struct {

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

@@ -0,0 +1,372 @@
+package job
+
+import (
+	"fmt"
+	"os"
+	. "public"
+	. "push/config"
+	putil "push/util"
+	"qfw/util"
+	"qfw/util/mail"
+	"qfw/util/mongodb"
+	"strconv"
+	"strings"
+	"time"
+
+	"github.com/donnie4w/go-logger/logger"
+	"gopkg.in/mgo.v2/bson"
+)
+
+func init() {
+	//推送1分钟限制
+	DoPush.minutePushPool = make(chan bool, SysConfig.MinutePushSize)
+	DoPush.fastigiumMinutePushPool = make(chan bool, SysConfig.FastigiumMinutePushSize)
+	for i := 0; i < SysConfig.MinutePushSize; i++ {
+		DoPush.minutePushPool <- true
+	}
+	for i := 0; i < SysConfig.FastigiumMinutePushSize; i++ {
+		DoPush.fastigiumMinutePushPool <- true
+	}
+	go func() {
+		t := time.NewTicker(time.Minute)
+		for {
+			select {
+			case <-t.C:
+				for i := 0; i < SysConfig.MinutePushSize-len(DoPush.minutePushPool); i++ {
+					DoPush.minutePushPool <- true
+				}
+				for i := 0; i < SysConfig.FastigiumMinutePushSize-len(DoPush.fastigiumMinutePushPool); i++ {
+					DoPush.fastigiumMinutePushPool <- true
+				}
+			}
+		}
+	}()
+}
+
+type doPush struct {
+	minutePushPool          chan bool
+	fastigiumMinutePushPool chan bool
+}
+
+func (d *doPush) Execute(taskType int, wxPush, appPush, mailPush int, u *UserInfo, list, tempList SortList) (isSaveSuccess bool, wxStatus, appStatus, mailStatus int) {
+	isSaveSuccess = true
+	//开通订阅推送或邮箱推送的用户,由实时推送修改成九点推送,app推送用list字段,微信和邮箱推送用templist字段
+	if wxPush == 1 || appPush == 1 || mailPush == 1 || u.PchelperPush == 1 {
+		if list != nil && tempList != nil {
+			isSaveSuccess, _, appStatus, _ = d.Do(taskType, true, 0, appPush, 0, u, &list)
+			if !isSaveSuccess {
+				return
+			}
+			_, wxStatus, _, mailStatus = d.Do(taskType, false, wxPush, 0, mailPush, u, &tempList)
+		} else if list != nil {
+			isSaveSuccess, wxStatus, appStatus, mailStatus = d.Do(taskType, true, wxPush, appPush, mailPush, u, &list)
+			if !isSaveSuccess {
+				return
+			}
+		} else if tempList != nil {
+			_, wxStatus, appStatus, mailStatus = d.Do(taskType, false, wxPush, 0, mailPush, u, &tempList)
+		}
+	}
+	return isSaveSuccess, wxStatus, appStatus, mailStatus
+}
+func (d *doPush) Do(taskType int, isSave bool, wxPush, appPush, mailPush int, k *UserInfo, sl *SortList) (isSaveSuccess bool, wxStatus, appStatus, mailStatus int) {
+	defer util.Catch()
+	mailContent := ""
+	i := 0
+	jpushtitle := ""
+	lastInfoDate := int64(0)
+	TitleArray := []string{}
+	infos := []map[string]interface{}{}
+	publishTitle := map[string]bool{}
+	pushIds := []string{}
+	//邮件附件
+	var fmdatas = []map[string]interface{}{}
+	for _, ks := range *sl {
+		k2 := *ks.Info
+		title := strings.Replace(k2["title"].(string), "\n", "", -1)
+		title = Re.ReplaceAllString(title, "$1")
+		area := util.ObjToString(k2["area"])
+		if area == "A" {
+			area = "全国"
+		}
+		newTitle := fmt.Sprintf("[%s]%s", area, title)
+		if publishTitle[newTitle] {
+			continue
+		}
+		publishTitle[newTitle] = true
+		i++
+		infos = append(infos, k2)
+		pushIds = append(pushIds, util.ObjToString(k2["_id"]))
+		TitleArray = append(TitleArray, newTitle)
+		if i == 1 {
+			jpushtitle = title
+			lastInfoDate = util.Int64All(k2["publishtime"])
+		}
+		//增加行业的处理
+		industry := ""
+		industryclass := "industry"
+		if k2["s_subscopeclass"] != nil {
+			k2sub := strings.Split(util.ObjToString(k2["s_subscopeclass"]), ",")
+			if len(k2sub) > 0 {
+				industry = k2sub[0]
+				if industry != "" {
+					ss := strings.Split(industry, "_")
+					if len(ss) > 1 {
+						industry = ss[0]
+					}
+				}
+			}
+		}
+		if mailPush == 1 { //关于邮件的处理
+			mailSid := util.CommonEncodeArticle("mailprivate", util.ObjToString(k2["_id"]))
+			url := fmt.Sprintf("%s/article/mailprivate/%s.html", SysConfig.JianyuDomain, mailSid)
+			classArea := "area"
+			classType := "type"
+			infotype := util.ObjToString(k2["subtype"])
+			if infotype == "" {
+				infotype = util.ObjToString(k2["toptype"])
+			}
+			if infotype == "" {
+				infotype = util.ObjToString(k2["type"])
+				if infotype == "tender" {
+					infotype = "招标"
+				} else if infotype == "bid" {
+					infotype = "中标"
+				}
+			}
+			dates := util.LongToDate(k2["publishtime"], false)
+			//标题替换
+			otitle := title
+			for _, kw := range k.OriginalKeys {
+				kws := strings.Split(kw, "+")
+				n := 0
+				otitle2 := otitle
+				for _, kwn := range kws {
+					ot := strings.Replace(otitle2, kwn, "<span class='keys'>"+kwn+"</span>", 1)
+					if ot != otitle {
+						n++
+						otitle2 = ot
+					} else {
+						break
+					}
+				}
+				if n == len(kws) {
+					otitle = otitle2
+					break
+				}
+			}
+			if industry == "" {
+				industryclass = ""
+			}
+			mailContent += fmt.Sprintf(SysConfig.Mail_content, i, url, otitle, classArea, area, classType, infotype, industryclass, industry, dates)
+		}
+		//附件数据
+		fmdata := map[string]interface{}{
+			"publishtime": k2["publishtime"],
+			"subtype":     k2["subtype"],
+			"buyer":       k2["buyer"],
+			"projectname": k2["projectname"],
+			"budget":      k2["budget"],
+			"bidopentime": k2["bidopentime"],
+			"winner":      k2["winner"],
+			"bidamount":   k2["bidamount"],
+		}
+		fmdatas = append(fmdatas, fmdata)
+		if i >= SysConfig.MaxPushSize {
+			//限制最大信息条数
+			break
+		}
+	}
+	if i == 0 {
+		logger.Info("推送任务", taskType, "没有要推送的数据!", k.S_m_openid, k.A_m_openid, k.Phone)
+		return
+	}
+	if taskType != 0 && isSave {
+		//推送记录id
+		pushId := putil.SaveSendInfo(k, pushIds, infos)
+		if pushId == "" {
+			logger.Info("推送任务", taskType, "保存到cassandra出错", k.Id, k.S_m_openid, k.A_m_openid, k.Phone)
+			return
+		} else {
+			logger.Info("推送任务", taskType, "成功保存到cassandra", pushId, k.Id, k.S_m_openid, k.A_m_openid, k.Phone)
+		}
+		isSaveSuccess = true
+		//pc端助手推送
+		if k.S_m_openid != "" {
+			putil.SendPcHelper(map[string]interface{}{"clientCode": k.S_m_openid})
+		}
+		if k.Phone != "" {
+			putil.SendPcHelper(map[string]interface{}{"clientCode": k.Phone})
+		}
+	}
+	//限制一分钟最大的推送数量
+	hour := time.Now().Hour()
+	fastigiumStart, fastigiumEnd := 0, 0
+	fastigiumTimes := strings.Split(SysConfig.FastigiumTime, "-")
+	if len(fastigiumTimes) == 2 {
+		fastigiumStart = util.IntAll(fastigiumTimes[0])
+		fastigiumEnd = util.IntAll(fastigiumTimes[1])
+	}
+	if hour >= fastigiumStart && hour <= fastigiumEnd {
+		<-d.fastigiumMinutePushPool //高峰期
+	} else {
+		<-d.minutePushPool //正常期
+	}
+	if wxPush == 1 {
+		isPushOk := true
+		if k.ApplyStatus == 1 {
+			TmpTip := ""
+			minute := time.Now().Unix() - lastInfoDate
+			if minute > -1 && minute < 61 {
+				TmpTip = fmt.Sprintf("%d秒前发布的", minute)
+			} else {
+				minute = minute / 60
+				if minute < 121 {
+					if minute < 1 {
+						minute = 1
+					}
+					TmpTip = fmt.Sprintf("%d分钟前发布的", minute)
+				}
+			}
+			Tip1 := util.If(TmpTip == "", "", TmpTip+":\n").(string)
+			LastTip := ""
+			if i > 1 {
+				LastTip = fmt.Sprintf("...(共%d条)", i)
+			}
+			LastTipLen := len([]rune(LastTip))
+			wxTitleKeys := strings.Join(k.OriginalKeys, ";")
+			if len([]rune(wxTitleKeys)) > 8 {
+				wxTitleKeys = string([]rune(wxTitleKeys)[:8]) + "..."
+			}
+			wxtitle := fmt.Sprintf(SysConfig.WxTitle, wxTitleKeys)
+			TitleLen := len([]rune(wxtitle))
+			GroupLen := len([]rune(k.ModifyDate))
+			reLen := 200 - TitleLen - GroupLen - WxContentLen - len([]rune(Tip1))
+			//if infoType == 2 {
+			//	reLen = reLen - 4
+			//}
+			WXTitle := ""
+			bshow := false
+			for n := 1; n < len(TitleArray)+1; n++ {
+				curTitle := TitleArray[n-1]
+				tmptitle := WXTitle + fmt.Sprintf("%d %s\n", n, curTitle)
+				ch := reLen - len([]rune(tmptitle))
+				if ch < LastTipLen { //加上后大于后辍,则没有完全显示
+					if ch == 0 && n == len(TitleArray) {
+						WXTitle = tmptitle
+						bshow = true
+					} else {
+						ch_1 := reLen - len([]rune(WXTitle)) - LastTipLen
+						if ch_1 > 8 {
+							curLen := len([]rune(curTitle))
+							if ch_1 > curLen {
+								ch_1 = curLen
+							}
+							WXTitle += fmt.Sprintf("%d %s\n", n, string([]rune(curTitle)[:ch_1-3]))
+						}
+					}
+				} else if ch == LastTipLen {
+					WXTitle = tmptitle
+					if n == len(TitleArray) {
+						bshow = true
+					}
+				} else {
+					WXTitle = tmptitle
+					if n == len(TitleArray) {
+						bshow = true
+					}
+				}
+			}
+			if bshow {
+				LastTip = ""
+			}
+			//推送微信
+			isPushOk = putil.SendWeixin(k, Tip1+WXTitle+LastTip, wxtitle)
+			if isPushOk {
+				wxStatus = 1
+			} else {
+				wxStatus = -1
+			}
+		}
+		logger.Info("推送任务", taskType, "微信推送", isPushOk, k.Id, k.S_m_openid, k.RateMode, k.ApplyStatus)
+	}
+	if appPush == 1 {
+		if len([]rune(jpushtitle)) > 80 {
+			jpushtitle = string([]rune(jpushtitle)[:80]) + "..."
+		}
+		if i > 1 {
+			jpushtitle = fmt.Sprintf("1. %s\n...(共%d条)", jpushtitle, i)
+		}
+		go mongodb.Update("user", map[string]interface{}{
+			"_id": bson.ObjectIdHex(k.Id),
+		}, map[string]interface{}{
+			"$inc": map[string]interface{}{
+				"i_apppushunread": 1,
+			},
+		}, false, false)
+		isPushOk := putil.SendApp(map[string]interface{}{
+			"phoneType": k.AppPhoneType,
+			"descript":  jpushtitle,
+			"type":      "bid",
+			"userId":    k.Id,
+			"url":       "/jyapp/free/sess/" + Se.EncodeString(k.Id+",_id,"+strconv.Itoa(int(time.Now().Unix()))+",historypush"),
+			//"url":       "/jyapp/free/sess/" + Se.EncodeString(sess_openid+",_id,"+strconv.Itoa(int(time.Now().Unix()))+",historypush"),
+			//"url":         "/jyapp/free/sess/" + push.Se.EncodeString(k.Openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",wxpushlist") + "__" + pushid,
+			"otherPushId": k.Opushid,
+			"jgPushId":    k.Jpushid, //极光-推送id
+		})
+		if isPushOk {
+			appStatus = 1
+		} else {
+			appStatus = -1
+		}
+		logger.Info("推送任务", taskType, "app推送", isPushOk, k.Id, k.S_m_openid, k.A_m_openid, k.Phone, k.AppPhoneType, k.Jpushid, k.Opushid, k.RateMode)
+	}
+	//发送邮件
+	if mailPush == 1 {
+		html := fmt.Sprintf(SysConfig.Mail_html, strings.Replace(strings.Join(k.OriginalKeys, ";"), "+", " ", -1), mailContent)
+		subject := fmt.Sprintf(SysConfig.Mail_title, "招标")
+		isPushOk := d.SendMail(k.Email, subject, html, fmdatas)
+		if isPushOk {
+			mailStatus = 1
+		} else {
+			mailStatus = -1
+		}
+		logger.Info("推送任务", taskType, "发送邮件", isPushOk, k.Id, k.S_m_openid, k.A_m_openid, k.Phone, k.Email, k.DataExport)
+	}
+	return
+}
+
+//推送邮件(含附件)
+func (d *doPush) SendMail(email, subject, html string, fmdatas []map[string]interface{}) bool {
+	if !SysConfig.IsPushMail || len(Gmails) == 0 {
+		return true
+	}
+	if SysConfig.MailSleep > 0 {
+		time.Sleep(time.Duration(SysConfig.MailSleep) * time.Millisecond)
+	}
+	defer util.Catch()
+	//生成附件
+	var fnamepath, rename string
+	if len(fmdatas) > 0 { //开启导出
+		fnamepath, rename = putil.GetBidInfoXlsx(fmdatas)
+	}
+	status := false
+	index := len(email) % 2
+	if index >= len(Gmails) {
+		index = 0
+	}
+	gmail := Gmails[index]
+	for i := 0; i < len(Gmails); i++ {
+		status = mail.GSendMail("剑鱼标讯", email, "", "", subject, html, fnamepath, rename, gmail)
+		if status {
+			break
+		} else {
+			gmail = Gmails[index^1]
+		}
+	}
+	if fnamepath != "" {
+		os.Remove(fnamepath)
+	}
+	return status
+}

+ 18 - 13
src/jfw/modules/pushsubscribe/src/push/job/job.go

@@ -5,20 +5,25 @@ import (
 	"sync"
 )
 
-type Job interface {
-	MySelf() interface{}
-	Execute(taskType int, isMove bool)
-}
+const (
+	BulkSize = 200
+	DbName   = "qfw"
+)
 
-type jobs struct {
-	Nine Job
-	Push Job
-}
+var DoPush = &doPush{}
 
-var Jobs = &jobs{
-	Push: &PushJob{
-		pushPool:    make(chan bool, config.SysConfig.PushPoolSize),
-		pushWait:    &sync.WaitGroup{},
-		pushJobLock: &sync.Mutex{},
+var Jobs = struct {
+	Push   *pushJob
+	Repair *repairJob
+}{
+	Push: &pushJob{
+		pool: make(chan bool, config.SysConfig.PushPoolSize),
+		wait: &sync.WaitGroup{},
+		lock: &sync.Mutex{},
+	},
+	Repair: &repairJob{
+		pool: make(chan bool, config.SysConfig.PushPoolSize),
+		wait: &sync.WaitGroup{},
+		lock: &sync.Mutex{},
 	},
 }

+ 150 - 524
src/jfw/modules/pushsubscribe/src/push/job/pushjob.go

@@ -1,20 +1,12 @@
 package job
 
 import (
-	"encoding/json"
-	"fmt"
-	"math"
-	"os"
 	. "public"
 	. "push/config"
 	putil "push/util"
 	"qfw/util"
-	"qfw/util/mail"
 	"qfw/util/mongodb"
-	"regexp"
 	"sort"
-	"strconv"
-	"strings"
 	"sync"
 	"time"
 
@@ -23,74 +15,37 @@ import (
 	"gopkg.in/mgo.v2/bson"
 )
 
-const (
-	BulkSize = 200
-	DbName   = "qfw"
-)
-
 var (
-	messyCodeEmailReg = regexp.MustCompile(SysConfig.MessyCodeEmailReg)
-	MoveFields        = []string{"s_m_openid", "a_m_openid", "phone", "usertype", "jpushid", "opushid", "words", "ratemode", "wxpush", "apppush", "mailpush", "smartset", "timestamp", "subscribe", "applystatus", "appphonetype", "email", "size", "modifydate", "mergeorder"}
+	MoveFields = []string{"s_m_openid", "a_m_openid", "phone", "usertype", "jpushid", "opushid", "words", "ratemode", "wxpush", "apppush", "mailpush", "pchelperpush", "smartset", "timestamp", "subscribe", "applystatus", "appphonetype", "email", "size", "modifydate", "mergeorder", "nickname", "firstpushtime"}
 )
 
-func init() {
-	mySelf := Jobs.Push.MySelf().(*PushJob)
-	//推送1分钟限制
-	mySelf.minutePushPool = make(chan bool, SysConfig.MinutePushSize)
-	mySelf.fastigiumMinutePushPool = make(chan bool, SysConfig.FastigiumMinutePushSize)
-	for i := 0; i < SysConfig.MinutePushSize; i++ {
-		mySelf.minutePushPool <- true
-	}
-	for i := 0; i < SysConfig.FastigiumMinutePushSize; i++ {
-		mySelf.fastigiumMinutePushPool <- true
-	}
-	go func() {
-		t := time.NewTicker(time.Minute)
-		for {
-			select {
-			case <-t.C:
-				for i := 0; i < SysConfig.MinutePushSize-len(mySelf.minutePushPool); i++ {
-					mySelf.minutePushPool <- true
-				}
-				for i := 0; i < SysConfig.FastigiumMinutePushSize-len(mySelf.fastigiumMinutePushPool); i++ {
-					mySelf.fastigiumMinutePushPool <- true
-				}
-			}
-		}
-	}()
-}
-
 type Move struct {
 	Info map[string]interface{}
 	Ids  []interface{}
 }
 
-type PushJob struct {
-	pushPool                chan bool
-	minutePushPool          chan bool
-	fastigiumMinutePushPool chan bool
-	pushWait                *sync.WaitGroup
-	pushJobLock             *sync.Mutex
-	lastId                  string
-	pushDatas               *[]map[string]interface{}
-}
-
-func (p *PushJob) MySelf() interface{} {
-	return p
+type pushJob struct {
+	taskType int
+	pool     chan bool
+	wait     *sync.WaitGroup
+	lock     *sync.Mutex
+	lastId   string
+	users    *[]map[string]interface{}
 }
 
 //taskType 1--实时推送 2--实时推送+一天三次的8点推送 3--一天三次推送 4--九点推送
-func (p *PushJob) Execute(taskType int, isMoveDatas bool) {
-	p.pushJobLock.Lock()
-	defer p.pushJobLock.Unlock()
-	logger.Info("开始推送任务。。。", taskType)
+func (p *pushJob) Execute(taskType int, isMoveDatas bool) {
+	p.lock.Lock()
+	defer p.lock.Unlock()
+	p.taskType = taskType
+	logger.Info("开始推送任务。。。", p.taskType)
 	if isMoveDatas {
-		p.Move(taskType)
+		p.Move()
 	}
-	p.Push(taskType)
+	p.Push()
 }
-func (p *PushJob) Move(taskType int) {
-	logger.Info("推送任务", taskType, "开始迁移数据。。。")
+func (p *pushJob) Move() {
+	logger.Info("推送任务", p.taskType, "开始迁移数据。。。")
 	nowUnix := time.Now().Unix()
 	sess := mongodb.GetMgoConn()
 	defer mongodb.DestoryMongoConn(sess)
@@ -100,7 +55,7 @@ func (p *PushJob) Move(taskType int) {
 		},
 	}).Sort("userid").Iter()
 	moves := map[string]*Move{}
-	logger.Info("推送任务", taskType, "开始遍历pushspace_temp")
+	logger.Info("推送任务", p.taskType, "开始遍历pushspace_temp")
 	index, number, length := 0, 0, 0
 	for temp := make(map[string]interface{}); it.Next(&temp); {
 		userId := util.ObjToString(temp["userid"])
@@ -111,7 +66,7 @@ func (p *PushJob) Move(taskType int) {
 			for _, v := range list {
 				idMap[util.ObjToString((*v.Info)["_id"])] = true
 			}
-			newList := p.ToSortList(temp["list"])
+			newList := putil.ToSortList(temp["list"])
 			for _, v := range newList {
 				if idMap[util.ObjToString((*v.Info)["_id"])] {
 					continue
@@ -126,7 +81,7 @@ func (p *PushJob) Move(taskType int) {
 			move.Info = temp
 			move.Ids = append(move.Ids, temp["_id"])
 		} else {
-			temp["list"] = p.ToSortList(temp["list"])
+			temp["list"] = putil.ToSortList(temp["list"])
 			move = &Move{
 				Info: temp,
 				Ids:  []interface{}{temp["_id"]},
@@ -137,23 +92,23 @@ func (p *PushJob) Move(taskType int) {
 		index++
 		length++
 		if index%500 == 0 {
-			logger.Info("推送任务", taskType, "pushspace_temp加载到内存:", index)
+			logger.Info("推送任务", p.taskType, "pushspace_temp加载到内存:", index)
 		}
 		if length == SysConfig.MoveBatch {
 			length = 0
-			p.Merge(taskType, &number, nowUnix, moves)
+			p.Merge(&number, nowUnix, moves)
 			moves = map[string]*Move{}
 		}
 	}
 	if length > 0 {
-		p.Merge(taskType, &number, nowUnix, moves)
+		p.Merge(&number, nowUnix, moves)
 	}
 	moves = nil
-	logger.Info("推送任务", taskType, "迁移数据结束。。。", index)
+	logger.Info("推送任务", p.taskType, "迁移数据结束。。。", index)
 }
-func (p *PushJob) Merge(taskType int, number *int, nowUnix int64, moves map[string]*Move) {
+func (p *pushJob) Merge(number *int, nowUnix int64, moves map[string]*Move) {
 	*number++
-	logger.Info("推送任务", taskType, "第", *number, "次开始合并数据")
+	logger.Info("推送任务", p.taskType, "第", *number, "次开始合并数据")
 	index := 0
 	saveArray := []map[string]interface{}{}
 	saveArray_delete := []interface{}{}
@@ -186,7 +141,7 @@ func (p *PushJob) Merge(taskType int, number *int, nowUnix int64, moves map[stri
 			}
 			pushAll := make(map[string]interface{})
 			for _, v := range []string{"", "temp"} {
-				oldList := p.ToSortList(data[v+"list"])
+				oldList := putil.ToSortList(data[v+"list"])
 				if v == "temp" && oldList == nil {
 					continue
 				}
@@ -232,7 +187,7 @@ func (p *PushJob) Merge(taskType int, number *int, nowUnix int64, moves map[stri
 		}
 		index++
 		if index%500 == 0 {
-			logger.Info("推送任务", taskType, "第", *number, "次合并数据:", index)
+			logger.Info("推送任务", p.taskType, "第", *number, "次合并数据:", index)
 		}
 	}
 	if len(saveArray) > 0 {
@@ -241,9 +196,9 @@ func (p *PushJob) Merge(taskType int, number *int, nowUnix int64, moves map[stri
 	if len(updateArray_query) > 0 {
 		p.UpdateBulk(sess, &updateArray_query, &updateArray_set, &updateArray_delete)
 	}
-	logger.Info("推送任务", taskType, "第", *number, "次合并数据结束。。。", index)
+	logger.Info("推送任务", p.taskType, "第", *number, "次合并数据结束。。。", index)
 }
-func (p *PushJob) SaveBulk(sess *mgo.Session, saves *[]map[string]interface{}, deletes *[]interface{}) {
+func (p *pushJob) SaveBulk(sess *mgo.Session, saves *[]map[string]interface{}, deletes *[]interface{}) {
 	coll := sess.DB(DbName).C("pushspace")
 	bulk := coll.Bulk()
 	for _, v := range *saves {
@@ -257,7 +212,7 @@ func (p *PushJob) SaveBulk(sess *mgo.Session, saves *[]map[string]interface{}, d
 	}
 	*saves = []map[string]interface{}{}
 }
-func (p *PushJob) UpdateBulk(sess *mgo.Session, array_q, array_s *[]map[string]interface{}, array_d *[]interface{}) {
+func (p *pushJob) UpdateBulk(sess *mgo.Session, array_q, array_s *[]map[string]interface{}, array_d *[]interface{}) {
 	coll := sess.DB(DbName).C("pushspace")
 	bulk := coll.Bulk()
 	for k, v := range *array_q {
@@ -272,7 +227,7 @@ func (p *PushJob) UpdateBulk(sess *mgo.Session, array_q, array_s *[]map[string]i
 	*array_q = []map[string]interface{}{}
 	*array_s = []map[string]interface{}{}
 }
-func (p *PushJob) DelBulk(sess *mgo.Session, array *[]interface{}) {
+func (p *pushJob) DelBulk(sess *mgo.Session, array *[]interface{}) {
 	coll := sess.DB(DbName).C("pushspace_temp")
 	count := 0
 	bulk := coll.Bulk()
@@ -298,49 +253,48 @@ func (p *PushJob) DelBulk(sess *mgo.Session, array *[]interface{}) {
 	}
 	*array = []interface{}{}
 }
-func (p *PushJob) Push(taskType int) {
-	logger.Info("推送任务", taskType, "开始推送。。。")
-	p.lastId = ""
+func (p *pushJob) Push() {
+	logger.Info("推送任务", p.taskType, "开始推送。。。")
 	batch_index := 0
 	for {
 		batch_index++
-		batch_size := p.OncePushBatch(batch_index, taskType)
-		for _, temp := range *p.pushDatas {
-			p.pushPool <- true
-			p.pushWait.Add(1)
+		batch_size := p.OncePushBatch(batch_index)
+		for _, temp := range *p.users {
+			p.pool <- true
+			p.wait.Add(1)
 			go func(v map[string]interface{}) {
 				defer func() {
-					<-p.pushPool
-					p.pushWait.Done()
+					<-p.pool
+					p.wait.Done()
 				}()
 				words, _ := v["words"].([]interface{})
 				u := &UserInfo{
-					Id:           util.ObjToString(v["userid"]),
-					OriginalKeys: util.ObjArrToStringArr(words),
-					WxPush:       util.IntAll(v["wxpush"]),
-					AppPush:      util.IntAll(v["apppush"]),
-					MailPush:     util.IntAll(v["mailpush"]),
-					Email:        util.ObjToString(v["email"]),
-					S_m_openid:   util.ObjToString(v["s_m_openid"]),
-					A_m_openid:   util.ObjToString(v["a_m_openid"]),
-					Phone:        util.ObjToString(v["phone"]),
-					Jpushid:      util.ObjToString(v["jpushid"]),
-					Opushid:      util.ObjToString(v["opushid"]),
-					UserType:     util.IntAll(v["usertype"]),
-					RateMode:     util.IntAllDef(v["ratemode"], 1),
-					SmartSet:     util.IntAllDef(v["smartset"], 1),
-					DataExport:   util.IntAll(v["dataexport"]),
-					AppPhoneType: util.ObjToString(v["appphonetype"]),
-					ApplyStatus:  util.IntAll(v["applystatus"]),
-					Subscribe:    util.IntAllDef(v["subscribe"], 1),
-					ModifyDate:   util.ObjToString(v["modifydate"]),
-					MergeOrder:   v["mergeorder"],
+					Id:            util.ObjToString(v["userid"]),
+					OriginalKeys:  util.ObjArrToStringArr(words),
+					WxPush:        util.IntAll(v["wxpush"]),
+					AppPush:       util.IntAll(v["apppush"]),
+					MailPush:      util.IntAll(v["mailpush"]),
+					PchelperPush:  util.IntAll(v["pchelperpush"]),
+					Email:         util.ObjToString(v["email"]),
+					S_m_openid:    util.ObjToString(v["s_m_openid"]),
+					A_m_openid:    util.ObjToString(v["a_m_openid"]),
+					Phone:         util.ObjToString(v["phone"]),
+					Jpushid:       util.ObjToString(v["jpushid"]),
+					Opushid:       util.ObjToString(v["opushid"]),
+					UserType:      util.IntAll(v["usertype"]),
+					RateMode:      util.IntAllDef(v["ratemode"], 1),
+					SmartSet:      util.IntAllDef(v["smartset"], 1),
+					DataExport:    util.IntAll(v["dataexport"]),
+					AppPhoneType:  util.ObjToString(v["appphonetype"]),
+					ApplyStatus:   util.IntAll(v["applystatus"]),
+					Subscribe:     util.IntAllDef(v["subscribe"], 1),
+					ModifyDate:    util.ObjToString(v["modifydate"]),
+					MergeOrder:    v["mergeorder"],
+					FirstPushTime: util.Int64All(v["firstpushtime"]),
 				}
-				logger.Info("推送任务", taskType, "开始推送用户,userid", u.Id, "s_m_openid", u.S_m_openid, "a_m_openid", u.A_m_openid, "phone", u.Phone, "subscribe", u.Subscribe, "applystatus", u.ApplyStatus, "jpushid", u.Jpushid, "opushid", u.Opushid)
+				logger.Info("推送任务", p.taskType, "开始推送用户,userid", u.Id, "s_m_openid", u.S_m_openid, "a_m_openid", u.A_m_openid, "phone", u.Phone, "subscribe", u.Subscribe, "applystatus", u.ApplyStatus, "jpushid", u.Jpushid, "opushid", u.Opushid)
 				wxPush, appPush, mailPush := 0, 0, 0
-				list := p.ToSortList(v["list"])
-				templist := p.ToSortList(v["templist"])
-				if taskType == 1 {
+				if p.taskType == 1 {
 					if u.WxPush == 1 {
 						if u.ApplyStatus == 1 {
 							wxPush = -1
@@ -352,9 +306,15 @@ func (p *PushJob) Push(taskType int) {
 						appPush = 1
 					}
 					if u.MailPush == 1 {
-						mailPush = -1
+						if u.UserType == 0 && u.ApplyStatus == 1 {
+							mailPush = -1
+						} else if u.UserType == 5 && u.ApplyStatus == 1 && u.AppPush == 0 {
+							mailPush = -1
+						} else {
+							mailPush = 1
+						}
 					}
-				} else if taskType == 2 || taskType == 4 {
+				} else if p.taskType == 2 || p.taskType == 4 {
 					if u.WxPush == 1 {
 						wxPush = 1
 					}
@@ -364,26 +324,18 @@ func (p *PushJob) Push(taskType int) {
 					if u.MailPush == 1 {
 						mailPush = 1
 					}
-				} else if taskType == 3 {
+				} else if p.taskType == 3 {
 					if u.WxPush == 1 && u.ApplyStatus == 1 {
 						wxPush = 1
 					}
 					if u.MailPush == 1 {
 						mailPush = 1
 					}
-				} else if taskType == 4 {
-					if u.WxPush == 1 {
-						wxPush = 1
-					}
-					if u.AppPush == 1 {
-						appPush = 1
-					}
-					if u.MailPush == 1 {
-						mailPush = 1
-					}
 				}
+				list := putil.ToSortList(v["list"])
+				tempList := putil.ToSortList(v["templist"])
 				t_wxPush, t_mailPush := util.IntAll(v["tempwxpush"]), util.IntAll(v["tempmailpush"])
-				if templist != nil {
+				if tempList != nil {
 					if wxPush == 1 && t_wxPush == 0 {
 						wxPush = 0
 					}
@@ -391,7 +343,7 @@ func (p *PushJob) Push(taskType int) {
 						mailPush = 0
 					}
 				}
-				logger.Info("推送任务", taskType, "用户接收方式,userid", u.Id, "wxPush", wxPush, "appPush", appPush, "mailPush", mailPush, "t_wxPush", t_wxPush, "t_mailPush", t_mailPush)
+				logger.Info("推送任务", p.taskType, "用户接收方式,userid", u.Id, "wxPush", wxPush, "appPush", appPush, "mailPush", mailPush, "t_wxPush", t_wxPush, "t_mailPush", t_mailPush)
 				if wxPush != 1 && appPush != 1 && mailPush != 1 {
 					return
 				}
@@ -403,50 +355,31 @@ func (p *PushJob) Push(taskType int) {
 					appPush = 0
 				}
 				if mailPush != 0 {
-					if (u.UserType == 0 || u.UserType == 3) && u.Subscribe == 0 {
+					if u.UserType == 0 && u.Subscribe == 0 {
 						mailPush = 0
-					} else if (u.UserType == 1 || u.UserType == 2 || u.UserType == 4) && u.Jpushid == "" && u.Opushid == "" {
+					} else if (u.UserType == 1 || u.UserType == 2) && u.Jpushid == "" && u.Opushid == "" {
 						mailPush = 0
 					} else if u.UserType == 5 && u.Subscribe == 0 && u.Jpushid == "" && u.Opushid == "" {
 						mailPush = 0
 					}
 				}
-				if wxPush == 1 || appPush == 1 || mailPush == 1 {
-					isSaveSuccess := false
-					//wxPushStatus, appPushStatus, mailPushStatus := 0, 0, 0
-					//开通订阅推送或邮箱推送的用户,由实时推送修改成九点推送,app推送用list字段,微信和邮箱推送用templist字段
-					if list != nil && templist != nil {
-						isSaveSuccess, _, _, _ = p.DealSend(taskType, true, 0, appPush, 0, u, &list)
-						if !isSaveSuccess {
-							return
-						}
-						p.DealSend(taskType, false, wxPush, 0, mailPush, u, &templist)
-					} else if list != nil {
-						isSaveSuccess, _, _, _ = p.DealSend(taskType, true, wxPush, appPush, mailPush, u, &list)
-						if !isSaveSuccess {
-							return
-						}
-					} else if templist != nil {
-						p.DealSend(taskType, false, wxPush, 0, mailPush, u, &templist)
-					}
-				}
-				/*if wxPush == 1 {
-					if wxPushStatus == -1 {
-						wxPush = -1
-					} else {
-						wxPush = 0
+				isSaveSuccess, wxStatus, appStatus, mailStatus := DoPush.Execute(p.taskType, wxPush, appPush, mailPush, u, list, tempList)
+				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
 				}
-				if mailPush == 1 {
-					if mailPushStatus == -1 {
-						mailPush = -1
-					} else {
-						mailPush = 0
-					}
-				}*/
 				//判断是否要删除数据
-				_sess := mongodb.GetMgoConn()
-				defer mongodb.DestoryMongoConn(_sess)
+				sess := mongodb.GetMgoConn()
+				defer mongodb.DestoryMongoConn(sess)
 				if wxPush == -1 || mailPush == -1 {
 					//如果该用户还有微信或者邮箱推送,把list字段的值挪到templist
 					update := map[string]interface{}{}
@@ -454,384 +387,93 @@ func (p *PushJob) Push(taskType int) {
 						"tempwxpush":   wxPush,
 						"tempmailpush": mailPush,
 					}
-					if templist == nil {
+					if tempList == nil {
 						update["$rename"] = map[string]interface{}{"list": "templist"}
 					} else {
 						update["$unset"] = map[string]interface{}{"list": ""}
 					}
 					update["$set"] = set
-					_sess.DB(DbName).C("pushspace").UpdateId(v["_id"], update)
-				} else {
-					_sess.DB(DbName).C("pushspace").RemoveId(v["_id"])
-				}
-			}(temp)
-		}
-		if batch_size < SysConfig.PushBatch {
-			break
-		}
-	}
-	p.pushWait.Wait()
-	logger.Info("推送任务结束。。。", taskType)
-}
-func (p *PushJob) DealSend(taskType int, isSave bool, wxPush, appPush, mailPush int, k *UserInfo, sl *SortList) (isSaveSuccess bool, wxPushStatus, appPushStatus, mailPushStatus int) {
-	defer util.Catch()
-	str := fmt.Sprintf("<div>根据您设置的关键词(%s),给您推送以下信息:</div>", strings.Join(k.OriginalKeys, ";"))
-	mailContent := ""
-	//发送内容组合
-	i := 0
-	jpushtitle := ""
-	lastInfoDate := int64(0)
-	TitleArray := []string{}
-	o_pushinfo := map[string]map[string]interface{}{}
-	matchKey_infoIndex := map[string]string{}
-	publishTitle := map[string]bool{}
-	//邮件附件
-	var fmdatas = []map[string]interface{}{}
-	for _, ks := range *sl {
-		k2 := *ks.Info
-		title := strings.Replace(k2["title"].(string), "\n", "", -1)
-		area := util.ObjToString(k2["area"])
-		if area == "A" {
-			area = "全国"
-		}
-		newTitle := fmt.Sprintf("[%s]%s", area, title)
-		if publishTitle[newTitle] {
-			continue
-		}
-		publishTitle[title] = true
-		i++
-		TitleArray = append(TitleArray, Re.ReplaceAllString(newTitle, "$1"))
-		if i == 1 {
-			jpushtitle = title
-			lastInfoDate = util.Int64All(k2["publishtime"])
-		}
-		//_sid := util.EncodeArticleId(util.BsonIdToSId(k2["_id"]))
-		//url := fmt.Sprintf("%s/pcdetail/%s.html", Domain, _sid)
-		_sid := util.EncodeArticleId2ByCheck(util.ObjToString(k2["_id"]))
-		//增加行业的处理
-		industry := ""
-		industryclass := "industry"
-		if k2["s_subscopeclass"] != nil {
-			k2sub := strings.Split(util.ObjToString(k2["s_subscopeclass"]), ",")
-			if len(k2sub) > 0 {
-				industry = k2sub[0]
-				if industry != "" {
-					ss := strings.Split(industry, "_")
-					if len(ss) > 1 {
-						industry = ss[0]
+					err := sess.DB(DbName).C("pushspace").UpdateId(v["_id"], update)
+					if err != nil {
+						logger.Error("推送任务", p.taskType, "update error", err)
 					}
-				}
-			}
-		}
-		if mailPush == 1 { //关于邮件的处理
-			mailSid := util.CommonEncodeArticle("mailprivate", util.ObjToString(k2["_id"]))
-			url := fmt.Sprintf("%s/article/mailprivate/%s.html", SysConfig.JianyuDomain, mailSid)
-			classArea := "area"
-			classType := "type"
-			types := util.ObjToString(k2["subtype"])
-			if types == "" {
-				types = util.ObjToString(k2["toptype"])
-				if types == "" {
-					types = "其他"
-				}
-			}
-			dates := util.LongToDate(k2["publishtime"], false)
-			//标题替换
-			otitle := title
-			for _, kw := range k.OriginalKeys {
-				kws := strings.Split(kw, "+")
-				n := 0
-				otitle2 := otitle
-				for _, kwn := range kws {
-					ot := strings.Replace(otitle2, kwn, "<span class='keys'>"+kwn+"</span>", 1)
-					if ot != otitle {
-						n++
-						otitle2 = ot
-					} else {
-						break
+				} else {
+					err := sess.DB(DbName).C("pushspace").RemoveId(v["_id"])
+					if err != nil {
+						logger.Error("推送任务", p.taskType, "update error", err)
 					}
 				}
-				if n == len(kws) {
-					otitle = otitle2
-					break
-				}
-			}
-			if industry == "" {
-				industryclass = ""
-			}
-			mailContent += fmt.Sprintf(SysConfig.Mail_content, i, url, otitle, classArea, area, classType, types, industryclass, industry, dates)
-		}
-		str += "<div class='tslist'><span class='xh'>" + fmt.Sprintf("%d", i) + ".</span><a class='bt' target='_blank' eid='" + _sid + "' href='" + util.ObjToString(k2["href"]) + "'>[<span class='area'>" + area + "</span>]" + title + "</a></div>"
-		o_pushinfo[strconv.Itoa(i)] = map[string]interface{}{
-			"publishtime":   k2["publishtime"],
-			"stype":         util.ObjToString(k2["type"]),
-			"topstype":      util.ObjToString(k2["toptype"]),
-			"substype":      util.ObjToString(k2["subtype"]),
-			"subscopeclass": industry,
-			"buyer":         k2["buyer"],
-			"projectname":   k2["projectname"],
-			"budget":        k2["budget"],
-			"bidopentime":   k2["bidopentime"],
-			"winner":        k2["winner"],
-			"bidamount":     k2["bidamount"],
-		}
-		//附件数据
-		fmdata := map[string]interface{}{
-			"publishtime": k2["publishtime"],
-			"subtype":     k2["subtype"],
-			"buyer":       k2["buyer"],
-			"projectname": k2["projectname"],
-			"budget":      k2["budget"],
-			"bidopentime": k2["bidopentime"],
-			"winner":      k2["winner"],
-			"bidamount":   k2["bidamount"],
-		}
-		fmdatas = append(fmdatas, fmdata)
-		//匹配到的关键词
-		for _, key := range (*ks).Keys {
-			if matchKey_infoIndex[key] != "" {
-				matchKey_infoIndex[key] = matchKey_infoIndex[key] + ","
-			}
-			matchKey_infoIndex[key] = matchKey_infoIndex[key] + strconv.Itoa(i)
-		}
-		if i >= SysConfig.MaxPushSize {
-			//限制最大信息条数
-			break
-		}
-	}
-	if i == 0 {
-		logger.Info("推送任务", taskType, "没有要推送的数据!", k.S_m_openid, k.A_m_openid, k.Phone)
-		return
-	}
-	if isSave {
-		//推送记录id
-		pushId := putil.SaveSendInfo(taskType, k, str, o_pushinfo, matchKey_infoIndex)
-		if pushId == "" {
-			logger.Info("推送任务", taskType, "保存到cassandra出错", k.Id, k.S_m_openid, k.A_m_openid, k.Phone)
-			return
-		} else {
-			logger.Info("推送任务", taskType, "成功保存到cassandra", pushId, k.Id, k.S_m_openid, k.A_m_openid, k.Phone)
-		}
-		isSaveSuccess = true
-	}
-	//九点推送的时候,限制一分钟最大的推送数量
-	if taskType == 4 && (wxPush == 1 || appPush == 1) {
-		hour := time.Now().Hour()
-		fastigiumStart, fastigiumEnd := 0, 0
-		fastigiumTimes := strings.Split(SysConfig.FastigiumTime, "-")
-		if len(fastigiumTimes) == 2 {
-			fastigiumStart = util.IntAll(fastigiumTimes[0])
-			fastigiumEnd = util.IntAll(fastigiumTimes[1])
-		}
-		if hour >= fastigiumStart && hour <= fastigiumEnd {
-			<-p.fastigiumMinutePushPool //高峰期
-		} else {
-			<-p.minutePushPool //正常期
-		}
-	}
-	if wxPush == 1 {
-		isPushOk := true
-		if k.ApplyStatus == 1 {
-			TmpTip := ""
-			minute := time.Now().Unix() - lastInfoDate
-			if minute > -1 && minute < 61 {
-				TmpTip = fmt.Sprintf("%d秒前发布的", minute)
-			} else {
-				minute = minute / 60
-				if minute < 121 {
-					if minute < 1 {
-						minute = 1
+				if wxStatus == -1 || appStatus == -1 || mailStatus == -1 {
+					f_count, err := sess.DB(DbName).C("pushspace").FindId(v["_id"]).Count()
+					if err != nil {
+						logger.Error("推送任务", p.taskType, "find count error", err)
+						return
 					}
-					TmpTip = fmt.Sprintf("%d分钟前发布的", minute)
-				}
-			}
-			Tip1 := util.If(TmpTip == "", "", TmpTip+":\n").(string)
-			LastTip := ""
-			if i > 1 {
-				LastTip = fmt.Sprintf("...(共%d条)", i)
-			}
-			LastTipLen := len([]rune(LastTip))
-			wxTitleKeys := strings.Join(k.OriginalKeys, ";")
-			if len([]rune(wxTitleKeys)) > 8 {
-				wxTitleKeys = string([]rune(wxTitleKeys)[:8]) + "..."
-			}
-			wxtitle := fmt.Sprintf(SysConfig.WxTitle, wxTitleKeys)
-			TitleLen := len([]rune(wxtitle))
-			GroupLen := len([]rune(k.ModifyDate))
-			reLen := 200 - TitleLen - GroupLen - WxContentLen - len([]rune(Tip1))
-			//if infoType == 2 {
-			//	reLen = reLen - 4
-			//}
-			WXTitle := ""
-			bshow := false
-			for n := 1; n < len(TitleArray)+1; n++ {
-				curTitle := TitleArray[n-1]
-				tmptitle := WXTitle + fmt.Sprintf("%d %s\n", n, curTitle)
-				ch := reLen - len([]rune(tmptitle))
-				if ch < LastTipLen { //加上后大于后辍,则没有完全显示
-					if ch == 0 && n == len(TitleArray) {
-						WXTitle = tmptitle
-						bshow = true
+					if f_count == 0 {
+						v["failtime"] = time.Now().Unix()
+						if wxStatus == -1 {
+							v["wxfail"] = 1
+						}
+						if appStatus == -1 {
+							v["appfail"] = 1
+						}
+						if mailStatus == -1 {
+							v["mailfail"] = 1
+						}
+						err := sess.DB(DbName).C("pushspace_fail").Insert(v)
+						if err != nil {
+							logger.Error("推送任务", p.taskType, "update error", err)
+						}
 					} else {
-						ch_1 := reLen - len([]rune(WXTitle)) - LastTipLen
-						if ch_1 > 8 {
-							curLen := len([]rune(curTitle))
-							if ch_1 > curLen {
-								ch_1 = curLen
-							}
-							WXTitle += fmt.Sprintf("%d %s\n", n, string([]rune(curTitle)[:ch_1-3]))
+						f_update := map[string]interface{}{}
+						if wxStatus == -1 {
+							f_update["wxfail"] = 1
+						}
+						if appStatus == -1 {
+							f_update["appfail"] = 1
+						}
+						if mailStatus == -1 {
+							f_update["mailfail"] = 1
+						}
+						err := sess.DB(DbName).C("pushspace_fail").UpdateId(v["_id"], map[string]interface{}{"$set": f_update})
+						if err != nil {
+							logger.Error("推送任务", p.taskType, "update error", err)
 						}
-					}
-				} else if ch == LastTipLen {
-					WXTitle = tmptitle
-					if n == len(TitleArray) {
-						bshow = true
-					}
-				} else {
-					WXTitle = tmptitle
-					if n == len(TitleArray) {
-						bshow = true
 					}
 				}
-			}
-			if bshow {
-				LastTip = ""
-			}
-			//推送微信
-			isPushOk = putil.SendWeixin(k, Tip1+WXTitle+LastTip, o_pushinfo, matchKey_infoIndex, wxtitle)
-			if isPushOk {
-				wxPushStatus = 1
-			} else {
-				wxPushStatus = -1
-			}
-		}
-		logger.Info("推送任务", taskType, "微信推送", isPushOk, k.Id, k.S_m_openid, k.RateMode, k.ApplyStatus)
-	}
-	if appPush == 1 {
-		if len([]rune(jpushtitle)) > 80 {
-			jpushtitle = string([]rune(jpushtitle)[:80]) + "..."
-		}
-		if i > 1 {
-			jpushtitle = fmt.Sprintf("1. %s\n...(共%d条)", jpushtitle, i)
-		}
-		go mongodb.Update("user", map[string]interface{}{
-			"_id": bson.ObjectIdHex(k.Id),
-		}, map[string]interface{}{
-			"$inc": map[string]interface{}{
-				"i_apppushunread": 1,
-			},
-		}, false, false)
-		sess_openid := k.A_m_openid
-		if sess_openid == "" {
-			sess_openid = k.Phone
-		}
-		if sess_openid == "" {
-			sess_openid = k.S_m_openid
-		}
-		isPushOk := putil.SendApp(map[string]interface{}{
-			"phoneType": k.AppPhoneType,
-			"descript":  jpushtitle,
-			"type":      "bid",
-			"userId":    k.Id,
-			"openId":    sess_openid,
-			"url":       "/jyapp/free/sess/" + Se.EncodeString(sess_openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",historypush"),
-			//"url":         "/jyapp/free/sess/" + push.Se.EncodeString(k.Openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",wxpushlist") + "__" + pushid,
-			"otherPushId": k.Opushid,
-			"jgPushId":    k.Jpushid, //极光-推送id
-		})
-		if isPushOk {
-			appPushStatus = 1
-		} else {
-			appPushStatus = -1
-		}
-		logger.Info("推送任务", taskType, "app推送", isPushOk, k.Id, k.S_m_openid, k.A_m_openid, k.Phone, k.AppPhoneType, k.Jpushid, k.Opushid, k.RateMode)
-	}
-	//发送邮件
-	if mailPush == 1 {
-		html := fmt.Sprintf(SysConfig.Mail_html, strings.Replace(strings.Join(k.OriginalKeys, ";"), "+", " ", -1), mailContent)
-		subject := fmt.Sprintf(SysConfig.Mail_title, "招标")
-		isPushOk := p.SendMail(k.Email, subject, html, fmdatas)
-		if isPushOk {
-			mailPushStatus = 1
-		} else {
-			mailPushStatus = -1
-		}
-		logger.Info("推送任务", taskType, "发送邮件", isPushOk, k.Id, k.S_m_openid, k.A_m_openid, k.Phone, k.Email, k.DataExport)
-	}
-	if wxPush == 1 || appPush == 1 || (mailPush == 1 && wxPush == 0 && appPush == 0) {
-		//pc端助手推送
-		openid := k.S_m_openid
-		if openid == "" {
-			openid = k.Phone
-		}
-		if openid != "" {
-			putil.SendPcHelper(map[string]interface{}{"clientCode": openid})
-		}
-	}
-	return
-}
-
-//推送邮件(含附件)
-func (p *PushJob) SendMail(email, subject, html string, fmdatas []map[string]interface{}) bool {
-	if !SysConfig.IsPushMail || len(Gmails) == 0 {
-		return true
-	}
-	if SysConfig.MailSleep > 0 {
-		time.Sleep(time.Duration(SysConfig.MailSleep) * time.Millisecond)
-	}
-	defer util.Catch()
-	//生成附件
-	var fnamepath, rename string
-	if len(fmdatas) > 0 { //开启导出
-		fnamepath, rename = putil.GetBidInfoXlsx(fmdatas)
-		if messyCodeEmailReg.MatchString(email) {
-			rename = time.Now().Format("2006-01-02") + ".xlsx"
+			}(temp)
 		}
-	}
-	status := false
-	index := len(email) % 2
-	var gmail *mail.GmailAuth
-	if index >= len(Gmails) {
-		index = 0
-	}
-	gmail = Gmails[index]
-	for i := 0; i < len(Gmails); i++ {
-		status = mail.GSendMail("剑鱼标讯", email, "", "", subject, html, fnamepath, rename, gmail)
-		if status {
+		if batch_size < SysConfig.PushBatch {
 			break
-		} else {
-			gmail = Gmails[int(math.Abs(float64(index-1)))]
 		}
 	}
-	if fnamepath != "" {
-		os.Remove(fnamepath)
-	}
-	return status
+	p.wait.Wait()
+	p.lastId = ""
+	p.users = nil
+	logger.Info("推送任务结束。。。", p.taskType)
 }
-
-/************************************************/
-func (p *PushJob) OncePushBatch(batch_index, taskType int) int {
-	p.pushDatas = &[]map[string]interface{}{}
+func (p *pushJob) OncePushBatch(batch_index int) int {
+	p.users = &[]map[string]interface{}{}
 	i := 0
 	sess := mongodb.GetMgoConn()
 	defer mongodb.DestoryMongoConn(sess)
 	var query map[string]interface{}
-	//实时推送,只查找ratemode==1的用户
-	if taskType == 1 || taskType == 2 {
+	//根据任务类型,查找ratemode
+	if p.taskType == 1 || p.taskType == 2 {
 		query = map[string]interface{}{
 			"ratemode": 1,
 		}
-	} else if taskType == 3 {
+	} else if p.taskType == 3 {
 		query = map[string]interface{}{
 			"ratemode":    1,
 			"applystatus": 1,
 		}
-	} else if taskType == 4 {
+	} else if p.taskType == 4 {
 		query = map[string]interface{}{
 			"ratemode": 2,
 		}
 	} else {
-		logger.Error("taskType error", taskType)
+		logger.Error("taskType error", p.taskType)
 		return i
 	}
 	if len(SysConfig.TestIds) > 0 {
@@ -844,33 +486,17 @@ func (p *PushJob) OncePushBatch(batch_index, taskType int) int {
 			"$gt": bson.ObjectIdHex(p.lastId),
 		}
 	}
-	logger.Info("推送任务", taskType, "开始加载第", batch_index, "批用户", query)
+	logger.Info("推送任务", p.taskType, "开始加载第", batch_index, "批用户", query)
 	it := sess.DB(DbName).C("pushspace").Find(query).Sort("_id").Iter()
 	for temp := make(map[string]interface{}); it.Next(&temp); {
 		i++
 		p.lastId = util.BsonIdToSId(temp["_id"])
-		*p.pushDatas = append(*p.pushDatas, temp)
+		*p.users = append(*p.users, temp)
 		temp = make(map[string]interface{})
 		if i == SysConfig.PushBatch {
 			break
 		}
 	}
-	logger.Info("推送任务", taskType, "第", batch_index, "批用户加载结束", p.lastId)
+	logger.Info("推送任务", p.taskType, "第", batch_index, "批用户加载结束", p.lastId)
 	return i
 }
-func (p *PushJob) ToSortList(list interface{}) SortList {
-	if list == nil {
-		return nil
-	}
-	b, err := json.Marshal(list)
-	if err != nil {
-		return nil
-	}
-	sl := make(SortList, 0)
-	err = json.Unmarshal(b, &sl)
-	if err != nil {
-		return nil
-	}
-	sort.Sort(sl)
-	return sl
-}

+ 160 - 0
src/jfw/modules/pushsubscribe/src/push/job/repairjob.go

@@ -0,0 +1,160 @@
+package job
+
+import (
+	"public"
+	. "push/config"
+	putil "push/util"
+	"qfw/util"
+	"qfw/util/mongodb"
+	"strings"
+	"sync"
+
+	"github.com/donnie4w/go-logger/logger"
+	"gopkg.in/mgo.v2/bson"
+)
+
+//补推接口
+type repairJob struct {
+	pool   chan bool
+	wait   *sync.WaitGroup
+	lock   *sync.Mutex
+	lastId string
+	users  *[]map[string]interface{}
+}
+
+func (r *repairJob) Execute(param string) bool {
+	logger.Info("开始补推任务。。。")
+	batch_index := 0
+	for {
+		batch_index++
+		batch_size := r.OncePushBatch(batch_index, param)
+		for _, temp := range *r.users {
+			r.pool <- true
+			r.wait.Add(1)
+			go func(v map[string]interface{}) {
+				defer func() {
+					<-r.pool
+					r.wait.Done()
+				}()
+				words, _ := v["words"].([]interface{})
+				u := &public.UserInfo{
+					Id:           util.ObjToString(v["userid"]),
+					OriginalKeys: util.ObjArrToStringArr(words),
+					WxPush:       util.IntAll(v["wxpush"]),
+					AppPush:      util.IntAll(v["apppush"]),
+					MailPush:     util.IntAll(v["mailpush"]),
+					Email:        util.ObjToString(v["email"]),
+					S_m_openid:   util.ObjToString(v["s_m_openid"]),
+					A_m_openid:   util.ObjToString(v["a_m_openid"]),
+					Phone:        util.ObjToString(v["phone"]),
+					Jpushid:      util.ObjToString(v["jpushid"]),
+					Opushid:      util.ObjToString(v["opushid"]),
+					UserType:     util.IntAll(v["usertype"]),
+					RateMode:     util.IntAllDef(v["ratemode"], 1),
+					SmartSet:     util.IntAllDef(v["smartset"], 1),
+					DataExport:   util.IntAll(v["dataexport"]),
+					AppPhoneType: util.ObjToString(v["appphonetype"]),
+					ApplyStatus:  util.IntAll(v["applystatus"]),
+					Subscribe:    util.IntAllDef(v["subscribe"], 1),
+					ModifyDate:   util.ObjToString(v["modifydate"]),
+					MergeOrder:   v["mergeorder"],
+				}
+				logger.Info("补推任务", "开始推送用户,userid", u.Id, "s_m_openid", u.S_m_openid, "a_m_openid", u.A_m_openid, "phone", u.Phone, "subscribe", u.Subscribe, "applystatus", u.ApplyStatus, "jpushid", u.Jpushid, "opushid", u.Opushid)
+				wxPush, appPush, mailPush := 0, 0, 0
+				wxFail, appFail, mailFail := util.IntAll(v["wxfail"]), util.IntAll(v["appfail"]), util.IntAll(v["mailfail"])
+				if wxFail > 0 {
+					wxPush = 1
+				}
+				if appFail > 0 {
+					appPush = 1
+				}
+				if mailFail > 0 {
+					mailPush = 1
+				}
+				list := putil.ToSortList(v["list"])
+				tempList := putil.ToSortList(v["templist"])
+				_, wxStatus, appStatus, mailStatus := DoPush.Execute(0, wxPush, appPush, mailPush, u, list, tempList)
+				sess := mongodb.GetMgoConn()
+				defer mongodb.DestoryMongoConn(sess)
+				if wxStatus == -1 || appStatus == -1 || mailStatus == -1 {
+					set := map[string]interface{}{}
+					inc := map[string]interface{}{}
+					if wxStatus == -1 {
+						inc["wxfail"] = 1
+					} else {
+						set["wxfail"] = 0
+					}
+					if appStatus == -1 {
+						inc["appfail"] = 1
+					} else {
+						set["appfail"] = 0
+					}
+					if mailStatus == -1 {
+						inc["mailfail"] = 1
+					} else {
+						set["mailfail"] = 0
+					}
+					update := map[string]interface{}{
+						"$inc": inc,
+					}
+					if len(set) > 0 {
+						update["$set"] = set
+					}
+					err := sess.DB(DbName).C("pushspace_fail").UpdateId(v["_id"], update)
+					if err != nil {
+						logger.Error("补推任务,update error", err)
+					}
+				} else {
+					err := sess.DB(DbName).C("pushspace_fail").RemoveId(v["_id"])
+					if err != nil {
+						logger.Error("补推任务,update error", err)
+					}
+				}
+			}(temp)
+		}
+		if batch_size < SysConfig.PushBatch || param != "all" {
+			break
+		}
+	}
+	r.wait.Wait()
+	r.lastId = ""
+	r.users = nil
+	logger.Info("补推任务结束。。。")
+	return true
+}
+
+func (r *repairJob) OncePushBatch(batch_index int, param string) int {
+	r.users = &[]map[string]interface{}{}
+	i := 0
+	sess := mongodb.GetMgoConn()
+	defer mongodb.DestoryMongoConn(sess)
+	query := map[string]interface{}{}
+	if param == "all" {
+		if r.lastId != "" {
+			query["_id"] = map[string]interface{}{
+				"$gt": bson.ObjectIdHex(r.lastId),
+			}
+		}
+	} else {
+		ids := []bson.ObjectId{}
+		for _, v := range strings.Split(param, ",") {
+			ids = append(ids, bson.ObjectIdHex(v))
+		}
+		query["_id"] = map[string]interface{}{
+			"$in": ids,
+		}
+	}
+	logger.Info("补推任务,开始加载第", batch_index, "批用户", query)
+	it := sess.DB(DbName).C("pushspace_fail").Find(query).Sort("_id").Iter()
+	for temp := make(map[string]interface{}); it.Next(&temp); {
+		i++
+		r.lastId = util.BsonIdToSId(temp["_id"])
+		*r.users = append(*r.users, temp)
+		temp = make(map[string]interface{})
+		if param == "all" && i == SysConfig.PushBatch {
+			break
+		}
+	}
+	logger.Info("补推任务,第", batch_index, "批用户加载结束", r.lastId)
+	return i
+}

+ 22 - 0
src/jfw/modules/pushsubscribe/src/push/main.go

@@ -4,8 +4,13 @@ package main
 import (
 	"flag"
 	"log"
+	"net"
+	"net/http"
+	"net/rpc"
 	. "push/config"
 	"push/job"
+	prpc "push/rpc"
+	"push/util"
 	"qfw/util/mongodb"
 	"qfw/util/redis"
 	"time"
@@ -18,6 +23,7 @@ func main() {
 	sleep := flag.Int("s", 0, "程序启动完以后,实时推送休眠s分钟再开始")
 	modle := flag.Int("m", 0, "0 定时任务模式推送;1 非定时任务模式推送;2 定时任务模式推送之前先执行-t的任务")
 	taskType := flag.Int("t", 1, "1 实时推送;2 实时推送+一天三次的八点推送;3 一天三次推送;4 九点推送")
+	customCaDate := flag.String("d", "", "自定义日志库,推送数据时间;例(2006-01-02)")
 	moveDatas := flag.String("v", "y", "是否迁移数据")
 	flag.Parse()
 	logger.SetConsole(false)
@@ -34,6 +40,22 @@ func main() {
 			"timeout":   SysConfig.Cassandra.Timeout,
 		},
 	)
+	//register rpc
+	err := rpc.Register(new(prpc.Rpc))
+	if err != nil {
+		log.Fatalln("register rpc error", err)
+	}
+	rpc.HandleHTTP()
+	lis, err := net.Listen("tcp", ":"+SysConfig.RpcPort)
+	if err != nil {
+		log.Fatalln("listen rpc error", err)
+	} else {
+		go http.Serve(lis, nil)
+	}
+	if *customCaDate != "" {
+		util.CustomCaDate = *customCaDate
+	}
+	//
 	log.Println("订阅推送-推送程序启动。。。")
 	isMoveDatas := *moveDatas == "y"
 	if *modle == 1 {

BIN
src/jfw/modules/pushsubscribe/src/push/push


+ 21 - 0
src/jfw/modules/pushsubscribe/src/push/rpc/rpc.go

@@ -0,0 +1,21 @@
+package rpc
+
+import (
+	"push/job"
+
+	"github.com/donnie4w/go-logger/logger"
+)
+
+type Rpc struct {
+}
+
+//企明星后台补推rpc接口
+func (p *Rpc) RepairPush(req string, res *string) error {
+	logger.Info("rpc接收到需要补推的请求", req)
+	if job.Jobs.Repair.Execute(req) {
+		*res = "y"
+	} else {
+		*res = "n"
+	}
+	return nil
+}

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

@@ -1,9 +1,7 @@
 package util
 
 import (
-	"fmt"
 	"log"
-	"math/rand"
 	"os"
 	qu "qfw/util"
 	"time"
@@ -80,8 +78,8 @@ func GetBidInfoXlsx(data []map[string]interface{}) (fnamepath, rename string) {
 	fx.AppendSheet(sheet, "剑鱼标讯")
 
 	t := time.Now()
-	rename = "剑鱼标讯_" + t.Format("2006-01-02") + "_推送信息表.xlsx"
-	fnamepath = "./xlsx/" + t.Format("20060102150405") + fmt.Sprint(rand.Intn(10000)) + ".xlsx"
+	rename = t.Format("2006-01-02") + ".xlsx"
+	fnamepath = "./xlsx/" + t.Format("20060102150405") + qu.GetRandom(4) + ".xlsx"
 
 	err := fx.Save(fnamepath)
 	//log.Println("err", err)

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác