|
@@ -9,7 +9,9 @@ import (
|
|
|
"hongze/hz_crm_api/services"
|
|
|
"hongze/hz_crm_api/services/alarm_msg"
|
|
|
"hongze/hz_crm_api/utils"
|
|
|
+ "html"
|
|
|
"strconv"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -101,6 +103,16 @@ func SendWxMsgWithCygxActivityUpdateLimitPeople(activityId int) (err error) {
|
|
|
openiditems = append(openiditems, openiditem)
|
|
|
}
|
|
|
|
|
|
+ if activityInfo.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN {
|
|
|
+
|
|
|
+ jmcjOpenId := GetUserOpenidByComapnyIdRai(utils.JMCJ_COMPANY_ID)
|
|
|
+ for _, v := range jmcjOpenId {
|
|
|
+ if !utils.InArrayByStr(openIdArr, v) {
|
|
|
+ openIdArr = append(openIdArr, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
first := "您好,本场活动已增加活动名额至" + activityInfo.LimitPeopleNum + "人,欢迎报名"
|
|
|
keyword1 := activityInfo.ActivityName
|
|
|
keyword2 := "已增加活动名额至" + activityInfo.LimitPeopleNum + "人,欢迎报名"
|
|
@@ -336,3 +348,244 @@ func SendWxMsgWithUpdateActivityVideoAndVoice(activityId int, fileName string) (
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+func SendWxMsgWithCygxActivityUpdateTime(activityId int, oldStr, newStr, strType string) (err error) {
|
|
|
+ var msg string
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ go alarm_msg.SendAlarmMsg("发送模版消息失败,Err:"+err.Error()+";msg:"+msg, 3)
|
|
|
+ utils.FileLogCygx.Info(fmt.Sprintf("发送模版消息失败,Err:%s,%s", err.Error(), msg))
|
|
|
+ }
|
|
|
+ if msg != "" {
|
|
|
+ utils.FileLogCygx.Info("发送模版消息失败,msg:%s", msg)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ activityInfo, err := cygx.GetAddActivityInfoById(activityId)
|
|
|
+ if err != nil {
|
|
|
+ msg = "GetReportInfo Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if activityInfo == nil {
|
|
|
+ utils.FileLogCygx.Info("活动信息不存在")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var openIdList []*cygx.OpenIdList
|
|
|
+
|
|
|
+ openIdList, err = cygx.GetActivityOpenIdList(activityId)
|
|
|
+ if err != nil {
|
|
|
+ msg = "get openIdList err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ mapOpenid := make(map[int]string)
|
|
|
+ for _, v := range openIdList {
|
|
|
+ mapOpenid[v.UserId] = v.OpenId
|
|
|
+ }
|
|
|
+
|
|
|
+ openIdListAppointment, err := cygx.GetActivityAppointmentOpenIdList(activityId)
|
|
|
+ if err != nil {
|
|
|
+ msg = "GetActivityAppointmentOpenIdList err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(openIdListAppointment) > 0 {
|
|
|
+ for _, v := range openIdListAppointment {
|
|
|
+ if _, ok := mapOpenid[v.UserId]; !ok {
|
|
|
+ item := new(cygx.OpenIdList)
|
|
|
+ item.UserId = v.UserId
|
|
|
+ item.OpenId = v.OpenId
|
|
|
+ openIdList = append(openIdList, item)
|
|
|
+ }
|
|
|
+ mapOpenid[v.UserId] = v.OpenId
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ openIdListActivityHelpAsk, err := cygx.GetActivityHelpAskOpenIdList(activityId)
|
|
|
+ if err != nil {
|
|
|
+ msg = "openIdListActivityHelpAsk err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(openIdListActivityHelpAsk) > 0 {
|
|
|
+ for _, v := range openIdListActivityHelpAsk {
|
|
|
+ if _, ok := mapOpenid[v.UserId]; !ok {
|
|
|
+ item := new(cygx.OpenIdList)
|
|
|
+ item.UserId = v.UserId
|
|
|
+ item.OpenId = v.OpenId
|
|
|
+ openIdList = append(openIdList, item)
|
|
|
+ }
|
|
|
+ mapOpenid[v.UserId] = v.OpenId
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(openIdList) == 0 {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var first string
|
|
|
+ var keyword1, keyword2, keyword3, keyword4, redirectUrl string
|
|
|
+
|
|
|
+ activityInfo.ActivityTypeName = strings.Replace(activityInfo.ActivityTypeName, "(C类)", "", -1)
|
|
|
+ if strType == "timeType" {
|
|
|
+
|
|
|
+ keyword2 = "时间变更为:【 " + newStr + "】"
|
|
|
+ } else if strType == "expertType" {
|
|
|
+
|
|
|
+ keyword2 = "专家变更为:【" + newStr + "】"
|
|
|
+ } else if strType == "addressType" {
|
|
|
+
|
|
|
+ keyword2 = "地点变更为:【" + newStr + "】"
|
|
|
+ } else if strType == "participationCode" {
|
|
|
+
|
|
|
+ keyword2 = "拨入密码为: " + newStr
|
|
|
+ } else if strType == "Theme" {
|
|
|
+
|
|
|
+ newStr = strings.Replace(newStr, "</p><p>", "\n", -1)
|
|
|
+ newStr = html.EscapeString(newStr)
|
|
|
+ newStrHtml, _ := cygx.GetReportContentTextSub(newStr)
|
|
|
+ newStr = newStrHtml
|
|
|
+ keyword2 = "主题变更为: " + newStr
|
|
|
+ }
|
|
|
+
|
|
|
+ keyword1 = activityInfo.ActivityName
|
|
|
+ var openIdArr []string
|
|
|
+ for _, v := range openIdList {
|
|
|
+ openIdArr = append(openIdArr, v.OpenId)
|
|
|
+ }
|
|
|
+ if activityInfo.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN {
|
|
|
+
|
|
|
+ jmcjOpenId := GetUserOpenidByComapnyIdRai(utils.JMCJ_COMPANY_ID)
|
|
|
+ for _, v := range jmcjOpenId {
|
|
|
+ if !utils.InArrayByStr(openIdArr, v) {
|
|
|
+ openIdArr = append(openIdArr, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ redirectUrl = utils.WX_MSG_PATH_ACTIVITY_DETAIL + strconv.Itoa(activityId) + "&IsSendWx=1"
|
|
|
+ sendInfo := new(services.SendWxTemplate)
|
|
|
+ sendInfo.First = first
|
|
|
+ sendInfo.Keyword1 = keyword1
|
|
|
+ sendInfo.Keyword2 = keyword2
|
|
|
+ sendInfo.Keyword3 = keyword3
|
|
|
+ sendInfo.Keyword4 = keyword4
|
|
|
+
|
|
|
+ sendInfo.TemplateId = utils.WxMsgTemplateIdActivityChangeApplyXzs
|
|
|
+ sendInfo.RedirectUrl = redirectUrl
|
|
|
+ sendInfo.RedirectTarget = 3
|
|
|
+ sendInfo.Resource = strconv.Itoa(activityId)
|
|
|
+ sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ACTIVITY_UPDATE
|
|
|
+ sendInfo.OpenIdArr = openIdArr
|
|
|
+ e := services.SendTemplateMsg(sendInfo)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("推送模板消息失败" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func SendWxMsgWithCygxActivity(activityId int) (err error) {
|
|
|
+ var msg string
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ go alarm_msg.SendAlarmMsg("发送模版消息失败,Err:"+err.Error()+";msg:"+msg, 3)
|
|
|
+ utils.FileLogCygx.Info(fmt.Sprintf("发送模版消息失败,Err:%s,%s", err.Error(), msg))
|
|
|
+ }
|
|
|
+ if msg != "" {
|
|
|
+ utils.FileLogCygx.Info("发送模版消息失败,msg:%s", msg)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ activityInfo, err := cygx.GetAddActivityInfoById(activityId)
|
|
|
+ if err != nil {
|
|
|
+ msg = "GetReportInfo Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var openIdList []*cygx.OpenIdList
|
|
|
+ openIdList, err = cygx.GetActivityOpenIdList(activityId)
|
|
|
+ if err != nil {
|
|
|
+ msg = "get GetActivityOpenIdList err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mapOpenid := make(map[int]string)
|
|
|
+ for _, v := range openIdList {
|
|
|
+ mapOpenid[v.UserId] = v.OpenId
|
|
|
+ }
|
|
|
+
|
|
|
+ openIdListAppointment, err := cygx.GetActivityAppointmentOpenIdList(activityId)
|
|
|
+ if err != nil {
|
|
|
+ msg = "GetActivityAppointmentOpenIdList err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(openIdListAppointment) > 0 {
|
|
|
+ for _, v := range openIdListAppointment {
|
|
|
+ if _, ok := mapOpenid[v.UserId]; !ok {
|
|
|
+ item := new(cygx.OpenIdList)
|
|
|
+ item.UserId = v.UserId
|
|
|
+ item.OpenId = v.OpenId
|
|
|
+ openIdList = append(openIdList, item)
|
|
|
+ }
|
|
|
+ mapOpenid[v.UserId] = v.OpenId
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ openIdListActivityHelpAsk, err := cygx.GetActivityHelpAskOpenIdList(activityId)
|
|
|
+ if err != nil {
|
|
|
+ msg = "openIdListActivityHelpAsk err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(openIdListActivityHelpAsk) > 0 {
|
|
|
+ for _, v := range openIdListActivityHelpAsk {
|
|
|
+ if _, ok := mapOpenid[v.UserId]; !ok {
|
|
|
+ item := new(cygx.OpenIdList)
|
|
|
+ item.UserId = v.UserId
|
|
|
+ item.OpenId = v.OpenId
|
|
|
+ openIdList = append(openIdList, item)
|
|
|
+ }
|
|
|
+ mapOpenid[v.UserId] = v.OpenId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ activityInfo.ActivityTypeName = strings.Replace(activityInfo.ActivityTypeName, "(C类)", "", -1)
|
|
|
+ if len(openIdList) == 0 {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ var keyword1, keyword2, keyword3, keyword4, redirectUrl string
|
|
|
+ keyword1 = activityInfo.ActivityName
|
|
|
+ keyword2 = "活动已取消"
|
|
|
+
|
|
|
+ var openIdArr []string
|
|
|
+ for _, v := range openIdList {
|
|
|
+ openIdArr = append(openIdArr, v.OpenId)
|
|
|
+ }
|
|
|
+ if activityInfo.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN {
|
|
|
+
|
|
|
+ jmcjOpenId := GetUserOpenidByComapnyIdRai(utils.JMCJ_COMPANY_ID)
|
|
|
+ for _, v := range jmcjOpenId {
|
|
|
+ if !utils.InArrayByStr(openIdArr, v) {
|
|
|
+ openIdArr = append(openIdArr, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ redirectUrl = utils.WX_MSG_PATH_ACTIVITY_DETAIL + strconv.Itoa(activityId) + "&IsSendWx=1"
|
|
|
+ sendInfo := new(services.SendWxTemplate)
|
|
|
+
|
|
|
+ sendInfo.Keyword1 = keyword1
|
|
|
+ sendInfo.Keyword2 = keyword2
|
|
|
+ sendInfo.Keyword3 = keyword3
|
|
|
+ sendInfo.Keyword4 = keyword4
|
|
|
+
|
|
|
+ sendInfo.TemplateId = utils.WxMsgTemplateIdActivityChangeApplyXzs
|
|
|
+ sendInfo.RedirectUrl = redirectUrl
|
|
|
+ sendInfo.RedirectTarget = 3
|
|
|
+ sendInfo.Resource = strconv.Itoa(activityId)
|
|
|
+ sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ACTIVITY_CACLE
|
|
|
+ sendInfo.OpenIdArr = openIdArr
|
|
|
+ err = services.SendTemplateMsg(sendInfo)
|
|
|
+ return
|
|
|
+}
|