|
@@ -1198,6 +1198,86 @@ func DoArticleOnenIdWxTemplateMsg(articleId int) (err error) {
|
|
|
}
|
|
|
chartPermissionId = chartPermissionDetail.ChartPermissionId
|
|
|
}
|
|
|
+
|
|
|
+ //文章关联的产业
|
|
|
+ var industryName string
|
|
|
+ var industrialManagementId string
|
|
|
+ if chartPermissionId == utils.CE_LUE_ID {
|
|
|
+ industryName = reportMapDetail.SubCategoryName
|
|
|
+ } else {
|
|
|
+ detailIndustryNameList, err := models.GetIndustrialManagemenDetailByAaticleID(articleId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ //如果不存在关联的产业则不推送
|
|
|
+ if len(detailIndustryNameList) == 0 {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ for _, v := range detailIndustryNameList {
|
|
|
+ industryName += v.IndustryName + ","
|
|
|
+ industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
|
|
|
+ }
|
|
|
+ industryName = strings.TrimRight(industryName, ",")
|
|
|
+ industrialManagementId = strings.TrimRight(industrialManagementId, ",")
|
|
|
+
|
|
|
+ //处理勾选了全部行业赛道的用户
|
|
|
+ var allIn string
|
|
|
+ allIn = DoXzsChooseSend(reportMapDetail.ChartPermissionName)
|
|
|
+ if allIn != "" {
|
|
|
+ allInList, err := models.GetCygxXzsChooseSendByAllIn(allIn)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if len(allInList) > 0 {
|
|
|
+ var allInUserId string
|
|
|
+ for _, v := range allInList {
|
|
|
+ allInUserId += strconv.Itoa(v.UserId) + ","
|
|
|
+ }
|
|
|
+ allInUserId = strings.TrimRight(allInUserId, ",")
|
|
|
+
|
|
|
+ userFllowIndustrialList, err := models.GetUserFllowIndustrialListByUserIdAndIndustrial(allInUserId, industrialManagementId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ mapUserFllowed := make(map[string]int)
|
|
|
+ for _, v := range userFllowIndustrialList {
|
|
|
+ //用户ID与其关注的产业组成唯一索引,判断是否存在,如果不存在就进行自动关注
|
|
|
+ mapUserFllowed[fmt.Sprint("uid:", v.UserId, "_Industrial:", v.IndustrialManagementId)] = v.UserId
|
|
|
+ }
|
|
|
+ //获取这些allIN用户的的信息进行遍历生成需要插入的数据
|
|
|
+ userList, err := models.GetWxUserListByUserIds(allInUserId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ var industryFllowItems []*models.CygxIndustryFllow
|
|
|
+ for _, v := range detailIndustryNameList {
|
|
|
+ for _, vUser := range userList {
|
|
|
+ //如果用户这个用户没有关注这个产业就进行自动关注
|
|
|
+ if mapUserFllowed[fmt.Sprint("uid:", vUser.UserId, "_Industrial:", v.IndustrialManagementId)] == 0 {
|
|
|
+ item := new(models.CygxIndustryFllow)
|
|
|
+ item.IndustrialManagementId = v.IndustrialManagementId
|
|
|
+ item.UserId = vUser.UserId
|
|
|
+ item.Email = vUser.Email
|
|
|
+ item.Mobile = vUser.Mobile
|
|
|
+ item.RealName = vUser.RealName
|
|
|
+ item.CompanyId = vUser.CompanyId
|
|
|
+ item.CompanyName = vUser.CompanyName
|
|
|
+ item.Source = 3
|
|
|
+ item.Type = 1
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.ModifyTime = time.Now()
|
|
|
+ industryFllowItems = append(industryFllowItems, item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ err = models.AddCygxIndustryFllowMulti(industryFllowItems)
|
|
|
+ if err != nil {
|
|
|
+ go utils.SendAlarmMsg("用户关注全部赛道,出现新赛道批量添加失败 ,AddCygxIndustryFllowMulti ErrMsg:"+err.Error(), 2)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 获取所有有权的用户的 openid
|
|
|
mapOpenidPower := make(map[int]string)
|
|
|
permissionIdList := make([]string, 0)
|
|
@@ -1261,20 +1341,7 @@ func DoArticleOnenIdWxTemplateMsg(articleId int) (err error) {
|
|
|
}
|
|
|
//已经推送了的openid
|
|
|
mapOpenidPushed := make(map[int]string)
|
|
|
- //文章关联的产业
|
|
|
- var industryName string
|
|
|
- if chartPermissionId != utils.CE_LUE_ID {
|
|
|
- detailIndustryNameList, err := models.GetIndustrialManagemenDetailByAaticleID(articleId)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- return err
|
|
|
- }
|
|
|
- for _, v := range detailIndustryNameList {
|
|
|
- industryName += v.IndustryName + ","
|
|
|
- }
|
|
|
- industryName = strings.TrimRight(industryName, ",")
|
|
|
- } else {
|
|
|
- industryName = reportMapDetail.SubCategoryName
|
|
|
- }
|
|
|
+
|
|
|
keyword2 := articleInfo.Title
|
|
|
keyword3 := time.Now().Format(utils.FormatDateTime)
|
|
|
keyword4 := articleInfo.Abstract
|