multiplesavemsglogic.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package logic
  2. import (
  3. service "app.yhyue.com/moapp/MessageCenter/rpc/internal/common"
  4. "app.yhyue.com/moapp/MessageCenter/rpc/internal/config"
  5. "app.yhyue.com/moapp/MessageCenter/rpc/internal/svc"
  6. "app.yhyue.com/moapp/MessageCenter/rpc/messageclient"
  7. "app.yhyue.com/moapp/MessageCenter/rpc/type/message"
  8. "context"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type MultipleSaveMsgLogic struct {
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. logx.Logger
  15. }
  16. func NewMultipleSaveMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MultipleSaveMsgLogic {
  17. return &MultipleSaveMsgLogic{
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. Logger: logx.WithContext(ctx),
  21. }
  22. }
  23. // 批量保存消息
  24. func (l *MultipleSaveMsgLogic) MultipleSaveMsg(in *messageclient.MultipleSaveMsgReq) (*messageclient.MultipleSaveMsgResp, error) {
  25. var (
  26. code = 1
  27. msg = "发送成功"
  28. )
  29. msgLogId := service.InsertMsgSendLog(in)
  30. if msgLogId > 0 {
  31. var err error
  32. in.MsgLogId = msgLogId
  33. if in.Title == config.ConfigJson.NewUserMsgTitle {
  34. err = service.NewUserSendMsg(&message.NewUserInsertMsgReq{
  35. UserIds: in.UserIds,
  36. Title: in.Title,
  37. Content: in.Content,
  38. MsgType: in.MsgType,
  39. Link: in.Link,
  40. Appid: in.Appid,
  41. MsgLogId: in.MsgLogId,
  42. PositionIds: in.PositionIds,
  43. Row4: in.Row4,
  44. ProductName: in.ProductName,
  45. OrderId: in.OrderId,
  46. OrderMoney: in.OrderMoney,
  47. Identity: in.Identity,
  48. AppPushUrl: in.AppPushUrl,
  49. WxPushUrl: in.WxPushUrl,
  50. IosPushUrl: in.IosPushUrl,
  51. })
  52. } else {
  53. err = service.UpdateUserMsgSummary(in)
  54. }
  55. if err != nil {
  56. code = 0
  57. msg = err.Error()
  58. }
  59. } else {
  60. code = 0
  61. msg = "插入message_send_log表出错"
  62. }
  63. return &messageclient.MultipleSaveMsgResp{
  64. Code: int64(code),
  65. Message: msg,
  66. }, nil
  67. }