浏览代码

Merge branch 'feature/v1.2.7' into dev/v1.2.7_rjj

renjiaojiao 2 年之前
父节点
当前提交
3083720913

+ 5 - 2
api/internal/logic/sendwxtmplmsglogic.go

@@ -35,10 +35,13 @@ func (l *SendWxTmplMsgLogic) SendWxTmplMsg(req *types.WxTmplMessageReq) (resp *t
 		Url:          req.Url,
 	})
 	if err != nil {
-		return nil, err
+		return &types.WxTmplMessageResponse{
+			Code:    1,
+			Message: err.Error(),
+		}, err
 	}
 	return &types.WxTmplMessageResponse{
-		Code:    1,
+		Code:    0,
 		Total:   res.Total,
 		Message: res.Message,
 	}, nil

+ 2 - 1
rpc/etc/message.yaml

@@ -50,13 +50,14 @@ mail:
     user: public03@topnet.net.cn
 
 #发送微信模版消息
+WxWebdomain: "https://web-wky.jydev.jianyu360.com/" #微信域名
 WxTmplConfig:
   rpcAddr: 127.0.0.1:8083 #微信rpc地址
   closeNotice: "如不再接收此类信息,请在我的-设置-推送设置关闭设置。"
   limit:
     total: 300000 # 每日发送信息数量限制
     oneDayLimit: 5 #每天私信数量限制
-    duringMine: 60 #间隔时间单位分钟
+    duringMine: 1 #间隔时间单位分钟
     alert: #告警
       nums: [ 150000,250000 ] #告警数量
       toMail: [ "wangkaiyue@topnet.net.cn" ] #告警邮箱收件地址

+ 28 - 29
rpc/internal/common/sendMsg.go

