|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package service
-
- import (
- jg_push "code.fnuoos.com/go_rely_warehouse/zyos_go_jg_push.git/hdl"
- md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_jg_push.git/md"
- "fmt"
- "gim/internal/business/comm/db"
- svc "gim/internal/business/comm/service"
- md3 "gim/internal/logic/domain/message/md"
- "gim/pkg/logger"
- "go.uber.org/zap"
-
- "strings"
- )
-
- func getChangeContent(args md3.PushParams, Content string) string {
- Content = strings.Replace(Content, "[MasterId]", args.MasterId, -1)
- Content = strings.Replace(Content, "[消费发送者-会员昵称]", args.SendUserNickname, -1)
- Content = strings.Replace(Content, "[备注]", args.Memo, -1)
- Content = strings.Replace(Content, "[时间]", args.Times, -1)
- return Content
- }
-
- // CommAddPush 公共处理推送数据
- func CommAddPush(args md3.PushParams) {
- logger.Logger.Debug("CommAddPush",
- zap.String("master_id", args.MasterId),
- zap.String("uid", args.Uid),
- zap.String("push_alia", args.PushAlia),
- zap.String("title", args.Title),
- zap.String("content", args.Content),
- zap.String("push_type", args.PushType),
- zap.String("message_type", args.MessageType),
- zap.String("send_user_nickname", args.SendUserNickname),
- zap.String("send_user_avatar_url", args.SendUserAvatarUrl),
- zap.String("reason", args.Memo),
- zap.String("times", args.Times),
- )
- pushPlatform := svc.SysCfgGet(args.MasterId, "app_push_platform")
- fmt.Println(">>>>>>>>>>>>>>>>>>>>pushPlatform<<<<<<<<<<<<<<<<<<<<<<", pushPlatform)
- if pushPlatform == "JgPush" { //极光
- args.Content = getChangeContent(args, args.Content)
- JgPush(args)
- return
- }
- return
- }
-
- func JgPush(args md3.PushParams) {
- thirdJgPush := db.DbSysCfg.SysCfgFindWithDb(args.MasterId, "jg_push_app_key", "jg_push_app_secret")
- if thirdJgPush["jg_push_app_key"] == "" || thirdJgPush["jg_push_app_secret"] == "" {
- return
- }
- //alia := db.DbUserPushForJg.UserPushForJgGetWithDb(args.MasterId, args.Uid)
- var aud = md2.PushAudience{Alias: []string{args.PushAlia}}
- var extras interface{}
- var param = md2.PushParam{
- Platform: "all",
- Audience: aud,
- Title: args.Title,
- Content: args.Content,
- Extras: extras,
- }
- send, _, err := jg_push.Send(thirdJgPush["jg_push_app_key"], thirdJgPush["jg_push_app_secret"], param)
- logger.Logger.Debug("JgPush",
- zap.String("push_alia", args.PushAlia),
- zap.String("title", param.Title),
- zap.String("content", param.Content),
- zap.String("jg_push_app_key", thirdJgPush["jg_push_app_key"]),
- zap.String("jg_push_app_secret", thirdJgPush["jg_push_app_secret"]),
- zap.String("err", err.Error()),
- )
- if err != nil {
- return
- }
- if send == "" {
- return
- }
- //TODO::发送成功处理
- return
- }
|