|
@@ -6,7 +6,6 @@ import (
|
|
|
"fmt"
|
|
|
"hongze/hongze_mobile_admin/models/tables/admin"
|
|
|
"hongze/hongze_mobile_admin/models/tables/user_template_record"
|
|
|
- "hongze/hongze_mobile_admin/models/tables/wx_user"
|
|
|
"hongze/hongze_mobile_admin/services/alarm_msg"
|
|
|
"hongze/hongze_mobile_admin/utils"
|
|
|
"io/ioutil"
|
|
@@ -14,7 +13,7 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-func sendTemplateMsg(sendUrl string, sendMap map[string]interface{}, items []*wx_user.OpenIdList, resource string, sendType int) (err error) {
|
|
|
+func sendTemplateMsg(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)
|
|
@@ -32,7 +31,7 @@ func sendTemplateMsg(sendUrl string, sendMap map[string]interface{}, items []*wx
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func toSendTemplateMsg(sendUrl string, data []byte, resource string, sendType int, dataItem *wx_user.OpenIdList) (err error) {
|
|
|
+func toSendTemplateMsg(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))
|
|
@@ -60,7 +59,7 @@ func toSendTemplateMsg(sendUrl string, data []byte, resource string, sendType in
|
|
|
}
|
|
|
tr := &user_template_record.UserTemplateRecord{
|
|
|
Id: 0,
|
|
|
- UserId: dataItem.UserId,
|
|
|
+ // UserId: dataItem.UserId,
|
|
|
OpenId: dataItem.OpenId,
|
|
|
Resource: resource,
|
|
|
SendData: string(data),
|
|
@@ -115,17 +114,11 @@ func SendCompanyApplyWxTemplateMsg(mobile, redirectUrl, wxAppPath string, wxMsgM
|
|
|
|
|
|
//获取openid列表
|
|
|
openIdStr := WxAdminOpenIdGet()
|
|
|
- adminOpenIdList, err := admin.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
+ openIdList, err := admin.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
if err != nil {
|
|
|
msg = "get openIdList err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- openIdList := make([]*wx_user.OpenIdList, 0)
|
|
|
- for _, v := range adminOpenIdList {
|
|
|
- tmp := new(wx_user.OpenIdList)
|
|
|
- tmp.OpenId = v.OpenId
|
|
|
- openIdList = append(openIdList, tmp)
|
|
|
- }
|
|
|
utils.FileLog.Info("openIdListCount:%s", len(openIdList))
|
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
@@ -202,17 +195,12 @@ func SendWxMsgWithRoadshowDetailResult(first, keyword1, keyword2, remark, mobile
|
|
|
|
|
|
//获取openid列表
|
|
|
openIdStr := WxAdminOpenIdGet()
|
|
|
- adminOpenIdList, err := admin.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
+ openIdList, err := admin.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
if err != nil {
|
|
|
msg = "get openIdList err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- openIdList := make([]*wx_user.OpenIdList, 0)
|
|
|
- for _, v := range adminOpenIdList {
|
|
|
- tmp := new(wx_user.OpenIdList)
|
|
|
- tmp.OpenId = v.OpenId
|
|
|
- openIdList = append(openIdList, tmp)
|
|
|
- }
|
|
|
+
|
|
|
utils.FileLog.Info("openIdListCount:%s", len(openIdList))
|
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
@@ -269,17 +257,11 @@ func SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4,
|
|
|
|
|
|
//获取openid列表
|
|
|
openIdStr := WxAdminOpenIdGet()
|
|
|
- adminOpenIdList, err := admin.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
+ openIdList, err := admin.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
if err != nil {
|
|
|
msg = "get openIdList err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- openIdList := make([]*wx_user.OpenIdList, 0)
|
|
|
- for _, v := range adminOpenIdList {
|
|
|
- tmp := new(wx_user.OpenIdList)
|
|
|
- tmp.OpenId = v.OpenId
|
|
|
- openIdList = append(openIdList, tmp)
|
|
|
- }
|
|
|
utils.FileLog.Info("openIdListCount:%s", len(openIdList))
|
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
@@ -336,17 +318,11 @@ func SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppP
|
|
|
|
|
|
//获取openid列表
|
|
|
openIdStr := WxAdminOpenIdGet()
|
|
|
- adminOpenIdList, err := admin.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
+ openIdList, err := admin.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
if err != nil {
|
|
|
msg = "get openIdList err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- openIdList := make([]*wx_user.OpenIdList, 0)
|
|
|
- for _, v := range adminOpenIdList {
|
|
|
- tmp := new(wx_user.OpenIdList)
|
|
|
- tmp.OpenId = v.OpenId
|
|
|
- openIdList = append(openIdList, tmp)
|
|
|
- }
|
|
|
utils.FileLog.Info("openIdListCount:%s", len(openIdList))
|
|
|
//fmt.Println("openIdListCount:", len(openIdList))
|
|
|
if len(openIdList) > 0 && utils.TemplateIdByCompanyApply != "" {
|
|
@@ -396,17 +372,12 @@ func SendSealFinishedWxTemplateMsg(mobile string, companyName string, sealId int
|
|
|
}
|
|
|
utils.FileLog.Info("mobile:%s", mobile)
|
|
|
openIdStr := WxAdminOpenIdGet()
|
|
|
- adminOpenIdList, err := admin.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
+ openIdList, err := admin.GetOpenIdListByMobile(mobile, openIdStr)
|
|
|
if err != nil {
|
|
|
msg = "get openIdList err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- openIdList := make([]*wx_user.OpenIdList, 0)
|
|
|
- for _, v := range adminOpenIdList {
|
|
|
- tmp := new(wx_user.OpenIdList)
|
|
|
- tmp.OpenId = v.OpenId
|
|
|
- openIdList = append(openIdList, tmp)
|
|
|
- }
|
|
|
+
|
|
|
utils.FileLog.Info("openIdListCount:%s", len(openIdList))
|
|
|
|
|
|
if len(openIdList) > 0 && utils.WxMsgTemplateIdWithSealApplyFinished != "" {
|
|
@@ -440,7 +411,7 @@ func SendSealFinishedWxTemplateMsg(mobile string, companyName string, sealId int
|
|
|
}
|
|
|
|
|
|
// SendYbQuestionDistributeWxMsg 推送研报小程序模板消息-问答社区分配
|
|
|
-func SendYbQuestionDistributeWxMsg(questionId, userId int, openid, questionTitle string) (err error) {
|
|
|
+func SendYbQuestionDistributeWxMsg(questionId, adminId int, openid, questionTitle string) (err error) {
|
|
|
var errMsg string
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
@@ -459,10 +430,10 @@ func SendYbQuestionDistributeWxMsg(questionId, userId int, openid, questionTitle
|
|
|
errMsg = "accessToken is empty"
|
|
|
return
|
|
|
}
|
|
|
- openIdList := make([]*wx_user.OpenIdList, 0)
|
|
|
- openIdList = append(openIdList, &wx_user.OpenIdList{
|
|
|
+ openIdList := make([]*admin.OpenIdList, 0)
|
|
|
+ openIdList = append(openIdList, &admin.OpenIdList{
|
|
|
OpenId: openid,
|
|
|
- UserId: userId,
|
|
|
+ AdminId: adminId,
|
|
|
})
|
|
|
|
|
|
sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
|