12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- package services
- import (
- "errors"
- "fmt"
- "hongze/hongze_clpt/models"
- "hongze/hongze_clpt/utils"
- "strconv"
- "time"
- )
- // SendResearchActivitiesTemplateMsg 线下调研活动报名给所属销售跟建会人员推送
- func SendResearchActivitiesTemplateMsg(user *models.WxUserItem, activityDetail *models.ActivityDetail, doStatus string) (err error) {
- //如果不是公司线下调研就返回
- if activityDetail.ActivityTypeId != 4 {
- return
- }
- defer func() {
- if err != nil {
- go utils.SendEmail("线下调研活动报名给所属销售跟建会人员推送失败Err"+time.Now().Format("2006-01-02 15:04:05"), ";Err:"+err.Error(), utils.EmailSendToUsers)
- go utils.SendAlarmMsg(fmt.Sprint("线下调研活动报名给所属销售跟建会人员推送失败Err:", err.Error(), "活动ID:", activityDetail.ActivityId, "手机号:", user.Mobile), 2)
- }
- }()
- var mobiles []string
- //获取销售信息
- sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
- if err != nil && err.Error() != utils.ErrNoRow() {
- return
- }
- if sellerItem != nil {
- mobiles = append(mobiles, sellerItem.Mobile)
- }
- //获取建会人员信息
- admin, err := models.GetSysAdminById(activityDetail.AdminId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- return
- }
- if admin != nil {
- mobiles = append(mobiles, admin.Mobile)
- }
- var first string
- var keyword1 string
- var keyword2 string
- var keyword3 string
- var keyword4 string
- var remark string
- var redirectUrl string
- //first = "【" + activityDetail.ActivityName + "】有客户报名"
- keyword1 = user.RealName + "——" + user.CompanyName + "(" + sellerItem.RealName + ")"
- keyword2 = user.Mobile
- keyword3 = time.Now().Format(utils.FormatDateTime)
- keyword4 = doStatus + ":" + activityDetail.ActivityName
- //remark = "点击查看报告详情"
- openIdList, e := models.GetWxOpenIdByMobileSliceList(mobiles)
- if e != nil {
- err = errors.New("GetWxOpenIdByMobileList, Err: " + e.Error())
- return
- }
- openIdArr := make([]string, 0)
- for _, v := range openIdList {
- openIdArr = append(openIdArr, v.OpenId)
- }
- redirectUrl = utils.WX_MSG_PATH_ACTIVITY_DETAIL + strconv.Itoa(activityDetail.ActivityId)
- sendInfo := new(SendWxTemplate)
- sendInfo.First = first
- sendInfo.Keyword1 = keyword1
- sendInfo.Keyword2 = keyword2
- sendInfo.Keyword3 = keyword3
- sendInfo.Keyword4 = keyword4
- sendInfo.Remark = remark
- sendInfo.TemplateId = utils.WxMsgTemplateIdApplyXzs
- sendInfo.RedirectUrl = redirectUrl
- sendInfo.RedirectTarget = 3
- sendInfo.Resource = strconv.Itoa(activityDetail.ArticleId)
- sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_COMMENT
- sendInfo.OpenIdArr = openIdArr
- err = PublicSendTemplateMsg(sendInfo)
- if err != nil {
- return
- }
- return
- }
|