wcj 6 年之前
父節點
當前提交
0cbc935c70
共有 4 個文件被更改,包括 54 次插入11 次删除
  1. 2 2
      core/src/config.json
  2. 1 0
      core/src/qfw/coreconfig/SysConfig.go
  3. 27 0
      core/src/qfw/coreutil/rpccall.go
  4. 24 9
      core/src/qfw/manage/message.go

+ 2 - 2
core/src/config.json

@@ -70,6 +70,6 @@
 		"addr": "192.168.3.11",
 		"port": 1483
 	},
-	"per_del_openid":["o5Z_R0nlDnwkXdFHTQHgWBY0uJZc","o5Z_R0nlDnwkXdFHTQHgWBY0uJZc"]
-	
+	"per_del_openid":["o5Z_R0nlDnwkXdFHTQHgWBY0uJZc","o5Z_R0nlDnwkXdFHTQHgWBY0uJZc"],
+	"appPushServiceRpc":"127.0.0.1:5566"
 }

+ 1 - 0
core/src/qfw/coreconfig/SysConfig.go

@@ -44,6 +44,7 @@ type config struct {
 	JyopWebdomain      string                 `json:"jyopWebdomain"`
 	UdpHandle          udphandle              `json:"udpHandle"`
 	Per_del_openid     []string               `json:"per_del_openid"`
+	AppPushServiceRpc  string                 `json:"appPushServiceRpc"`
 }
 type smtp struct {
 	Addr     string `json:"addr"`

+ 27 - 0
core/src/qfw/coreutil/rpccall.go

@@ -0,0 +1,27 @@
+package coreutil
+
+import (
+	"encoding/json"
+	"log"
+	"net/rpc"
+	"qfw/coreconfig"
+	"qfw/util"
+)
+
+func AppPushServiceCall(m map[string]interface{}) bool {
+	defer util.Catch()
+	var repl string
+	client, err := rpc.DialHTTP("tcp", coreconfig.SysConfig.AppPushServiceRpc)
+	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"
+}

+ 24 - 9
core/src/qfw/manage/message.go

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"html/template"
 	. "qfw/coreconfig"
+	"qfw/coreutil"
 	"qfw/jgpush"
 	"qfw/util"
 	. "qfw/util/mongodb"
@@ -184,13 +185,13 @@ func sendMes(id, title, subtitle, url, pic string) error {
 	if mos != nil && util.ObjToString(mos) != "" {
 		openids := strings.Split(util.ObjToString(mos), ",")
 		for _, v := range openids {
-			userData := FindOneByField("user", `{"s_m_openid":"`+v+`"}`, `{"s_m_openid":1,"s_jpushid":1,"s_province":1,"s_city":1,"s_nickname":1}`)
+			userData := FindOneByField("user", `{"s_m_openid":"`+v+`"}`, `{"s_m_openid":1,"s_jpushid":1,"s_province":1,"s_city":1,"s_nickname":1,"s_appponetype":1}`)
 			if userData != nil && len(*userData) > 0 {
 				userDatas = append(userDatas, *userData)
 			}
 		}
 	} else {
-		userDatas = *Find("user", `{"i_type":{"$in": [1,2]}}`, `{"l_registedate":-1}`, `{"s_m_openid":1,"s_jpushid":1,"s_province":1,"s_city":1,"s_nickname":1}`, false, -1, -1)
+		userDatas = *Find("user", `{"i_type":{"$in": [1,2]}}`, `{"l_registedate":-1}`, `{"s_m_openid":1,"s_jpushid":1,"s_province":1,"s_city":1,"s_nickname":1,"s_appponetype":1}`, false, -1, -1)
 	}
 	var total = 0
 	for _, v := range userDatas {
@@ -199,6 +200,7 @@ func sendMes(id, title, subtitle, url, pic string) error {
 		province := util.ObjToString(v["s_province"])
 		city := util.ObjToString(v["s_city"])
 		nickname := util.ObjToString(v["s_nickname"])
+		ponetype := util.ObjToString(v["s_appponetype"])
 		if jpushid != "" && openid != "" && id != "" {
 			total = total + 1
 			go ca.SaveCache("jy_message", map[string]interface{}{
@@ -214,13 +216,26 @@ func sendMes(id, title, subtitle, url, pic string) error {
 				"date":     time.Now().Unix(),
 				"url":      url,
 			})
-			jgpush.JgpushNc(subtitle, "message", []string{jpushid}, map[string]interface{}{
-				"url":     url + "==" + id,
-				"openid":  openid,
-				"title":   title,
-				"type":    "message",
-				"content": pic,
-			}, false)
+			if ponetype == "HUAWEI" {
+				coreutil.AppPushServiceCall(map[string]interface{}{
+					"phoneType":   "HUAWEI",
+					"deviceToken": jpushid,
+					"url":         url + "==" + id,
+					"openid":      openid,
+					"title":       title,
+					"type":        "message",
+					"content":     subtitle,
+					"descript":    pic,
+				})
+			} else {
+				jgpush.JgpushNc(subtitle, "message", []string{jpushid}, map[string]interface{}{
+					"url":     url + "==" + id,
+					"openid":  openid,
+					"title":   title,
+					"type":    "message",
+					"content": pic,
+				}, false)
+			}
 		}
 	}
 	go Update("message_app", map[string]interface{}{"_id": bson.ObjectIdHex(id)}, map[string]interface{}{"$set": map[string]interface{}{"i_total": total}}, false, false)