Browse Source

修改模版消息的openid

xiexiaoyuan 2 years ago
parent
commit
d1e4d31e06
2 changed files with 5 additions and 76 deletions
  1. 5 60
      services/wechat_send_msg.go
  2. 0 16
      services/yb/community_question.go

+ 5 - 60
services/wechat_send_msg.go

@@ -59,16 +59,6 @@ func SendCompanyApplyWxTemplateMsg(mobile, redirectUrl, wxAppPath string, wxMsgM
 		}
 	}()
 	utils.FileLog.Info("%s", "services SendMsg")
-
-	accessToken, err := WxGetRedisAccessToken(utils.AdminWxAppId, utils.AdminWxAppSecret)
-	if err != nil {
-		msg = "GetWxAccessToken Err:" + err.Error()
-		return
-	}
-	if accessToken == "" {
-		msg = "accessToken is empty"
-		return
-	}
 	utils.FileLog.Info("mobile:%s", mobile)
 
 	//获取openid列表
@@ -164,16 +154,6 @@ func SendWxMsgWithRoadshowDetailResult(first, keyword1, keyword2, remark, mobile
 		}
 	}()
 	utils.FileLog.Info("%s", "services SendMsg")
-
-	accessToken, err := WxGetRedisAccessToken(utils.AdminWxAppId, utils.AdminWxAppSecret)
-	if err != nil {
-		msg = "GetWxAccessToken Err:" + err.Error()
-		return
-	}
-	if accessToken == "" {
-		msg = "accessToken is empty"
-		return
-	}
 	utils.FileLog.Info("mobile:%s", mobile)
 
 	//获取openid列表
@@ -248,16 +228,6 @@ func SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4,
 	}()
 	utils.FileLog.Info("%s", "services SendMsg")
 
-	accessToken, err := WxGetRedisAccessToken(utils.AdminWxAppId, utils.AdminWxAppSecret)
-	if err != nil {
-		msg = "GetWxAccessToken Err:" + err.Error()
-		return
-	}
-	if accessToken == "" {
-		msg = "accessToken is empty"
-		return
-	}
-
 	//获取openid列表
 	openIdStr := WxAdminOpenIdGet()
 	openIdList, err := admin.GetOpenIdListByMobile(mobile, openIdStr)
@@ -332,17 +302,6 @@ func SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppP
 		}
 	}()
 	utils.FileLog.Info("%s", "services SendMsg")
-
-	accessToken, err := WxGetRedisAccessToken(utils.AdminWxAppId, utils.AdminWxAppSecret)
-	if err != nil {
-		msg = "GetWxAccessToken Err:" + err.Error()
-		return
-	}
-	if accessToken == "" {
-		msg = "accessToken is empty"
-		return
-	}
-
 	//获取openid列表
 	openIdStr := WxAdminOpenIdGet()
 	openIdList, err := admin.GetOpenIdListByMobile(mobile, openIdStr)
@@ -410,15 +369,6 @@ func SendSealFinishedWxTemplateMsg(mobile string, companyName string, sealId int
 		}
 	}()
 	utils.FileLog.Info("%s", "services SendMsg")
-	accessToken, err := WxGetRedisAccessToken(utils.AdminWxAppId, utils.AdminWxAppSecret)
-	if err != nil {
-		msg = "GetWxAccessToken Err:" + err.Error()
-		return
-	}
-	if accessToken == "" {
-		msg = "accessToken is empty"
-		return
-	}
 	utils.FileLog.Info("mobile:%s", mobile)
 	openIdStr := WxAdminOpenIdGet()
 	openIdList, err := admin.GetOpenIdListByMobile(mobile, openIdStr)
@@ -461,6 +411,7 @@ func SendSealFinishedWxTemplateMsg(mobile string, companyName string, sealId int
 		}
 
 		sendInfo := new(SendWxTemplate)
+		sendInfo.WxAppId = utils.AdminWxAppId
 		sendInfo.First = first
 		sendInfo.Keyword1 = keyword1
 		sendInfo.Keyword2 = keyword2
@@ -488,16 +439,6 @@ func SendYbQuestionDistributeWxMsg(questionId, adminId int, openid, questionTitl
 			go alarm_msg.SendAlarmMsg(alarmMsg, 3)
 		}
 	}()
-	// todo 修改openID
-	accessToken, err := WxGetRedisAccessToken(utils.AdminWxAppId, utils.AdminWxAppSecret)
-	if err != nil {
-		errMsg = "GetWxAccessToken Err:" + err.Error()
-		return
-	}
-	if accessToken == "" {
-		errMsg = "accessToken is empty"
-		return
-	}
 	openIdList := make([]*admin.OpenIdList, 0)
 	openIdList = append(openIdList, &admin.OpenIdList{
 		OpenId: openid,
@@ -533,6 +474,7 @@ func SendYbQuestionDistributeWxMsg(questionId, adminId int, openid, questionTitl
 	}
 
 	sendInfo := new(SendWxTemplate)
+	sendInfo.WxAppId = utils.AdminWxAppId
 	sendInfo.First = first
 	sendInfo.Keyword1 = keyword1
 	sendInfo.Keyword2 = keyword2
@@ -543,6 +485,9 @@ func SendYbQuestionDistributeWxMsg(questionId, adminId int, openid, questionTitl
 	sendInfo.Resource = wxAppPath
 	sendInfo.SendType = utils.TEMPLATE_MSG_YB_COMMUNITY_QUESTION
 	sendInfo.OpenIdArr = openIdArr
+	err = SendTemplateMsg(sendInfo)
+
+	utils.FileLog.Info("send end")
 	return
 }
 

+ 0 - 16
services/yb/community_question.go

@@ -9,7 +9,6 @@ import (
 	"hongze/hongze_mobile_admin/models/tables/company_approval_message"
 	"hongze/hongze_mobile_admin/models/tables/sys_role"
 	"hongze/hongze_mobile_admin/models/tables/sys_role_admin"
-	"hongze/hongze_mobile_admin/models/tables/user_record"
 	"hongze/hongze_mobile_admin/models/tables/variety_classify"
 	"hongze/hongze_mobile_admin/models/tables/variety_tag"
 	"hongze/hongze_mobile_admin/models/tables/wx_user"
@@ -199,22 +198,7 @@ func DistributeQuestion(questionId, adminId, researchGroupFirstId, researchGroup
 	}
 	// 回复人openid, 此处可能会出现取不到openid的情况, 可直接忽略掉
 	replierUserId := int(userInfo.UserId)
-	userRecord, e := user_record.GetUserRecordByUserId(replierUserId, utils.USER_RECORD_PLATFORM_RDDP)
-	if e != nil && e.Error() != utils.ErrNoRow() {
-		errMsg = "分配失败, 研究员相关的联系人记录有误"
-		err = errors.New("获取手机号所属联系人失败, Err:" + e.Error())
-		return
-	}
 	replierOpenid := ""
-	if userRecord != nil {
-		if userRecord.Subscribe == 0 {
-			errMsg = "该研究员已取消关注公众号,无法收到消息通知"
-		} else {
-			replierOpenid = userRecord.OpenId
-		}
-	} else {
-		errMsg = "该研究员未关注公众号,无法收到消息通知"
-	}
 	// 分组、品种权限信息
 	//firstGroup, e := admin.GetResearchGroupById(researchGroupFirstId)
 	firstGroup, e := variety_classify.GetVarietyClassifyById(researchGroupFirstId)