|
@@ -12,11 +12,12 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
//访谈申请
|
|
//访谈申请
|
|
-func SendInterviewApplyTemplateMsg(realName, companyName, mobile, articleTitle, openId string) (err error) {
|
|
|
|
|
|
+func SendInterviewApplyTemplateMsg(realName, companyName, mobile, articleTitle string, itemOpenid *models.OpenIdList) (err error) {
|
|
var msg string
|
|
var msg string
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
go utils.SendEmail("发送模版消息失败"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
|
|
go utils.SendEmail("发送模版消息失败"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
|
|
|
|
+ go utils.SendAlarmMsg(fmt.Sprint("访谈申请模板消息推送消息失败,手机号", mobile, "公司:", companyName, "手机号:", mobile), 2)
|
|
}
|
|
}
|
|
if msg != "" {
|
|
if msg != "" {
|
|
utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
|
|
utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
|
|
@@ -52,17 +53,18 @@ func SendInterviewApplyTemplateMsg(realName, companyName, mobile, articleTitle,
|
|
|
|
|
|
sendMap["template_id"] = utils.WxMsgTemplateIdApplyXzs
|
|
sendMap["template_id"] = utils.WxMsgTemplateIdApplyXzs
|
|
sendMap["data"] = sendData
|
|
sendMap["data"] = sendData
|
|
- sendTemplateMsg(sendUrl, openId, sendMap)
|
|
|
|
|
|
+ sendTemplateMsg(sendUrl, sendMap, itemOpenid, mobile, utils.TEMPLATE_MSG_CYGX_APPLY)
|
|
fmt.Println("send end")
|
|
fmt.Println("send end")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
//访谈申请取消
|
|
//访谈申请取消
|
|
-func SendInterviewApplyCancelTemplateMsg(realName, companyName, mobile, articleTitle, openId string) (err error) {
|
|
|
|
|
|
+func SendInterviewApplyCancelTemplateMsg(realName, companyName, mobile, articleTitle string, itemOpenid *models.OpenIdList) (err error) {
|
|
var msg string
|
|
var msg string
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
go utils.SendEmail("发送模版消息失败"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
|
|
go utils.SendEmail("发送模版消息失败"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
|
|
|
|
+ go utils.SendAlarmMsg(fmt.Sprint("访谈申请取消模板消息推送消息失败,手机号", mobile, "公司:", companyName, "手机号:", mobile), 2)
|
|
}
|
|
}
|
|
if msg != "" {
|
|
if msg != "" {
|
|
utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
|
|
utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
|
|
@@ -93,17 +95,18 @@ func SendInterviewApplyCancelTemplateMsg(realName, companyName, mobile, articleT
|
|
|
|
|
|
sendMap["template_id"] = utils.WxMsgTemplateIdApplyCancelXzs
|
|
sendMap["template_id"] = utils.WxMsgTemplateIdApplyCancelXzs
|
|
sendMap["data"] = sendData
|
|
sendMap["data"] = sendData
|
|
- sendTemplateMsg(sendUrl, openId, sendMap)
|
|
|
|
|
|
+ sendTemplateMsg(sendUrl, sendMap, itemOpenid, mobile, utils.TEMPLATE_MSG_CYGX_APPLY)
|
|
fmt.Println("send end")
|
|
fmt.Println("send end")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
//权限申请
|
|
//权限申请
|
|
-func SendPermissionApplyTemplateMsg(realName, companyName, mobile, openId, applyMethod string) (err error) {
|
|
|
|
|
|
+func SendPermissionApplyTemplateMsg(realName, companyName, mobile, applyMethod string, itemOpenid *models.OpenIdList) (err error) {
|
|
var msg string
|
|
var msg string
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
go utils.SendEmail("发送模版消息失败"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
|
|
go utils.SendEmail("发送模版消息失败"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
|
|
|
|
+ go utils.SendAlarmMsg(fmt.Sprint("权限申请模板消息推送消息失败,手机号", mobile, "公司:", companyName, "手机号:", mobile), 2)
|
|
}
|
|
}
|
|
if msg != "" {
|
|
if msg != "" {
|
|
utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
|
|
utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
|
|
@@ -155,26 +158,26 @@ func SendPermissionApplyTemplateMsg(realName, companyName, mobile, openId, apply
|
|
sendMap["template_id"] = utils.WxMsgTemplateIdApply
|
|
sendMap["template_id"] = utils.WxMsgTemplateIdApply
|
|
}
|
|
}
|
|
sendMap["data"] = sendData
|
|
sendMap["data"] = sendData
|
|
- sendTemplateMsg(sendUrl, openId, sendMap)
|
|
|
|
|
|
+ sendTemplateMsg(sendUrl, sendMap, itemOpenid, mobile, utils.TEMPLATE_MSG_CYGX_APPLY)
|
|
fmt.Println("send end")
|
|
fmt.Println("send end")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-func sendTemplateMsg(sendUrl, openId string, sendMap map[string]interface{}) (err error) {
|
|
|
|
- sendMap["touser"] = openId
|
|
|
|
|
|
+func sendTemplateMsg(sendUrl string, sendMap map[string]interface{}, itemOpenid *models.OpenIdList, resource string, sendType int) (err error) {
|
|
|
|
+ sendMap["touser"] = itemOpenid.OpenId
|
|
data, err := json.Marshal(sendMap)
|
|
data, err := json.Marshal(sendMap)
|
|
if err != nil {
|
|
if err != nil {
|
|
fmt.Println("SendTemplateMsgOne Marshal Err:", err.Error())
|
|
fmt.Println("SendTemplateMsgOne Marshal Err:", err.Error())
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
- err = toSendTemplateMsg(sendUrl, data)
|
|
|
|
|
|
+ err = toSendTemplateMsg(sendUrl, data, resource, sendType, itemOpenid)
|
|
if err != nil {
|
|
if err != nil {
|
|
fmt.Println("send err:", err.Error())
|
|
fmt.Println("send err:", err.Error())
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-func toSendTemplateMsg(sendUrl string, data []byte) (err error) {
|
|
|
|
|
|
+func toSendTemplateMsg(sendUrl string, data []byte, resource string, sendType int, dataItem *models.OpenIdList) (err error) {
|
|
client := http.Client{}
|
|
client := http.Client{}
|
|
resp, err := client.Post(sendUrl, "application/json", bytes.NewBuffer(data))
|
|
resp, err := client.Post(sendUrl, "application/json", bytes.NewBuffer(data))
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -191,6 +194,29 @@ func toSendTemplateMsg(sendUrl string, data []byte) (err error) {
|
|
utils.FileLog.Info("SendResult Unmarshal Err:%s", err.Error())
|
|
utils.FileLog.Info("SendResult Unmarshal Err:%s", err.Error())
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
+ //新增模板消息推送记录
|
|
|
|
+ {
|
|
|
|
+ tr := new(models.UserTemplateRecord)
|
|
|
|
+ tr.UserId = dataItem.UserId
|
|
|
|
+ tr.OpenId = dataItem.OpenId
|
|
|
|
+ tr.Resource = resource
|
|
|
|
+ tr.SendData = string(data)
|
|
|
|
+ tr.Result = string(body)
|
|
|
|
+ tr.CreateDate = time.Now().Format(utils.FormatDate)
|
|
|
|
+ tr.CreateTime = time.Now().Format(utils.FormatDateTime)
|
|
|
|
+ if templateResponse.Errcode == 0 {
|
|
|
|
+ tr.SendStatus = 1
|
|
|
|
+ } else {
|
|
|
|
+ tr.SendStatus = 0
|
|
|
|
+ }
|
|
|
|
+ tr.SendType = sendType
|
|
|
|
+ go func() {
|
|
|
|
+ err = models.AddUserTemplateRecord(tr)
|
|
|
|
+ if err != nil {
|
|
|
|
+ utils.FileLog.Info(fmt.Sprintf("AddUserTemplateRecord Err:%s", err.Error()))
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
+ }
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -199,9 +225,3 @@ type SendTemplateResponse struct {
|
|
Errmsg string `json:"errmsg"`
|
|
Errmsg string `json:"errmsg"`
|
|
MsgID int `json:"msgid"`
|
|
MsgID int `json:"msgid"`
|
|
}
|
|
}
|
|
-
|
|
|
|
-func ini123() {
|
|
|
|
- fmt.Println("start")
|
|
|
|
- SendPermissionApplyTemplateMsg("沈涛", "弘则", "18767183922", "oW3Gts7Ji6Ngv7v2pLeLOFaajfus", "潜在客户申请")
|
|
|
|
- fmt.Println("end")
|
|
|
|
-}
|
|
|