瀏覽代碼

no message

zhangchuanxing 7 月之前
父節點
當前提交
eff7123afc

+ 1 - 0
models/article.go

@@ -187,6 +187,7 @@ type ArticleDetail struct {
 	IsRoadShow               bool   `description:"是否是路演精华"`
 	ReportType               int    `description:"报告类型,1行业报告,2产业报告,0无"`
 	FieldName                string `description:"策略平台的领域字段名称"`
+	SeriesName               string `description:"策略平台系列名称"`
 	TypeName                 string `description:"策略平台类型字段名称"`
 	IsApplyAppointmentExpert bool   `description:"是否属于专家访谈"`
 	ArticleTypeName          string `description:"权限名称"`

+ 8 - 1
models/industry_fllow.go

@@ -97,6 +97,13 @@ func GetCountCygxIndustryFllow(userId, industrialManagementId int, condition str
 	return
 }
 
+// 获取关注数量
+func GetCountCygxIndustryFllowByType(userId, industrialManagementId int) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_industry_fllow WHERE user_id=? AND industrial_management_id=?  AND  follow_type = 1  `
+	err = orm.NewOrm().Raw(sql, userId, industrialManagementId).QueryRow(&count)
+	return
+}
+
 // 获取数量
 func GetCountCygxIndustryFllowByUid(userId int) (count int, err error) {
 	sql := `SELECT COUNT(1) AS count FROM cygx_industry_fllow WHERE user_id=? `
@@ -227,7 +234,7 @@ func GetTopIndustryFollowData(startSize, pageSize int, condition string, pars []
 }
 
 // 列表
-func GetCygxIndustryFllowListByCon(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxIndustryFllow, err error) {
+func GetCygxIndustryFllowListByCon(condition string, pars []interface{}) (items []*CygxIndustryFllow, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_industry_fllow as art WHERE 1= 1 `
 	if condition != "" {

+ 1 - 0
models/wx_user_code.go

@@ -63,6 +63,7 @@ func GetCygxUserFllowOpenid(articleId int) (items []*OpenIdList, err error) {
 		WHERE
 			1 = 1 
 			AND mg.article_id = ? 
+			AND f.follow_type = 1
 			GROUP BY f.user_id `
 	_, err = o.Raw(sql, articleId).QueryRows(&items)
 	return

+ 15 - 0
models/xzs_choose_category.go

@@ -95,3 +95,18 @@ func UpdateCygxXzsChooseCategory(idCygx, id int) (err error) {
 	_, err = o.Raw(sql, idCygx, id).Exec()
 	return
 }
+
+// 列表
+func GetCygxXzsChooseCategoryListFollowType(categoryId, followType int) (items []*CygxXzsChooseCategory, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_xzs_choose_category as art WHERE category_id  = ? AND  follow_type = ?  `
+	_, err = o.Raw(sql, categoryId, followType).QueryRows(&items)
+	return
+}
+
+// 获取重点关注数量
+func GetCountCygxXzsChooseCategoryFllowByType(userId, categoryId int) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_xzs_choose_category WHERE user_id=? AND category_id=?  AND  follow_type = 1  `
+	err = orm.NewOrm().Raw(sql, userId, categoryId).QueryRow(&count)
+	return
+}

+ 16 - 0
models/xzs_choose_category_zhouqi.go

@@ -26,3 +26,19 @@ func GetCygxXzsChooseCategoryZhouqiList(mobile string) (items []*CygxXzsChooseCa
 	_, err = o.Raw(sql, mobile).QueryRows(&items)
 	return
 }
+
+// 列表
+func GetCygxXzsChooseCategoryZhouqiListFollowType(categoryName, seriesName string, followType int) (items []*CygxXzsChooseCategoryZhouqi, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	f.* 
+FROM
+	cygx_zhouqi_article_map AS m
+	INNER JOIN cygx_xzs_choose_category_zhouqi AS f ON f.category_id = m.category_id 
+WHERE
+	1 = 1 
+	AND ( m.match_type_name = ? OR m.series_name = ? ) 
+	AND follow_type = ?  `
+	_, err = o.Raw(sql, categoryName, seriesName, followType).QueryRows(&items)
+	return
+}

+ 413 - 306
services/article.go

@@ -938,29 +938,27 @@ func HandleArticleListByApi(artcleId int) (err error) {
 //}
 
 // 过滤策略平台报告,研选报告重复推送,以及权限勾选的推送
-func DoArticleOnenIdWxTemplateMsg(articleId int) (err error) {
+func DoArticleOnenIdWxTemplateMsg(articleId int) {
 
+	var err error
 	//策略平台同步过来的文章ID,做微信模板消息推送,同一篇报告12小时只推送一次
 	cacheKey := fmt.Sprint(utils.CACHE_KEY_ARTICLE_ID_TEMPLATE, ":ArticleId", articleId)
 	ttlTime := utils.Rc.GetRedisTTL(cacheKey)
 	if ttlTime > 0 {
 		fmt.Println(ttlTime)
-		return err
+		return
 	}
-	var msg string
 	defer func() {
 		if err != nil {
 			go utils.SendAlarmMsg("过滤策略平台报告,研选报告重复推送,以及权限勾选的推送失败 DoArticleOnenIdWxTemplateMsg  ErrMsg:"+err.Error(), 2)
 			fmt.Println(err)
 		}
-		if msg != "" {
-			utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
-		}
 	}()
 
 	//获取文章详情
-	articleInfo, err := models.GetArticleDetailById(articleId)
-	if err != nil {
+	articleInfo, e := models.GetArticleDetailById(articleId)
+	if e != nil {
+		err = errors.New("GetArticleDetailById, Err: " + e.Error())
 		return
 	}
 	articleInfo.Abstract, _ = GetReportContentTextSub(articleInfo.Abstract)
@@ -968,10 +966,13 @@ func DoArticleOnenIdWxTemplateMsg(articleId int) (err error) {
 
 	//固收的权限,暂时当策略的逻辑一样处理
 	var chartPermissionName string
-	reportMapDetail, err := models.GetdetailByCategoryIdPush(articleInfo.CategoryId)
-	if err != nil {
-		return err
+	var permissionName string
+	reportMapDetail, e := models.GetdetailByCategoryIdPush(articleInfo.CategoryId)
+	if e != nil {
+		err = errors.New("GetdetailByCategoryIdPush, Err: " + e.Error())
+		return
 	}
+	permissionName = reportMapDetail.ChartPermissionName
 	if reportMapDetail.ChartPermissionId == utils.CE_LUE_ID {
 		chartPermissionId = utils.CE_LUE_ID
 	} else if reportMapDetail.ChartPermissionId == utils.GU_SHOU_ID_CHART {
@@ -982,9 +983,10 @@ func DoArticleOnenIdWxTemplateMsg(articleId int) (err error) {
 		} else {
 			chartPermissionName = reportMapDetail.ChartPermissionName + "(客观)"
 		}
-		chartPermissionDetail, err := models.GetChartPermissionByRemark(chartPermissionName)
-		if err != nil {
-			return err
+		chartPermissionDetail, e := models.GetChartPermissionByRemark(chartPermissionName)
+		if e != nil {
+			err = errors.New("GetdetailByCategoryIdPush, Err: " + e.Error())
+			return
 		}
 		chartPermissionId = chartPermissionDetail.ChartPermissionId
 	}
@@ -994,84 +996,10 @@ func DoArticleOnenIdWxTemplateMsg(articleId int) (err error) {
 	var industrialManagementId string
 	if chartPermissionId == utils.CE_LUE_ID || chartPermissionId == utils.GU_SHOU_ID_CHART {
 		industryName = reportMapDetail.SubCategoryName
-	} else {
-		if articleInfo.ReportType == 2 {
-			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)
+	//mapOpenidPower := make(map[int]string)
 	permissionIdList := make([]string, 0)
 	var condition string
 	var pars []interface{}
@@ -1086,9 +1014,21 @@ func DoArticleOnenIdWxTemplateMsg(articleId int) (err error) {
 		condition += ` AND p.chart_permission_id  IN (` + utils.GetOrmInReplace(len(slicepermissionId)) + ` )  `
 		pars = append(pars, permissionIdList)
 	}
-	openidPowerListMobile, err := models.GetCygxUserRecordPower(condition, pars)
-	if err != nil {
-		return err
+	openidPowerListMobile, e := models.GetCygxUserRecordPower(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxUserRecordPower, Err: " + e.Error())
+		return
+	}
+
+	//获取拒绝接收推送的的用户的 openid
+	mapOpenidRefuset := make(map[int]string)
+	openidRefusetList, e := models.GetCygxUserRefusetOpenid()
+	if e != nil {
+		err = errors.New("GetCygxUserRefusetOpenid, Err: " + e.Error())
+		return
+	}
+	for _, v := range openidRefusetList {
+		mapOpenidRefuset[v.UserId] = v.OpenId
 	}
 
 	var mobileArr []string
@@ -1096,248 +1036,415 @@ func DoArticleOnenIdWxTemplateMsg(articleId int) (err error) {
 		mobileArr = append(mobileArr, v.Mobile)
 	}
 	openidPowerList, err := models.GetWxOpenIdByMobileSliceList(mobileArr)
-	if err != nil {
-		return err
+	if e != nil {
+		err = errors.New("GetWxOpenIdByMobileSliceList, Err: " + e.Error())
+		return
 	}
 
 	//四大行业的行业综述报告,对所有开通了对应行业权限的客户都推送。
-	if articleInfo.ReportType == 1 && chartPermissionId != utils.CE_LUE_ID && chartPermissionId != utils.GU_SHOU_ID_CHART {
+	if articleInfo.ReportType == 1 && permissionName != utils.CE_LUE_NAME && permissionName != utils.GU_SHOU_NAME && permissionName != utils.ZHOU_QI_NAME {
+		keyword1 := "【" + articleInfo.SubCategoryName + "】有报告发布/更新"
+		//openIditem := new(models.OpenIdList)
+		var openIdArr []string
 		for _, item := range openidPowerList {
-			first := "您关注的赛道,有新的报告发布/更新,欢迎查看"
-			keyword1 := "【" + articleInfo.SubCategoryName + "】有报告发布/更新"
-			openIditem := new(models.OpenIdList)
-			openIditem.OpenId = item.OpenId
-			openIditem.UserId = item.UserId
-			SendWxMsgWithArticleUpdate(first, keyword1, articleInfo.Title, articleInfo.PublishDate, articleInfo.Abstract, openIditem, articleId)
+			if mapOpenidRefuset[item.UserId] != "" {
+				continue // 拒绝消息推送的用户不接收模版消息
+			}
+			openIdArr = append(openIdArr, item.OpenId)
 		}
-		return err
-	}
-	for _, v := range openidPowerList {
-		mapOpenidPower[v.UserId] = v.OpenId
+		go SendWxMsgWithArticleUpdateList(keyword1, articleInfo.Title, articleInfo.PublishDate, articleInfo.Abstract, openIdArr, articleId)
+		return
 	}
-	//获取关注这个文章对应产业的用户的 openid
-	mapOpenidFllow := make(map[int]string)
-	if chartPermissionId != utils.CE_LUE_ID && chartPermissionId != utils.GU_SHOU_ID_CHART {
-		openidFllowListMobile, err := models.GetCygxUserFllowOpenid(articleId)
-		if err != nil {
-			return err
-		}
+	//for _, v := range openidPowerList {
+	//	mapOpenidPower[v.UserId] = v.OpenId
+	//}
 
-		var mobileArrFllow []string
-		for _, v := range openidFllowListMobile {
-			mobileArrFllow = append(mobileArrFllow, v.Mobile)
+	if permissionName == utils.CE_LUE_NAME || permissionName == utils.GU_SHOU_NAME {
+		celueListUninterested, e := models.GetCygxXzsChooseCategoryListFollowType(articleInfo.CategoryId, 3)
+		if e != nil {
+			err = errors.New("GetCygxXzsChooseCategoryListFollowType " + e.Error())
+			return
 		}
-
-		openidFllowList, err := models.GetWxOpenIdByMobileSliceList(mobileArrFllow)
-		if err != nil {
-			return err
+		mapUninterestedClue := make(map[int]string)
+		for _, v := range celueListUninterested {
+			mapUninterestedClue[v.UserId] = "_"
+			mapOpenidRefuset[v.UserId] = "_" //归类成拒绝推送的人
 		}
-
-		for _, v := range openidFllowList {
-			mapOpenidFllow[v.UserId] = v.OpenId
+		keyword1 := "【" + articleInfo.SubCategoryName + "】有报告发布/更新"
+		var openIdArr []string
+		for _, item := range openidPowerList {
+			if mapOpenidRefuset[item.UserId] != "" {
+				continue // 拒绝消息推送的用户不接收模版消息
+			}
+			openIdArr = append(openIdArr, item.OpenId)
 		}
-
-	}
-
-	//获取拒绝接收推送的的用户的 openid
-	mapOpenidRefuset := make(map[int]string)
-	openidRefusetList, err := models.GetCygxUserRefusetOpenid()
-	if err != nil {
-		return err
-	}
-	for _, v := range openidRefusetList {
-		mapOpenidRefuset[v.UserId] = v.OpenId
-	}
-	//获取提交过推送规则的用户的 openid
-	mapUserIdChooseSend := make(map[int]int)
-	mapUserIdChooseSendTypeNoPermission := make(map[int]int)
-	chooseSendtList, err := models.GetCygxXzsChooseSend()
-	for _, v := range chooseSendtList {
-		mapUserIdChooseSend[v.UserId] = v.UserId
-		if v.IsRefuse == 1 {
-			continue
+		go SendWxMsgWithArticleUpdateList(keyword1, articleInfo.Title, articleInfo.PublishDate, articleInfo.Abstract, openIdArr, articleId)
+		return
+	} else if permissionName == utils.ZHOU_QI_NAME {
+		if articleInfo.SeriesName == "" {
+			articleInfo.SeriesName = articleInfo.FieldName
 		}
-		//获取选择主客观赛道的用户
-		if reportMapDetail.PermissionType == 1 {
-			if v.IsSubjective == 1 {
-				mapUserIdChooseSendTypeNoPermission[v.UserId] = v.UserId
-			}
-		} else {
-			if v.IsObjective == 1 {
-				mapUserIdChooseSendTypeNoPermission[v.UserId] = v.UserId
+		zhouqiListUninterested, e := models.GetCygxXzsChooseCategoryZhouqiListFollowType(articleInfo.FieldName, articleInfo.SeriesName, 3)
+		if e != nil {
+			err = errors.New("GetCygxXzsChooseCategoryListFollowType " + e.Error())
+			return
+		}
+		mapUninterestedClue := make(map[int]string)
+		for _, v := range zhouqiListUninterested {
+			mapUninterestedClue[v.UserId] = "_"
+			mapOpenidRefuset[v.UserId] = "_" //归类成拒绝推送的人
+		}
+		keyword1 := "【" + articleInfo.SubCategoryName + "】有报告发布/更新"
+		var openIdArr []string
+		for _, item := range openidPowerList {
+			if mapOpenidRefuset[item.UserId] != "" {
+				continue // 拒绝消息推送的用户不接收模版消息
 			}
+			openIdArr = append(openIdArr, item.OpenId)
 		}
-	}
-	//已经推送了的openid
-	mapOpenidPushed := make(map[int]string)
+		go SendWxMsgWithArticleUpdateList(keyword1, articleInfo.Title, articleInfo.PublishDate, articleInfo.Abstract, openIdArr, articleId)
+		return
+	} else {
 
-	keyword2 := articleInfo.Title
-	keyword3 := time.Now().Format(utils.FormatDateTime)
-	keyword4 := articleInfo.Abstract
-	mapAlreadySend := make(map[int]int)
-	//如果是策略就按照策略的推送方式来写
-	if reportMapDetail.ChartPermissionName == utils.CE_LUE_NAME || reportMapDetail.ChartPermissionName == utils.GU_SHOU_NAME {
-		//获取提交过推送规则的用户的 openid
-		mapUserFllowCeLue := make(map[int]string)
-		userFllowCeLueList, err := models.GetCygxUserFllowCeLueOpenid(articleInfo.CategoryId)
-		if err != nil {
-			return err
-		}
-		for _, v := range userFllowCeLueList {
-			mapUserFllowCeLue[v.UserId] = v.OpenId
+		//if articleInfo.ReportType == 2 {
+		detailIndustryNameList, e := models.GetIndustrialManagemenDetailByAaticleID(articleId)
+		if e != nil {
+			err = errors.New("GetIndustrialManagemenDetailByAaticleID, Err: " + e.Error())
+			return
 		}
-		for k, v := range mapOpenidPower {
-			if mapOpenidPushed[k] != "" {
-				continue
-			}
-			openIditem := new(models.OpenIdList)
-			openIditem.UserId = k
-			openIditem.OpenId = v
-			first := "您关注的赛道,有新的报告发布/更新,欢迎查看"
-			keyword1 := "【" + articleInfo.SubCategoryName + "】有报告发布/更新"
-			mapActivityUserId := make(map[int]string)
-			if articleInfo.ReportType == 2 {
-				sliceSubjectId, _ := models.GetSubjectIds(articleId)
-				if sliceSubjectId != "" {
-					appointmentList, err := models.GetCygxAppointmentSummaryBySubjectId(sliceSubjectId)
-					if err != nil {
-						fmt.Println("GetCygxAppointmentSummaryListBySubjectId Err:", err.Error())
-						return err
-					}
-					var userIds []string
-					if len(appointmentList) > 0 {
-						for _, v := range appointmentList {
-							//fmt.Println("mapActivityUserId:", v.UserId)
-							userIds = append(userIds, strconv.Itoa(v.UserId))
-							mapActivityUserId[v.UserId] += v.ActivityName + ","
-						}
-						userIdstr := strings.Join(userIds, ",")
-						openIdLists, err := models.GetOpenIdByUserIds(userIdstr)
-						if err != nil {
-							fmt.Println("GetOpenIdByUserIds Err:", err.Error())
-							return err
-						}
-						for _, item := range openIdLists {
-							first := "您预约的调研,有关联的纪要发布/更新了"
-							keyword1 := industryName
-							openIditem := new(models.OpenIdList)
-							openIditem.OpenId = item.OpenId
-							openIditem.UserId = item.UserId
-							if _, ok := mapAlreadySend[openIditem.UserId]; !ok {
-								SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4, openIditem, articleId)
-								delete(mapUserIdChooseSendTypeNoPermission, openIditem.UserId)
-								fmt.Println("AlreadySend:", openIditem.UserId)
-								mapAlreadySend[openIditem.UserId] = openIditem.UserId
-							}
-						}
-					}
-				}
-				//fmt.Println("openIditem.UserId:", openIditem.UserId)
-				//if _,ok := mapActivityUserId[openIditem.UserId]; ok{
-				//	first = "您预约的调研,有关联的纪要发布/更新了"
-				//	keyword1 = industryName
-				//	SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4, openIditem, articleId)
-				//	delete(mapUserIdChooseSendTypeNoPermission, openIditem.UserId)
-				//	mapAlreadySend[openIditem.UserId] = openIditem.UserId
-				//}
+		//如果不存在关联的产业则不推送
+		if len(detailIndustryNameList) == 0 {
+			return
+		} else {
+
+			var industrialIds []int
+			for _, v := range detailIndustryNameList {
+				industrialIds = append(industrialIds, v.IndustrialManagementId)
 			}
-			_, ok := mapAlreadySend[openIditem.UserId]
-			//如果有权限而且小助手没有提交过信息的 就做正常推送
-			if mapUserIdChooseSend[openIditem.UserId] == 0 && !ok {
-				fmt.Println("1:", articleId)
-				SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4, openIditem, articleId)
+			var conditionFollow string
+			var parsFollow []interface{}
+			//根据产业关注ID,获取用户不感兴趣的产业信息
+			conditionFollow = " AND  industrial_management_id IN (" + utils.GetOrmInReplace(len(industrialIds)) + ")  AND follow_type = 3  "
+			parsFollow = append(parsFollow, industrialIds)
+			userFllowListUninterested, e := models.GetCygxIndustryFllowListByCon(conditionFollow, parsFollow)
+			if e != nil {
+				err = errors.New("GetCygxIndustryFllowList, Err: " + e.Error())
+				return
 			}
-			//如果小助手勾选了对应的权限信息 就做正常推送
-			if mapUserIdChooseSend[openIditem.UserId] != 0 && mapUserFllowCeLue[openIditem.UserId] != "" && !ok {
-				fmt.Println("2:", articleId)
-				SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4, openIditem, articleId)
+			var userFllowNum = make(map[int]int)
+			for _, v := range userFllowListUninterested {
+				userFllowNum[v.UserId]++
+				//如果活动对应的产业数量,跟用户不感兴趣的产业数量一致,就不做推送
+				if userFllowNum[v.UserId] == len(detailIndustryNameList) {
+					mapOpenidRefuset[v.UserId] = "_"
+				}
 			}
+
 		}
-	} else {
-		for k, v := range mapOpenidPower {
-			if mapOpenidPushed[k] != "" {
-				continue
+		for _, v := range detailIndustryNameList {
+			industryName += v.IndustryName + ","
+			industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
+		}
+		industryName = strings.TrimRight(industryName, ",")
+		industrialManagementId = strings.TrimRight(industrialManagementId, ",")
+		//}
+
+		keyword1 := fmt.Sprint("【", industryName, "】有报告发布/更新")
+		keyword2 := articleInfo.Title
+		keyword3 := time.Now().Format(utils.FormatDateTime)
+		keyword4 := articleInfo.Abstract
+		sliceSubjectId, _ := models.GetSubjectIds(articleId)
+		var appointmentList []*models.CygxAppointment
+		var mapOpenidSubjectId = make(map[int]string) //预约相关纪要的用户
+		if sliceSubjectId != "" {
+			appointmentList, e = models.GetCygxAppointmentSummaryBySubjectId(sliceSubjectId)
+			if e != nil {
+				err = errors.New("GetCygxAppointmentSummaryBySubjectId, Err: " + e.Error())
+				return
 			}
-			mapUserIdChooseSendType := make(map[int]int)
-			for _, vS := range chooseSendtList {
-				if vS.IsRefuse == 1 {
-					continue
+			var userIds []string
+			if len(appointmentList) > 0 {
+				for _, v := range appointmentList {
+					userIds = append(userIds, strconv.Itoa(v.UserId))
 				}
-				//获取选择主客观赛道的用户
-				if reportMapDetail.PermissionType == 1 {
-					if vS.IsSubjective == 1 {
-						mapUserIdChooseSendType[vS.UserId] = vS.UserId
-					}
-				} else if reportMapDetail.PermissionType == 2 {
-					if vS.IsObjective == 1 {
-						mapUserIdChooseSendType[vS.UserId] = vS.UserId
-					}
-				} else {
-					if vS.IsSubjective == 1 || vS.IsObjective == 1 {
-						mapUserIdChooseSendType[vS.UserId] = vS.UserId
-					}
+				userIdstr := strings.Join(userIds, ",")
+				openIdLists, e := models.GetOpenIdByUserIds(userIdstr)
+				if e != nil {
+					err = errors.New("GetOpenIdByUserIds, Err: " + e.Error())
+					return
 				}
-			}
-			openIditem := new(models.OpenIdList)
-			openIditem.UserId = k
-			openIditem.OpenId = v
-			first := "您关注的赛道,有新的报告发布/更新,欢迎查看"
-			keyword1 := "【" + articleInfo.SubCategoryName + "】有报告发布/更新"
-			mapActivityUserId := make(map[int]string)
-			if articleInfo.ReportType == 2 {
-				keyword1 = fmt.Sprint("【", industryName, "】有报告发布/更新")
-				sliceSubjectId, _ := models.GetSubjectIds(articleId)
-				if sliceSubjectId != "" {
-					appointmentList, err := models.GetCygxAppointmentSummaryBySubjectId(sliceSubjectId)
-					if err != nil {
-						fmt.Println("GetCygxAppointmentSummaryListBySubjectId Err:", err.Error())
-						return err
-					}
-					var userIds []string
-					if len(appointmentList) > 0 {
-						for _, v := range appointmentList {
-							//fmt.Println("mapActivityUserId:", v.UserId)
-							userIds = append(userIds, strconv.Itoa(v.UserId))
-							mapActivityUserId[v.UserId] += v.ActivityName + ","
-						}
-						userIdstr := strings.Join(userIds, ",")
-						openIdLists, err := models.GetOpenIdByUserIds(userIdstr)
-						if err != nil {
-							fmt.Println("GetOpenIdByUserIds Err:", err.Error())
-							return err
-						}
-						for _, item := range openIdLists {
-							//first := "您预约的调研,有关联的纪要发布/更新了"
-							//keyword1 := industryName
-							openIditem := new(models.OpenIdList)
-							openIditem.OpenId = item.OpenId
-							openIditem.UserId = item.UserId
-							if _, ok := mapAlreadySend[openIditem.UserId]; !ok {
-								SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4, openIditem, articleId)
-								delete(mapUserIdChooseSendTypeNoPermission, openIditem.UserId)
-								fmt.Println("AlreadySend:", openIditem.UserId)
-								mapAlreadySend[openIditem.UserId] = openIditem.UserId
-							}
-						}
+				keyword1 = industryName
+				var openIdArr []string
+				for _, item := range openIdLists {
+					if mapOpenidRefuset[item.UserId] != "" {
+						continue // 拒绝消息推送的用户不接收模版消息
 					}
+					openIdArr = append(openIdArr, item.OpenId)
+					mapOpenidSubjectId[item.UserId] = "_"
 				}
+				go SendWxMsgWithArticleUpdateList(industryName, keyword2, keyword3, keyword4, openIdArr, articleId)
 			}
-
-			//如果有权限而且小助手没有提交过信息的 就做正常推送
-			_, ok := mapAlreadySend[openIditem.UserId]
-			if mapUserIdChooseSend[openIditem.UserId] == 0 && !ok {
-				SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4, openIditem, articleId)
-				delete(mapUserIdChooseSendTypeNoPermission, openIditem.UserId)
-				mapAlreadySend[openIditem.UserId] = openIditem.UserId
-			}
-			//如果小助手勾选了对应的权限信息 就做正常推送
-			if mapUserIdChooseSend[openIditem.UserId] != 0 && mapOpenidFllow[openIditem.UserId] != "" && mapUserIdChooseSendType[openIditem.UserId] > 0 && !ok {
-				SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4, openIditem, articleId)
-				delete(mapUserIdChooseSendTypeNoPermission, openIditem.UserId)
-				mapAlreadySend[openIditem.UserId] = openIditem.UserId
+		}
+		var openIdArr2 []string
+		for _, item := range openidPowerList {
+			if mapOpenidRefuset[item.UserId] != "" || mapOpenidSubjectId[item.UserId] != "" {
+				continue // 拒绝消息推送的用户不接收模版消息
 			}
+			openIdArr2 = append(openIdArr2, item.OpenId)
 		}
+		go SendWxMsgWithArticleUpdateList(keyword1, keyword2, keyword3, keyword4, openIdArr2, articleId)
 	}
+
+	////获取关注这个文章对应产业的用户的 openid
+	//mapOpenidFllow := make(map[int]string)
+	//if chartPermissionId != utils.CE_LUE_ID && chartPermissionId != utils.GU_SHOU_ID_CHART && chartPermissionId != utils.ZHOU_QI_ID {
+	//	openidFllowListMobile, e := models.GetCygxUserFllowOpenid(articleId)
+	//	if e != nil {
+	//		err = errors.New("GetCygxUserFllowOpenid, Err: " + e.Error())
+	//		return
+	//	}
+	//
+	//	var mobileArrFllow []string
+	//	for _, v := range openidFllowListMobile {
+	//		mobileArrFllow = append(mobileArrFllow, v.Mobile)
+	//	}
+	//
+	//	openidFllowList, e := models.GetWxOpenIdByMobileSliceList(mobileArrFllow)
+	//	if e != nil {
+	//		err = errors.New("GetWxOpenIdByMobileSliceList, Err: " + e.Error())
+	//		return
+	//	}
+	//
+	//	for _, v := range openidFllowList {
+	//		mapOpenidFllow[v.UserId] = v.OpenId
+	//	}
+	//}
+	//
+	////获取提交过推送规则的用户的 openid
+	//mapUserIdChooseSend := make(map[int]int)
+	//mapUserIdChooseSendTypeNoPermission := make(map[int]int)
+	//chooseSendtList, e := models.GetCygxXzsChooseSend()
+	//if e != nil {
+	//	err = errors.New("GetCygxXzsChooseSend, Err: " + e.Error())
+	//	return
+	//}
+	//for _, v := range chooseSendtList {
+	//	mapUserIdChooseSend[v.UserId] = v.UserId
+	//	if v.IsRefuse == 1 {
+	//		continue
+	//	}
+	//	//获取选择主客观赛道的用户
+	//	if reportMapDetail.PermissionType == 1 {
+	//		if v.IsSubjective == 1 {
+	//			mapUserIdChooseSendTypeNoPermission[v.UserId] = v.UserId
+	//		}
+	//	} else {
+	//		if v.IsObjective == 1 {
+	//			mapUserIdChooseSendTypeNoPermission[v.UserId] = v.UserId
+	//		}
+	//	}
+	//}
+	////已经推送了的openid
+	//mapOpenidPushed := make(map[int]string)
+	//
+	//keyword2 := articleInfo.Title
+	//keyword3 := time.Now().Format(utils.FormatDateTime)
+	//keyword4 := articleInfo.Abstract
+	//mapAlreadySend := make(map[int]int)
+	//
+	//sliceSubjectId, _ := models.GetSubjectIds(articleId)
+	//var appointmentList []*models.CygxAppointment
+	//if sliceSubjectId != "" {
+	//	appointmentList, e = models.GetCygxAppointmentSummaryBySubjectId(sliceSubjectId)
+	//	if e != nil {
+	//		err = errors.New("GetCygxAppointmentSummaryBySubjectId, Err: " + e.Error())
+	//		return
+	//	}
+	//	//var userIds []string
+	//	//if len(appointmentList) > 0 {
+	//	//	for _, v := range appointmentList {
+	//	//		//fmt.Println("mapActivityUserId:", v.UserId)
+	//	//		userIds = append(userIds, strconv.Itoa(v.UserId))
+	//	//		mapActivityUserId[v.UserId] += v.ActivityName + ","
+	//	//	}
+	//	//	userIdstr := strings.Join(userIds, ",")
+	//	//	openIdLists, err := models.GetOpenIdByUserIds(userIdstr)
+	//	//	if err != nil {
+	//	//		fmt.Println("GetOpenIdByUserIds Err:", err.Error())
+	//	//		return err
+	//	//	}
+	//	//	for _, item := range openIdLists {
+	//	//		//first := "您预约的调研,有关联的纪要发布/更新了"
+	//	//		//keyword1 := industryName
+	//	//		openIditem := new(models.OpenIdList)
+	//	//		openIditem.OpenId = item.OpenId
+	//	//		openIditem.UserId = item.UserId
+	//	//		if _, ok := mapAlreadySend[openIditem.UserId]; !ok {
+	//	//			SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4, openIditem, articleId)
+	//	//			delete(mapUserIdChooseSendTypeNoPermission, openIditem.UserId)
+	//	//			fmt.Println("AlreadySend:", openIditem.UserId)
+	//	//			mapAlreadySend[openIditem.UserId] = openIditem.UserId
+	//	//		}
+	//	//	}
+	//	//}
+	//}
+	////如果是策略就按照策略的推送方式来写
+	//if reportMapDetail.ChartPermissionName == utils.CE_LUE_NAME || reportMapDetail.ChartPermissionName == utils.GU_SHOU_NAME {
+	//	//获取提交过推送规则的用户的 openid
+	//	mapUserFllowCeLue := make(map[int]string)
+	//	userFllowCeLueList, e := models.GetCygxUserFllowCeLueOpenid(articleInfo.CategoryId)
+	//	if e != nil {
+	//		err = errors.New("GetCygxUserFllowCeLueOpenid, Err: " + e.Error())
+	//		return
+	//	}
+	//	for _, v := range userFllowCeLueList {
+	//		mapUserFllowCeLue[v.UserId] = v.OpenId
+	//	}
+	//	for k, v := range mapOpenidPower {
+	//		if mapOpenidPushed[k] != "" {
+	//			continue
+	//		}
+	//		openIditem := new(models.OpenIdList)
+	//		openIditem.UserId = k
+	//		openIditem.OpenId = v
+	//		first := "您关注的赛道,有新的报告发布/更新,欢迎查看"
+	//		keyword1 := "【" + articleInfo.SubCategoryName + "】有报告发布/更新"
+	//		mapActivityUserId := make(map[int]string)
+	//		if articleInfo.ReportType == 2 {
+	//			sliceSubjectId, _ = models.GetSubjectIds(articleId)
+	//			if sliceSubjectId != "" {
+	//				appointmentList, e = models.GetCygxAppointmentSummaryBySubjectId(sliceSubjectId)
+	//				if e != nil {
+	//					err = errors.New("GetCygxAppointmentSummaryBySubjectId, Err: " + e.Error())
+	//					return
+	//				}
+	//				var userIds []string
+	//				if len(appointmentList) > 0 {
+	//					for _, v := range appointmentList {
+	//						//fmt.Println("mapActivityUserId:", v.UserId)
+	//						userIds = append(userIds, strconv.Itoa(v.UserId))
+	//						mapActivityUserId[v.UserId] += v.ActivityName + ","
+	//					}
+	//					userIdstr := strings.Join(userIds, ",")
+	//					openIdLists, e := models.GetOpenIdByUserIds(userIdstr)
+	//					appointmentList, e = models.GetCygxAppointmentSummaryBySubjectId(sliceSubjectId)
+	//					if e != nil {
+	//						err = errors.New("GetCygxAppointmentSummaryBySubjectId, Err: " + e.Error())
+	//						return
+	//					}
+	//					for _, item := range openIdLists {
+	//						first = "您预约的调研,有关联的纪要发布/更新了"
+	//						keyword1 = industryName
+	//						openIditem = new(models.OpenIdList)
+	//						openIditem.OpenId = item.OpenId
+	//						openIditem.UserId = item.UserId
+	//						if _, ok := mapAlreadySend[openIditem.UserId]; !ok {
+	//							SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4, openIditem, articleId)
+	//							delete(mapUserIdChooseSendTypeNoPermission, openIditem.UserId)
+	//							fmt.Println("AlreadySend:", openIditem.UserId)
+	//							mapAlreadySend[openIditem.UserId] = openIditem.UserId
+	//						}
+	//					}
+	//				}
+	//			}
+	//		}
+	//		_, ok := mapAlreadySend[openIditem.UserId]
+	//		//如果有权限而且小助手没有提交过信息的 就做正常推送
+	//		if mapUserIdChooseSend[openIditem.UserId] == 0 && !ok {
+	//			fmt.Println("1:", articleId)
+	//			SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4, openIditem, articleId)
+	//		}
+	//		//如果小助手勾选了对应的权限信息 就做正常推送
+	//		if mapUserIdChooseSend[openIditem.UserId] != 0 && mapUserFllowCeLue[openIditem.UserId] != "" && !ok {
+	//			fmt.Println("2:", articleId)
+	//			SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4, openIditem, articleId)
+	//		}
+	//	}
+	//} else {
+	//	for k, v := range mapOpenidPower {
+	//		if mapOpenidPushed[k] != "" {
+	//			continue
+	//		}
+	//		mapUserIdChooseSendType := make(map[int]int)
+	//		for _, vS := range chooseSendtList {
+	//			if vS.IsRefuse == 1 {
+	//				continue
+	//			}
+	//			//获取选择主客观赛道的用户
+	//			if reportMapDetail.PermissionType == 1 {
+	//				if vS.IsSubjective == 1 {
+	//					mapUserIdChooseSendType[vS.UserId] = vS.UserId
+	//				}
+	//			} else if reportMapDetail.PermissionType == 2 {
+	//				if vS.IsObjective == 1 {
+	//					mapUserIdChooseSendType[vS.UserId] = vS.UserId
+	//				}
+	//			} else {
+	//				if vS.IsSubjective == 1 || vS.IsObjective == 1 {
+	//					mapUserIdChooseSendType[vS.UserId] = vS.UserId
+	//				}
+	//			}
+	//		}
+	//		openIditem := new(models.OpenIdList)
+	//		openIditem.UserId = k
+	//		openIditem.OpenId = v
+	//		first := "您关注的赛道,有新的报告发布/更新,欢迎查看"
+	//		keyword1 := "【" + articleInfo.SubCategoryName + "】有报告发布/更新"
+	//		mapActivityUserId := make(map[int]string)
+	//		if articleInfo.ReportType == 2 {
+	//			keyword1 = fmt.Sprint("【", industryName, "】有报告发布/更新")
+	//			//sliceSubjectId, _ = models.GetSubjectIds(articleId)
+	//			if sliceSubjectId != "" {
+	//				//appointmentList, e = models.GetCygxAppointmentSummaryBySubjectId(sliceSubjectId)
+	//				//if e != nil {
+	//				//	err = errors.New("GetCygxAppointmentSummaryBySubjectId, Err: " + e.Error())
+	//				//	return
+	//				//}
+	//				var userIds []string
+	//				if len(appointmentList) > 0 {
+	//					for _, v := range appointmentList {
+	//						//fmt.Println("mapActivityUserId:", v.UserId)
+	//						userIds = append(userIds, strconv.Itoa(v.UserId))
+	//						mapActivityUserId[v.UserId] += v.ActivityName + ","
+	//					}
+	//					userIdstr := strings.Join(userIds, ",")
+	//					openIdLists, e := models.GetOpenIdByUserIds(userIdstr)
+	//					if e != nil {
+	//						err = errors.New("GetOpenIdByUserIds, Err: " + e.Error())
+	//						return
+	//					}
+	//					for _, item := range openIdLists {
+	//						//first := "您预约的调研,有关联的纪要发布/更新了"
+	//						//keyword1 := industryName
+	//						openIditem := new(models.OpenIdList)
+	//						openIditem.OpenId = item.OpenId
+	//						openIditem.UserId = item.UserId
+	//						if _, ok := mapAlreadySend[openIditem.UserId]; !ok {
+	//							SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4, openIditem, articleId)
+	//							delete(mapUserIdChooseSendTypeNoPermission, openIditem.UserId)
+	//							fmt.Println("AlreadySend:", openIditem.UserId)
+	//							mapAlreadySend[openIditem.UserId] = openIditem.UserId
+	//						}
+	//					}
+	//				}
+	//			}
+	//		}
+	//
+	//		//如果有权限而且小助手没有提交过信息的 就做正常推送
+	//		_, ok := mapAlreadySend[openIditem.UserId]
+	//		if mapUserIdChooseSend[openIditem.UserId] == 0 && !ok {
+	//			SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4, openIditem, articleId)
+	//			delete(mapUserIdChooseSendTypeNoPermission, openIditem.UserId)
+	//			mapAlreadySend[openIditem.UserId] = openIditem.UserId
+	//		}
+	//		//如果小助手勾选了对应的权限信息 就做正常推送
+	//		if mapUserIdChooseSend[openIditem.UserId] != 0 && mapOpenidFllow[openIditem.UserId] != "" && mapUserIdChooseSendType[openIditem.UserId] > 0 && !ok {
+	//			SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4, openIditem, articleId)
+	//			delete(mapUserIdChooseSendTypeNoPermission, openIditem.UserId)
+	//			mapAlreadySend[openIditem.UserId] = openIditem.UserId
+	//		}
+	//	}
+	//}
 	utils.Rc.Put(cacheKey, articleId, time.Hour*12)
 	return
 }

+ 50 - 50
services/init_10.5.1.go

@@ -10,56 +10,56 @@ import (
 
 //10.5.1版本上线需要更新的数据
 
-func init1111() {
-	var condition string
-	var pars []interface{}
-	var err error
-	fmt.Print()
-
-	var topCond string
-	var topPars []interface{}
-	toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
-	if err != nil {
-		return
-	}
-
-	mapIndustryName := make(map[int]string)
-	for _, v := range toplist {
-		mapIndustryName[v.IndustrialManagementId] = v.IndustryName
-	}
-	fmt.Println(mapIndustryName)
-	//处理上周纪要汇总
-	condition = ` AND  type = 1  `
-	list, err := models.GetCygxIndustryFllowListByCon(condition, pars, 0, 100000)
-	if err != nil {
-		fmt.Println(err)
-	}
-	var items []*models.CygxUserLabel
-	for _, user := range list {
-		item := new(models.CygxUserLabel)
-		item.UserId = user.UserId
-		item.CompanyId = user.CompanyId
-		item.RealName = user.RealName
-		item.Mobile = user.Mobile
-		item.Email = user.Email
-		item.Label = mapIndustryName[user.IndustrialManagementId]
-		item.SourceId = user.IndustrialManagementId
-		item.Source = 1
-		item.IsFollow = 1
-		item.CreateTime = time.Now()
-		item.ModifyTime = time.Now()
-		items = append(items, item)
-		if len(items)%5000 == 0 {
-			err = models.CygxUserLabelMulti(items)
-			fmt.Println(err)
-			items = make([]*models.CygxUserLabel, 0)
-		}
-	}
-	if len(items) > 0 {
-		err = models.CygxUserLabelMulti(items)
-		fmt.Println(err, "555")
-	}
-}
+//func init1111() {
+//	var condition string
+//	var pars []interface{}
+//	var err error
+//	fmt.Print()
+//
+//	var topCond string
+//	var topPars []interface{}
+//	toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+//	if err != nil {
+//		return
+//	}
+//
+//	mapIndustryName := make(map[int]string)
+//	for _, v := range toplist {
+//		mapIndustryName[v.IndustrialManagementId] = v.IndustryName
+//	}
+//	fmt.Println(mapIndustryName)
+//	//处理上周纪要汇总
+//	condition = ` AND  type = 1  `
+//	list, err := models.GetCygxIndustryFllowListByCon(condition, pars, 0, 100000)
+//	if err != nil {
+//		fmt.Println(err)
+//	}
+//	var items []*models.CygxUserLabel
+//	for _, user := range list {
+//		item := new(models.CygxUserLabel)
+//		item.UserId = user.UserId
+//		item.CompanyId = user.CompanyId
+//		item.RealName = user.RealName
+//		item.Mobile = user.Mobile
+//		item.Email = user.Email
+//		item.Label = mapIndustryName[user.IndustrialManagementId]
+//		item.SourceId = user.IndustrialManagementId
+//		item.Source = 1
+//		item.IsFollow = 1
+//		item.CreateTime = time.Now()
+//		item.ModifyTime = time.Now()
+//		items = append(items, item)
+//		if len(items)%5000 == 0 {
+//			err = models.CygxUserLabelMulti(items)
+//			fmt.Println(err)
+//			items = make([]*models.CygxUserLabel, 0)
+//		}
+//	}
+//	if len(items) > 0 {
+//		err = models.CygxUserLabelMulti(items)
+//		fmt.Println(err, "555")
+//	}
+//}
 
 func init123() {
 	var condition string

+ 13 - 0
services/user_label.go

@@ -409,6 +409,12 @@ func IndustryFllowUserLabelLogReduce(log models.CygxUserLabelLogRedis) (err erro
 		err = errors.New("GetIndustrialManagementDetail" + e.Error())
 		return
 	}
+	countFllow, e := models.GetCountCygxIndustryFllowByType(userId, industrialManagementId) // 是否重点关注
+	if e != nil {
+		err = errors.New("GetCountCygxIndustryFllowByType" + e.Error())
+		return
+	}
+	isFllow = countFllow
 	label := detailIndustrial.IndustryName
 	if isFllow == 0 {
 		e = models.UpdateCygxUserLabelIsFollow(isFllow, industrialManagementId, source, userId, label)
@@ -572,6 +578,13 @@ func CategoryFllowUserLabelLogReduce(log models.CygxUserLabelLogRedis) (err erro
 		return
 	}
 	label := detailIndustrial.MatchTypeName
+
+	countFllow, e := models.GetCountCygxXzsChooseCategoryFllowByType(userId, industrialManagementId) // 是否重点关注
+	if e != nil {
+		err = errors.New("GetCountCygxIndustryFllowByType" + e.Error())
+		return
+	}
+	isFllow = countFllow
 	if isFllow == 0 {
 		e = models.UpdateCygxUserLabelIsFollow(isFllow, industrialManagementId, source, userId, label)
 		if e != nil {

+ 23 - 25
services/wx_template_msg.go

@@ -497,31 +497,6 @@ func SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4 st
 			go utils.SendAlarmMsg(fmt.Sprint("发送报告提问消息提醒模版消息失败,SendWxMsgWithArticleUpdate 文章ID:", articleId, "Err:"+err.Error()), 2)
 		}
 	}()
-	//accessToken, err := models.GetWxAccessTokenByXzs()
-	//if err != nil {
-	//	msg = "GetWxAccessToken Err:" + err.Error()
-	//	return
-	//}
-	//if accessToken == "" {
-	//	msg = "accessToken is empty"
-	//	return
-	//}
-	//var openIdList []*models.OpenIdList
-	//openIdList = append(openIdList, item)
-	//sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
-	//templateId := utils.TemplateIdByProductXzs
-	//sendMap := make(map[string]interface{})
-	//sendData := make(map[string]interface{})
-	//sendMap["template_id"] = templateId
-	//sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId, "pagepath": "pageMy/reportDetail/reportDetail?id=" + strconv.Itoa(articleId) + "&IsSendWx=1"}
-	//sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
-	//sendData["keyword1"] = map[string]interface{}{"value": keyWord1, "color": "#173177"}
-	//sendData["keyword2"] = map[string]interface{}{"value": keyWord2, "color": "#173177"}
-	//sendData["keyword3"] = map[string]interface{}{"value": keyWord3, "color": "#173177"}
-	//sendData["keyword4"] = map[string]interface{}{"value": keyWord4, "color": "#173177"}
-	//sendData["remark"] = map[string]interface{}{"value": "点击查看报告详情", "color": "#173177"}
-	//sendMap["data"] = sendData
-	//WxSendTemplateMsg(sendUrl, sendMap, openIdList, strconv.Itoa(articleId), utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD)
 
 	openIdArr := make([]string, 0)
 	openIdArr = append(openIdArr, item.OpenId)
@@ -541,6 +516,29 @@ func SendWxMsgWithArticleUpdate(first, keyword1, keyword2, keyword3, keyword4 st
 	return
 }
 
+func SendWxMsgWithArticleUpdateList(keyword1, keyword2, keyword3, keyword4 string, openIdArr []string, articleId int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("发送报告提问消息提醒模版消息失败,SendWxMsgWithArticleUpdate 文章ID:", articleId, "Err:"+err.Error()), 2)
+		}
+	}()
+
+	redirectUrl := utils.WX_MSG_PATH_ARTICLE_DETAIL + strconv.Itoa(articleId)
+	sendInfo := new(SendWxTemplate)
+	sendInfo.Keyword1 = keyword1
+	sendInfo.Keyword2 = keyword2
+	sendInfo.Keyword3 = keyword3
+	sendInfo.Keyword4 = keyword4
+	sendInfo.TemplateId = utils.TemplateIdByProductXzs
+	sendInfo.RedirectUrl = redirectUrl
+	sendInfo.RedirectTarget = 3
+	sendInfo.Resource = strconv.Itoa(articleId)
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	err = PublicSendTemplateMsg(sendInfo)
+	return
+}
+
 // 周日下午4点半,推送全部活动
 func SendActivityOnenIdWxTemplateMsg(first, keyword1, keyword2, keyword3, keyword4 string, openIdList []*models.OpenIdList) (err error) {
 	defer func() {