|
@@ -12,9 +12,39 @@ import (
|
|
|
"io/ioutil"
|
|
|
"net/http"
|
|
|
"strconv"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
+ "errors"
|
|
|
)
|
|
|
|
|
|
+type SendWxTemplate struct {
|
|
|
+ First string `description:"模板消息first字段"`
|
|
|
+ Keyword1 string `description:"模板消息keyword1字段"`
|
|
|
+ Keyword2 string `description:"模板消息keyword2字段"`
|
|
|
+ Keyword3 string `description:"模板消息keyword3字段"`
|
|
|
+ Keyword4 string `description:"模板消息keyword4字段"`
|
|
|
+ Remark string `description:"模板消息remark字段"`
|
|
|
+ TemplateId string `description:"模板id"`
|
|
|
+ RedirectUrl string `description:"跳转地址"`
|
|
|
+ RedirectTarget int `description:"小程序跳转目标:1:弘则研报小程序,2:随手办公小程序"`
|
|
|
+ Resource string `description:"资源唯一标识"`
|
|
|
+ SendType int `description:"发送的消息类型:1:报告,2:指标更新提醒,3:审批通知,4:销售领取客户通知,5:活动取消通知,6活动更改时间通知,7:关注的作者发布报告通知,8:发送日报(周报、双周报、月报)模板消息,9:活动预约/报名时间通知"`
|
|
|
+ OpenIdArr []string `description:"消息接收者openid"`
|
|
|
+}
|
|
|
+
|
|
|
+type BaseResponse struct {
|
|
|
+ Ret int
|
|
|
+ Msg string
|
|
|
+ ErrMsg string
|
|
|
+ ErrCode string
|
|
|
+ Data interface{}
|
|
|
+ Success bool `description:"true 执行成功,false 执行失败"`
|
|
|
+ IsSendEmail bool `json:"-" description:"true 发送邮件,false 不发送邮件"`
|
|
|
+ IsAddLog bool `json:"-" description:"true 新增操作日志,false 不新增操作日志" `
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
func SendWxTemplateMsg(reportId int) (err error) {
|
|
|
var msg string
|
|
|
defer func() {
|
|
@@ -187,8 +217,8 @@ func SendCompanyApplyWxTemplateMsg(mobile, redirectUrl, wxAppPath string, wxMsgM
|
|
|
utils.FileLog.Info("mobile:%s", mobile)
|
|
|
|
|
|
//获取openid列表
|
|
|
- openIdStr := WxUsersGet()
|
|
|
- openIdList, err := wx_user.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
+ //openIdStr := WxUsersGet()
|
|
|
+ openIdList, err := wx_user.GetOpenIdListByMobile(mobile)
|
|
|
if err != nil {
|
|
|
msg = "get openIdList err:" + err.Error()
|
|
|
return
|
|
@@ -197,11 +227,11 @@ func SendCompanyApplyWxTemplateMsg(mobile, redirectUrl, wxAppPath string, wxMsgM
|
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
|
utils.FileLog.Info("start send")
|
|
|
- sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
|
|
|
+ //sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
|
|
|
fmt.Println("send start")
|
|
|
utils.FileLog.Info("send start")
|
|
|
- sendMap := make(map[string]interface{})
|
|
|
- sendData := make(map[string]interface{})
|
|
|
+ //sendMap := make(map[string]interface{})
|
|
|
+ //sendData := make(map[string]interface{})
|
|
|
|
|
|
var first, keyword1, keyword2, keyword3, remark string
|
|
|
if tmpStr, ok := wxMsgMap[0]; ok {
|
|
@@ -222,20 +252,43 @@ func SendCompanyApplyWxTemplateMsg(mobile, redirectUrl, wxAppPath string, wxMsgM
|
|
|
remark = tmpStr
|
|
|
}
|
|
|
|
|
|
- sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
|
|
|
- sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
|
|
|
- sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
|
|
|
- sendData["keyword3"] = map[string]interface{}{"value": keyword3, "color": "#173177"}
|
|
|
- sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
|
|
|
+ //sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
|
|
|
+ //sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
|
|
|
+ //sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
|
|
|
+ //sendData["keyword3"] = map[string]interface{}{"value": keyword3, "color": "#173177"}
|
|
|
+ //sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
|
|
|
+ //
|
|
|
+ //sendMap["template_id"] = utils.TemplateIdByCompanyApply
|
|
|
+ //sendMap["url"] = redirectUrl
|
|
|
+ //sendMap["data"] = sendData
|
|
|
+ ////小程序信息
|
|
|
+ //if wxAppPath != "" {
|
|
|
+ // sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId2, "pagepath": wxAppPath}
|
|
|
+ //}
|
|
|
+ //sendTemplateMsg(sendUrl, sendMap, openIdList, mobile, utils.TEMPLATE_MSG_APPLY)
|
|
|
+
|
|
|
+
|
|
|
+ openIdArr := make([]string, len(openIdList))
|
|
|
+ for i, v := range openIdList {
|
|
|
+ openIdArr[i] = v.OpenId
|
|
|
+ }
|
|
|
|
|
|
- sendMap["template_id"] = utils.TemplateIdByCompanyApply
|
|
|
- sendMap["url"] = redirectUrl
|
|
|
- sendMap["data"] = sendData
|
|
|
- //小程序信息
|
|
|
+ sendInfo := new(SendWxTemplate)
|
|
|
+ sendInfo.First = first
|
|
|
+ sendInfo.Keyword1 = keyword1
|
|
|
+ sendInfo.Keyword2 = keyword2
|
|
|
+ sendInfo.Keyword3 = keyword3
|
|
|
+ sendInfo.Remark = remark
|
|
|
+ sendInfo.TemplateId = utils.TemplateIdByCompanyApply
|
|
|
+ sendInfo.RedirectUrl = redirectUrl
|
|
|
+ sendInfo.RedirectTarget = 2
|
|
|
+ sendInfo.Resource = mobile
|
|
|
+ sendInfo.SendType = utils.TEMPLATE_MSG_APPLY
|
|
|
+ sendInfo.OpenIdArr = openIdArr
|
|
|
if wxAppPath != "" {
|
|
|
- sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId2, "pagepath": wxAppPath}
|
|
|
+ sendInfo.RedirectUrl = wxAppPath
|
|
|
}
|
|
|
- sendTemplateMsg(sendUrl, sendMap, openIdList, mobile, utils.TEMPLATE_MSG_APPLY)
|
|
|
+ err = SendTemplateMsg(sendInfo)
|
|
|
}
|
|
|
utils.FileLog.Info("send end")
|
|
|
return
|
|
@@ -268,8 +321,8 @@ func SendWxMsgWithRoadshowDetailResult(first, keyword1, keyword2, remark, mobile
|
|
|
utils.FileLog.Info("mobile:%s", mobile)
|
|
|
|
|
|
//获取openid列表
|
|
|
- openIdStr := WxUsersGet()
|
|
|
- openIdList, err := wx_user.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
+ //openIdStr := WxUsersGet()
|
|
|
+ openIdList, err := wx_user.GetOpenIdListByMobile(mobile)
|
|
|
if err != nil {
|
|
|
msg = "get openIdList err:" + err.Error()
|
|
|
return
|
|
@@ -278,25 +331,44 @@ func SendWxMsgWithRoadshowDetailResult(first, keyword1, keyword2, remark, mobile
|
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
|
utils.FileLog.Info("start send")
|
|
|
- sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
|
|
|
- fmt.Println("send start")
|
|
|
- utils.FileLog.Info("send start")
|
|
|
- sendMap := make(map[string]interface{})
|
|
|
- sendData := make(map[string]interface{})
|
|
|
-
|
|
|
- sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
|
|
|
- sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
|
|
|
- sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
|
|
|
- sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
|
|
|
-
|
|
|
- sendMap["template_id"] = utils.WxMsgTemplateIdWithRoadshowDetailResult
|
|
|
- sendMap["url"] = redirectUrl
|
|
|
- sendMap["data"] = sendData
|
|
|
- //小程序信息
|
|
|
- if wxAppPath != "" {
|
|
|
- sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId2, "pagepath": wxAppPath}
|
|
|
+ //sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
|
|
|
+ //fmt.Println("send start")
|
|
|
+ //utils.FileLog.Info("send start")
|
|
|
+ //sendMap := make(map[string]interface{})
|
|
|
+ //sendData := make(map[string]interface{})
|
|
|
+ //
|
|
|
+ //sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
|
|
|
+ //sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
|
|
|
+ //sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
|
|
|
+ //sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
|
|
|
+ //
|
|
|
+ //sendMap["template_id"] = utils.WxMsgTemplateIdWithRoadshowDetailResult
|
|
|
+ //sendMap["url"] = redirectUrl
|
|
|
+ //sendMap["data"] = sendData
|
|
|
+ ////小程序信息
|
|
|
+ //if wxAppPath != "" {
|
|
|
+ // sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId2, "pagepath": wxAppPath}
|
|
|
+ //}
|
|
|
+ //sendTemplateMsg(sendUrl, sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT)
|
|
|
+
|
|
|
+ openIdArr := make([]string, len(openIdList))
|
|
|
+ for i, v := range openIdList {
|
|
|
+ openIdArr[i] = v.OpenId
|
|
|
+ }
|
|
|
+
|
|
|
+ sendInfo := new(SendWxTemplate)
|
|
|
+ sendInfo.First = first
|
|
|
+ sendInfo.Keyword1 = keyword1
|
|
|
+ sendInfo.Keyword2 = keyword2
|
|
|
+ sendInfo.Remark = remark
|
|
|
+ sendInfo.TemplateId = utils.WxMsgTemplateIdWithRoadshowDetailResult
|
|
|
+ if wxAppPath != "" && utils.RunMode == "release" {
|
|
|
+ sendInfo.RedirectUrl = wxAppPath
|
|
|
}
|
|
|
- sendTemplateMsg(sendUrl, sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT)
|
|
|
+ sendInfo.RedirectTarget = 2
|
|
|
+ sendInfo.Resource = wxAppPath
|
|
|
+ sendInfo.SendType = utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT
|
|
|
+ sendInfo.OpenIdArr = openIdArr
|
|
|
}
|
|
|
utils.FileLog.Info("send end")
|
|
|
return
|
|
@@ -329,8 +401,8 @@ func SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4,
|
|
|
}
|
|
|
|
|
|
//获取openid列表
|
|
|
- openIdStr := WxUsersGet()
|
|
|
- openIdList, err := wx_user.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
+ //openIdStr := WxUsersGet()
|
|
|
+ openIdList, err := wx_user.GetOpenIdListByMobile(mobile)
|
|
|
if err != nil {
|
|
|
msg = "get openIdList err:" + err.Error()
|
|
|
return
|
|
@@ -339,26 +411,49 @@ func SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4,
|
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
|
utils.FileLog.Info("start send")
|
|
|
- sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
|
|
|
- fmt.Println("send start")
|
|
|
- utils.FileLog.Info("send start")
|
|
|
- sendMap := make(map[string]interface{})
|
|
|
- sendData := make(map[string]interface{})
|
|
|
-
|
|
|
- sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
|
|
|
- sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
|
|
|
- sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
|
|
|
- sendData["keyword3"] = map[string]interface{}{"value": keyword3, "color": "#173177"}
|
|
|
- sendData["keyword4"] = map[string]interface{}{"value": keyword4, "color": "#173177"}
|
|
|
- sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
|
|
|
-
|
|
|
- sendMap["template_id"] = utils.WxMsgTemplateIdWithRoadshowPending
|
|
|
- sendMap["data"] = sendData
|
|
|
- //小程序信息
|
|
|
- if wxAppPath != "" {
|
|
|
- sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId2, "pagepath": wxAppPath}
|
|
|
+ //sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
|
|
|
+ //fmt.Println("send start")
|
|
|
+ //utils.FileLog.Info("send start")
|
|
|
+ //sendMap := make(map[string]interface{})
|
|
|
+ //sendData := make(map[string]interface{})
|
|
|
+ //
|
|
|
+ //sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
|
|
|
+ //sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
|
|
|
+ //sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
|
|
|
+ //sendData["keyword3"] = map[string]interface{}{"value": keyword3, "color": "#173177"}
|
|
|
+ //sendData["keyword4"] = map[string]interface{}{"value": keyword4, "color": "#173177"}
|
|
|
+ //sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
|
|
|
+ //
|
|
|
+ //sendMap["template_id"] = utils.WxMsgTemplateIdWithRoadshowPending
|
|
|
+ //sendMap["data"] = sendData
|
|
|
+ ////小程序信息
|
|
|
+ //if wxAppPath != "" {
|
|
|
+ // sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId2, "pagepath": wxAppPath}
|
|
|
+ //}
|
|
|
+ //sendTemplateMsg(sendUrl, sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT)
|
|
|
+
|
|
|
+ openIdArr := make([]string, len(openIdList))
|
|
|
+ for i, v := range openIdList {
|
|
|
+ openIdArr[i] = v.OpenId
|
|
|
+ }
|
|
|
+
|
|
|
+ sendInfo := new(SendWxTemplate)
|
|
|
+ sendInfo.First = first
|
|
|
+ sendInfo.Keyword1 = keyword1
|
|
|
+ sendInfo.Keyword2 = keyword2
|
|
|
+ sendInfo.Keyword3 = keyword3
|
|
|
+ sendInfo.Keyword4 = keyword4
|
|
|
+ sendInfo.Remark = remark
|
|
|
+ sendInfo.TemplateId = utils.WxMsgTemplateIdWithRoadshowPending
|
|
|
+ if wxAppPath != "" && utils.RunMode == "release" {
|
|
|
+ sendInfo.RedirectUrl = wxAppPath
|
|
|
}
|
|
|
- sendTemplateMsg(sendUrl, sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT)
|
|
|
+ sendInfo.RedirectTarget = 2
|
|
|
+ sendInfo.Resource = wxAppPath
|
|
|
+ sendInfo.SendType = utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT
|
|
|
+ sendInfo.OpenIdArr = openIdArr
|
|
|
+
|
|
|
+ err = SendTemplateMsg(sendInfo)
|
|
|
}
|
|
|
utils.FileLog.Info("send end")
|
|
|
return
|
|
@@ -390,8 +485,8 @@ func SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppP
|
|
|
}
|
|
|
|
|
|
//获取openid列表
|
|
|
- openIdStr := WxUsersGet()
|
|
|
- openIdList, err := wx_user.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
+ //openIdStr := WxUsersGet()
|
|
|
+ openIdList, err := wx_user.GetOpenIdListByMobile(mobile)
|
|
|
if err != nil {
|
|
|
msg = "get openIdList err:" + err.Error()
|
|
|
return
|
|
@@ -400,21 +495,42 @@ func SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppP
|
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
|
utils.FileLog.Info("start send")
|
|
|
- sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
|
|
|
- sendMap := make(map[string]interface{})
|
|
|
- sendData := make(map[string]interface{})
|
|
|
-
|
|
|
- sendMap["template_id"] = utils.WxMsgTemplateIdWithRoadshowDeleteNotice
|
|
|
- sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
|
|
|
- sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
|
|
|
- sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
|
|
|
- sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
|
|
|
- //小程序信息
|
|
|
- if wxAppPath != "" {
|
|
|
- sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId2, "pagepath": wxAppPath}
|
|
|
+ //sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
|
|
|
+ //sendMap := make(map[string]interface{})
|
|
|
+ //sendData := make(map[string]interface{})
|
|
|
+ //
|
|
|
+ //sendMap["template_id"] = utils.WxMsgTemplateIdWithRoadshowDeleteNotice
|
|
|
+ //sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
|
|
|
+ //sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
|
|
|
+ //sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
|
|
|
+ //sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
|
|
|
+ ////小程序信息
|
|
|
+ //if wxAppPath != "" {
|
|
|
+ // sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId2, "pagepath": wxAppPath}
|
|
|
+ //}
|
|
|
+ //sendMap["data"] = sendData
|
|
|
+ //sendTemplateMsg(sendUrl, sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT)
|
|
|
+
|
|
|
+ openIdArr := make([]string, len(openIdList))
|
|
|
+ for i, v := range openIdList {
|
|
|
+ openIdArr[i] = v.OpenId
|
|
|
+ }
|
|
|
+
|
|
|
+ sendInfo := new(SendWxTemplate)
|
|
|
+ sendInfo.First = first
|
|
|
+ sendInfo.Keyword1 = keyword1
|
|
|
+ sendInfo.Keyword2 = keyword2
|
|
|
+ sendInfo.Remark = remark
|
|
|
+ sendInfo.TemplateId = utils.WxMsgTemplateIdWithRoadshowDeleteNotice
|
|
|
+ if wxAppPath != "" && utils.RunMode == "release" {
|
|
|
+ sendInfo.RedirectUrl = wxAppPath
|
|
|
}
|
|
|
- sendMap["data"] = sendData
|
|
|
- sendTemplateMsg(sendUrl, sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT)
|
|
|
+ sendInfo.RedirectTarget = 2
|
|
|
+ sendInfo.Resource = wxAppPath
|
|
|
+ sendInfo.SendType = utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT
|
|
|
+ sendInfo.OpenIdArr = openIdArr
|
|
|
+
|
|
|
+ err = SendTemplateMsg(sendInfo)
|
|
|
}
|
|
|
utils.FileLog.Info("send end")
|
|
|
return
|
|
@@ -444,8 +560,8 @@ func SendSealFinishedWxTemplateMsg(mobile string, companyName string, sealId int
|
|
|
return
|
|
|
}
|
|
|
utils.FileLog.Info("mobile:%s", mobile)
|
|
|
- openIdStr := WxUsersGet()
|
|
|
- openIdList, err := wx_user.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
+ //openIdStr := WxUsersGet()
|
|
|
+ openIdList, err := wx_user.GetOpenIdListByMobile(mobile)
|
|
|
if err != nil {
|
|
|
msg = "get openIdList err:" + err.Error()
|
|
|
return
|
|
@@ -454,29 +570,48 @@ func SendSealFinishedWxTemplateMsg(mobile string, companyName string, sealId int
|
|
|
|
|
|
if len(openIdList) > 0 && utils.WxMsgTemplateIdWithSealApplyFinished != "" {
|
|
|
utils.FileLog.Info("start send")
|
|
|
- sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
|
|
|
- fmt.Println("send start")
|
|
|
- utils.FileLog.Info("send start")
|
|
|
- sendMap := make(map[string]interface{})
|
|
|
- sendData := make(map[string]interface{})
|
|
|
+ //sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
|
|
|
+ //fmt.Println("send start")
|
|
|
+ //utils.FileLog.Info("send start")
|
|
|
+ //sendMap := make(map[string]interface{})
|
|
|
+ //sendData := make(map[string]interface{})
|
|
|
first := "您的用印申请已签回,可前往提交转正/续约申请"
|
|
|
keyword1 := companyName
|
|
|
keyword2 := "已签回"
|
|
|
remark := "点击查看用印详情"
|
|
|
-
|
|
|
- sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
|
|
|
- sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
|
|
|
- sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
|
|
|
- sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
|
|
|
-
|
|
|
- sendMap["template_id"] = utils.WxMsgTemplateIdWithSealApplyFinished
|
|
|
- sendMap["url"] = "" //跳转地址
|
|
|
- sendMap["data"] = sendData
|
|
|
+ //
|
|
|
+ //sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
|
|
|
+ //sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
|
|
|
+ //sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
|
|
|
+ //sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
|
|
|
+ //
|
|
|
+ //sendMap["template_id"] = utils.WxMsgTemplateIdWithSealApplyFinished
|
|
|
+ //sendMap["url"] = "" //跳转地址
|
|
|
+ //sendMap["data"] = sendData
|
|
|
|
|
|
// TODO 随手办公小程序的跳转地址
|
|
|
wxAppPath := fmt.Sprintf("pages-approve/seal/detail?SealId=%d", sealId)
|
|
|
- sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId2, "pagepath": wxAppPath}
|
|
|
- err = sendTemplateMsg(sendUrl, sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_SEAL_FINISHED)
|
|
|
+ //sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId2, "pagepath": wxAppPath}
|
|
|
+ //err = sendTemplateMsg(sendUrl, sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_SEAL_FINISHED)
|
|
|
+
|
|
|
+ openIdArr := make([]string, len(openIdList))
|
|
|
+ for i, v := range openIdList {
|
|
|
+ openIdArr[i] = v.OpenId
|
|
|
+ }
|
|
|
+
|
|
|
+ sendInfo := new(SendWxTemplate)
|
|
|
+ sendInfo.First = first
|
|
|
+ sendInfo.Keyword1 = keyword1
|
|
|
+ sendInfo.Keyword2 = keyword2
|
|
|
+ sendInfo.Remark = remark
|
|
|
+ sendInfo.RedirectUrl = wxAppPath
|
|
|
+ sendInfo.TemplateId = utils.WxMsgTemplateIdWithSealApplyFinished
|
|
|
+ sendInfo.RedirectTarget = 2
|
|
|
+ sendInfo.Resource = wxAppPath
|
|
|
+ sendInfo.SendType = utils.TEMPLATE_MSG_SEAL_FINISHED
|
|
|
+ sendInfo.OpenIdArr = openIdArr
|
|
|
+
|
|
|
+ err = SendTemplateMsg(sendInfo)
|
|
|
}
|
|
|
utils.FileLog.Info("send end")
|
|
|
return
|
|
@@ -508,27 +643,84 @@ func SendYbQuestionDistributeWxMsg(questionId, userId int, openid, questionTitle
|
|
|
UserId: userId,
|
|
|
})
|
|
|
|
|
|
- sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
|
|
|
- sendMap := make(map[string]interface{})
|
|
|
- sendData := make(map[string]interface{})
|
|
|
+ //sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
|
|
|
+ //sendMap := make(map[string]interface{})
|
|
|
+ //sendData := make(map[string]interface{})
|
|
|
|
|
|
first := "您好,有新的提问待回复"
|
|
|
keyword1 := questionTitle
|
|
|
keyword2 := "待回复"
|
|
|
remark := "请点击详情尽快处理"
|
|
|
|
|
|
- sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
|
|
|
- sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
|
|
|
- sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
|
|
|
- sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
|
|
|
+ //sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
|
|
|
+ //sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
|
|
|
+ //sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
|
|
|
+ //sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
|
|
|
+ //
|
|
|
+ //sendMap["template_id"] = utils.WxMsgTemplateIdWithYbCommunityQuestion
|
|
|
+ //sendMap["data"] = sendData
|
|
|
+ //
|
|
|
+ wxAppPath := fmt.Sprintf("pages-question/answerDetail?id=%d", questionId)
|
|
|
+ //if wxAppPath != "" {
|
|
|
+ // sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxYbAppId, "pagepath": wxAppPath}
|
|
|
+ //}
|
|
|
+ //err = sendTemplateMsg(sendUrl, sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_YB_COMMUNITY_QUESTION)
|
|
|
+
|
|
|
+ openIdArr := make([]string, len(openIdList))
|
|
|
+ for i, v := range openIdList {
|
|
|
+ openIdArr[i] = v.OpenId
|
|
|
+ }
|
|
|
+
|
|
|
+ sendInfo := new(SendWxTemplate)
|
|
|
+ sendInfo.First = first
|
|
|
+ sendInfo.Keyword1 = keyword1
|
|
|
+ sendInfo.Keyword2 = keyword2
|
|
|
+ sendInfo.Remark = remark
|
|
|
+ sendInfo.RedirectUrl = wxAppPath
|
|
|
+ sendInfo.TemplateId = utils.WxMsgTemplateIdWithYbCommunityQuestion
|
|
|
+ sendInfo.RedirectTarget = 1
|
|
|
+ sendInfo.Resource = wxAppPath
|
|
|
+ sendInfo.SendType = utils.TEMPLATE_MSG_YB_COMMUNITY_QUESTION
|
|
|
+ sendInfo.OpenIdArr = openIdArr
|
|
|
+ return
|
|
|
+}
|
|
|
|
|
|
- sendMap["template_id"] = utils.WxMsgTemplateIdWithYbCommunityQuestion
|
|
|
- sendMap["data"] = sendData
|
|
|
|
|
|
- wxAppPath := fmt.Sprintf("pages-question/answerDetail?id=%d", questionId)
|
|
|
- if wxAppPath != "" {
|
|
|
- sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxYbAppId, "pagepath": wxAppPath}
|
|
|
+//推送模板消息
|
|
|
+func SendTemplateMsg(sendInfo *SendWxTemplate) (err error) {
|
|
|
+ postData, err := json.Marshal(sendInfo)
|
|
|
+ if err != nil {
|
|
|
+ alarm_msg.SendAlarmMsg("SendTemplateMsg json.Marshal Err:"+err.Error(), 1)
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ body := ioutil.NopCloser(strings.NewReader(string(postData)))
|
|
|
+ client := &http.Client{}
|
|
|
+ req, err := http.NewRequest("POST", utils.SendWxTemplateMsgUrl, body)
|
|
|
+ if err != nil {
|
|
|
+ alarm_msg.SendAlarmMsg("SendTemplateMsg http.NewRequest Err:"+err.Error(), 1)
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ contentType := "application/json;charset=utf-8"
|
|
|
+ req.Header.Set("Content-Type", contentType)
|
|
|
+ req.Header.Set("Authorization", utils.SendTemplateMsgAuthorization)
|
|
|
+ resp, err := client.Do(req)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("http client.Do Err:" + err.Error())
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ defer resp.Body.Close()
|
|
|
+ b, err := ioutil.ReadAll(resp.Body)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ result := new(BaseResponse)
|
|
|
+ err = json.Unmarshal(b, &result)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if result.Ret != 200 {
|
|
|
+ err = errors.New(string(b))
|
|
|
+ return err
|
|
|
}
|
|
|
- err = sendTemplateMsg(sendUrl, sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_YB_COMMUNITY_QUESTION)
|
|
|
return
|
|
|
-}
|
|
|
+}
|