浏览代码

fix:app push推送提醒修改

duxin 11 月之前
父节点
当前提交
1cf8defe2c
共有 1 个文件被更改,包括 35 次插入38 次删除
  1. 35 38
      rpc/internal/common/appPush.go

+ 35 - 38
rpc/internal/common/appPush.go

@@ -19,17 +19,15 @@ func AppPushMsg(userInfo map[string]interface{}, sth, appPushUrl, title, detail
 	}
 	//限制
 	//校验发送间隔
+	i_apppush := int64(1)
 	userId := mongodb.BsonIdToSId(userInfo["_id"])
 	if pushSetMap := qutil.ObjToMap(userInfo["o_pushset"]); pushSetMap != nil && len(*pushSetMap) > 0 {
 		if pushKeyMap := qutil.ObjToMap((*pushSetMap)[sth]); pushKeyMap != nil && len(*pushKeyMap) > 0 {
-			i_apppush := int64(0)
 			switch sth {
 			case "o_msg_active", "o_msg_service", "o_msg_jyschool", "o_msg_privateletter", "o_msg_business", "o_msg_pending":
 				registedate := qutil.Int64All(userInfo["l_registedate"])
 				if registedate > config.ConfigJson.Registedate {
-					if (*pushKeyMap)["i_apppush"] == nil {
-						i_apppush = 1
-					} else {
+					if (*pushKeyMap)["i_apppush"] != nil {
 						i_apppush = qutil.Int64All((*pushKeyMap)["i_apppush"])
 					}
 				} else {
@@ -42,43 +40,42 @@ func AppPushMsg(userInfo map[string]interface{}, sth, appPushUrl, title, detail
 			default:
 				i_apppush = qutil.Int64All((*pushKeyMap)["i_apppush"])
 			}
-			if i_apppush == 1 {
-				//用户信息
-				var otherPushId, jgPushId, phoneType, name, appVersion = "", "", "", "", ""
-				otherPushId = qutil.ObjToString(userInfo["s_opushid"])
-				jgPushId = qutil.ObjToString(userInfo["s_jpushid"])
-				phoneType = qutil.ObjToString(userInfo["s_appponetype"])
-				name = qutil.ObjToString(userInfo["s_name"])
-				appVersion = qutil.ObjToString(userInfo["s_appversion"])
-				if strings.Contains(phoneType, "iPhone") && strings.HasPrefix(appPushUrl, "/") && msgType != 10 {
-					appPushUrl = appPushUrl[1:]
-				}
-				dt := map[string]interface{}{
-					"receiveUserId": userId,
-					"receiveName":   name,
-					"title":         title,
-					"content":       detail,
-					"msgType":       "messagecenter",
-					"link":          appPushUrl,
-					"appid":         "10000",
-					"menuName":      "message",
-				}
-				//推送消息
-				if appVersion > "3.0.3" {
-					if sth == "o_msg_privateletter" {
-						category = "私信"
-					} else if sth == "o_msg_pending" {
-						category = "服务通知_工作事项"
-					}
-					if err := AppGrpcPush(dt, otherPushId, jgPushId, phoneType, appPushUrl, category); err != nil {
-						return err
-					}
-					//redis.Put(CacheDb, userKey, 1, config.ConfigJson.WxTmplConfig.Limit.DuringMine*60)
-				}
+		}
+	}
+	if i_apppush == 1 {
+		//用户信息
+		var otherPushId, jgPushId, phoneType, name, appVersion = "", "", "", "", ""
+		otherPushId = qutil.ObjToString(userInfo["s_opushid"])
+		jgPushId = qutil.ObjToString(userInfo["s_jpushid"])
+		phoneType = qutil.ObjToString(userInfo["s_appponetype"])
+		name = qutil.ObjToString(userInfo["s_name"])
+		appVersion = qutil.ObjToString(userInfo["s_appversion"])
+		if strings.Contains(phoneType, "iPhone") && strings.HasPrefix(appPushUrl, "/") && msgType != 10 {
+			appPushUrl = appPushUrl[1:]
+		}
+		dt := map[string]interface{}{
+			"receiveUserId": userId,
+			"receiveName":   name,
+			"title":         title,
+			"content":       detail,
+			"msgType":       "messagecenter",
+			"link":          appPushUrl,
+			"appid":         "10000",
+			"menuName":      "message",
+		}
+		//推送消息
+		if appVersion > "3.0.3" {
+			if sth == "o_msg_privateletter" {
+				category = "私信"
+			} else if sth == "o_msg_pending" {
+				category = "服务通知_工作事项"
+			}
+			if err := AppGrpcPush(dt, otherPushId, jgPushId, phoneType, appPushUrl, category); err != nil {
+				return err
 			}
+			//redis.Put(CacheDb, userKey, 1, config.ConfigJson.WxTmplConfig.Limit.DuringMine*60)
 		}
 	}
-
 	return nil
 }