12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- package logic
- import (
- "app.yhyue.com/moapp/MessageCenter/rpc/internal/common"
- "app.yhyue.com/moapp/MessageCenter/rpc/internal/svc"
- "app.yhyue.com/moapp/MessageCenter/rpc/type/message"
- "app.yhyue.com/moapp/jybase/go-xweb/log"
- "context"
- "strings"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type AppLetterPushLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewAppLetterPushLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AppLetterPushLogic {
- return &AppLetterPushLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- // 发送剑鱼微信模版消息
- func (l *AppLetterPushLogic) AppLetterPush(in *message.WxTmplMsgRequest) (*message.SendMsgResponse, error) {
- var userArr []string
- log.Println("app私信push推送内容===", in)
- userArr = strings.Split(in.PositionIds, ",")
- pushConfig, err := common.GetWxTmplConfig(in.MsgType)
- if err != nil {
- return &message.SendMsgResponse{
- Total: 0,
- Message: err.Error(),
- }, nil
- }
- for _, uId := range userArr {
- if uId == "" {
- continue
- }
- p := &common.WxTmplPush{
- Config: pushConfig,
- }
- p.Position = uId
- uData := p.GetUserPushInfo()
- if err = common.AppPushMsg(uData, pushConfig.Switch, in.Url, in.Title, in.Detail, in.MsgType); err != nil {
- return &message.SendMsgResponse{
- Total: 0,
- Message: err.Error(),
- }, err
- }
- }
- return &message.SendMsgResponse{
- Total: 1,
- }, nil
- }
|