12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package logic
- import (
- "app.yhyue.com/moapp/MessageCenter/rpc/internal/common"
- "app.yhyue.com/moapp/MessageCenter/rpc/internal/config"
- "app.yhyue.com/moapp/MessageCenter/rpc/internal/svc"
- "app.yhyue.com/moapp/MessageCenter/rpc/type/message"
- "app.yhyue.com/moapp/MessageCenter/util"
- qrpc "app.yhyue.com/moapp/jybase/rpc"
- "context"
- "strings"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type SendWxTmplJySchoolMsgLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewSendWxTmplJySchoolMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendWxTmplJySchoolMsgLogic {
- return &SendWxTmplJySchoolMsgLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- // SendWxTmplJySchoolMsg 发送剑鱼学堂微信模版消息
- func (l *SendWxTmplJySchoolMsgLogic) SendWxTmplJySchoolMsg(in *message.JySchoolMsg) (*message.SendMsgResponse, error) {
- var total int
- userIdArr := strings.Split(in.UserIds, ",")
- for index, userId := range userIdArr {
- p := &common.WxTmplPush{
- MgoId: userId,
- MessageClass: "o_msg_jyschool",
- PushTmplId: config.ConfigJson.WxTmplConfig.TmplSetting.JySchoolTmplId,
- }
- err := p.SendMsg(in.Url, func() map[string]*qrpc.TmplItem {
- // 消息模版 课程名称 {{thing1.DATA}} 课程时间 {{time7.DATA}} 课程地点 {{thing6.DATA}} 课程类型 {{const11.DATA}}
- return map[string]*qrpc.TmplItem{
- "thing1": &qrpc.TmplItem{
- Value: in.Title,
- },
- "time7": &qrpc.TmplItem{
- Value: in.Date,
- },
- "thing6": &qrpc.TmplItem{
- Value: in.Address,
- },
- "const11": &qrpc.TmplItem{
- Value: in.Class,
- },
- }
- })
- if err != nil {
- logx.Error(err)
- } else {
- total++
- }
- if index%10 == 0 {
- logx.Infof("共%d条,已送达%d条,失败%d条", len(userIdArr), total, index-total)
- }
- }
- return &message.SendMsgResponse{
- Total: util.Int64All(total),
- Message: "",
- }, nil
- }
|