@@ -305,37 +305,36 @@ func UserUnreadMsgList(this *message.UserUnreadMsgListReq) (int64, []*message.Me
 }
 
 func MessageGetLast(this *message.UserMsgListReq) *message.Messages {
-	if this.IsColumn {
-		query := map[string]interface{}{
-			"receive_userid": this.UserId,
-			"isdel":          1,
-			"appid":          this.Appid,
-			"isRead":         0,
-			"msg_type":       1,
-		}
-		lastMsg := entity.Mysql.FindOne("message", query, "", "createtime desc")
-		if lastMsg != nil && len(*lastMsg) > 0 {
-			_id := util.Int64All((*lastMsg)["id"])
-			id := strconv.FormatInt(_id, 10)
-			msg := message.Messages{
-				Id:            id,
-				Appid:         common.InterfaceToStr((*lastMsg)["appid"]),
-				ReceiveUserId: common.InterfaceToStr((*lastMsg)["receive_userid"]),
-				ReceiveName:   common.InterfaceToStr((*lastMsg)["receive_name"]),
-				SendUserId:    common.InterfaceToStr((*lastMsg)["send_userid"]),
-				SendName:      common.InterfaceToStr((*lastMsg)["send_name"]),
-				Createtime:    common.InterfaceToStr((*lastMsg)["createtime"]),
-				Title:         common.InterfaceToStr((*lastMsg)["title"]),
-				MsgType:       common.Int64All((*lastMsg)["msg_type"]),
-				Link:          common.InterfaceToStr((*lastMsg)["link"]),
-				CiteId:        common.Int64All((*lastMsg)["cite_id"]),
-				Content:       common.InterfaceToStr((*lastMsg)["content"]),
-				IsRead:        common.Int64All((*lastMsg)["isRead"]),
-				MsgLogId:      common.Int64All((*lastMsg)["msg_log_id"]),
-			}
-			return &msg
+	query := map[string]interface{}{
+		"receive_userid": this.UserId,
+		"isdel":          1,
+		"appid":          this.Appid,
+		"isRead":         0,
+		"msg_type":       1,
+	}
+	lastMsg := entity.Mysql.FindOne("message", query, "", "createtime desc")
+	if lastMsg != nil && len(*lastMsg) > 0 {
+		_id := util.Int64All((*lastMsg)["id"])
+		id := strconv.FormatInt(_id, 10)
+		msg := message.Messages{
+			Id:            id,
+			Appid:         common.InterfaceToStr((*lastMsg)["appid"]),
+			ReceiveUserId: common.InterfaceToStr((*lastMsg)["receive_userid"]),
+			ReceiveName:   common.InterfaceToStr((*lastMsg)["receive_name"]),
+			SendUserId:    common.InterfaceToStr((*lastMsg)["send_userid"]),
+			SendName:      common.InterfaceToStr((*lastMsg)["send_name"]),
+			Createtime:    common.InterfaceToStr((*lastMsg)["createtime"]),
+			Title:         common.InterfaceToStr((*lastMsg)["title"]),
+			MsgType:       common.Int64All((*lastMsg)["msg_type"]),
+			Link:          common.InterfaceToStr((*lastMsg)["link"]),
+			CiteId:        common.Int64All((*lastMsg)["cite_id"]),
+			Content:       common.InterfaceToStr((*lastMsg)["content"]),
+			IsRead:        common.Int64All((*lastMsg)["isRead"]),
+			MsgLogId:      common.Int64All((*lastMsg)["msg_log_id"]),
 		}
+		return &msg
 	}
+
 	return nil
 }
 

+ 2 - 1
rpc/internal/common/sendWxTmplMsg.go

@@ -86,7 +86,8 @@ func (stm *WxTmplPush) SendMsg(link, title, detail, date string) error {
 		return err
 	}
 	// 发送信息
-	if _, err := stm.Send(link, msg); err != nil {
+	autoLoginHref := fmt.Sprintf("%s/swordfish/SingleLogin?toHref=%s", config.ConfigJson.WxWebdomain, link)
+	if _, err := stm.Send(autoLoginHref, msg); err != nil {
 		return err
 	}
 	// 发送数量计数

+ 1 - 0
rpc/internal/config/config.go

@@ -14,6 +14,7 @@ type Config struct {
 	Mongodb         *mgoConf
 	SurvivalTime    int
 	SaveConcurrency int       // 消息保存并发数
+	WxWebdomain     string    `json:"WxWebdomain"`
 	WxTmplConfig    WxTmplMsg `json:"WxTmplConfig"`
 	Mail            []struct {
 		Addr string `json:"addr"`

+ 7 - 2
rpc/internal/logic/sendwxtmplmsglogic.go

@@ -75,9 +75,14 @@ func (l *SendWxTmplMsgLogic) SendWxTmplMsg(in *message.WxTmplMsgRequest) (*messa
 	}
 
 	if messageTotal == 1 {
+		if err != nil {
+			return &message.SendMsgResponse{
+				Total:   util.Int64All(messageSendOk),
+				Message: err.Error(),
+			}, nil
+		}
 		return &message.SendMsgResponse{
-			Total:   util.Int64All(messageSendOk),
-			Message: err.Error(),
+			Total: util.Int64All(messageSendOk),
 		}, nil
 	} else {
 		logx.Infof("共%d条,已送达%d条,失败%d条", messageTotal, messageSendOk, messageTotal-messageSendOk)

+ 0 - 3
rpc/internal/logic/usermsglistlogic.go

@@ -27,8 +27,6 @@ func NewUserMsgListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserM
 
 // new用户消息列表
 func (l *UserMsgListLogic) UserMsgList(in *message.UserMsgListReq) (*message.UserMsgListRes, error) {
-	// todo: add your logic here and delete this line
-
 	data := new(message.UserMsgListRes)
 	res1 := service.UserMsgList(in)    //具体信息
 	res2 := service.MessageGetLast(in) //最新信息
@@ -55,7 +53,6 @@ func (l *UserMsgListLogic) UserMsgList(in *message.UserMsgListReq) (*message.Use
 			"weChatUrl":  weChatUrl4,
 		}
 	}
-
 	data.Column = res1.SortData
 	data.List = finalData
 	data.Last = res2