|
@@ -1,84 +1,42 @@
|
|
package services
|
|
package services
|
|
|
|
|
|
import (
|
|
import (
|
|
- "bytes"
|
|
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
"hongze/hongze_mobile_admin/models/tables/admin"
|
|
"hongze/hongze_mobile_admin/models/tables/admin"
|
|
- "hongze/hongze_mobile_admin/models/tables/user_template_record"
|
|
|
|
"hongze/hongze_mobile_admin/services/alarm_msg"
|
|
"hongze/hongze_mobile_admin/services/alarm_msg"
|
|
"hongze/hongze_mobile_admin/utils"
|
|
"hongze/hongze_mobile_admin/utils"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"net/http"
|
|
|
|
+ "strings"
|
|
"time"
|
|
"time"
|
|
|
|
+ "errors"
|
|
)
|
|
)
|
|
-
|
|
|
|
-func sendTemplateMsg(wxAppId string,sendUrl string, sendMap map[string]interface{}, items []*admin.OpenIdList, resource string, sendType int) (err error) {
|
|
|
|
- for _, v := range items {
|
|
|
|
- sendMap["touser"] = v.OpenId
|
|
|
|
- data, err := json.Marshal(sendMap)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("SendTemplateMsgOne Marshal Err:", err.Error())
|
|
|
|
- utils.FileLog.Info(fmt.Sprintf("SendTemplateMsgOne Marshal Err:%s", err.Error()))
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- err = toSendTemplateMsg(wxAppId, sendUrl, data, resource, sendType, v)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("send err:", err.Error())
|
|
|
|
- utils.FileLog.Info(fmt.Sprintf("ToSendTemplateMsg Err:%s", err.Error()))
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return
|
|
|
|
|
|
+type SendWxTemplate struct {
|
|
|
|
+ WxAppId string `description:"公众号appId"`
|
|
|
|
+ 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"`
|
|
}
|
|
}
|
|
|
|
|
|
-func toSendTemplateMsg(wxAppId string,sendUrl string, data []byte, resource string, sendType int, dataItem *admin.OpenIdList) (err error) {
|
|
|
|
- utils.FileLog.Info("Send:" + string(data))
|
|
|
|
- client := http.Client{}
|
|
|
|
- resp, err := client.Post(sendUrl, "application/json", bytes.NewBuffer(data))
|
|
|
|
- if err != nil {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- defer resp.Body.Close()
|
|
|
|
-
|
|
|
|
- body, _ := ioutil.ReadAll(resp.Body)
|
|
|
|
- utils.FileLog.Info("SendResult:" + string(body))
|
|
|
|
- var templateResponse SendTemplateResponse
|
|
|
|
- err = json.Unmarshal(body, &templateResponse)
|
|
|
|
- if err != nil {
|
|
|
|
- utils.FileLog.Info("SendResult Unmarshal Err:%s", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //新增模板消息推送记录
|
|
|
|
- {
|
|
|
|
- sendStatus := 0
|
|
|
|
- if templateResponse.Errcode == 0 {
|
|
|
|
- sendStatus = 1
|
|
|
|
- } else {
|
|
|
|
- sendStatus = 0
|
|
|
|
- }
|
|
|
|
- tr := &user_template_record.UserTemplateRecord{
|
|
|
|
- Id: 0,
|
|
|
|
- // UserId: dataItem.UserId,
|
|
|
|
- OpenId: dataItem.OpenId,
|
|
|
|
- Resource: resource,
|
|
|
|
- SendData: string(data),
|
|
|
|
- Result: string(body),
|
|
|
|
- CreateDate: time.Now().Format(utils.FormatDate),
|
|
|
|
- CreateTime: time.Now().Format(utils.FormatDateTime),
|
|
|
|
- SendStatus: sendStatus,
|
|
|
|
- SendType: sendType,
|
|
|
|
- WxAppId: wxAppId,
|
|
|
|
- }
|
|
|
|
- go func() {
|
|
|
|
- err = user_template_record.AddUserTemplateRecord(tr)
|
|
|
|
- if err != nil {
|
|
|
|
- utils.FileLog.Info(fmt.Sprintf("AddUserTemplateRecord Err:%s", err.Error()))
|
|
|
|
- }
|
|
|
|
- }()
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return
|
|
|
|
|
|
+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 不新增操作日志" `
|
|
}
|
|
}
|
|
|
|
|
|
type SendTemplateResponse struct {
|
|
type SendTemplateResponse struct {
|
|
@@ -124,11 +82,11 @@ func SendCompanyApplyWxTemplateMsg(mobile, redirectUrl, wxAppPath string, wxMsgM
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
utils.FileLog.Info("start send")
|
|
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")
|
|
fmt.Println("send start")
|
|
utils.FileLog.Info("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
|
|
var first, keyword1, keyword2, keyword3, remark string
|
|
if tmpStr, ok := wxMsgMap[0]; ok {
|
|
if tmpStr, ok := wxMsgMap[0]; ok {
|
|
@@ -149,20 +107,44 @@ func SendCompanyApplyWxTemplateMsg(mobile, redirectUrl, wxAppPath string, wxMsgM
|
|
remark = tmpStr
|
|
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.WxAppId = utils.AdminWxAppId
|
|
|
|
+ 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 != "" {
|
|
if wxAppPath != "" {
|
|
- sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId2, "pagepath": wxAppPath}
|
|
|
|
|
|
+ sendInfo.RedirectUrl = wxAppPath
|
|
}
|
|
}
|
|
- sendTemplateMsg(utils.AdminWxAppId, sendUrl, sendMap, openIdList, mobile, utils.TEMPLATE_MSG_APPLY)
|
|
|
|
|
|
+ err = SendTemplateMsg(sendInfo)
|
|
}
|
|
}
|
|
utils.FileLog.Info("send end")
|
|
utils.FileLog.Info("send end")
|
|
return
|
|
return
|
|
@@ -206,25 +188,45 @@ func SendWxMsgWithRoadshowDetailResult(first, keyword1, keyword2, remark, mobile
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
utils.FileLog.Info("start send")
|
|
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
|
|
}
|
|
}
|
|
- sendTemplateMsg(utils.AdminWxAppId, sendUrl, sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT)
|
|
|
|
|
|
+
|
|
|
|
+ sendInfo := new(SendWxTemplate)
|
|
|
|
+ sendInfo.WxAppId = utils.AdminWxAppId
|
|
|
|
+ sendInfo.First = first
|
|
|
|
+ sendInfo.Keyword1 = keyword1
|
|
|
|
+ sendInfo.Keyword2 = keyword2
|
|
|
|
+ sendInfo.Remark = remark
|
|
|
|
+ sendInfo.TemplateId = utils.WxMsgTemplateIdWithRoadshowDetailResult
|
|
|
|
+ if wxAppPath != "" && utils.RunMode == "release" {
|
|
|
|
+ sendInfo.RedirectUrl = wxAppPath
|
|
|
|
+ }
|
|
|
|
+ sendInfo.RedirectTarget = 2
|
|
|
|
+ sendInfo.Resource = wxAppPath
|
|
|
|
+ sendInfo.SendType = utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT
|
|
|
|
+ sendInfo.OpenIdArr = openIdArr
|
|
}
|
|
}
|
|
utils.FileLog.Info("send end")
|
|
utils.FileLog.Info("send end")
|
|
return
|
|
return
|
|
@@ -267,26 +269,50 @@ func SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4,
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
utils.FileLog.Info("start send")
|
|
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
|
|
}
|
|
}
|
|
- sendTemplateMsg(utils.AdminWxAppId, sendUrl, sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT)
|
|
|
|
|
|
+
|
|
|
|
+ sendInfo := new(SendWxTemplate)
|
|
|
|
+ sendInfo.WxAppId = utils.AdminWxAppId
|
|
|
|
+ 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
|
|
|
|
+ }
|
|
|
|
+ sendInfo.RedirectTarget = 2
|
|
|
|
+ sendInfo.Resource = wxAppPath
|
|
|
|
+ sendInfo.SendType = utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT
|
|
|
|
+ sendInfo.OpenIdArr = openIdArr
|
|
|
|
+
|
|
|
|
+ err = SendTemplateMsg(sendInfo)
|
|
}
|
|
}
|
|
utils.FileLog.Info("send end")
|
|
utils.FileLog.Info("send end")
|
|
return
|
|
return
|
|
@@ -328,21 +354,43 @@ func SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppP
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
utils.FileLog.Info("start send")
|
|
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
|
|
}
|
|
}
|
|
- sendMap["data"] = sendData
|
|
|
|
- sendTemplateMsg(utils.AdminWxAppId, sendUrl, sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT)
|
|
|
|
|
|
+
|
|
|
|
+ sendInfo := new(SendWxTemplate)
|
|
|
|
+ sendInfo.WxAppId = utils.AdminWxAppId
|
|
|
|
+ sendInfo.First = first
|
|
|
|
+ sendInfo.Keyword1 = keyword1
|
|
|
|
+ sendInfo.Keyword2 = keyword2
|
|
|
|
+ sendInfo.Remark = remark
|
|
|
|
+ sendInfo.TemplateId = utils.WxMsgTemplateIdWithRoadshowDeleteNotice
|
|
|
|
+ if wxAppPath != "" && utils.RunMode == "release" {
|
|
|
|
+ sendInfo.RedirectUrl = wxAppPath
|
|
|
|
+ }
|
|
|
|
+ sendInfo.RedirectTarget = 2
|
|
|
|
+ sendInfo.Resource = wxAppPath
|
|
|
|
+ sendInfo.SendType = utils.TEMPLATE_MSG_ACTIVITY_APPOINTMENT
|
|
|
|
+ sendInfo.OpenIdArr = openIdArr
|
|
|
|
+
|
|
|
|
+ err = SendTemplateMsg(sendInfo)
|
|
}
|
|
}
|
|
utils.FileLog.Info("send end")
|
|
utils.FileLog.Info("send end")
|
|
return
|
|
return
|
|
@@ -383,29 +431,48 @@ func SendSealFinishedWxTemplateMsg(mobile string, companyName string, sealId int
|
|
|
|
|
|
if len(openIdList) > 0 && utils.WxMsgTemplateIdWithSealApplyFinished != "" {
|
|
if len(openIdList) > 0 && utils.WxMsgTemplateIdWithSealApplyFinished != "" {
|
|
utils.FileLog.Info("start send")
|
|
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 := "您的用印申请已签回,可前往提交转正/续约申请"
|
|
first := "您的用印申请已签回,可前往提交转正/续约申请"
|
|
keyword1 := companyName
|
|
keyword1 := companyName
|
|
keyword2 := "已签回"
|
|
keyword2 := "已签回"
|
|
remark := "点击查看用印详情"
|
|
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 随手办公小程序的跳转地址
|
|
// TODO 随手办公小程序的跳转地址
|
|
wxAppPath := fmt.Sprintf("pages-approve/seal/detail?SealId=%d", sealId)
|
|
wxAppPath := fmt.Sprintf("pages-approve/seal/detail?SealId=%d", sealId)
|
|
- sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId2, "pagepath": wxAppPath}
|
|
|
|
- err = sendTemplateMsg(utils.AdminWxAppId, 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")
|
|
utils.FileLog.Info("send end")
|
|
return
|
|
return
|
|
@@ -437,27 +504,84 @@ func SendYbQuestionDistributeWxMsg(questionId, adminId int, openid, questionTitl
|
|
AdminId: adminId,
|
|
AdminId: adminId,
|
|
})
|
|
})
|
|
|
|
|
|
- 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 := "您好,有新的提问待回复"
|
|
first := "您好,有新的提问待回复"
|
|
keyword1 := questionTitle
|
|
keyword1 := questionTitle
|
|
keyword2 := "待回复"
|
|
keyword2 := "待回复"
|
|
remark := "请点击详情尽快处理"
|
|
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.WxMsgTemplateIdWithYbCommunityQuestion
|
|
|
|
- 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.WxMsgTemplateIdWithYbCommunityQuestion
|
|
|
|
+ //sendMap["data"] = sendData
|
|
|
|
+ //
|
|
wxAppPath := fmt.Sprintf("pages-question/answerDetail?id=%d", questionId)
|
|
wxAppPath := fmt.Sprintf("pages-question/answerDetail?id=%d", questionId)
|
|
- if wxAppPath != "" {
|
|
|
|
- sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxYbAppId, "pagepath": wxAppPath}
|
|
|
|
|
|
+ //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
|
|
}
|
|
}
|
|
- err = sendTemplateMsg(utils.AdminWxAppId, sendUrl, sendMap, openIdList, wxAppPath, utils.TEMPLATE_MSG_YB_COMMUNITY_QUESTION)
|
|
|
|
|
|
+
|
|
|
|
+ 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
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+//推送模板消息
|
|
|
|
+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
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+}
|