|
@@ -284,6 +284,46 @@ func SendVoiceBroadcastWxMsg(broadcastId int, sectionName, broadcastName string)
|
|
if wxAppPath != "" {
|
|
if wxAppPath != "" {
|
|
sendMap["miniprogram"] = map[string]interface{}{"appid": WxYbAppId, "pagepath": wxAppPath}
|
|
sendMap["miniprogram"] = map[string]interface{}{"appid": WxYbAppId, "pagepath": wxAppPath}
|
|
}
|
|
}
|
|
- err = SendMultiTemplateMsg(sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_YB_VOICE_BROADCAST)
|
|
|
|
|
|
+ err = SendMultiTemplateMsgNoReturn(sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_YB_VOICE_BROADCAST)
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// SendMultiTemplateMsg 推送模板消息至多个用户中间出错不返回
|
|
|
|
+func SendMultiTemplateMsgNoReturn(sendMap map[string]interface{}, items []*OpenIdList, resource string, sendType int) (err error) {
|
|
|
|
+ ws := GetWxChat()
|
|
|
|
+ accessToken, err := ws.GetAccessToken()
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ for _, item := range items {
|
|
|
|
+ sendMap["touser"] = item.OpenId
|
|
|
|
+ data, e := json.Marshal(sendMap)
|
|
|
|
+ if e != nil {
|
|
|
|
+ err = e
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ ts := &TemplateMsgSendClient{
|
|
|
|
+ AccessToken: accessToken,
|
|
|
|
+ Data: data,
|
|
|
|
+ }
|
|
|
|
+ result, e := ts.SendMsg()
|
|
|
|
+ if result == nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 推送消息记录
|
|
|
|
+ {
|
|
|
|
+ go func(v *OpenIdList) {
|
|
|
|
+ sendStatus := 1
|
|
|
|
+ if e != nil {
|
|
|
|
+ sendStatus = 0
|
|
|
|
+ }
|
|
|
|
+ resultJson, _ := json.Marshal(result)
|
|
|
|
+ _ = AddUserTemplateRecord(v.UserId, sendStatus, sendType, v.OpenId, resource, string(data), string(resultJson))
|
|
|
|
+ }(item)
|
|
|
|
+ }
|
|
|
|
+ if e != nil {
|
|
|
|
+ err = e
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return
|
|
return
|
|
}
|
|
}
|