golang-im聊天
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

82 lines
2.6 KiB

  1. package service
  2. import (
  3. jg_push "code.fnuoos.com/go_rely_warehouse/zyos_go_jg_push.git/hdl"
  4. md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_jg_push.git/md"
  5. "fmt"
  6. "gim/internal/business/comm/db"
  7. svc "gim/internal/business/comm/service"
  8. md3 "gim/internal/logic/domain/message/md"
  9. "gim/pkg/logger"
  10. "go.uber.org/zap"
  11. "strings"
  12. )
  13. func getChangeContent(args md3.PushParams, Content string) string {
  14. Content = strings.Replace(Content, "[MasterId]", args.MasterId, -1)
  15. Content = strings.Replace(Content, "[消费发送者-会员昵称]", args.SendUserNickname, -1)
  16. Content = strings.Replace(Content, "[备注]", args.Memo, -1)
  17. Content = strings.Replace(Content, "[时间]", args.Times, -1)
  18. return Content
  19. }
  20. // CommAddPush 公共处理推送数据
  21. func CommAddPush(args md3.PushParams) {
  22. logger.Logger.Debug("CommAddPush",
  23. zap.String("master_id", args.MasterId),
  24. zap.String("uid", args.Uid),
  25. zap.String("push_alia", args.PushAlia),
  26. zap.String("title", args.Title),
  27. zap.String("content", args.Content),
  28. zap.String("push_type", args.PushType),
  29. zap.String("message_type", args.MessageType),
  30. zap.String("send_user_nickname", args.SendUserNickname),
  31. zap.String("send_user_avatar_url", args.SendUserAvatarUrl),
  32. zap.String("reason", args.Memo),
  33. zap.String("times", args.Times),
  34. )
  35. pushPlatform := svc.SysCfgGet(args.MasterId, "app_push_platform")
  36. fmt.Println(">>>>>>>>>>>>>>>>>>>>pushPlatform<<<<<<<<<<<<<<<<<<<<<<", pushPlatform)
  37. if pushPlatform == "JgPush" { //极光
  38. args.Content = getChangeContent(args, args.Content)
  39. JgPush(args)
  40. return
  41. }
  42. return
  43. }
  44. func JgPush(args md3.PushParams) {
  45. thirdJgPush := db.DbSysCfg.SysCfgFindWithDb(args.MasterId, "jg_push_app_key", "jg_push_app_secret")
  46. if thirdJgPush["jg_push_app_key"] == "" || thirdJgPush["jg_push_app_secret"] == "" {
  47. return
  48. }
  49. //alia := db.DbUserPushForJg.UserPushForJgGetWithDb(args.MasterId, args.Uid)
  50. var aud = md2.PushAudience{Alias: []string{args.PushAlia}}
  51. var extras interface{}
  52. var param = md2.PushParam{
  53. Platform: "all",
  54. Audience: aud,
  55. Title: args.Title,
  56. Content: args.Content,
  57. Extras: extras,
  58. }
  59. send, _, err := jg_push.Send(thirdJgPush["jg_push_app_key"], thirdJgPush["jg_push_app_secret"], param)
  60. logger.Logger.Debug("JgPush",
  61. zap.String("push_alia", args.PushAlia),
  62. zap.String("title", param.Title),
  63. zap.String("content", param.Content),
  64. zap.String("jg_push_app_key", thirdJgPush["jg_push_app_key"]),
  65. zap.String("jg_push_app_secret", thirdJgPush["jg_push_app_secret"]),
  66. zap.String("err", err.Error()),
  67. )
  68. if err != nil {
  69. return
  70. }
  71. if send == "" {
  72. return
  73. }
  74. //TODO::发送成功处理
  75. return
  76. }