Эх сурвалжийг харах

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into mfyx_2.0

xingzai 10 сар өмнө
parent
commit
86db0e75bb
46 өөрчлөгдсөн 3218 нэмэгдсэн , 151 устгасан
  1. 1 0
      controllers/activity_sign.go
  2. 4 4
      controllers/activity_special.go
  3. 8 2
      controllers/chart_permission.go
  4. 8 1
      controllers/home.go
  5. 5 0
      controllers/research.go
  6. 1 1
      controllers/tag.go
  7. 61 27
      controllers/yanxuan_special.go
  8. 51 0
      models/activity.go
  9. 48 0
      models/article.go
  10. 45 12
      models/article_history_record_newpv.go
  11. 2 1
      models/chart_permission.go
  12. 15 0
      models/company.go
  13. 100 21
      models/company_interaction_num.go
  14. 2 0
      models/crm_company.go
  15. 11 2
      models/cygx_yanxuan_special.go
  16. 22 0
      models/cygx_yanxuan_special_record.go
  17. 9 0
      models/cygx_yanxuan_special_user.go
  18. 1 1
      models/home.go
  19. 5 2
      models/report.go
  20. 8 1
      models/report_mapping.go
  21. 10 9
      models/search_key_word.go
  22. 17 0
      models/seller.go
  23. 3 2
      models/send_company_user.go
  24. 276 0
      models/user_interaction_num.go
  25. 57 0
      models/user_record.go
  26. 22 0
      models/wx_template_msg.go
  27. 3 2
      services/activity.go
  28. 10 7
      services/activity_special_trip.go
  29. 3 2
      services/activity_task.go
  30. 808 4
      services/article.go
  31. 14 3
      services/article_history.go
  32. 1 1
      services/config.go
  33. 41 4
      services/cygx_yanxuan_special.go
  34. 31 11
      services/cygx_yanxuan_special_company.go
  35. 265 0
      services/html2Img.go
  36. 1 0
      services/keyword.go
  37. 51 6
      services/oss.go
  38. 8 8
      services/sms.go
  39. 15 0
      services/tag.go
  40. 13 1
      services/task.go
  41. 3 0
      services/user_label.go
  42. 36 0
      services/user_permission.go
  43. 603 0
      services/wx_category_template_msg.go
  44. 441 2
      services/wx_user.go
  45. 63 8
      utils/config.go
  46. 16 6
      utils/constants.go

+ 1 - 0
controllers/activity_sign.go

@@ -139,6 +139,7 @@ func (this *ActivitySignCoAntroller) Detail() {
 
 		//线下调研活动扫码签到给对应销售发模版消息
 		services.SendActivitieSignTemplateMsg(user, activityInfo)
+		services.SendActivitieSignCategoryTemplateMsg(user, activityInfo)
 
 		//处理用户标签
 		services.ActivityUserLabelLogAdd(activityId, []string{user.Mobile})

+ 4 - 4
controllers/activity_special.go

@@ -250,8 +250,8 @@ func (this *ActivitySpecialCoAntroller) SpecialTripAdd() {
 			itemBill.ChartPermissionId = activityInfo.ChartPermissionId
 			itemBill.ChartPermissionName = activityInfo.ChartPermissionName
 
-			if activityInfo.ChartPermissionName == utils.CE_LUE_NAME || activityInfo.ChartPermissionName == utils.GU_SHOU_NAME {
-				//如果是策略、固收行业,把代扣行业信息放入流水表,取消报名的时候,返点使用
+			if utils.InArrayByStr(utils.ACTIVITY_SPECIAL_TRIP_PERMISSION_NAME_OTHER, activityInfo.ChartPermissionName) {
+				//如果是策略、固收、周期行业,把代扣行业信息放入流水表,取消报名的时候,返点使用
 				maxChartPermissionId, maxChartPermissionName, err := services.GetSpecialBillMaxChartPermissionId(user)
 				if err != nil {
 					br.Msg = "操作失败"
@@ -478,8 +478,8 @@ func (this *ActivitySpecialCoAntroller) Tripcancel() {
 	itemBill.ChartPermissionName = activityInfo.ChartPermissionName
 	resultTime := utils.StrTimeToTime(activityInfo.ActivityTime)
 
-	if activityInfo.ChartPermissionName == utils.CE_LUE_NAME || activityInfo.ChartPermissionName == utils.GU_SHOU_NAME {
-		//如果是策略、固收行业,把代扣行业信息放入流水表,取消报名的时候,返点使用
+	if utils.InArrayByStr(utils.ACTIVITY_SPECIAL_TRIP_PERMISSION_NAME_OTHER, activityInfo.ChartPermissionName) {
+		//如果是策略、固收、周期行业,把代扣行业信息放入流水表,取消报名的时候,返点使用
 		lastTripBill, err := models.GetCygxActivitySpecialTripBillLastDetialByActivityId(activityInfo.ActivityId, user.UserId)
 		if err != nil {
 			br.Msg = "操作失败"

+ 8 - 2
controllers/chart_permission.go

@@ -73,6 +73,10 @@ func (this *ChartPermissionAuthController) Detail() {
 		if v.ChartPermissionId == utils.GU_SHOU_ID_CHART {
 			continue
 		}
+		//周期不进行展示
+		if v.PermissionName == utils.ZHOU_QI_NAME {
+			continue
+		}
 		if userType == 1 {
 			if v.PermissionName != "研选" {
 				resp.List = append(resp.List, v)
@@ -215,18 +219,20 @@ func (this *ChartPermissionAuthController) StrategyDetail() {
 		return
 	}
 	resp := new(models.ReportMappingHomeResp)
-	if chartPermissionId != utils.GU_SHOU_ID_CHART {
+	if chartPermissionId != utils.GU_SHOU_ID_CHART && chartPermissionId != utils.ZHOU_QI_ID {
 		if cf.ConfigValue == "1" || user.CompanyId == utils.HZ_COMPANY_ID {
 			item := new(models.ReportMappingHome)
 			item.CategoryId = utils.TIME_LINE_ID
 			item.SubCategoryName = utils.TIME_LINE_NAME
 			item.MatchTypeName = utils.TIME_LINE_NAME
+			item.ListGroup = 1
 			resp.List = append(resp.List, item)
 		}
 	}
 	for _, v := range list {
 		resp.List = append(resp.List, v)
 	}
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
@@ -352,7 +358,7 @@ func (this *ChartPermissionAuthController) Noyx() {
 		return
 	}
 	var condition string
-	condition += ` AND permission_name IN ('医药','消费','科技','智造','策略','固收') `
+	condition += ` AND permission_name IN ('医药','消费','科技','智造','策略','固收','周期') `
 	list, err := models.GetChartPermissionReportAll(condition)
 	if err != nil {
 		br.Msg = "获取信息失败"

+ 8 - 1
controllers/home.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"encoding/json"
+	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
@@ -144,8 +145,14 @@ func (this *HomeController) ListHome() {
 		imgUrlChart = vslice[len(vslice)-1]
 		mapCategoryUrl[categoryId] = imgUrlChart
 	}
-
+	var articleIds []int
+	for _, v := range list {
+		articleIds = append(articleIds, v.ArticleId)
+	}
+	articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
+	fmt.Println(articleMapPv)
 	for k, v := range list {
+		list[k].Pv = articleMapPv[v.ArticleId]
 		item := list[k]
 		//如果文章一开始的内容是图片,优先展示第一张图片
 		imgurl, _ := services.FixArticleImgUrl(html.UnescapeString(list[k].Body))

+ 5 - 0
controllers/research.go

@@ -136,6 +136,7 @@ func (this *ResearchController) CollectionList() {
 		}
 		articleIds = append(articleIds, v.ArticleId)
 	}
+	articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
 	//处理关联的产业
 	industrialMap, err := services.GetArticleIndustrialByArticleId(articleIds)
 	if err != nil {
@@ -150,6 +151,7 @@ func (this *ResearchController) CollectionList() {
 			list[k].List = make([]*models.IndustrialManagementResp, 0)
 		}
 		list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
+		list[k].Pv = articleMapPv[v.ArticleId]
 	}
 	resp := new(models.ArticleCollectionLIstResp)
 	resp.List = list
@@ -785,6 +787,8 @@ func (this *ResearchController) ArticleNewList() {
 	articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
 	articleCollectYanxuanSpecialMap, _ := services.GetYanxuanSpecialCollectMap(user.UserId) //用户收藏的研选专栏
 
+	yanxuanSpecialPv := services.GetYanxuanSpecialRecordByYanxuanSpecialId(articleIdsSpecialArr)
+
 	//处理关联的产业
 	industrialMap, err := services.GetArticleIndustrialByArticleId(articleIds)
 	if err != nil {
@@ -795,6 +799,7 @@ func (this *ResearchController) ArticleNewList() {
 	for k, v := range list {
 		if v.IsSpecial == 1 {
 			v.IsCollect = articleCollectYanxuanSpecialMap[v.ArticleId]
+			v.Pv = yanxuanSpecialPv[v.ArticleId]
 		} else {
 			v.Pv = articleMapPv[v.ArticleId]
 			v.CollectNum = articleCollectNumMap[v.ArticleId]

+ 1 - 1
controllers/tag.go

@@ -72,7 +72,7 @@ func (this *TagController) TagCustomizeList() {
 	}
 
 	//var condition string
-	condition = ` AND permission_name IN ('医药','消费','科技','智造','策略','固收') `
+	condition = ` AND permission_name IN ('医药','消费','科技','智造','策略','固收','周期') `
 	listPermission, err := models.GetChartPermissionReportAll(condition)
 	if err != nil {
 		br.Msg = "获取信息失败"

+ 61 - 27
controllers/yanxuan_special.go

@@ -76,6 +76,14 @@ func (this *YanxuanSpecialController) List() {
 		br.ErrMsg = "获取失败, Err:" + err.Error()
 		return
 	}
+
+	var yanxuanSpecialIds []int
+	for _, v := range list {
+		yanxuanSpecialIds = append(yanxuanSpecialIds, v.Id)
+	}
+
+	yanxuanSpecialPv := services.GetYanxuanSpecialRecordByYanxuanSpecialId(yanxuanSpecialIds)
+
 	for _, v := range list {
 		hasImg, err := utils.ArticleHasImgUrl(v.Content)
 		if err != nil {
@@ -92,6 +100,7 @@ func (this *YanxuanSpecialController) List() {
 		//}
 		//v.Content, _ = services.GetReportContentTextSubNew(v.Content)
 		v.Content = services.AnnotationHtml(v.Content)
+		v.Content = strings.Replace(v.Content, " <br> <br>", "", -1)
 		if v.DocUrl != "" {
 			var docs []models.Doc
 			err := json.Unmarshal([]byte(v.DocUrl), &docs)
@@ -114,6 +123,7 @@ func (this *YanxuanSpecialController) List() {
 			}
 			v.Tags += v.IndustryTags
 		}
+		v.Pv = yanxuanSpecialPv[v.Id]
 	}
 
 	isAuthor, isImproveInformation := services.GetYanxuanSpecialAuthorInfo(sysUser) //用户是否没开通研选专栏以及,专栏信息是否完善
@@ -122,7 +132,6 @@ func (this *YanxuanSpecialController) List() {
 	resp.List = list
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp.Paging = page
-
 	br.Data = resp
 	br.Ret = 200
 	br.Success = true
@@ -196,7 +205,7 @@ func (this *YanxuanSpecialController) Detail() {
 
 	//如果状态未审核通过,而且查看的不是本人,不是审核人员,就无法查看详情
 	var configCode string
-	configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
+	configCode = utils.TPL_MSG_YAN_XUAN_SPECIAL_APPROVAL
 	cnf, err := models.GetConfigByCode(configCode)
 	if err != nil {
 		br.Msg = "获取失败"
@@ -251,7 +260,7 @@ func (this *YanxuanSpecialController) Detail() {
 			br.ErrMsg = "获取失败, Err:" + err.Error()
 			return
 		}
-		if followCount == 1 {
+		if followCount > 0 {
 			resp.IsFollowAuthor = true
 		}
 	}
@@ -442,13 +451,18 @@ func (this *YanxuanSpecialController) Save() {
 		go services.UpdateYanxuanSpecialResourceData(specialId)        //  写入首页最新  cygx_resource_data 表
 		go services.EsAddYanxuanSpecial(specialId)                     //  写入es 综合搜索
 		go services.SendWxMsgSpecialFollow(req.Id)                     //研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
-		go services.SendWxMsgSpecialAuthor(req.Id, 2)                  //研选专栏审核完成时,给提交人发送模板消息
+		go services.SendWxMsgSpecialAuthor(req.Id, 1)                  //研选专栏审核完成时,给提交人发送模板消息
 		go services.UdpateYanxuanSpecialauthorArticleNum(authorUserId) //  更新作者发布文章的数量
+		go services.MakeYanxuanSpecialMomentsImg(specialId)            //  生成研选专栏分享到朋友圈的图片
+
+		go services.SendWxCategoryMsgSpecialAuthor(req.Id, 1) //研选专栏审核完成时,给提交人发送类目模板消息
+		go services.SendWxCategoryMsgSpecialFollow(req.Id)    // 研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
 	} else {
 		if req.DoType == 2 {
 			go services.SendReviewTemplateMsgAdmin(specialId)
-			go services.UpdateYanxuanSpecialResourceData(specialId) //  写入首页最新  cygx_resource_data 表
-			go services.EsAddYanxuanSpecial(specialId)              //  写入es 综合搜索
+			go services.SendReviewCategoryTemplateMsgAdmin(specialId) //买方研选类目消息
+			go services.UpdateYanxuanSpecialResourceData(specialId)   //  写入首页最新  cygx_resource_data 表
+			go services.EsAddYanxuanSpecial(specialId)                //  写入es 综合搜索
 		}
 	}
 
@@ -486,6 +500,9 @@ func (this *YanxuanSpecialController) AuthorDetail() {
 		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
 		return
 	}
+	if item.IsFollow > 0 {
+		item.IsFollow = 1
+	}
 
 	br.Data = item
 	br.Ret = 200
@@ -546,12 +563,15 @@ func (this *YanxuanSpecialController) Enable() {
 	}
 	if req.Status == 1 {
 		go services.SendWxMsgSpecialFollow(req.Id)
+		go services.SendWxCategoryMsgSpecialFollow(req.Id) // 研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
 	}
 	go services.SendWxMsgSpecialAuthor(req.Id, req.Status)
+	go services.SendWxCategoryMsgSpecialAuthor(req.Id, req.Status)
 	go services.UpdateYanxuanSpecialResourceData(req.Id)                                  //  写入首页最新  cygx_resource_data 表
 	go services.EsAddYanxuanSpecial(req.Id)                                               //  写入es 综合搜索
 	go services.AddAddCygxYanxuanSpecialApprovalLog(user, req.Id, req.Status, req.Reason) //  添加审核记录日志
 	go services.UdpateYanxuanSpecialauthorArticleNum(detail.UserId)                       //  更新作者发布文章的数量
+	go services.MakeYanxuanSpecialMomentsImg(req.Id)                                      //  生成研选专栏分享到朋友圈的图片
 	br.Msg = "审批成功"
 	br.Ret = 200
 	br.Success = true
@@ -593,12 +613,15 @@ func (this *YanxuanSpecialController) Collect() {
 	}
 	var sellerName string
 	sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
-	if err != nil {
+	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "查询栏目详情失败!"
 		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
 		return
 	}
-	sellerName = sellerItemQy.RealName
+	if sellerItemQy != nil {
+		sellerName = sellerItemQy.RealName
+	}
+
 	if req.Status == 1 {
 		item := models.CygxYanxuanSpecialCollect{
 			UserId:           user.UserId,
@@ -776,33 +799,44 @@ func (this *YanxuanSpecialController) Follow() {
 	}
 	var sellerName string
 	sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
-	if err != nil {
+	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "查询栏目详情失败!"
 		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
 		return
 	}
-	sellerName = sellerItemQy.RealName
+	if sellerItemQy != nil {
+		sellerName = sellerItemQy.RealName
+	}
+
 	if req.Status == 1 {
-		item := models.CygxYanxuanSpecialFollow{
-			UserId:           user.UserId,
-			FollowUserId:     req.FollowUserId,
-			Mobile:           user.Mobile,
-			Email:            user.Email,
-			CompanyId:        user.CompanyId,
-			CompanyName:      user.CompanyName,
-			RealName:         user.RealName,
-			SellerName:       sellerName,
-			CreateTime:       time.Now(),
-			ModifyTime:       time.Now(),
-			RegisterPlatform: utils.REGISTER_PLATFORM,
-			YanxuanSpecialId: req.SpecialId,
-		}
-		err = models.AddCygxYanxuanSpecialFollow(&item)
+		followCount, err := models.GetCygxYanxuanSpecialFollowCountByUser(user.UserId, req.FollowUserId)
 		if err != nil {
-			br.Msg = "新增失败"
-			br.ErrMsg = "新增失败,Err:" + err.Error()
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败, Err:" + err.Error()
 			return
 		}
+		if followCount == 0 && user.UserId > 0 {
+			item := models.CygxYanxuanSpecialFollow{
+				UserId:           user.UserId,
+				FollowUserId:     req.FollowUserId,
+				Mobile:           user.Mobile,
+				Email:            user.Email,
+				CompanyId:        user.CompanyId,
+				CompanyName:      user.CompanyName,
+				RealName:         user.RealName,
+				SellerName:       sellerName,
+				CreateTime:       time.Now(),
+				ModifyTime:       time.Now(),
+				RegisterPlatform: utils.REGISTER_PLATFORM,
+				YanxuanSpecialId: req.SpecialId,
+			}
+			err = models.AddCygxYanxuanSpecialFollow(&item)
+			if err != nil {
+				br.Msg = "新增失败"
+				br.ErrMsg = "新增失败,Err:" + err.Error()
+				return
+			}
+		}
 		br.Msg = "关注成功"
 	} else {
 		err = models.DelCygxYanxuanSpecialFollow(user.UserId, req.FollowUserId)

+ 51 - 0
models/activity.go

@@ -1302,3 +1302,54 @@ func UpdateActivityVmpRobotMeetingId(vmpRobotMeetingId, activityId int) (err err
 	_, err = o.Raw(sql, vmpRobotMeetingId, activityId).Exec()
 	return
 }
+
+func GetYxActivitySendMsgListAll(endDate string) (items []*WxMsgCygxActivityList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	s.id,
+	s.user_id,
+	s.fail_type,
+	cr.open_id,
+	a.*
+FROM
+	cygx_activity AS a
+	INNER JOIN cygx_activity_signup AS s ON s.activity_id = a.activity_id
+	INNER JOIN cygx_user_record AS cr ON cr.cygx_bind_account = s.mobile 
+WHERE
+	1 = 1 
+	AND s.is_send_wx_msg = 0 
+	AND s.do_fail_type = 0 
+	AND a.publish_status = 1
+	AND a.chart_permission_id = 31
+	AND a.activity_time <= ? AND a.activity_time >= NOW() 
+	AND s.is_cancel = 0
+	GROUP BY s.id`
+	_, err = o.Raw(sql, endDate).QueryRows(&items)
+	return
+}
+
+// 获取买方研选这边的openid
+func GetMfyxActivitySendMsgListAll(endDate string) (items []*WxMsgCygxActivityList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	s.id,
+	s.user_id,
+	s.fail_type,
+	cr.open_id,
+	a.*
+FROM
+	cygx_activity AS a
+	INNER JOIN cygx_activity_signup AS s ON s.activity_id = a.activity_id
+	INNER JOIN cygx_mfyx_gzh_user_record AS cr ON cr.cygx_bind_account = s.mobile 
+WHERE
+	1 = 1 
+	AND s.is_send_wx_msg = 0 
+	AND s.do_fail_type = 0 
+	AND a.publish_status = 1
+	AND a.chart_permission_id = 31
+	AND a.activity_time <= ? AND a.activity_time >= NOW() 
+	AND s.is_cancel = 0
+	GROUP BY s.id`
+	_, err = o.Raw(sql, endDate).QueryRows(&items)
+	return
+}

+ 48 - 0
models/article.go

@@ -960,3 +960,51 @@ func GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityType
 
 	return
 }
+
+// 获取文章列表
+func GetArticleInit13_5() (items []*ArticleDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	art.title,
+	art.article_id,
+	art.category_id,
+	art.publish_date,
+	art.is_class,
+	art.publish_status,
+	art.is_filter,
+	art.stock,
+	art.field_name,
+	art.id,
+	art.article_id_md5,
+	re.chart_permission_name,
+	re.match_type_name,
+	art.sub_category_name,
+	re.chart_permission_id 
+FROM
+	cygx_article AS art
+	LEFT JOIN cygx_report_mapping AS ret ON ret.category_id = art.category_id_two
+	LEFT JOIN cygx_report_mapping AS re ON re.category_id = art.category_id
+	LEFT JOIN cygx_industrial_article_group_management AS man ON man.article_id = art.article_id 
+WHERE
+	1 = 1 
+	
+	AND art.category_id IN ( SELECT category_id FROM cygx_report_mapping WHERE match_type_name = '热点问答' ) 
+	AND re.chart_permission_id = 22   	GROUP BY  art.article_id `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 获取文章列表
+func GetArticleInit13_5GuSHou() (items []*ArticleDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	art.title,
+	art.article_id
+FROM
+	cygx_article AS art
+
+WHERE
+	1 = 1  AND category_id  IN (10070,10082)  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 45 - 12
models/article_history_record_newpv.go

@@ -9,18 +9,19 @@ import (
 )
 
 type CygxArticleHistoryRecordNewpv struct {
-	Id          int `orm:"column(id);pk"`
-	ArticleId   int
-	UserId      int
-	CreateTime  time.Time
-	ModifyTime  time.Time
-	Mobile      string `description:"手机号"`
-	Email       string `description:"邮箱"`
-	CompanyId   int    `description:"公司id"`
-	CompanyName string `description:"公司名称"`
-	StopTime    int    `description:"停留时间"`
-	OutType     int    `description:"退出方式,1正常退出,2强制关闭"`
-	Source      string `description:"来源,MOBILE:手机端,PC:电脑端"`
+	Id               int `orm:"column(id);pk"`
+	ArticleId        int
+	UserId           int
+	CreateTime       time.Time
+	ModifyTime       time.Time
+	Mobile           string `description:"手机号"`
+	Email            string `description:"邮箱"`
+	CompanyId        int    `description:"公司id"`
+	CompanyName      string `description:"公司名称"`
+	StopTime         int    `description:"停留时间"`
+	OutType          int    `description:"退出方式,1正常退出,2强制关闭"`
+	Source           string `description:"来源,MOBILE:手机端,PC:电脑端"`
+	RegisterPlatform int    `description:"来源 1小程序,2:网页"`
 }
 
 // 添加阅读记录信息
@@ -339,6 +340,38 @@ func GetCygxArticleHistoryRecordNewpvListPv(condition string, pars []interface{}
 	return
 }
 
+// 查研PV列表
+func GetCygxArticleHistoryRecordNewpvListPvCy(condition string, pars []interface{}) (items []*ListPvUvResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) AS pv,
+			article_id
+		FROM
+			cygx_article_history_record_all  WHERE 1 = 1  AND platfor = 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY article_id `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+// 策略PV列表
+func GetCygxArticleHistoryRecordNewpvListPvCl(condition string, pars []interface{}) (items []*ListPvUvResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) AS pv,
+			article_id
+		FROM
+			cygx_article_history_record_all  WHERE 1 = 1  AND platfor = 2 AND is_del = 0 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY article_id `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
 // 获取数量
 func GetCygxArticleHistoryRecordAllCount(condition string, pars []interface{}) (count int, err error) {
 	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_history_record_all  WHERE 1= 1  `

+ 2 - 1
models/chart_permission.go

@@ -72,7 +72,8 @@ func GetChartPermissionById(chartPermissionId int) (item *ChartPermission, err e
 
 func GetChartPermissionActivity() (items []*ActivityChartPermission, err error) {
 	o := orm.NewOrmUsingDB("weekly_report")
-	sql := `SELECT * FROM chart_permission WHERE chart_permission_id IN (19,20,21,22,23,31,53) ORDER BY sort ASC `
+	//sql := `SELECT * FROM chart_permission WHERE chart_permission_id IN (19,20,21,22,23,31,53) ORDER BY sort ASC `
+	sql := `SELECT * FROM chart_permission WHERE product_id=2 AND is_report=1 AND permission_type!=2   AND permission_name IN ('医药','消费','科技','智造','策略','固收','研选订阅','周期') ORDER BY sort ASC  `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }

+ 15 - 0
models/company.go

@@ -275,3 +275,18 @@ func UpdateComapanyInteractionNum(interactionNum, interactionNumSeller, companyI
 	_, err = o.Raw(sql, interactionNum, interactionNumSeller, companyId).Exec()
 	return
 }
+
+// 获取有机构互动量的公司
+func GetCompanyInteractionNumList() (items []*Company, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := `SELECT *  FROM company  WHERE  interaction_num > 0  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+func GetCompanyProductCount(companyId, productId int) (count int, err error) {
+	sql := ` SELECT COUNT(1) AS count FROM  company_product WHERE company_id = ? AND product_id = ? `
+	o := orm.NewOrmUsingDB("weekly_report")
+	err = o.Raw(sql, companyId, productId).QueryRow(&count)
+	return
+}

+ 100 - 21
models/company_interaction_num.go

@@ -6,25 +6,28 @@ import (
 )
 
 type CygxCompanyInteractionNum struct {
-	Id                  int       `orm:"column(id);pk"`
-	CompanyId           int       `description:"用户ID"`
-	ArticleHistoryNum   int       `description:"文章浏览数量"`
-	ArticleCountNum     int       `description:"文章收藏数量"`
-	ChartCountNum       int       `description:"图表收藏"`
-	IndustryFllowNum    int       `description:"产业关注数量"`
-	DepartmentFollowNum int       `description:"作者关注数量"`
-	KeyWordNum          int       `description:"关键词搜索次数"`
-	ActivityOnLineNum   int       `description:"线上活动报名次数"`
-	ActivityOfficeNum   int       `description:"线下活动报名次数"`
-	ActivityNum         int       `description:"活动报名次数"`
-	TripNum             int       `description:"专项产业调研数量"`
-	RoadshowVideoNum    int       `description:"产业视频播放量"`
-	ActivityVideoNum    int       `description:"活动视频播放量"`
-	ActivityVoiceNum    int       `description:"活动音频播放量"`
-	RoadshowNum         int       `description:"路演播放总数量"`
-	TagNum              int       `description:"标签点击次数"`
-	CreateTime          time.Time `description:"创建时间"`
-	ModifyTime          time.Time `description:"更新时间"`
+	Id                       int       `orm:"column(id);pk"`
+	CompanyId                int       `description:"用户ID"`
+	ArticleHistoryNum        int       `description:"文章浏览数量"`
+	ArticleCountNum          int       `description:"文章收藏数量"`
+	ChartCountNum            int       `description:"图表收藏"`
+	IndustryFllowNum         int       `description:"产业关注数量"`
+	DepartmentFollowNum      int       `description:"作者关注数量"`
+	KeyWordNum               int       `description:"关键词搜索次数"`
+	ActivityOnLineNum        int       `description:"线上活动报名次数"`
+	ActivityOfficeNum        int       `description:"线下活动报名次数"`
+	ActivityNum              int       `description:"活动报名次数"`
+	TripNum                  int       `description:"专项产业调研数量"`
+	RoadshowVideoNum         int       `description:"产业视频播放量"`
+	ActivityVideoNum         int       `description:"活动视频播放量"`
+	ActivityVoiceNum         int       `description:"活动音频播放量"`
+	RoadshowNum              int       `description:"路演播放总数量"`
+	TagNum                   int       `description:"标签点击次数"`
+	YanxuanSpecialNum        int       `description:"研选专栏阅读数量"`
+	YanxuanSpecialCollectNum int       `description:"研选专栏收藏数量"`
+	YanxuanSpecialFollowNum  int       `description:"研选专栏作者关注数量"`
+	CreateTime               time.Time `description:"创建时间"`
+	ModifyTime               time.Time `description:"更新时间"`
 }
 
 // 添加
@@ -68,9 +71,85 @@ func GetCygxCompanyInteractionNumList() (items []*CygxCompanyInteractionNum, err
 	return
 }
 
-// 批量添加用户互动信息
+// 批量添加企业互动信息
 func AddCygxCompanyInteractionNumList(items []*CygxCompanyInteractionNum) (lastId int64, err error) {
 	o := orm.NewOrm()
-	_, err = o.InsertMulti(1, items)
+	_, err = o.InsertMulti(len(items), items)
+	return
+}
+
+// UpdateActivitySignupDetailMulti 批量修改
+func UpdateCygxCompanyInteractionNumMulti(items []*CygxCompanyInteractionNum) (err error) {
+	o := orm.NewOrm()
+	p, err := o.Raw(` UPDATE cygx_company_interaction_num SET 
+							article_history_num = ?,
+							article_count_num = ?,
+							industry_fllow_num = ?,
+							department_follow_num = ?,
+							key_word_num = ?,
+							activity_num = ?,
+							chart_count_num = ?,
+							trip_num = ?,
+							roadshow_video_num = ?,
+							activity_video_num = ?,
+							activity_voice_num = ?,
+							roadshow_num = ?,
+							tag_num = ?
+							WHERE company_id = ? `).Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close() // 别忘记关闭 statement
+	}()
+	for _, v := range items {
+		_, err = p.Exec(
+			v.ArticleHistoryNum,
+			v.ArticleCountNum,
+			v.ChartCountNum,
+			v.IndustryFllowNum,
+			v.DepartmentFollowNum,
+			v.KeyWordNum,
+			v.ActivityNum,
+			v.TripNum,
+			v.RoadshowVideoNum,
+			v.ActivityVideoNum,
+			v.ActivityVoiceNum,
+			v.RoadshowNum,
+			v.TagNum,
+			v.CompanyId)
+		if err != nil {
+			return
+		}
+	}
+	return
+}
+
+// 企业互动量
+type CompanyInteractionNumReq struct {
+	CompanyId            int `description:"用户ID"`
+	InteractionNum       int `description:"互动总量"`
+	InteractionNumSeller int `description:"销售可以查看的互动总量"`
+}
+
+// UpdateCompanyInteractionNumMulti 批量修改客户互动量
+func UpdateCompanyInteractionNumMulti(items []*CompanyInteractionNumReq) (err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
+	p, err := o.Raw(` UPDATE company SET interaction_num = ? ,  interaction_num_seller = ?  WHERE company_id=? `).Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close() // 别忘记关闭 statement
+	}()
+	for _, v := range items {
+		_, err = p.Exec(
+			v.InteractionNum,
+			v.InteractionNumSeller,
+			v.CompanyId)
+		if err != nil {
+			return
+		}
+	}
 	return
 }

+ 2 - 0
models/crm_company.go

@@ -36,6 +36,8 @@ type Company struct {
 	RegionType            string    `description:"地区类型,国内,国外"`
 	OpenCompanyCode       string    `description:"开放给第三方的客户编码,不让第三方定位我们的客户信息"`
 	TripartiteCompanyCode string    `description:"第三方给过来的客户编码,判断客户是否存在"`
+	InteractionNum        int       `description:"互动总量"`
+	InteractionNumSeller  int       `description:"销售可以查看的互动总量"`
 }
 
 type CompanyLog struct {

+ 11 - 2
models/cygx_yanxuan_special.go

@@ -102,8 +102,8 @@ type CygxYanxuanSpecialCenterResp struct {
 	Docs            []Doc
 	Annotation      string   `description:"核心观点"`
 	Source          string   `description:"来源"`
-	Pv              string   `description:"Pv"`
-	Uv              string   `description:"Uv"`
+	Pv              int      `description:"Pv"`
+	Uv              int      `description:"Uv"`
 	PublishDate     string   // 提审过审或驳回时间      string `description:"核心观点"`
 	BodyHighlight   []string `description:"搜索高亮展示结果"`
 }
@@ -357,3 +357,12 @@ func UpdateYanxuanSpecialarticleCollectNum(collectNum, id int) (err error) {
 	_, err = o.Raw(sql, collectNum, id).Exec()
 	return
 }
+
+// 添加朋友圈分享封面图片
+func UpdateYanxuanSpecialMomentsImg(momentsImg string, id int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET moments_img = ?  WHERE id = ? `
+	_, err = o.Raw(sql, momentsImg, id).Exec()
+	return
+}

+ 22 - 0
models/cygx_yanxuan_special_record.go

@@ -110,3 +110,25 @@ func GetCygxYanxuanSpecialRecordRespList(condition string, pars []interface{}, s
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
+
+type LisYanxuanSpecialRecordPvResp struct {
+	YanxuanSpecialId int `description:"文章ID"`
+	Pv               int `description:"pv"`
+	Uv               int `description:"pv"`
+}
+
+// pv 列表
+func GetCygxYanxuanSpecialRecordListPv(condition string, pars []interface{}) (items []*LisYanxuanSpecialRecordPvResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) AS pv,
+			yanxuan_special_id
+		FROM
+			cygx_yanxuan_special_record  WHERE 1 = 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY yanxuan_special_id  `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 9 - 0
models/cygx_yanxuan_special_user.go

@@ -46,6 +46,7 @@ type CygxYanxuanSpecialAuthorItem struct {
 	LatestPublishDate    string                              // 最近更新时间
 	IsFollow             int                                 // 是否已关注 1已关注 0 未关注
 	HasChangeHeadImg     int                                 // 是否更换过默认头像 1是,0否
+	MomentsImg           string                              `description:"分享到朋友圈的封面图片"`
 	YanxuanSpecialCenter *CygxYanxuanSpecialCenterAuthorResp // 研选专栏文章内容
 }
 
@@ -261,3 +262,11 @@ func UpdateYanxuanSpecialauthorUvUm(pv, userId int) (err error) {
 	_, err = o.Raw(sql, pv, userId).Exec()
 	return
 }
+
+// 更新作者分享到朋友圈的封面图片
+func UpdateYanxuanSpecialauthorMomentsImg(momentsImg string, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_yanxuan_special_author SET moments_img = ?  WHERE user_id = ? `
+	_, err = o.Raw(sql, momentsImg, userId).Exec()
+	return
+}

+ 1 - 1
models/home.go

@@ -19,7 +19,7 @@ func GetHomeCount(condition string, pars []interface{}) (count int, err error) {
 
 func GetHomeList(condition string, pars []interface{}, startSize, pageSize int) (items []*HomeArticle, err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv
+	sql := ` SELECT * 
                  FROM cygx_article AS a
                 WHERE a.publish_status=1 `
 	if condition != "" {

+ 5 - 2
models/report.go

@@ -224,6 +224,8 @@ func IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId int
 	o := orm.NewOrm()
 	sql := `SELECT
 			map.match_type_name,
+			map.sort,
+			map.id,
 			map.id AS category_id 
 		FROM
 			cygx_report_mapping_cygx AS map
@@ -242,6 +244,8 @@ func IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId int
 			map.match_type_name UNION ALL
 		SELECT
 			map.match_type_name,
+			map.sort,
+			map.id,
 			map.id AS category_id 
 		FROM
 			cygx_report_mapping_cygx AS map
@@ -254,7 +258,7 @@ func IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId int
 			AND art.visible_range = 1 
 			AND man_g.industrial_management_id = ? 
 		GROUP BY
-			map.match_type_name`
+				map.match_type_name  	ORDER BY  id ASC ,  sort DESC   `
 	_, err = o.Raw(sql, industrialManagementId, industrialManagementId).QueryRows(&items)
 	return
 }
@@ -539,7 +543,6 @@ func GetReportCollectionBillboardListYx(limit int, pars []interface{}, condition
 			a.article_type_id,
 			d.nick_name,
 			d.department_id,
-			( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
 			( SELECT count( 1 ) FROM cygx_article_collect AS ac   WHERE ac.article_id = a.article_id  ) AS collect_num, 
 			( SELECT count( 1 ) FROM cygx_article_collect AS ac   WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS collection_num
 		FROM

+ 8 - 1
models/report_mapping.go

@@ -42,6 +42,7 @@ type ReportMappingHome struct {
 	SubCategoryName string `description:"主题名称"`
 	MatchTypeName   string `description:"匹配类型"`
 	IsRed           bool   `description:"是否标红"`
+	ListGroup       int    `description:"第几组"`
 }
 
 type TradeReportMapping struct {
@@ -60,7 +61,11 @@ type ReportMappingResp struct {
 }
 
 type ReportMappingHomeResp struct {
-	List []*ReportMappingHome
+	List       []*ReportMappingHome
+	ListGroup1 []*ReportMappingHome
+	ListGroup2 []*ReportMappingHome
+	ListGroup3 []*ReportMappingHome
+	ListGroup4 []*ReportMappingHome
 }
 
 type TradeReportMappingResp struct {
@@ -99,6 +104,7 @@ func GetReportMappingStrategyHomeAllByCygx(chartPermissionId int) (items []*Repo
 	o := orm.NewOrm()
 	sql := `SELECT
 	re.id AS category_id,
+	re.list_group,
 	re.match_type_name 
 FROM
 	cygx_report_mapping_cygx AS re
@@ -108,6 +114,7 @@ WHERE
 	1 = 1 
 	AND re.chart_permission_id = ? 
 	AND re.report_type = 1 
+	AND re.list_group > 0 
 GROUP BY
 	re.match_type_name 
 ORDER BY

+ 10 - 9
models/search_key_word.go

@@ -6,15 +6,16 @@ import (
 )
 
 type CygxSearchKeyWord struct {
-	Id          int `orm:"column(id);" description:"id"`
-	KeyWord     string
-	UserId      int
-	CreateTime  time.Time
-	Mobile      string `description:"手机号"`
-	Email       string `description:"邮箱"`
-	CompanyId   int    `description:"公司id"`
-	CompanyName string `description:"公司名称"`
-	RealName    string `description:"用户实际名称"`
+	Id               int `orm:"column(id);" description:"id"`
+	KeyWord          string
+	UserId           int
+	CreateTime       time.Time
+	Mobile           string `description:"手机号"`
+	Email            string `description:"邮箱"`
+	CompanyId        int    `description:"公司id"`
+	CompanyName      string `description:"公司名称"`
+	RealName         string `description:"用户实际名称"`
+	RegisterPlatform int    `description:"来源 1小程序,2:网页"`
 }
 
 // 新增搜索

+ 17 - 0
models/seller.go

@@ -90,3 +90,20 @@ func GetAdminListByGroupId(groupId int) (items []*Admin, err error) {
 	_, err = o.Raw(sql, groupId).QueryRows(&items)
 	return
 }
+
+// 获取权益销售信息
+func GetRaiSellerByCompanyId(companyId int) (item *AdminItem, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := ` SELECT
+     		b.admin_id,
+			b.real_name,
+			b.mobile 
+		FROM
+			company_product AS a
+			INNER JOIN admin AS b ON a.seller_id = b.admin_id 
+		WHERE
+			a.product_id = 2 
+			AND a.company_id = ?`
+	err = o.Raw(sql, companyId).QueryRow(&item)
+	return
+}

+ 3 - 2
models/send_company_user.go

@@ -135,7 +135,8 @@ func GetSendCompanyPermissionDataList(condition string, pars []interface{}) (ite
 			WHERE
 				1 = 1
 				AND cp.STATUS IN ( '正式', '试用', '永续' )
-				AND c.chart_permission_name IN ( '医药', '消费', '科技', '智造', '策略', '研选扣点包', '专家', '路演服务','固收' ) ` + condition + ` GROUP BY c.permission_name, cp.company_id `
+				AND c.enabled = 1
+				AND c.chart_permission_name IN ( '医药', '消费', '科技', '智造', '策略', '研选扣点包', '专家', '路演服务','固收','周期' ) ` + condition + ` GROUP BY c.permission_name, cp.company_id `
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
@@ -155,7 +156,7 @@ func GetSendCompanyPermissionDataListNoChekcStatus(condition string, pars []inte
 			WHERE
 				1 = 1
 				AND cp.STATUS  NOT  IN ( '正式', '试用', '永续' )
-				AND c.chart_permission_name IN ( '医药', '消费', '科技', '智造', '策略', '研选扣点包', '专家', '路演服务' ,'固收' ) ` + condition + ` GROUP BY c.permission_name, cp.company_id `
+				AND c.chart_permission_name IN ( '医药', '消费', '科技', '智造', '策略', '研选扣点包', '专家', '路演服务' ,'固收','周期' ) ` + condition + ` GROUP BY c.permission_name, cp.company_id `
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }

+ 276 - 0
models/user_interaction_num.go

@@ -1,7 +1,9 @@
 package models
 
 import (
+	"fmt"
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_cygx/utils"
 	"time"
 )
 
@@ -74,3 +76,277 @@ func AddCygxUserInteractionNumList(items []*CygxUserInteractionNum) (lastId int6
 	_, err = o.InsertMulti(1, items)
 	return
 }
+
+// 联系人互动数量
+type CygxUserInteractionNumResp struct {
+	UserId         int `description:"用户ID"`
+	CompanyId      int `description:"公司ID"`
+	InteractionNum int `description:"互动数量"`
+}
+
+// 用户阅读记录数量统计
+func GetCygxArticleHistoryRecordInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_article_and_yanxuan_record AS h
+			INNER JOIN cygx_article AS art ON art.article_id = h.source_id 
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1 AND h.source = 'article'   ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户收藏文章数量统计
+func GetCygxArticleCollectInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_article_collect AS h
+			INNER JOIN cygx_article AS art ON art.article_id = h.article_id
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1  ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户收藏图表数量统计
+func GetCygxChartCollectInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_chart_collect AS h
+			INNER JOIN cygx_chart_all AS art ON art.chart_id = h.chart_id
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1  ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户关注产业数量统计
+func GetCygxIndustryFllowInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_industry_fllow AS h
+			INNER JOIN cygx_industrial_management AS art ON art.industrial_management_id = h.industrial_management_id
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1  AND h.type = 1  AND  h.source   IN (0,1,2) ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户搜索关键词数量统计
+func GetCygxSearchKeyWordInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_search_key_word AS h
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1  ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户活动报名参会数量统计
+func GetCygxActivitySignupInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_activity_signup_detail AS h
+			INNER JOIN cygx_activity AS art ON art.activity_id = h.activity_id
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1  ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户专项调研活动报名参会数量统计
+func GetCygxActivitySpecialSignupInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_activity_special_meeting_detail AS h
+			INNER JOIN cygx_activity_special AS art ON art.activity_id = h.activity_id
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1  ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户路演精华播放数量统计
+func GetCygxMicroRoadshowVideoHistoryInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_micro_roadshow_video_history AS h
+			INNER JOIN cygx_micro_roadshow_video AS art ON art.video_id = h.video_id
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1  ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户活动视频播放数量统计
+func GetCygxActivityVideoHistoryInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_activity_video_history AS h
+			INNER JOIN cygx_activity_video AS art ON art.activity_id = h.activity_id
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1  ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户活动音频播放数量统计
+func GetCygxActivityVoiceHistoryInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_activity_voice_history AS h
+			INNER JOIN cygx_activity_voice AS art ON art.activity_id = h.activity_id
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1  ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户首页标签点击量数量统计
+func GetCygxTagHistoryInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_tag_history AS h
+			INNER JOIN cygx_tag AS art ON art.tag_id = h.tag_id
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1  ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户关注研选作者数量统计
+func GetCygxArticleDepartmentFollowInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_article_department_follow AS h
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1  ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户收藏研选专栏数量统计
+func GetCygxYanxuanSpecialCollectInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_yanxuan_special_collect AS h
+			INNER JOIN cygx_yanxuan_special AS art ON art.id = h.yanxuan_special_id
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1  ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户关注研选专栏作者数量统计
+func GetCygxYanxuanSpecialFollowInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_yanxuan_special_follow AS h
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1  ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户研选专栏阅读数量数量统计
+func GetCygxYanxuanSpecialRecordInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
+	o := orm.NewOrm()
+	var sql string
+	sql += ` SELECT
+			COUNT( 1 ) AS interaction_num,
+			h.user_id,
+			h.company_id 
+		FROM
+			cygx_yanxuan_special_record AS h
+			INNER JOIN cygx_yanxuan_special AS art ON art.id = h.yanxuan_special_id
+			INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id  WHERE 1=1  ` + condition + ` GROUP BY w.user_id `
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 57 - 0
models/user_record.go

@@ -3,6 +3,7 @@ package models
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"hongze/hongze_cygx/utils"
+	"strings"
 	"time"
 )
 
@@ -189,3 +190,59 @@ func GetUserRecordListByMobileArr(mobiles []string) (items []*OpenIdList, err er
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+// 根据用户id和平台id获取用户关系
+func GetMfyxUserRecordByMobile(platform int, bindAccount string) (item *OpenIdList, err error) {
+	var sql string
+	sql = `SELECT open_id,cygx_user_id AS user_id  FROM	cygx_mfyx_gzh_user_record  WHERE	1 = 1  AND cygx_bind_account = ?`
+	err = orm.NewOrm().Raw(sql, bindAccount).QueryRow(&item)
+	return
+}
+
+// 根据手机号获取mfyx用户的openid
+func GetMfyxUserRecordListByMobileArr(mobiles []string) (items []*OpenIdList, err error) {
+	o := orm.NewOrm()
+	lenarr := len(mobiles)
+	if lenarr == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND u.cygx_bind_account IN (` + utils.GetOrmInReplace(lenarr) + `)`
+	pars = append(pars, mobiles)
+	sql := `SELECT
+			u.open_id,
+			u.cygx_user_id AS user_id 
+		FROM
+			cygx_mfyx_gzh_user_record AS u 
+		WHERE
+			1 = 1  ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+func GetMfyxWxOpenIdByMobileList(mobile string) (items []*OpenIdList, err error) {
+	sliceMobile := strings.Split(mobile, ",")
+	var mobiles []string
+	for _, v := range sliceMobile {
+		mobiles = append(mobiles, v)
+	}
+	o := orm.NewOrm()
+	lenarr := len(mobiles)
+	if lenarr == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND u.cygx_bind_account IN (` + utils.GetOrmInReplace(lenarr) + `)`
+	pars = append(pars, mobiles)
+	sql := `SELECT
+			u.open_id,
+			u.cygx_user_id AS user_id 
+		FROM
+			cygx_mfyx_gzh_user_record AS u 
+		WHERE
+			1 = 1  ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 22 - 0
models/wx_template_msg.go

@@ -96,3 +96,25 @@ func GetWxOpenIdByMobileSliceList(mobiles []string) (items []*OpenIdList, err er
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+// 根据手机号获取用户的openid
+func GetMfyxWxOpenIdByMobileSliceList(mobiles []string) (items []*OpenIdList, err error) {
+	o := orm.NewOrm()
+	lenarr := len(mobiles)
+	if lenarr == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND u.cygx_bind_account IN (` + utils.GetOrmInReplace(lenarr) + `)`
+	pars = append(pars, mobiles)
+	sql := `SELECT
+			u.open_id,
+			u.cygx_user_id AS user_id 
+		FROM
+			cygx_mfyx_gzh_user_record AS u 
+		WHERE
+			1 = 1  ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 3 - 2
services/activity.go

@@ -93,8 +93,9 @@ func SendActivityBeginMsgMeeting(cont context.Context) (err error) {
 	//func SendActivityBeginMsgMeeting() (err error) {
 	defer func() {
 		if err != nil {
-			go utils.SendAlarmMsg("15分钟会议消息提醒失败", 2)
-			fmt.Println("发送失败,Err:", err.Error())
+			//go utils.SendAlarmMsg("15分钟会议消息提醒失败", 2)
+			go utils.SendAlarmMsg(fmt.Sprint("15分钟会议消息提醒失败 SendActivityBeginMsgMeeting Err:", err.Error()), 2)
+			//fmt.Println("发送失败,Err:", err.Error())
 		}
 	}()
 	var condition string

+ 10 - 7
services/activity_special_trip.go

@@ -189,7 +189,8 @@ func CheckTripRemainingtimesBycompany(user *models.WxUserItem, activityInfo *mod
 	}
 
 	//判断是不是策略行业的活动,策略的任何一个行业有剩余点数都能参加
-	if chartPermissionName == utils.CE_LUE_NAME {
+	//if chartPermissionName == utils.CE_LUE_NAME {
+	if utils.InArrayByStr(utils.ACTIVITY_SPECIAL_TRIP_PERMISSION_NAME_OTHER, activityInfo.ChartPermissionName) {
 		return
 	} else {
 		for _, v := range activitySpecialPermissionPointsList {
@@ -226,7 +227,7 @@ func GetSpecialBillMaxChartPermissionId(user *models.WxUserItem) (maxChartPermis
 func DeductTripRemainingtimesByUser(user *models.WxUserItem, activityInfo *models.CygxActivitySpecialDetail) (err error) {
 	msgTemplate := "您的专项调研次数已用完,如仍想参加,请与您的对口销售商议"
 	companyId := user.CompanyId
-	chartPermissionName := activityInfo.ChartPermissionName
+	//chartPermissionName := activityInfo.ChartPermissionName
 
 	companyProduct, e := company.GetCompanyProductByCompanyIdAndProductId(companyId, utils.COMPANY_PRODUCT_RAI_ID)
 	if e != nil {
@@ -269,8 +270,9 @@ func DeductTripRemainingtimesByUser(user *models.WxUserItem, activityInfo *model
 		condition = " AND  company_id  = ?  AND points  > 0   ORDER BY  points DESC LIMIT 1   "
 		pars = append(pars, companyId)
 
-		//判断是不是策略、固收行业的活动,如果不是策略就获取对应行业的点数 ,策略的任何一个行业有剩余点数都能参加
-		if chartPermissionName != utils.CE_LUE_NAME && chartPermissionName != utils.GU_SHOU_NAME {
+		//判断是不是策略、固收、周期行业的活动,如果不是策略就获取对应行业的点数 ,策略的任何一个行业有剩余点数都能参加
+		//if chartPermissionName != utils.CE_LUE_NAME && chartPermissionName != utils.GU_SHOU_NAME {
+		if !utils.InArrayByStr(utils.ACTIVITY_SPECIAL_TRIP_PERMISSION_NAME_OTHER, activityInfo.ChartPermissionName) {
 			pars = make([]interface{}, 0)
 			condition = " AND  company_id  = ?  AND ( chart_permission_id  = ? OR  chart_permission_id =0 )    AND points  > 0   ORDER BY  points DESC LIMIT 1   "
 			pars = append(pars, companyId, activityInfo.ChartPermissionId)
@@ -302,14 +304,15 @@ func DeductTripRemainingtimesByUser(user *models.WxUserItem, activityInfo *model
 // RebateTripRemainingtimesByUser 返点用户专项调研剩余次数
 func RebateTripRemainingtimesByUser(user *models.WxUserItem, activityInfo *models.CygxActivitySpecialDetail) (err error) {
 	companyId := user.CompanyId
-	chartPermissionName := activityInfo.ChartPermissionName
+	//chartPermissionName := activityInfo.ChartPermissionName
 	var condition string
 	var pars []interface{}
 	condition = " AND  company_id  = ?    ORDER BY  points DESC LIMIT 1   "
 	pars = append(pars, companyId)
 
-	//判断是不是策略、固收行业的活动,如果不是策略就获取对应行业的点数 ,策略的任何一个行业有剩余点数都能参加
-	if chartPermissionName != utils.CE_LUE_NAME && chartPermissionName != utils.GU_SHOU_NAME {
+	//判断是不是策略、固收、周期行业的活动,如果不是策略就获取对应行业的点数 ,策略的任何一个行业有剩余点数都能参加
+	//if chartPermissionName != utils.CE_LUE_NAME && chartPermissionName != utils.GU_SHOU_NAME {
+	if !utils.InArrayByStr(utils.ACTIVITY_SPECIAL_TRIP_PERMISSION_NAME_OTHER, activityInfo.ChartPermissionName) {
 		pars = make([]interface{}, 0)
 		condition = " AND  company_id  = ? AND  (chart_permission_id  = ?   OR chart_permission_id = 0 )    LIMIT 1   "
 		pars = append(pars, companyId, activityInfo.ChartPermissionId)

+ 3 - 2
services/activity_task.go

@@ -74,8 +74,9 @@ func PushVmpRobotMeeting(cont context.Context) (err error) {
 	//func PushVmpRobotMeeting() (err error) {
 	defer func() {
 		if err != nil {
-			go utils.SendAlarmMsg("15分钟会议消息提醒失败", 2)
-			fmt.Println("发送失败,Err:", err.Error())
+			//go utils.SendAlarmMsg("15分钟会议消息提醒失败err :"+err.Error(), 2)
+			go utils.SendAlarmMsg(fmt.Sprint("研选活动会前15分钟推送给上海那边的机器人失败 PushVmpRobotMeeting Err:", err.Error()), 2)
+			//fmt.Println("发送失败,Err:", err.Error())
 		}
 	}()
 

+ 808 - 4
services/article.go

@@ -730,7 +730,7 @@ func UpdateArticleByRedis() (err error) {
 //	//for i := 8648; i < 9004; i++ {
 //	//	HandleArticleListByApi(9552)
 //	//}
-//	HandleArticleListByApi(9551)
+//	HandleArticleListByApi(10914)
 //	//UpdateArticleResourceData(9551)
 //}
 
@@ -858,6 +858,19 @@ func HandleArticleListByApi(artcleId int) (err error) {
 		item.CategoryIdTwo = exitMap[articleResult.SeriesId]
 		item.SubCategoryName = articleResult.Series.Name
 		item.Cover = cover
+
+		{
+			//这两种情况特殊处理
+			if articleResult.Field.Name == "宏观利率" {
+				item.CategoryId = 10070
+				item.CategoryIdTwo = item.CategoryId
+			}
+			if articleResult.Field.Name == "信用" {
+				item.CategoryId = 10082
+				item.CategoryIdTwo = item.CategoryId
+			}
+		}
+
 		if len(articleResult.Stock) > 0 {
 			var stock string
 			for _, vS := range articleResult.Stock {
@@ -1787,9 +1800,6 @@ func HandleArticleCategoryImg(list []*models.HomeArticle) (items []*models.HomeA
 		list[k].Annotation = ArticleAnnotation(item)
 		list[k].Body = ""
 		list[k].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
-		if item.Pv > 999 {
-			list[k].Pv = 999
-		}
 
 		list[k].ChartPermissionName = mapChartPerssion[v.CategoryId]
 		//如果是研选系列的任意取五张图片的中的一张
@@ -1842,6 +1852,7 @@ func HandleArticleCategoryImg(list []*models.HomeArticle) (items []*models.HomeA
 	for i := range list {
 		articleIds = append(articleIds, list[i].ArticleId)
 	}
+	articleMapPv := GetArticleHistoryByArticleId(articleIds) //文章Pv
 	// 报告关联产业信息
 	industryMap := make(map[int][]*models.IndustrialManagementIdInt, 0)
 	if len(articleIds) > 0 {
@@ -1870,6 +1881,10 @@ func HandleArticleCategoryImg(list []*models.HomeArticle) (items []*models.HomeA
 		} else {
 			list[k].List = make([]*models.IndustrialManagementIdInt, 0)
 		}
+		v.Pv = articleMapPv[v.ArticleId]
+		if v.Pv > 999 {
+			list[k].Pv = 999
+		}
 	}
 
 	if len(list) == 0 {
@@ -2279,3 +2294,792 @@ func GetYxArticleIdMap(articleIds []int) (mapResp map[int]bool) {
 	}
 	return
 }
+
+//func init() {
+//
+//	//listarticle, err := models.GetArticleInit13_5()
+//	//fmt.Println(err)
+//	//fmt.Println("listarticle", len(listarticle))
+//	//
+//	//for _, v := range listarticle {
+//	//	HandleArticleListByApiInit13_5(v.ArticleId)
+//	//}
+//	//HandleArticleListByApiInit13_5(10825)
+//
+//	listarticle, err := models.GetArticleInit13_5GuSHou()
+//	fmt.Println(err)
+//	fmt.Println("listarticle", len(listarticle))
+//
+//	for _, v := range listarticle {
+//		HandleArticleListByApiInit13_5GuShou(v.ArticleId)
+//	}
+//
+//}
+
+// 处理同步过来的文章
+func HandleArticleListByApiInit13_5(artcleId int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("处理同步策略平台数据失败"+"GetArticleListByApi ErrMsg:"+err.Error()+"artcleId:"+strconv.Itoa(artcleId), 2)
+			go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "GetArticleListByApi ErrMsg:"+err.Error()+"artcleId:"+strconv.Itoa(artcleId), utils.EmailSendToUsers)
+		}
+	}()
+	var clueApiUrl string
+	clueApiUrl = fmt.Sprint(utils.ApiUrl, "articles/", artcleId)
+	fmt.Println(clueApiUrl)
+
+	authorization := utils.ApiAuthorization
+	body, err := PublicGetDate(clueApiUrl, authorization)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	var articleResultDate models.ArticleDetailResultApi
+	err = json.Unmarshal(body, &articleResultDate)
+	if err != nil {
+		fmt.Println("Getres.PublicGetDate Err:", err.Error())
+		return err
+	}
+	item := new(models.CygxShanghaiCompanyLog)
+	item.CreateTime = time.Now()
+	item.Url = clueApiUrl
+	item.Body = ""
+	item.Result = string(body)
+
+	articleResult := articleResultDate.Data
+
+	exitMap := make(map[int]int)
+	categoryIdMap := make(map[int]int)
+	classMap := make(map[int]int)
+	reportMap := make(map[int]int)
+	summaryMap := make(map[int]int)
+	listMap, err := models.GetArticleApiMap()
+	if err != nil {
+		fmt.Println("GetlistMap Err:", err.Error())
+		return err
+	}
+
+	//新旧分类 反向隐射,是否归类,是否是报告,是否是纪要库
+	for _, v := range listMap {
+		exitMap[v.SeriesId] = v.OldId
+		categoryIdMap[v.SeriesId] = v.OldIdMap
+		if v.IsClass == 1 {
+			classMap[v.OldId] = 1
+		}
+		if v.IsReport == 1 {
+			reportMap[v.OldId] = 1
+		}
+		if v.IsSummary == 1 {
+			summaryMap[v.OldId] = 1
+		}
+	}
+	var list []*models.Tactics2
+	var listArticleData []*models.CygxArticleData
+	var listAuthor []*models.CygxArticleAuthor
+	//如果是英文报告 ,或者香港类型那么则不同步  publish_area   :all  全部  ;hk 香港
+	if articleResult.TypeId == 9 || articleResult.PublishArea != "all" {
+		// 如果是英文报告,或者是香港报告就进行删除处理
+		err = models.UpdateArticlePublish(artcleId, 0)
+		if err != nil {
+			fmt.Println("UpdateArticlePublish Err:", err.Error())
+			return err
+		}
+		UpdateArticleResourceData(artcleId) //把数据写入 cygx_resource_data 表
+		return
+	}
+
+	var cover string
+	if articleResult.Series.Name == "图解市场" {
+		cover = GetArticleCoverByChartFirst(articleResult.Content.Body)
+	} else if articleResult.Series.Name == "行业深度" {
+		cover = articleResult.Cover
+	}
+	fmt.Println(cover)
+	//return
+	//状态等于 2 跟 4 的进行同步 IsActive 为false 软删除的也不同步
+	if exitMap[articleResult.SeriesId] > 0 && (articleResult.PublishStatus == 2 || articleResult.PublishStatus == 4) && articleResult.IsActive {
+		articleResult.PublishDate = time.Date(articleResult.PublishDate.Year(), articleResult.PublishDate.Month(), articleResult.PublishDate.Day(), articleResult.PublishDate.Hour(), articleResult.PublishDate.Minute(), articleResult.PublishDate.Second(), articleResult.PublishDate.Nanosecond(), time.Local)
+		item := new(models.Tactics2)
+		itemArticleData := new(models.CygxArticleData)
+		itemArticleData.ArticleId = articleResult.ArticleId
+		itemArticleData.Cover = articleResult.Cover
+		itemArticleData.CreateTime = time.Now()
+		listArticleData = append(listArticleData, itemArticleData)
+		itemAuthor := new(models.CygxArticleAuthor)
+		item.ArticleId = articleResult.ArticleId
+		item.Title = articleResult.Title
+		item.TitleEn = articleResult.TitleEn
+		item.File = articleResult.File
+		if articleResult.Frequency == "日度" {
+			item.UpdateFrequency = "daily"
+		} else if articleResult.Frequency == "周度" {
+			item.UpdateFrequency = "weekly"
+		} else if articleResult.Frequency == "月度" {
+			item.UpdateFrequency = "monthly"
+		} else if articleResult.Frequency == "季度" {
+			item.UpdateFrequency = "quarterly"
+		} else if articleResult.Frequency == "年度" {
+			item.UpdateFrequency = "yearly"
+		} else {
+			item.UpdateFrequency = "unknow"
+		}
+		item.CreateDate = articleResult.CreateDate
+		item.PublishDate = articleResult.PublishDate.Add(time.Hour * 8)
+		item.PublishStatus = 1
+		item.Body = articleResult.Content.Body
+		item.Abstract = articleResult.Content.Abstract
+		item.Annotation = articleResult.Content.Annotation
+		item.CategoryName = articleResult.Industry.Name
+		item.CategoryId = categoryIdMap[articleResult.SeriesId]
+		item.CategoryIdTwo = exitMap[articleResult.SeriesId]
+		item.SubCategoryName = articleResult.Series.Name
+		item.Cover = cover
+
+		fmt.Println("item.CategoryIdTwo", item.CategoryIdTwo)
+		fmt.Println("item.CategoryId", item.CategoryId)
+
+		{
+			//这两种情况特殊处理
+			if articleResult.Field.Name == "宏观利率" {
+				item.CategoryId = 10070
+				item.CategoryIdTwo = item.CategoryId
+			}
+			if articleResult.Field.Name == "信用" {
+				item.CategoryId = 10082
+				item.CategoryIdTwo = item.CategoryId
+			}
+		}
+
+		if len(articleResult.Stock) > 0 {
+			var stock string
+			for _, vS := range articleResult.Stock {
+				stock += vS + "/"
+			}
+			stock = strings.TrimRight(stock, "/")
+			item.Stock = stock
+		}
+		item.FieldName = articleResult.Field.Name
+		item.TypeName = articleResult.Type.Name
+		item.UpdateDate = articleResult.UpdateDate
+		item.CeLueFieldId = articleResult.Field.Id
+		list = append(list, item)
+		itemAuthor.ArticleId = articleResult.ArticleId
+		itemAuthor.Name = articleResult.Author.Name
+		itemAuthor.Mobile = articleResult.Author.PhoneNumber
+		fmt.Println(articleResult.Cover)
+		listAuthor = append(listAuthor, itemAuthor)
+	} else {
+		// 如果这篇文章没有发布,那么就不作处理。
+		err = models.UpdateArticlePublish(artcleId, 0)
+		if err != nil {
+			fmt.Println("UpdateArticlePublish Err:", err.Error())
+			return err
+		}
+		UpdateArticleResourceData(artcleId) //把数据写入 cygx_resource_data 表
+		//go UpdateResourceData(artcleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
+		return
+	}
+
+	fmt.Println("同步文章条数:", len(list))
+	listCustomArticle, err := models.GetCustomArticleId() //手动归类的文章,不替换文章类型
+	if err != nil {
+		fmt.Println("GetTacticsList Err:", err.Error())
+		return err
+	}
+	listGetMatchTypeName, errMatch := models.GetMatchTypeNamenNotNull() //手动归类的文章,不替换文章类型
+	if errMatch != nil {
+		fmt.Println("GetTacticsList Err:", errMatch.Error())
+		return err
+	}
+	//mapCategoryIdSet := make(map[int]int)
+	//for _, vMatch := range listGetMatchTypeName {
+	//	mapCategoryIdSet[vMatch.CategoryId] = vMatch.CategoryIdSet
+	//}
+	fmt.Println("list len:", len(list))
+	noSummaryArticleIds := "" //非纪要库类型的文章ID
+	listNoSummaryArticleIds := strings.Split(noSummaryArticleIds, ",")
+	for k, v := range list {
+		//同步匹配类型
+		matchTypeName := ""
+		for _, vMatch := range listGetMatchTypeName {
+			if v.CategoryId == vMatch.CategoryId {
+				matchTypeName = vMatch.MatchTypeName
+			}
+		}
+		//是否属于纪要库的数据
+		//if _, has := summaryMap[v.CategoryId]; has {
+		//	v.IsSummary = 1
+		//}
+		if v.TypeName == "纪要" {
+			v.IsSummary = 1
+		}
+		//排除不属于纪要库类型的文章
+		for _, vArt := range listNoSummaryArticleIds {
+			vArtInt, _ := strconv.Atoi(vArt)
+			if v.ArticleId == vArtInt {
+				v.IsSummary = 0
+			}
+		}
+		if _, has := reportMap[v.CategoryIdTwo]; has {
+			v.IsReport = 1
+			if _, ok := classMap[v.CategoryIdTwo]; ok {
+				v.IsClass = 1
+				v.ReportType = 1 //是否属于行业报告
+			} else {
+				v.ReportType = 2 //是否属于产业报告
+			}
+		}
+		v.Department = "弘则权益研究"
+		//判断是否已经存在
+		if v.ArticleId < 0 {
+			fmt.Println("AddCygxArticle Err:")
+			return err
+		}
+		var count int
+		count, err = models.GetArticleCountById(v.ArticleId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			fmt.Println("AddCygxArticle Err:", err.Error())
+			return err
+		}
+		v.Body = strings.Replace(v.Body, "http://vmp.hzinsights.com", "https://vmp.hzinsights.com", -1)
+		expertNumStr, expertContentStr, interviewDateStr, _, bodyReturn := BodyAnalysis2(v.Body)
+		if strings.Index(v.Body, "报告全文(") > 0 && strings.Index(v.Body, "PDF格式报告下载.pdf") > 0 {
+			v.Body = strings.Replace(v.Body, "报告全文(", "", -1)
+			v.Body = strings.Replace(v.Body, "PDF格式报告下载.pdf", "", -1)
+			v.Body = strings.Replace(v.Body, "):", "", -1)
+		}
+		var titleNew string
+		titleNew = v.Title
+		// 7资金流向 、11大类资产 、51每日复盘 、80医药周报、9估值研究
+		if v.CategoryId == 7 || v.CategoryId == 11 || v.CategoryId == 51 || v.CategoryId == 9 {
+			if v.UpdateFrequency == "daily" {
+				var daystr string
+				daystr = strconv.Itoa(v.PublishDate.Day())
+				if len(daystr) == 1 {
+					daystr = "0" + daystr
+				}
+				titleNew = v.Title + "(" + strconv.Itoa(v.PublishDate.Year())[2:len(strconv.Itoa(v.PublishDate.Year()))-0] + v.PublishDate.Format("01") + daystr + ")"
+			} else if v.UpdateFrequency == "weekly" {
+				titleNew = v.Title + utils.WeekByDate(v.PublishDate)
+			}
+		}
+		if v.CategoryId == 80 {
+			titleNew = v.Title + utils.WeekByDate(v.PublishDate)
+		}
+
+		//类型是综述报告的,不区分是什么系列,统一归类到对应产业的路演精华
+		if articleResult.Type.Name == "综述报告" {
+			detailCategory, err := models.GetdetailByCategoryIdLyjh(v.CategoryIdTwo)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				return err
+			}
+			v.CategoryId = detailCategory.CategoryId
+			v.IsSummary = 0
+		}
+
+		if count > 0 {
+			fmt.Println(k, v.ArticleId, "edit")
+
+			bodyText, _ := GetReportContentTextSubNew(v.Body)
+
+			var isCustom bool
+			updateParams := make(map[string]interface{})
+			//updateParams["Title"] = v.Title
+			updateParams["Title"] = titleNew
+			updateParams["TitleEn"] = v.TitleEn
+			updateParams["UpdateFrequency"] = v.UpdateFrequency
+			updateParams["CreateDate"] = v.CreateDate
+			updateParams["PublishDate"] = v.PublishDate
+			//updateParams["Body"] = html.EscapeString(v.Body)
+			updateParams["Body"] = html.EscapeString(bodyReturn)
+			updateParams["BodyText"] = bodyText
+			updateParams["Abstract"] = html.EscapeString(v.Abstract)
+			updateParams["CategoryName"] = v.CategoryName
+			for _, vCustom := range listCustomArticle {
+				if v.ArticleId == vCustom.ArticleId {
+					fmt.Println("手动归类的文章:" + strconv.Itoa(v.ArticleId))
+					isCustom = true
+				}
+			}
+			if isCustom == false {
+				updateParams["CategoryId"] = v.CategoryId
+				updateParams["MatchTypeName"] = matchTypeName
+				updateParams["IsSummary"] = v.IsSummary
+				updateParams["IsReport"] = v.IsReport
+				updateParams["ReportType"] = v.ReportType
+				updateParams["SubCategoryName"] = v.SubCategoryName
+			}
+			//updateParams["CategoryId"] = v.CategoryId
+			updateParams["PublishStatus"] = 1
+			updateParams["ExpertBackground"] = expertContentStr
+			updateParams["ExpertNumber"] = expertNumStr
+			updateParams["InterviewDate"] = interviewDateStr
+			//updateParams["IsClass"] = v.IsClass
+			v.Department = "弘则权益研究"
+			updateParams["Department"] = v.Department
+			updateParams["FileLink"] = v.File
+			updateParams["Stock"] = v.Stock
+			updateParams["FieldName"] = v.FieldName
+			updateParams["Annotation"] = v.Annotation
+			updateParams["TypeName"] = v.TypeName
+			updateParams["ModifyTimeByCl"] = v.UpdateDate
+			updateParams["CeLueFieldId"] = v.CeLueFieldId
+			updateParams["Cover"] = v.Cover
+			//whereParam := map[string]interface{}{"article_id": v.ArticleId}
+			//err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
+			//if err != nil {
+			//	fmt.Println("UpdateByExpr Err:" + err.Error())
+			//	return err
+			//}
+			fmt.Println("v.ReportType", v.ReportType)
+
+			//if v.ReportType == 2 {
+			var subjectStr string
+			var industrialManagementIdStr string
+			var industrialSubjectIdStr string
+
+			sliceSubjects := strings.Split(v.Stock, "/")
+			mapManagementForSubject := make(map[string]string)
+			mapIndustrialId := make(map[int]int)
+			if len(sliceSubjects) > 0 {
+				for _, vSubject := range sliceSubjects {
+					sliceKuohao := strings.Split(vSubject, "(")           //过滤括号
+					sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
+					subject := sliceXiahuaxian[0]
+					subjectStr += "'" + subject + "',"
+				}
+				//获取该产业下所对应的行业图片
+				detailCategory, errCategory := models.GetdetailByCategoryIdOne(v.CategoryId)
+				if errCategory != nil {
+					fmt.Println("GetdetailByCategoryIdOne Err:", err.Error())
+					return err
+				}
+				subjectStr = strings.TrimRight(subjectStr, ",")
+				if subjectStr != "" {
+					listIndustrial, err := models.GetIndustrialManagementForSubjecName(subjectStr, detailCategory.ChartPermissionId)
+					if err != nil {
+						fmt.Println("GetIndustrialManagementForSubjecName Err:", err.Error())
+						return err
+					}
+					subjectStr = strings.Replace(subjectStr, "','", "】【", -1)
+					subjectStr = strings.Replace(subjectStr, "'", "", -1)
+					subjectStr = "【" + subjectStr + "】"
+					if len(listIndustrial) > 0 {
+						for _, vIndustrial := range listIndustrial {
+							if _, ok := mapIndustrialId[vIndustrial.IndustrialManagementId]; !ok {
+								industrialManagementIdStr += strconv.Itoa(vIndustrial.IndustrialManagementId) + ","
+							}
+							mapIndustrialId[vIndustrial.IndustrialManagementId] = vIndustrial.IndustrialManagementId
+							industrialSubjectIdStr += strconv.Itoa(vIndustrial.IndustrialSubjectId) + ","
+							mapManagementForSubject[vIndustrial.IndustryName] += vIndustrial.SubjectName + "/"
+							if vIndustrial.LayoutTime == "0000-00-00 00:00:00" {
+								go models.UpdateIndustrialManagementLayoutTime(v.PublishDate.AddDate(0, 0, -10).Format(utils.FormatDateTime), vIndustrial.IndustrialManagementId)
+							}
+						}
+
+						industrialManagementIdStr = strings.TrimRight(industrialManagementIdStr, ",")
+						industrialSubjectIdStr = strings.TrimRight(industrialSubjectIdStr, ",")
+						if industrialManagementIdStr != "" {
+							err = models.ReportArticleClassificationEditNew(artcleId, industrialManagementIdStr, v.ArticleId, industrialSubjectIdStr)
+							if err != nil {
+								fmt.Println("ReportArticleClassificationEditNew Err:", err.Error())
+								return err
+							}
+						}
+					}
+					//}
+				}
+			}
+
+		}
+	}
+
+	AddComprehensiveIndustrialSource("Hz", artcleId) // 同步到综合页面的搜索引擎(添加产业资源包)
+
+	AddCygxReportMappingCategoryGroupByArticleId(artcleId)
+	return err
+}
+
+func HandleArticleListByApiInit13_5GuShou(artcleId int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("处理同步策略平台数据失败"+"GetArticleListByApi ErrMsg:"+err.Error()+"artcleId:"+strconv.Itoa(artcleId), 2)
+			go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "GetArticleListByApi ErrMsg:"+err.Error()+"artcleId:"+strconv.Itoa(artcleId), utils.EmailSendToUsers)
+		}
+	}()
+	var clueApiUrl string
+	clueApiUrl = fmt.Sprint(utils.ApiUrl, "articles/", artcleId)
+	fmt.Println(clueApiUrl)
+
+	authorization := utils.ApiAuthorization
+	body, err := PublicGetDate(clueApiUrl, authorization)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	var articleResultDate models.ArticleDetailResultApi
+	err = json.Unmarshal(body, &articleResultDate)
+	if err != nil {
+		fmt.Println("Getres.PublicGetDate Err:", err.Error())
+		return err
+	}
+	item := new(models.CygxShanghaiCompanyLog)
+	item.CreateTime = time.Now()
+	item.Url = clueApiUrl
+	item.Body = ""
+	item.Result = string(body)
+
+	articleResult := articleResultDate.Data
+
+	exitMap := make(map[int]int)
+	categoryIdMap := make(map[int]int)
+	classMap := make(map[int]int)
+	reportMap := make(map[int]int)
+	summaryMap := make(map[int]int)
+	listMap, err := models.GetArticleApiMap()
+	if err != nil {
+		fmt.Println("GetlistMap Err:", err.Error())
+		return err
+	}
+
+	//新旧分类 反向隐射,是否归类,是否是报告,是否是纪要库
+	for _, v := range listMap {
+		exitMap[v.SeriesId] = v.OldId
+		categoryIdMap[v.SeriesId] = v.OldIdMap
+		if v.IsClass == 1 {
+			classMap[v.OldId] = 1
+		}
+		if v.IsReport == 1 {
+			reportMap[v.OldId] = 1
+		}
+		if v.IsSummary == 1 {
+			summaryMap[v.OldId] = 1
+		}
+	}
+	var list []*models.Tactics2
+	var listArticleData []*models.CygxArticleData
+	var listAuthor []*models.CygxArticleAuthor
+	//如果是英文报告 ,或者香港类型那么则不同步  publish_area   :all  全部  ;hk 香港
+	if articleResult.TypeId == 9 || articleResult.PublishArea != "all" {
+		// 如果是英文报告,或者是香港报告就进行删除处理
+		err = models.UpdateArticlePublish(artcleId, 0)
+		if err != nil {
+			fmt.Println("UpdateArticlePublish Err:", err.Error())
+			return err
+		}
+		UpdateArticleResourceData(artcleId) //把数据写入 cygx_resource_data 表
+		return
+	}
+
+	var cover string
+	if articleResult.Series.Name == "图解市场" {
+		cover = GetArticleCoverByChartFirst(articleResult.Content.Body)
+	} else if articleResult.Series.Name == "行业深度" {
+		cover = articleResult.Cover
+	}
+	fmt.Println(cover)
+	//return
+	//状态等于 2 跟 4 的进行同步 IsActive 为false 软删除的也不同步
+	if exitMap[articleResult.SeriesId] > 0 && (articleResult.PublishStatus == 2 || articleResult.PublishStatus == 4) && articleResult.IsActive {
+		articleResult.PublishDate = time.Date(articleResult.PublishDate.Year(), articleResult.PublishDate.Month(), articleResult.PublishDate.Day(), articleResult.PublishDate.Hour(), articleResult.PublishDate.Minute(), articleResult.PublishDate.Second(), articleResult.PublishDate.Nanosecond(), time.Local)
+		item := new(models.Tactics2)
+		itemArticleData := new(models.CygxArticleData)
+		itemArticleData.ArticleId = articleResult.ArticleId
+		itemArticleData.Cover = articleResult.Cover
+		itemArticleData.CreateTime = time.Now()
+		listArticleData = append(listArticleData, itemArticleData)
+		itemAuthor := new(models.CygxArticleAuthor)
+		item.ArticleId = articleResult.ArticleId
+		item.Title = articleResult.Title
+		item.TitleEn = articleResult.TitleEn
+		item.File = articleResult.File
+		if articleResult.Frequency == "日度" {
+			item.UpdateFrequency = "daily"
+		} else if articleResult.Frequency == "周度" {
+			item.UpdateFrequency = "weekly"
+		} else if articleResult.Frequency == "月度" {
+			item.UpdateFrequency = "monthly"
+		} else if articleResult.Frequency == "季度" {
+			item.UpdateFrequency = "quarterly"
+		} else if articleResult.Frequency == "年度" {
+			item.UpdateFrequency = "yearly"
+		} else {
+			item.UpdateFrequency = "unknow"
+		}
+		item.CreateDate = articleResult.CreateDate
+		item.PublishDate = articleResult.PublishDate.Add(time.Hour * 8)
+		item.PublishStatus = 1
+		item.Body = articleResult.Content.Body
+		item.Abstract = articleResult.Content.Abstract
+		item.Annotation = articleResult.Content.Annotation
+		item.CategoryName = articleResult.Industry.Name
+		item.CategoryId = categoryIdMap[articleResult.SeriesId]
+		item.CategoryIdTwo = exitMap[articleResult.SeriesId]
+		item.SubCategoryName = articleResult.Series.Name
+		item.Cover = cover
+
+		fmt.Println("item.CategoryIdTwo", item.CategoryIdTwo)
+		fmt.Println("item.CategoryId", item.CategoryId)
+
+		{
+			//这两种情况特殊处理
+			if articleResult.Field.Name == "宏观利率" {
+				item.CategoryId = 10070
+				item.CategoryIdTwo = item.CategoryId
+			}
+			if articleResult.Field.Name == "信用" {
+				item.CategoryId = 10082
+				item.CategoryIdTwo = item.CategoryId
+			}
+		}
+
+		if len(articleResult.Stock) > 0 {
+			var stock string
+			for _, vS := range articleResult.Stock {
+				stock += vS + "/"
+			}
+			stock = strings.TrimRight(stock, "/")
+			item.Stock = stock
+		}
+		item.FieldName = articleResult.Field.Name
+		item.TypeName = articleResult.Type.Name
+		item.UpdateDate = articleResult.UpdateDate
+		item.CeLueFieldId = articleResult.Field.Id
+		list = append(list, item)
+		itemAuthor.ArticleId = articleResult.ArticleId
+		itemAuthor.Name = articleResult.Author.Name
+		itemAuthor.Mobile = articleResult.Author.PhoneNumber
+		fmt.Println(articleResult.Cover)
+		listAuthor = append(listAuthor, itemAuthor)
+	} else {
+		// 如果这篇文章没有发布,那么就不作处理。
+		//err = models.UpdateArticlePublish(artcleId, 0)
+		//if err != nil {
+		//	fmt.Println("UpdateArticlePublish Err:", err.Error())
+		//	return err
+		//}
+		//UpdateArticleResourceData(artcleId) //把数据写入 cygx_resource_data 表
+		//go UpdateResourceData(artcleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
+		return
+	}
+
+	fmt.Println("同步文章条数:", len(list))
+	listCustomArticle, err := models.GetCustomArticleId() //手动归类的文章,不替换文章类型
+	if err != nil {
+		fmt.Println("GetTacticsList Err:", err.Error())
+		return err
+	}
+	listGetMatchTypeName, errMatch := models.GetMatchTypeNamenNotNull() //手动归类的文章,不替换文章类型
+	if errMatch != nil {
+		fmt.Println("GetTacticsList Err:", errMatch.Error())
+		return err
+	}
+	//mapCategoryIdSet := make(map[int]int)
+	//for _, vMatch := range listGetMatchTypeName {
+	//	mapCategoryIdSet[vMatch.CategoryId] = vMatch.CategoryIdSet
+	//}
+	fmt.Println("list len:", len(list))
+	noSummaryArticleIds := "" //非纪要库类型的文章ID
+	listNoSummaryArticleIds := strings.Split(noSummaryArticleIds, ",")
+	for k, v := range list {
+		//同步匹配类型
+		matchTypeName := ""
+		for _, vMatch := range listGetMatchTypeName {
+			if v.CategoryId == vMatch.CategoryId {
+				matchTypeName = vMatch.MatchTypeName
+			}
+		}
+		//是否属于纪要库的数据
+		//if _, has := summaryMap[v.CategoryId]; has {
+		//	v.IsSummary = 1
+		//}
+		if v.TypeName == "纪要" {
+			v.IsSummary = 1
+		}
+		//排除不属于纪要库类型的文章
+		for _, vArt := range listNoSummaryArticleIds {
+			vArtInt, _ := strconv.Atoi(vArt)
+			if v.ArticleId == vArtInt {
+				v.IsSummary = 0
+			}
+		}
+		if _, has := reportMap[v.CategoryIdTwo]; has {
+			v.IsReport = 1
+			if _, ok := classMap[v.CategoryIdTwo]; ok {
+				v.IsClass = 1
+				v.ReportType = 1 //是否属于行业报告
+			} else {
+				v.ReportType = 2 //是否属于产业报告
+			}
+		}
+		v.Department = "弘则权益研究"
+		//判断是否已经存在
+		if v.ArticleId < 0 {
+			fmt.Println("AddCygxArticle Err:")
+			return err
+		}
+		var count int
+		count, err = models.GetArticleCountById(v.ArticleId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			fmt.Println("AddCygxArticle Err:", err.Error())
+			return err
+		}
+		v.Body = strings.Replace(v.Body, "http://vmp.hzinsights.com", "https://vmp.hzinsights.com", -1)
+		expertNumStr, expertContentStr, interviewDateStr, _, bodyReturn := BodyAnalysis2(v.Body)
+		if strings.Index(v.Body, "报告全文(") > 0 && strings.Index(v.Body, "PDF格式报告下载.pdf") > 0 {
+			v.Body = strings.Replace(v.Body, "报告全文(", "", -1)
+			v.Body = strings.Replace(v.Body, "PDF格式报告下载.pdf", "", -1)
+			v.Body = strings.Replace(v.Body, "):", "", -1)
+		}
+		var titleNew string
+		titleNew = v.Title
+		// 7资金流向 、11大类资产 、51每日复盘 、80医药周报、9估值研究
+		if v.CategoryId == 7 || v.CategoryId == 11 || v.CategoryId == 51 || v.CategoryId == 9 {
+			if v.UpdateFrequency == "daily" {
+				var daystr string
+				daystr = strconv.Itoa(v.PublishDate.Day())
+				if len(daystr) == 1 {
+					daystr = "0" + daystr
+				}
+				titleNew = v.Title + "(" + strconv.Itoa(v.PublishDate.Year())[2:len(strconv.Itoa(v.PublishDate.Year()))-0] + v.PublishDate.Format("01") + daystr + ")"
+			} else if v.UpdateFrequency == "weekly" {
+				titleNew = v.Title + utils.WeekByDate(v.PublishDate)
+			}
+		}
+		if v.CategoryId == 80 {
+			titleNew = v.Title + utils.WeekByDate(v.PublishDate)
+		}
+
+		//类型是综述报告的,不区分是什么系列,统一归类到对应产业的路演精华
+		if articleResult.Type.Name == "综述报告" {
+			detailCategory, err := models.GetdetailByCategoryIdLyjh(v.CategoryIdTwo)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				return err
+			}
+			v.CategoryId = detailCategory.CategoryId
+			v.IsSummary = 0
+		}
+
+		if count > 0 {
+			fmt.Println(k, v.ArticleId, "edit")
+
+			bodyText, _ := GetReportContentTextSubNew(v.Body)
+
+			var isCustom bool
+			updateParams := make(map[string]interface{})
+			//updateParams["Title"] = v.Title
+			updateParams["Title"] = titleNew
+			updateParams["TitleEn"] = v.TitleEn
+			updateParams["UpdateFrequency"] = v.UpdateFrequency
+			updateParams["CreateDate"] = v.CreateDate
+			updateParams["PublishDate"] = v.PublishDate
+			//updateParams["Body"] = html.EscapeString(v.Body)
+			updateParams["Body"] = html.EscapeString(bodyReturn)
+			updateParams["BodyText"] = bodyText
+			updateParams["Abstract"] = html.EscapeString(v.Abstract)
+			updateParams["CategoryName"] = v.CategoryName
+			for _, vCustom := range listCustomArticle {
+				if v.ArticleId == vCustom.ArticleId {
+					fmt.Println("手动归类的文章:" + strconv.Itoa(v.ArticleId))
+					isCustom = true
+				}
+			}
+			if isCustom == false {
+				updateParams["CategoryId"] = v.CategoryId
+				updateParams["MatchTypeName"] = matchTypeName
+				updateParams["IsSummary"] = v.IsSummary
+				updateParams["IsReport"] = v.IsReport
+				updateParams["ReportType"] = v.ReportType
+				updateParams["SubCategoryName"] = v.SubCategoryName
+			}
+			//updateParams["CategoryId"] = v.CategoryId
+			updateParams["PublishStatus"] = 1
+			updateParams["ExpertBackground"] = expertContentStr
+			updateParams["ExpertNumber"] = expertNumStr
+			updateParams["InterviewDate"] = interviewDateStr
+			//updateParams["IsClass"] = v.IsClass
+			v.Department = "弘则权益研究"
+			updateParams["Department"] = v.Department
+			updateParams["FileLink"] = v.File
+			updateParams["Stock"] = v.Stock
+			updateParams["FieldName"] = v.FieldName
+			updateParams["Annotation"] = v.Annotation
+			updateParams["TypeName"] = v.TypeName
+			updateParams["ModifyTimeByCl"] = v.UpdateDate
+			updateParams["CeLueFieldId"] = v.CeLueFieldId
+			updateParams["Cover"] = v.Cover
+			whereParam := map[string]interface{}{"article_id": v.ArticleId}
+			err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
+			if err != nil {
+				fmt.Println("UpdateByExpr Err:" + err.Error())
+				return err
+			}
+			fmt.Println("v.ReportType", v.ReportType)
+
+			if v.ReportType == 2 {
+				var subjectStr string
+				var industrialManagementIdStr string
+				var industrialSubjectIdStr string
+
+				sliceSubjects := strings.Split(v.Stock, "/")
+				mapManagementForSubject := make(map[string]string)
+				mapIndustrialId := make(map[int]int)
+				if len(sliceSubjects) > 0 {
+					for _, vSubject := range sliceSubjects {
+						sliceKuohao := strings.Split(vSubject, "(")           //过滤括号
+						sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
+						subject := sliceXiahuaxian[0]
+						subjectStr += "'" + subject + "',"
+					}
+					//获取该产业下所对应的行业图片
+					detailCategory, errCategory := models.GetdetailByCategoryIdOne(v.CategoryId)
+					if errCategory != nil {
+						fmt.Println("GetdetailByCategoryIdOne Err:", err.Error())
+						return err
+					}
+					subjectStr = strings.TrimRight(subjectStr, ",")
+					if subjectStr != "" {
+						listIndustrial, err := models.GetIndustrialManagementForSubjecName(subjectStr, detailCategory.ChartPermissionId)
+						if err != nil {
+							fmt.Println("GetIndustrialManagementForSubjecName Err:", err.Error())
+							return err
+						}
+						subjectStr = strings.Replace(subjectStr, "','", "】【", -1)
+						subjectStr = strings.Replace(subjectStr, "'", "", -1)
+						subjectStr = "【" + subjectStr + "】"
+						if len(listIndustrial) > 0 {
+							for _, vIndustrial := range listIndustrial {
+								if _, ok := mapIndustrialId[vIndustrial.IndustrialManagementId]; !ok {
+									industrialManagementIdStr += strconv.Itoa(vIndustrial.IndustrialManagementId) + ","
+								}
+								mapIndustrialId[vIndustrial.IndustrialManagementId] = vIndustrial.IndustrialManagementId
+								industrialSubjectIdStr += strconv.Itoa(vIndustrial.IndustrialSubjectId) + ","
+								mapManagementForSubject[vIndustrial.IndustryName] += vIndustrial.SubjectName + "/"
+								if vIndustrial.LayoutTime == "0000-00-00 00:00:00" {
+									go models.UpdateIndustrialManagementLayoutTime(v.PublishDate.AddDate(0, 0, -10).Format(utils.FormatDateTime), vIndustrial.IndustrialManagementId)
+								}
+							}
+
+							industrialManagementIdStr = strings.TrimRight(industrialManagementIdStr, ",")
+							industrialSubjectIdStr = strings.TrimRight(industrialSubjectIdStr, ",")
+							if industrialManagementIdStr != "" {
+								err = models.ReportArticleClassificationEditNew(artcleId, industrialManagementIdStr, v.ArticleId, industrialSubjectIdStr)
+								if err != nil {
+									fmt.Println("ReportArticleClassificationEditNew Err:", err.Error())
+									return err
+								}
+							}
+						}
+						//}
+					}
+				}
+
+			}
+		}
+	}
+
+	AddComprehensiveIndustrialSource("Hz", artcleId) // 同步到综合页面的搜索引擎(添加产业资源包)
+
+	AddCygxReportMappingCategoryGroupByArticleId(artcleId)
+	return err
+}

+ 14 - 3
services/article_history.go

@@ -53,14 +53,24 @@ func GetArticleHistoryByArticleId(articleIds []int) (mapResp map[int]int) {
 	var pars []interface{}
 	condition = ` AND article_id IN (` + utils.GetOrmInReplace(lenIds) + `) `
 	pars = append(pars, articleIds)
-	list, err := models.GetCygxArticleHistoryRecordNewpvListPv(condition, pars)
-	if err != nil {
+	listCy, e := models.GetCygxArticleHistoryRecordNewpvListPvCy(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxArticleHistoryRecordNewpvListPvCy, Err: " + e.Error())
 		return
 	}
 	mapResp = make(map[int]int, 0)
-	for _, v := range list {
+	for _, v := range listCy {
 		mapResp[v.ArticleId] = v.Pv
 	}
+
+	listCl, e := models.GetCygxArticleHistoryRecordNewpvListPvCl(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxArticleHistoryRecordNewpvListPvCy, Err: " + e.Error())
+		return
+	}
+	for _, v := range listCl {
+		mapResp[v.ArticleId] += v.Pv
+	}
 	return
 }
 
@@ -126,6 +136,7 @@ func ArticleHistoryStopTime(articleId, stopTime, outType int, user *models.WxUse
 		record.CompanyName = user.CompanyName
 		record.StopTime = stopTime
 		record.OutType = outType
+		record.RegisterPlatform = utils.REGISTER_PLATFORM
 		record.Source = "MOBILE"
 		newId, e := models.AddCygxArticleViewRecordNewpv(record)
 		if e != nil {

+ 1 - 1
services/config.go

@@ -120,7 +120,7 @@ func CheckYxSpecialIsApprovalPersonnel(mobile string) (isApprovalPersonnel bool)
 	}()
 	var configCode string
 	//获取配置项里面审核人员的手机号
-	configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
+	configCode = utils.TPL_MSG_YAN_XUAN_SPECIAL_APPROVAL
 	cnf, e := models.GetConfigByCode(configCode)
 	if e != nil {
 		err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)

+ 41 - 4
services/cygx_yanxuan_special.go

@@ -1,6 +1,7 @@
 package services
 
 import (
+	"context"
 	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
@@ -84,7 +85,7 @@ func SendWxMsgSpecialFollow(specialId int) (err error) {
 	sendInfo.Keyword3 = keyword3
 	sendInfo.Keyword4 = keyword4
 	sendInfo.Remark = remark
-	sendInfo.TemplateId = utils.WxMsgTemplateIdAskMsgXzs
+	sendInfo.TemplateId = utils.WxMsgTemplateIdArticleUserRemind
 	sendInfo.RedirectUrl = redirectUrl
 	sendInfo.RedirectTarget = 3
 	sendInfo.Resource = strconv.Itoa(specialId)
@@ -97,7 +98,7 @@ func SendWxMsgSpecialFollow(specialId int) (err error) {
 	return
 }
 
-// SendReviewTemplateMsgAdmin 提交审核时给王芳,汪洋发消息
+// SendReviewTemplateMsgAdmin 提交审核时给王芳,葛琳发消息
 func SendReviewTemplateMsgAdmin(specialId int) (err error) {
 	defer func() {
 		if err != nil {
@@ -105,8 +106,8 @@ func SendReviewTemplateMsgAdmin(specialId int) (err error) {
 		}
 	}()
 	var configCode string
-	//如果是研选的就推送给汪洋跟王芳,否则就推送给王芳
-	configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
+	//研选专栏修改之后给这些手机号推送审核模版消息
+	configCode = utils.TPL_MSG_YAN_XUAN_SPECIAL_APPROVAL
 	cnf, e := models.GetConfigByCode(configCode)
 	if e != nil {
 		err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
@@ -192,6 +193,11 @@ func SendWxMsgSpecialAuthor(specialId, status int) (err error) {
 		return err
 	}
 
+	if len(openIdList) == 0 {
+		err = nil
+		return
+	}
+
 	keyword1 = "研选专栏内容审核"
 	if status == 1 {
 		keyword2 = "已通过审核,点击查看详情"
@@ -469,3 +475,34 @@ func GetYanxuanSpecialCollectMap(userId int) (mapResp map[int]bool, err error) {
 	}
 	return
 }
+
+//func init() {
+//	UpdateYanxuanSpecialAuthoMomentsImg()
+//}
+
+// 更新研选专栏作者朋友圈封面图片,并删除老的图片
+// func UpdateYanxuanSpecialAuthoMomentsImg() {
+func UpdateYanxuanSpecialAuthoMomentsImg(cont context.Context) (err error) {
+	//var err error
+	//time.Sleep(3*time.Second) // 有时候同时添加多个活动,延迟三秒
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go utils.SendAlarmMsg("生成研选专栏分享到朋友圈的图片,MakeArticleMomentsImg Err:"+err.Error(), 3)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	condition += ` AND  a.nick_name <> ''   `
+	condition += `	ORDER BY latest_publish_time DESC`
+	list, e := models.GetYanxuanSpecialAuthorList(condition, pars, 0, 999)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialAuthorList, Err: " + e.Error())
+		return
+	}
+	for _, v := range list {
+		time.Sleep(500 * time.Millisecond) // 延迟0.5秒
+		GetYanxuanSpecialAuthoMomentsImg(v.UserId)
+	}
+	return
+}

+ 31 - 11
services/cygx_yanxuan_special_company.go

@@ -77,16 +77,7 @@ func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err err
 	}()
 	var sellerName string
 	//获取销售信息
-	sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
-	if e != nil && e.Error() != utils.ErrNoRow() {
-		err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
-		return
-	}
-	if sellerItem == nil {
-		return
-	}
-	sellerName = sellerItem.RealName
-
+	sellerName, _ = GetSellerName(user)
 	if stopTime >= 3 {
 
 		//判断一个用户是否阅读过 某一篇研选专栏
@@ -168,10 +159,39 @@ func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err err
 	itemLog.RegisterPlatform = utils.REGISTER_PLATFORM
 	itemLog.YanxuanSpecialId = specialId
 	itemLog.StopTime = stopTime
-	_, e = models.AddCygxYanxuanSpecialRecordLog(itemLog) // 添加历史记录
+	_, e := models.AddCygxYanxuanSpecialRecordLog(itemLog) // 添加历史记录
 	if e != nil {
 		err = errors.New("AddCygxYanxuanSpecialRecordLog, Err: " + e.Error())
 		return
 	}
 	return
 }
+
+// GetYanxuanSpecialRecordByYanxuanSpecialId 获取研选专栏阅读 pv map
+func GetYanxuanSpecialRecordByYanxuanSpecialId(articleIds []int) (mapResp map[int]int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("获取研选专栏阅读,信息失败,GetYanxuanSpecialRecordByYanxuanSpecialId Err:"+err.Error(), 3)
+		}
+	}()
+	lenIds := len(articleIds)
+	if lenIds == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND yanxuan_special_id IN (` + utils.GetOrmInReplace(lenIds) + `) `
+	pars = append(pars, articleIds)
+	listPv, e := models.GetCygxYanxuanSpecialRecordListPv(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxArticleHistoryRecordNewpvListPvCy, Err: " + e.Error())
+		return
+	}
+	mapResp = make(map[int]int, 0)
+	for _, v := range listPv {
+		mapResp[v.YanxuanSpecialId] = v.Pv
+	}
+	return
+}

+ 265 - 0
services/html2Img.go

@@ -0,0 +1,265 @@
+package services
+
+import (
+	"encoding/json"
+	"errors"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"io/ioutil"
+	"net/http"
+	"strconv"
+	"strings"
+)
+
+var (
+	ServerUrl                = "http://127.0.0.1:5008/"
+	Cygx_activity_sigin_html = "cygx_activity_sigin_html"
+	Cygx_mp3_html            = "cygx_mp3_html"
+	Cygx_mp4_html            = "cygx_mp4_html"
+)
+
+type Html2ImgResp struct {
+	Code int    `json:"code"`
+	Msg  string `json:"msg"`
+	Data string `json:"data"`
+}
+
+// postHtml2Img 请求htm2img接口
+func postHtml2Img(param map[string]interface{}) (resp *Html2ImgResp, err error) {
+	// 目前仅此处调用该接口,暂不加授权、校验等
+	postUrl := ServerUrl + "htm2img"
+	postData, err := json.Marshal(param)
+	if err != nil {
+		return
+	}
+	result, err := Html2ImgHttpPost(postUrl, string(postData), "application/json")
+	if err != nil {
+		return
+	}
+	if err = json.Unmarshal(result, &resp); err != nil {
+		return
+	}
+	return resp, nil
+}
+
+// Html2ImgHttpPost post请求
+func Html2ImgHttpPost(url, postData string, params ...string) ([]byte, error) {
+	body := ioutil.NopCloser(strings.NewReader(postData))
+	client := &http.Client{}
+	req, err := http.NewRequest("POST", url, body)
+	if err != nil {
+		return nil, err
+	}
+	contentType := "application/x-www-form-urlencoded;charset=utf-8"
+	if len(params) > 0 && params[0] != "" {
+		contentType = params[0]
+	}
+	req.Header.Set("Content-Type", contentType)
+	resp, err := client.Do(req)
+	if err != nil {
+		return nil, err
+	}
+	defer resp.Body.Close()
+	b, err := ioutil.ReadAll(resp.Body)
+	fmt.Println("HttpPost:" + string(b))
+	return b, err
+}
+
+//func init() {
+//MakeYanxuanSpecialMomentsImg(185)
+//var condition string
+//var pars []interface{}
+//condition += ` AND a.status = 3 `
+//
+//list, err := models.GetYanxuanSpecialList(0, condition, pars, 0, 999)
+//fmt.Println(err)
+//for _, v := range list {
+//	MakeYanxuanSpecialMomentsImg(v.Id)
+//}
+
+//GetYanxuanSpecialAuthoListMomentsImg()
+//}
+
+// 生成研选专栏分享到朋友圈的图片
+func MakeYanxuanSpecialMomentsImg(specialId int) (imgUrl string) {
+	var err error
+	//time.Sleep(3*time.Second) // 有时候同时添加多个活动,延迟三秒
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go utils.SendAlarmMsg("生成研选专栏分享到朋友圈的图片,MakeYanxuanSpecialMomentsImg Err:"+err.Error()+"专栏ID"+strconv.Itoa(specialId), 3)
+		}
+	}()
+	detail, e := models.GetYanxuanSpecialById(specialId, 0)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialById, Err: " + e.Error())
+		return
+	}
+	go GetYanxuanSpecialAuthoListMomentsImg() //有专栏生成的时候,最新专栏列表封面图
+	configCode := "yanxuan_special_moments_img_html"
+	detailConfig, e := models.GetConfigByCode(configCode)
+	if e != nil {
+		err = errors.New("GetCygxConfigDetailByCode 获取生成研选专栏分享到朋友圈的图片格式信息失败, Err: " + e.Error())
+		return
+	}
+	var typeName, content string
+	if detail.Type == 1 {
+		typeName = "笔记"
+	} else {
+		typeName = "观点"
+	}
+	content, _ = GetReportContentTextSubNew(detail.Content)
+	configValue := detailConfig.ConfigValue
+	configValue = strings.Replace(configValue, "{{HeadImg}}", detail.HeadImg, -1)
+	configValue = strings.Replace(configValue, "{{NickName}}", detail.NickName, -1)
+	configValue = strings.Replace(configValue, "{{TypeName}}", typeName, -1)
+	configValue = strings.Replace(configValue, "{{PublishTime}}", detail.PublishTime, -1)
+	configValue = strings.Replace(configValue, "{{Title}}", detail.Title, -1)
+	configValue = strings.Replace(configValue, "{{Content}}", content, -1)
+
+	htm2ImgReq := make(map[string]interface{})
+	htm2ImgReq["html_content"] = configValue
+	htm2ImgReq["width"] = 2250
+	htm2ImgReq["height"] = 3813
+	res, err := postHtml2Img(htm2ImgReq)
+	if err != nil || res == nil {
+		err = errors.New("html转图片失败: " + res.Msg)
+		return
+	}
+	if res.Code != 200 {
+		err = errors.New("html转图片失败: " + res.Msg)
+		return
+	}
+	imgUrl = res.Data
+
+	err = models.UpdateYanxuanSpecialMomentsImg(imgUrl, specialId)
+
+	return
+}
+
+// 生成研选专栏列表分享到朋友圈的图片
+func GetYanxuanSpecialAuthoListMomentsImg() (imgUrl string) {
+	var err error
+	//time.Sleep(3*time.Second) // 有时候同时添加多个活动,延迟三秒
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go utils.SendAlarmMsg("生成研选专栏分享到朋友圈的图片,MakeArticleMomentsImg Err:"+err.Error(), 3)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	condition += ` AND  a.nick_name <> ''   `
+	condition += `	ORDER BY latest_publish_time DESC`
+	list, e := models.GetYanxuanSpecialAuthorList(condition, pars, 0, 1)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialAuthorList, Err: " + e.Error())
+		return
+	}
+
+	var SpecialName, HeadImg, NickName, Introduction, PublishTime, Title string
+	var userIds []int
+	for _, v := range list {
+		SpecialName = v.SpecialName
+		HeadImg = v.HeadImg
+		NickName = v.NickName
+		Introduction = v.Introduction
+		userIds = append(userIds, v.UserId)
+	}
+	bestNew := GetBestNewYanxuanSpecialByUserId(userIds)
+	for _, v := range list {
+		if bestNew[v.UserId] != nil {
+			PublishTime = bestNew[v.UserId].PublishTime
+			Title = bestNew[v.UserId].Title
+		}
+	}
+	configCode := "special_author_list_moments_img_html"
+	detailConfig, e := models.GetConfigByCode(configCode)
+	if e != nil {
+		err = errors.New("GetCygxConfigDetailByCode 获取生成研选专栏分享到朋友圈的图片格式信息失败, Err: " + e.Error())
+		return
+	}
+	configValue := detailConfig.ConfigValue
+	configValue = strings.Replace(configValue, "{{SpecialName}}", SpecialName, -1)
+	configValue = strings.Replace(configValue, "{{HeadImg}}", HeadImg, -1)
+	configValue = strings.Replace(configValue, "{{NickName}}", NickName, -1)
+	configValue = strings.Replace(configValue, "{{Introduction}}", Introduction, -1)
+	configValue = strings.Replace(configValue, "{{PublishTime}}", PublishTime, -1)
+	configValue = strings.Replace(configValue, "{{Title}}", Title, -1)
+
+	htm2ImgReq := make(map[string]interface{})
+	htm2ImgReq["html_content"] = configValue
+	htm2ImgReq["width"] = 2250
+	htm2ImgReq["height"] = 3813
+	res, err := postHtml2Img(htm2ImgReq)
+	if err != nil || res == nil {
+		err = errors.New("html转图片失败: " + res.Msg)
+		return
+	}
+	if res.Code != 200 {
+		err = errors.New("html转图片失败: " + res.Msg)
+		return
+	}
+	imgUrl = res.Data
+	configCodeUpdate := "special_author_list_moments_img"
+	err = models.UpdateConfigByCode(imgUrl, configCodeUpdate)
+	return
+}
+
+// 生成研选专栏分享到朋友圈的图片
+func GetYanxuanSpecialAuthoMomentsImg(userId int) (err error) {
+	//var err error
+	//time.Sleep(3*time.Second) // 有时候同时添加多个活动,延迟三秒
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go utils.SendAlarmMsg("生成研选专栏分享到朋友圈的图片,GetYanxuanSpecialAuthoMomentsImg Err:"+err.Error()+"用户ID"+strconv.Itoa(userId), 3)
+		}
+	}()
+
+	authorInfo, e := models.GetYanxuanSpecialAuthor(userId, 0, "")
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialAuthor, Err: " + e.Error())
+		return
+	}
+
+	configCode := "special_author_moments_img_html"
+	detailConfig, e := models.GetConfigByCode(configCode)
+	if e != nil {
+		err = errors.New("GetCygxConfigDetailByCode 获取生成研选专栏分享到朋友圈的图片格式信息失败, Err: " + e.Error())
+		return
+	}
+	configValue := detailConfig.ConfigValue
+	configValue = strings.Replace(configValue, "{{HeadImg}}", authorInfo.HeadImg, -1)
+	configValue = strings.Replace(configValue, "{{SpecialName}}", authorInfo.SpecialName, -1)
+	configValue = strings.Replace(configValue, "{{NickName}}", authorInfo.NickName, -1)
+	configValue = strings.Replace(configValue, "{{SpecialArticleNum}}", strconv.Itoa(authorInfo.SpecialArticleNum), -1)
+	configValue = strings.Replace(configValue, "{{CollectNum}}", strconv.Itoa(authorInfo.CollectNum), -1)
+	configValue = strings.Replace(configValue, "{{FollowNum}}", strconv.Itoa(authorInfo.FollowNum), -1)
+	configValue = strings.Replace(configValue, "{{Introduction}}", authorInfo.Introduction, -1)
+
+	htm2ImgReq := make(map[string]interface{})
+	htm2ImgReq["html_content"] = configValue
+	htm2ImgReq["width"] = 2250
+	htm2ImgReq["height"] = 3813
+	res, err := postHtml2Img(htm2ImgReq)
+	if err != nil || res == nil {
+		err = errors.New("html转图片失败: " + res.Msg)
+		return
+	}
+	if res.Code != 200 {
+		err = errors.New("html转图片失败: " + res.Msg)
+		return
+	}
+	imgUrl := res.Data
+	e = models.UpdateYanxuanSpecialauthorMomentsImg(imgUrl, userId)
+	if e != nil {
+		err = errors.New("UpdateYanxuanSpecialauthorMomentsImg Err: " + e.Error())
+		return
+	}
+	DeleteUploadFileToAliyun(authorInfo.MomentsImg) // 删除老的图片
+	fmt.Println(imgUrl)
+	return
+
+}

+ 1 - 0
services/keyword.go

@@ -30,6 +30,7 @@ func AddSearchKeyWord(user *models.WxUserItem, keyWord string, source int) (err
 	keyWordItem.CompanyId = user.CompanyId
 	keyWordItem.CompanyName = user.CompanyName
 	keyWordItem.RealName = user.RealName
+	keyWordItem.RegisterPlatform = utils.REGISTER_PLATFORM
 	_, err = models.AddSearchKeyWord(keyWordItem)
 	go AddUserSearchLog(user, keyWord, source)
 	go SearchKeywordUserRmind(user, keyWord)

+ 51 - 6
services/oss.go

@@ -1,8 +1,10 @@
 package services
 
 import (
+	"fmt"
 	"github.com/aliyun/aliyun-oss-go-sdk/oss"
 	"os"
+	"strings"
 	"time"
 
 	"hongze/hongze_cygx/utils"
@@ -26,7 +28,7 @@ func init() {
 }
 */
 
-//图片上传到阿里云
+// 图片上传到阿里云
 func UploadAliyun(filename, filepath string) (string, error) {
 	client, err := oss.New(utils.Endpoint, utils.AccessKeyId, utils.AccessKeySecret)
 	if err != nil {
@@ -46,7 +48,7 @@ func UploadAliyun(filename, filepath string) (string, error) {
 	return path, err
 }
 
-//音频上传到阿里云
+// 音频上传到阿里云
 func UploadAudioAliyun(filename, filepath string) (string, error) {
 	client, err := oss.New(utils.Endpoint, utils.AccessKeyId, utils.AccessKeySecret)
 	if err != nil {
@@ -66,7 +68,7 @@ func UploadAudioAliyun(filename, filepath string) (string, error) {
 	return path, err
 }
 
-//视频上传到阿里云
+// 视频上传到阿里云
 func UploadVideoAliyun(filename, filepath, savePath string) error {
 	defer func() {
 		os.Remove(filepath)
@@ -90,7 +92,7 @@ func UploadVideoAliyun(filename, filepath, savePath string) error {
 	return err
 }
 
-//PDF上传到阿里云
+// PDF上传到阿里云
 func UploadPdfAliyun(filename, filepath string) (string, error) {
 	client, err := oss.New(utils.Endpoint, utils.AccessKeyId, utils.AccessKeySecret)
 	if err != nil {
@@ -115,7 +117,7 @@ const (
 	HzBucketName string = "hzchart"
 )
 
-//上传文件到阿里云
+// 上传文件到阿里云
 func UploadFileToAliyun(filename, filepath, savePath string) error {
 	defer func() {
 		os.Remove(filepath)
@@ -172,4 +174,47 @@ func GetCloudDiskResourceFileTypeExtMap() map[string]string {
 		".mp3": "https://hzstatic.hzinsights.com/static/icon/file_type_audio.png",
 		".wma": "https://hzstatic.hzinsights.com/static/icon/file_type_audio.png",
 	}
-}
+}
+
+//func init() {
+//	DeleteUploadFileToAliyun("https://hzstatic.hzinsights.com/static/images/htm2img/9iElUd8oxpWgggf5pcKOCB8LZTiB.jpg")
+//}
+
+// 根据图片路径删除阿里云上的文件
+func DeleteUploadFileToAliyun(imgUrl string) error {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go utils.SendAlarmMsg("删除Oss图片失败, Err:"+err.Error()+"图片路径:"+imgUrl, 3)
+		}
+	}()
+	client, err := oss.New(HzEndpoint, utils.AccessKeyId, utils.AccessKeySecret)
+	if err != nil {
+		return err
+	}
+	bucket, err := client.Bucket(HzBucketName)
+	if err != nil {
+		return err
+	}
+	var objectName string
+	sliceObj := strings.Split(imgUrl, ".com/")
+	if len(sliceObj) == 2 {
+		objectName = sliceObj[1]
+	}
+	if objectName == "" {
+		return err
+	}
+	fmt.Println(objectName)
+
+	//return err
+	// 如需删除文件夹,请将objectName设置为对应的文件夹名称。如果文件夹非空,则需要将文件夹下的所有object删除后才能删除该文件夹。
+	//objectName = "static/images/htm2img/G32q2Lgp6soeh7xOW12yfZ4zC2uK.jpg"
+
+	// 删除单个文件。
+	err = bucket.DeleteObject(objectName)
+	if err != nil {
+		return err
+	}
+	return err
+}

+ 8 - 8
services/sms.go

@@ -21,16 +21,16 @@ func SendSmsCode(mobile, vcode string) bool {
 	var netReturn map[string]interface{}
 	err = json.Unmarshal(result, &netReturn)
 	if err != nil {
-		go utils.SendAlarmMsg("短信验证码发送失败", 1)
-		go utils.SendEmail("短信验证码发送失败", "err:"+err.Error()+" result"+string(result), utils.EmailSendToUsers)
+		go utils.SendAlarmMsg("短信验证码发送失败err:"+err.Error()+" result"+string(result)+"mobile:"+mobile, 1)
+		//go utils.SendEmail("短信验证码发送失败", "err:"+err.Error()+" result"+string(result), utils.EmailSendToUsers)
 		flag = false
 	}
 	if netReturn["error_code"].(float64) == 0 {
 		fmt.Printf("接口返回result字段是:\r\n%v", netReturn["result"])
 		flag = true
 	} else {
-		go utils.SendAlarmMsg("短信验证码发送失败", 1)
-		go utils.SendEmail("短信验证码发送失败", " result"+string(result), utils.EmailSendToUsers)
+		go utils.SendAlarmMsg("短信验证码发送失败 result"+string(result)+"mobile:"+mobile, 1)
+		//go utils.SendEmail("短信验证码发送失败", " result"+string(result), utils.EmailSendToUsers)
 		flag = false
 	}
 	return flag
@@ -74,16 +74,16 @@ func SendSmsCodeGj(mobile, vcode, areaNum string) bool {
 	var netReturn map[string]interface{}
 	err = json.Unmarshal(result, &netReturn)
 	if err != nil {
-		go utils.SendAlarmMsg("短信验证码发送失败", 1)
-		go utils.SendEmail("短信验证码发送失败", "err:"+err.Error()+" result"+string(result), utils.EmailSendToUsers)
+		go utils.SendAlarmMsg("国际短信验证码发送失败err:"+err.Error()+" result"+string(result)+"mobile:"+mobile, 1)
+		//go utils.SendEmail("短信验证码发送失败", "err:"+err.Error()+" result"+string(result), utils.EmailSendToUsers)
 		flag = false
 	}
 	if netReturn["error_code"].(float64) == 0 {
 		fmt.Printf("接口返回result字段是:\r\n%v", netReturn["result"])
 		flag = true
 	} else {
-		go utils.SendAlarmMsg("短信验证码发送失败", 1)
-		go utils.SendEmail("短信验证码发送失败", " result"+string(result), utils.EmailSendToUsers)
+		go utils.SendAlarmMsg("国际短信验证码发送失败 result"+string(result)+"mobile:"+mobile, 1)
+		//go utils.SendEmail("短信验证码发送失败", " result"+string(result), utils.EmailSendToUsers)
 		flag = false
 	}
 	return flag

+ 15 - 0
services/tag.go

@@ -256,6 +256,21 @@ func GetConditionInitByTagIds(tagIds string, chartPermissionId int) (conditionIn
 
 	case 4: // 语音问答
 		conditionInit = "   AND source = '" + utils.CYGX_OBJ_ASKSERIEVIDEO + "'"
+
+	case 5: //固定标签【跟踪】,包含以下系列:医药-趋势观察 ,科技-产业跟踪 ,智造-产业跟踪 ,消费-月度调研 ,周期-(周度观点,产业跟踪)
+		condition = " AND sub_category_name  IN ('趋势观察','产业跟踪','月度调研')  AND category_name IN ('医药行业','智造行业','消费行业','科技行业') OR  ( sub_category_name IN  ('周度观点','产业跟踪')  AND  category_name  = '周期' )  AND publish_status = 1 "
+		pars = make([]interface{}, 0)
+		articleList, e := models.GetArticleList(condition, pars)
+		if e != nil {
+			err = errors.New("GetArticleList, Err: " + e.Error())
+			return
+		}
+		//文章一定会有值,这里就不做为空判断了 。。。
+		var articleIds []string
+		for _, v := range articleList {
+			articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
+		}
+		conditionInit = "  AND source_id IN ( " + strings.Join(articleIds, ",") + ")  AND source = '" + utils.CYGX_OBJ_ARTICLE + "'"
 	}
 
 	return

+ 13 - 1
services/task.go

@@ -131,6 +131,18 @@ func Task() {
 		updateCygxUserYanxuanPermissionToClose := task.NewTask("updateCygxUserYanxuanPermissionToClose", "0 10 1 * * *", UpdateCygxUserYanxuanPermissionToClose)
 		task.AddTask("updateCygxUserYanxuanPermissionToClose", updateCygxUserYanxuanPermissionToClose) //关闭到期个人用户研选权限
 
+		updateYanxuanSpecialAuthoMomentsImg := task.NewTask("updateYanxuanSpecialAuthoMomentsImg", "0 0 1 * * *", UpdateYanxuanSpecialAuthoMomentsImg)
+		task.AddTask(" 更新研选专栏作者朋友圈封面图片,并删除老的图片", updateYanxuanSpecialAuthoMomentsImg) // 更新研选专栏作者朋友圈封面图片,并删除老的图片
+
+		sendMfyxEmailFileForAskMsgResearch := task.NewTask("sendMfyxEmailFileForAskMsgResearch", "0 */5 6-23 * * *", SendMfyxEmailFileForAskMsgResearch) //研选系列专家电话会,会前1小时将问题列表发送给邮箱
+		task.AddTask("sendMfyxEmailFileForAskMsgResearch", sendMfyxEmailFileForAskMsgResearch)
+
+		sendMfyxActivityBeginMsgMeeting := task.NewTask("sendMfyxActivityBeginMsgMeeting", "0 */5 6-23 * * *", SendMfyxActivityBeginMsgMeeting) //会议前15分钟的提醒
+		task.AddTask("sendMfyxActivityBeginMsgMeeting", sendMfyxActivityBeginMsgMeeting)
+
+		sendMfyxActivityBeginMsg := task.NewTask("sendMfyxActivityBeginMsg", "0 */5 6-23 * * *", SendMfyxActivityBeginMsg) //会议前60分钟的提醒
+		task.AddTask("sendMfyxActivityBeginMsg", sendMfyxActivityBeginMsg)
+
 		cancelCygxOrder := task.NewTask("CancelCygxOrder", "0 */1 * * * *", CancelCygxOrder)
 		task.AddTask("十分钟内未付款的订单自动取消", cancelCygxOrder) //十分钟内未付款的订单自动取消
 
@@ -139,8 +151,8 @@ func Task() {
 
 		handleOrderRefundHandleask := task.NewTask("HandleOrderRefundHandleask", "0 */1 * * * *", HandleOrderRefundHandleask)
 		task.AddTask("定时任务处理退款回调", handleOrderRefundHandleask) //定时任务处理退款回调
-
 	}
+
 	//if utils.RunMode != "release" {
 	//	getArticleListByApi := task.NewTask("getArticleListByApi", "0 */60 * * * *", GetArticleListByApi) //通过三方接口获取策略平台上的文章
 	//	task.AddTask("getArticleListByApi", getArticleListByApi)

+ 3 - 0
services/user_label.go

@@ -215,6 +215,9 @@ func ArticleHistoryUserLabelLogReduce(log models.CygxUserLabelLogRedis) (err err
 
 	articleId := log.SourceId
 	userId := log.UserId
+	if userId == 0 || articleId == 0 {
+		return
+	}
 	var source int
 	user, e := models.GetWxUserItemByUserId(userId)
 	if e != nil {

+ 36 - 0
services/user_permission.go

@@ -2,6 +2,7 @@ package services
 
 import (
 	"errors"
+	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
 	"strings"
@@ -115,3 +116,38 @@ func GetUserRaiPermissionYanXuanInfo(user *models.WxUserItem) (hasPermission int
 	}
 	return
 }
+
+// 获取权益销售姓名
+func GetSellerName(user *models.WxUserItem) (sellerName string, sellerId int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("获取权益销售姓名失败 GetSellerName, err:", err.Error()), 2)
+		}
+	}()
+	companyId := user.CompanyId
+	//潜在客户没有销售
+	if user.CompanyId <= 1 {
+		return
+	}
+	//权益客户
+	raiCount, e := models.GetCompanyProductCount(companyId, utils.COMPANY_PRODUCT_RAI_ID)
+	if e != nil {
+		err = errors.New("GetCompanyProductCount, Err: " + e.Error())
+		return
+	}
+	//仅开通FICC的客户不展示销售姓名
+	if raiCount == 0 {
+		return
+	}
+	sealldetail, e := models.GetRaiSellerByCompanyId(companyId)
+	if e != nil {
+		err = errors.New("GetRaiSellerByCompanyId, Err: " + e.Error())
+		return
+	}
+	sellerName = sealldetail.RealName
+	sellerId = sealldetail.AdminId
+	return
+
+}

+ 603 - 0
services/wx_category_template_msg.go

@@ -0,0 +1,603 @@
+package services
+
+import (
+	"context"
+	"encoding/json"
+	"errors"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"io/ioutil"
+	"net/http"
+	"strconv"
+	"strings"
+	"time"
+)
+
+type SendWxCategoryTemplate struct {
+	WxAppId        string   `description:"公众号appId"`
+	Keywords       []string `description:"模板消息keyword字段"`
+	TemplateId     string   `description:"模板id"`
+	RedirectUrl    string   `description:"跳转地址"`
+	RedirectTarget int      `description:"小程序跳转目标:1:弘则研报小程序,2:随手办公小程序,3:查研观向,4:买方研选"`
+	Resource       string   `description:"资源唯一标识"`
+	SendType       int      `description:"发送的消息类型:1:报告,2:指标更新提醒,3:审批通知,4:销售领取客户通知,5:活动取消通知,6活动更改时间通知,7:关注的作者发布报告通知,8:发送日报(周报、双周报、月报)模板消息,9:活动预约/报名时间通知"`
+	OpenIdArr      []string `description:"消息接收者openid"`
+}
+
+// 推送类目模板消息
+func SendCategoryTemplateMsg(sendInfo *SendWxCategoryTemplate) (err error) {
+	if len(sendInfo.OpenIdArr) == 0 {
+		return
+	}
+
+	postData, err := json.Marshal(sendInfo)
+	if err != nil {
+		go utils.SendAlarmMsg("SendCategoryTemplateMsg json.Marshal Err:"+err.Error(), 1)
+		return err
+	}
+	body := ioutil.NopCloser(strings.NewReader(string(postData)))
+	client := &http.Client{}
+	req, err := http.NewRequest("POST", utils.SendWxCategoryTemplateMsgUrl, body)
+	if err != nil {
+		go utils.SendAlarmMsg("SendCategoryTemplateMsg http.NewRequest Err:"+err.Error(), 1)
+		return err
+	}
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("Authorization", utils.SendTemplateMsgAuthorization)
+	resp, err := client.Do(req)
+	if err != nil {
+		fmt.Println("http client.Do Err:" + err.Error())
+		return err
+	}
+	defer resp.Body.Close()
+	b, err := ioutil.ReadAll(resp.Body)
+	if err != nil {
+		return err
+	}
+	result := new(models.BaseResponse)
+	err = json.Unmarshal(b, &result)
+	if err != nil {
+		return err
+	}
+	if result.Ret != 200 {
+		err = errors.New(string(b))
+		return err
+	}
+	return
+}
+
+// 帮我带问的问题,会前1小时发送
+func SendMfyxEmailFileForAskMsgResearch(cont context.Context) (err error) {
+	var msg string
+	//var touser string
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("发送附件模版消息失败:"+err.Error(), 2)
+			go utils.SendEmail("发送附件模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format(utils.FormatDateTime), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
+		}
+		if msg != "" {
+			go utils.SendAlarmMsg(msg, 2)
+			utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
+		}
+	}()
+	endDate := time.Now().Add(+time.Minute * 60).Format(utils.FormatDateTime)
+	condition := `AND  a.activity_type_id = 1 AND a.chart_permission_id = 31 `
+	total, err := models.GetCountActivityResearchToSendFile(condition, endDate)
+	if total == 0 {
+		fmt.Println("发送附件完成0")
+		return nil
+	}
+	if err != nil {
+		msg = "发送附件模版消息失败 Err:" + err.Error()
+		return
+	}
+	listActivity, err := models.GetActivityResearchToSendFile(condition, endDate)
+	if err != nil {
+		msg = "发送附件模版消息失败 Err:" + err.Error()
+		return
+	}
+	for _, v := range listActivity {
+		activityInfo, _ := models.GetAddActivityInfoById(v.ActivityId)
+		if activityInfo == nil {
+			msg = "活动不存在,Err:activityId:" + strconv.Itoa(v.ActivityId)
+			return
+		}
+		list, errFile := models.GetActivityMsgExport(v.ActivityId)
+		if errFile != nil {
+			msg = "获取失败,Err:" + errFile.Error()
+			return
+		}
+
+		for _, v2 := range list {
+			user, e := models.GetWxUserItemByUserId(v2.UserId)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				err = errors.New("GetWxUserItemByUserId, Err: " + e.Error())
+				return err
+			}
+			//获取销售信息
+			sellerItem, e := models.GetSellerByCompanyIdCheckFicc(v2.CompanyId, 2)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
+				return
+			}
+
+			//给所属销售推送消息
+			if sellerItem != nil && user != nil {
+				openIpItem, _ := models.GetMfyxUserRecordByMobile(12, sellerItem.Mobile)
+				openIdList := make([]*models.OpenIdList, 0)
+				openIdList = append(openIdList, openIpItem)
+				SendWxCategoryMsgWithActivityAsk(user.CompanyName, user.RealName, sellerItem.RealName, time.Now().Format(utils.FormatDateTimeMinute2), v2.Content, openIdList, v.ActivityId)
+			}
+		}
+		errFile = models.UPdateActivityMsgToSendFile(v.ActivityId)
+		if errFile != nil {
+			msg = "获取失败,Err:" + errFile.Error()
+			return
+		}
+	}
+	return
+}
+
+// 发送报告提问消息提醒
+func SendWxCategoryMsgWithActivityAsk(companyName, realName, sellerName, askTime, askMsg string, openIdList []*models.OpenIdList, msgId int) (err error) {
+	if len(openIdList) == 0 {
+		return
+	}
+	var msg string
+	defer func() {
+		if err != nil {
+			go utils.SendEmail("发送类目模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
+			go utils.SendAlarmMsg(fmt.Sprint("发送报告提问消息提醒类目模版消息失败,用户名", realName, "留言ID:", msgId), 2)
+			utils.FileLog.Info("发送类目模版消息失败,Err:%s", err.Error())
+		}
+		fmt.Println("line 21", err, msg)
+	}()
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var keyword5 string
+
+	keyword1 = realName
+	keyword2 = companyName
+	keyword3 = sellerName
+	keyword4 = askTime
+	keyword5 = utils.TruncateActivityNameString("活动提问:" + askMsg)
+
+	keywords := []string{keyword1, keyword2, keyword3, keyword4, keyword5}
+
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	redirectUrl := utils.WX_MSG_PATH_YX_ACTIVITY_DETAIL + strconv.Itoa(msgId)
+
+	sendInfo := new(SendWxCategoryTemplate)
+	sendInfo.Keywords = keywords
+	sendInfo.TemplateId = utils.WxCategoryMsgTemplateIdApplyXzs
+	sendInfo.RedirectTarget = 4
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	sendInfo.RedirectUrl = redirectUrl
+	err = SendCategoryTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}
+
+// 推送会议开始消息提醒60分钟前
+func SendMfyxActivityBeginMsg(cont context.Context) (err error) {
+	//func SendActivityBeginMsg() (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("60分钟会议消息提醒失败"+err.Error(), 2)
+			fmt.Println("发送失败,Err:", err.Error())
+		}
+	}()
+	endDate := time.Now().Add(+time.Minute * 60).Format(utils.FormatDateTime)
+	listActivity, err := models.GetMfyxActivitySendMsgListAll(endDate)
+	fmt.Println(len(listActivity))
+	if err != nil {
+		fmt.Println("GetActivitySendMsgListAll Err:", err.Error())
+		return
+	}
+	if len(listActivity) == 0 {
+		return
+	}
+	//var remark = "点击查看活动详情"
+	var signupIds string
+	for _, v := range listActivity {
+		signupIds += strconv.Itoa(v.Id) + ","
+		//var reserveResults string
+		//var first string
+		openIdItem := new(models.OpenIdList)
+		openIdItem.OpenId = v.OpenId
+		openIdItem.UserId = v.UserId
+		openIdList := make([]*models.OpenIdList, 0)
+		openIdList = append(openIdList, openIdItem)
+
+		openIdArr := make([]string, 0)
+		for _, v := range openIdList {
+			openIdArr = append(openIdArr, v.OpenId)
+		}
+		keywords := []string{utils.TruncateActivityNameString(v.ActivityName), v.ActivityTime}
+
+		sendInfo := new(SendWxCategoryTemplate)
+		sendInfo.Keywords = keywords
+		sendInfo.TemplateId = utils.WxMsgCategoryTemplateIdArticleUserRemind
+		sendInfo.RedirectTarget = 4
+		sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+		sendInfo.OpenIdArr = openIdArr
+		sendInfo.RedirectUrl = utils.WX_MSG_PATH_YX_ACTIVITY_DETAIL + strconv.Itoa(v.ActivityId)
+		err = SendCategoryTemplateMsg(sendInfo)
+		if err != nil {
+			return
+		}
+	}
+	if len(signupIds) == 0 {
+		return
+	}
+	signupIds = strings.TrimRight(signupIds, ",")
+	err = models.UPdateSendedMsgStatus(signupIds)
+	if err != nil {
+		var msg string
+		go utils.SendEmail("发送模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format(utils.FormatDateTime), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
+		utils.FileLog.Info("发送模版消息失败,Err:%s", err.Error())
+	}
+	return
+}
+
+// 推送会议开始消息提醒15分钟前
+func SendMfyxActivityBeginMsgMeeting(cont context.Context) (err error) {
+	//func SendActivityBeginMsgMeeting() (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("15分钟会议消息提醒失败:"+err.Error(), 2)
+			fmt.Println("发送失败,Err:", err.Error())
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	endDate := time.Now().Add(+time.Minute * 15).Format(utils.FormatDateTime)
+	condition = ` AND activity_time <= ? AND activity_time >= NOW()  AND  publish_status = 1 `
+	pars = append(pars, endDate)
+	listActivity, e := models.GetCygxActivityList(condition, pars, 0, 100000)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCygxActivityList, Err: " + e.Error())
+		return
+	}
+	if len(listActivity) == 0 {
+		return
+	}
+	//var signupIds string
+	//var remark = "点击查看活动详情"
+
+	var activityIds []int
+	//同一时间举办的活动不多所以这里循环查询
+	for _, v := range listActivity {
+		activityIds = append(activityIds, v.ActivityId)
+		var mobiles []string
+		pars = make([]interface{}, 0)
+		condition = ` AND activity_id = ?  AND is_send_wx_msg = 0 `
+		pars = append(pars, v.ActivityId)
+		//获取设置消息提醒的用户列表
+		listxReminder, e := models.GetCygxReminderListByUser(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxReminderListByUser, Err: " + e.Error())
+			return
+		}
+		for _, vReminder := range listxReminder {
+			mobiles = append(mobiles, vReminder.Mobile)
+		}
+
+		pars = make([]interface{}, 0)
+		condition = ` AND do_fail_type = 0 AND activity_id  = ? AND signup_type = 1  AND is_send_wx_msg = 0 `
+		pars = append(pars, v.ActivityId)
+		//获取设置预约外呼的用户列表
+		listSignup, e := models.GetActivitySignupList(condition, pars)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetActivitySignupList, Err: " + e.Error())
+			return
+		}
+		for _, vSignup := range listSignup {
+			mobiles = append(mobiles, vSignup.Mobile)
+		}
+		//获取这些手机号对应的Openid
+		listOpenid, e := models.GetMfyxUserRecordListByMobileArr(mobiles)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetUserRecordListByMobileArr, Err: " + e.Error())
+			return
+		}
+		openIdList := make([]*models.OpenIdList, 0)
+		for _, vOpenid := range listOpenid {
+			openIdItem := new(models.OpenIdList)
+			openIdItem.OpenId = vOpenid.OpenId
+			openIdItem.UserId = vOpenid.UserId
+			openIdList = append(openIdList, openIdItem)
+		}
+		openIdArr := make([]string, 0)
+		for _, v := range openIdList {
+			openIdArr = append(openIdArr, v.OpenId)
+		}
+		keywords := []string{utils.TruncateActivityNameString(v.ActivityName), v.ActivityTime}
+
+		sendInfo := new(SendWxCategoryTemplate)
+		sendInfo.Keywords = keywords
+		sendInfo.TemplateId = utils.WxMsgCategoryTemplateIdArticleUserRemind
+		sendInfo.RedirectTarget = 4
+		sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+		sendInfo.OpenIdArr = openIdArr
+		sendInfo.RedirectUrl = utils.WX_MSG_PATH_YX_ACTIVITY_DETAIL + strconv.Itoa(v.ActivityId)
+		err = SendCategoryTemplateMsg(sendInfo)
+		if err != nil {
+			return
+		}
+	}
+	err = models.UpdateSendedMsgMeetingSendWxMsg(activityIds)
+	return
+}
+
+// 线下调研活动扫码签到给对应销售发类目模班消息
+func SendActivitieSignCategoryTemplateMsg(user *models.WxUserItem, activityDetail *models.ActivityDetail) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("线下调研活动扫码签到给对应销售发模班消息推送失败 SendActivitieSignCategoryTemplateMsg 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, utils.MobileWuAngDi, utils.MobileDongHeng, utils.MobileShenTao)
+	}
+
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var keyword5 string
+
+	var redirectUrl string
+
+	keyword1 = user.RealName
+	keyword2 = user.CompanyName
+	keyword3 = sellerItem.RealName
+	keyword4 = utils.TruncateActivityNameString(activityDetail.ActivityName)
+	keyword5 = time.Now().Format(utils.FormatDateTimeMinute2)
+
+	openIdList, e := models.GetMfyxWxOpenIdByMobileSliceList(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_YX_SIGNUP_DETAIL + strconv.Itoa(activityDetail.ActivityId)
+
+	keywords := []string{keyword1, keyword2, keyword3, keyword4, keyword5}
+	sendInfo := new(SendWxCategoryTemplate)
+	sendInfo.Keywords = keywords
+	sendInfo.TemplateId = utils.WxCategoryMsgTemplateIdActivitySign
+	sendInfo.RedirectTarget = 4
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	sendInfo.RedirectUrl = redirectUrl
+	err = SendCategoryTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}
+
+// 研选专栏审核完成时,给提交人发送类目模板消息
+func SendWxCategoryMsgSpecialAuthor(specialId, status int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("研选专栏审核完成时,给提交人发送模板消息 SendWxCategoryMsgSpecialAuthor ", specialId, ", specialId", err.Error()), 2)
+		}
+	}()
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var redirectUrl string
+
+	specialItem, e := models.GetYanxuanSpecialItemById(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
+		return
+	}
+	user, e := models.GetWxUserItemByUserId(specialItem.UserId)
+	if e != nil {
+		err = errors.New("GetWxUserItemByUserId, Err: " + e.Error())
+		return err
+	}
+
+	openIdList, err := models.GetMfyxWxOpenIdByMobileList(user.Mobile)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+
+	if len(openIdList) == 0 {
+		return
+	}
+
+	keyword1 = utils.TruncateActivityNameString(specialItem.Title)
+	keyword2 = specialItem.NickName
+	if status == 1 {
+		keyword3 = "文章已通过审核,点击查看详情"
+		redirectUrl = utils.WX_MSG_PATH_YX_SPECIAL_DETAIL + strconv.Itoa(specialId)
+	} else {
+		keyword3 = "文章未通过审核,点击查看驳回原因"
+		redirectUrl = utils.WX_MSG_PATH_YX_SPECIAL_CENTER
+	}
+	keyword4 = time.Now().Format(utils.FormatDateTimeMinute2)
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+
+	keywords := []string{keyword1, keyword2, keyword3, keyword4}
+
+	sendInfo := new(SendWxCategoryTemplate)
+	sendInfo.Keywords = keywords
+	sendInfo.TemplateId = utils.WxMsgCategoryTemplateIdCompanyApprovalMessageRai
+	sendInfo.RedirectTarget = 4
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	sendInfo.RedirectUrl = redirectUrl
+	err = SendCategoryTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}
+
+// 研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
+func SendWxCategoryMsgSpecialFollow(specialId int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("研选专栏有新内容审核通过时,给关注此专栏的客户发送类目模板消息失败", specialId, ", specialId", err.Error()), 2)
+		}
+	}()
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+
+	followers, e := models.GetYanxuanSpecialFollowUserById(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
+		return
+	}
+	if len(followers) == 0 {
+		return
+	}
+	specialItem, e := models.GetYanxuanSpecialItemById(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
+		return
+	}
+	var allInUserId string
+	for _, v := range followers {
+		allInUserId += strconv.Itoa(v) + ","
+	}
+
+	allInUserId = strings.TrimRight(allInUserId, ",")
+
+	userList, err := models.GetWxUserListByUserIds(allInUserId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+
+	var mobiles []string
+	for _, v := range userList {
+		if v.Mobile != "" {
+			mobiles = append(mobiles, v.Mobile)
+		}
+	}
+
+	openIdList, e := models.GetMfyxUserRecordListByMobileArr(mobiles)
+	if e != nil {
+		err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+		return
+	}
+	if len(openIdList) == 0 {
+		return
+	}
+
+	keyword1 = specialItem.SpecialName
+	keyword2 = "发布了新报告"
+	keyword3 = specialItem.Title
+	keyword4 = time.Now().Format(utils.FormatDateTimeMinute2)
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	redirectUrl := ""
+	redirectUrl = utils.WX_MSG_PATH_YX_SPECIAL_DETAIL + strconv.Itoa(specialId)
+	keywords := []string{keyword1, keyword2, keyword3, keyword4}
+
+	sendInfo := new(SendWxCategoryTemplate)
+	sendInfo.Keywords = keywords
+	sendInfo.TemplateId = utils.WxMsgCategoryTemplateIdActivityPublishApply
+	sendInfo.RedirectTarget = 4
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	sendInfo.RedirectUrl = redirectUrl
+	err = SendCategoryTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}
+
+// SendReviewCategoryTemplateMsgAdmin 提交审核时给王芳、葛琳和沈涛发研选类目模板消息
+func SendReviewCategoryTemplateMsgAdmin(specialId int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("处理试用申请给王芳,汪洋发消息失败, specialId:", specialId, "ErrMsg", err.Error()), 2)
+		}
+	}()
+	//王芳、葛琳和沈涛
+	mobile := utils.WxMsgTemplateIdAskMsgMobilePublic + utils.RAI_MOBILE_GE_LIN_WEN
+	openIdList, e := models.GetMfyxWxOpenIdByMobileList(mobile)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetUserRecordListByMobile, Err: " + e.Error())
+		return err
+	}
+	if len(openIdList) == 0 {
+		return
+	}
+
+	specialItem, e := models.GetYanxuanSpecialItemById(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
+		return
+	}
+	user, e := models.GetWxUserItemByUserId(specialItem.UserId)
+	if e != nil {
+		err = errors.New("GetWxUserItemByUserId, Err: " + e.Error())
+		return err
+	}
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var keyword5 string
+	keyword1 = specialItem.NickName
+	keyword2 = specialItem.RealName + "-" + user.CompanyName
+	keyword2 = utils.TruncateActivityNameString(keyword2)
+	keyword3 = specialItem.SpecialName
+	keyword4 = time.Now().Format(utils.FormatDateTimeMinute2)
+	keyword5 = "研选专栏提交了内容待审核"
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	redirectUrl := utils.WX_MSG_PATH_YX_SPECIAL_ENABLE_DETAIL + strconv.Itoa(specialId)
+
+	keywords := []string{keyword1, keyword2, keyword3, keyword4, keyword5}
+
+	sendInfo := new(SendWxCategoryTemplate)
+	sendInfo.Keywords = keywords
+	sendInfo.TemplateId = utils.WxCategoryMsgTemplateIdApplyXzs
+	sendInfo.RedirectTarget = 4
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	sendInfo.RedirectUrl = redirectUrl
+	err = SendCategoryTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}

+ 441 - 2
services/wx_user.go

@@ -2,6 +2,7 @@ package services
 
 import (
 	"context"
+	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
@@ -10,7 +11,7 @@ import (
 	"time"
 )
 
-func UpdateWxUserLabel(cont context.Context) (err error) {
+func UpdateWxUserLabelOLd(cont context.Context) (err error) {
 	defer func() {
 		if err != nil {
 			go utils.SendAlarmMsg("更新用户标签失败;Err:"+err.Error(), 2)
@@ -780,7 +781,7 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 	}
 
 	//更新用户标签以及权重
-	go UpdateUserLabelWeight()
+	//go UpdateUserLabelWeight()
 	return
 }
 
@@ -1057,3 +1058,441 @@ func init123123() {
 		}
 	}
 }
+
+//func init() {
+//	UpdateWxUserLabelNew()
+//}
+
+func UpdateWxUserLabel(cont context.Context) (err error) {
+	//func UpdateWxUserLabel() (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("更新用户标签失败UpdateWxUserLabel, err:", err.Error()), 2)
+		}
+	}()
+
+	mapComapnyInteractionNum := make(map[int]int)                                   // 机构互动数量
+	mapComapnyInteractionNumSeller := make(map[int]int)                             // 销售可查看的机构互动数量
+	mapComapnyInteractionSeller := make(map[int]bool)                               // 跟销售建立绑定关系的用户
+	mapComapnyInteractionNumItem := make(map[int]*models.CygxCompanyInteractionNum) // 公司互动详情结构体
+	var comapnyInteractionNumItemAdd []*models.CygxCompanyInteractionNum            // 公司互动详情结构体新增
+	var comapnyInteractionNumItemUpdate []*models.CygxCompanyInteractionNum         // 公司互动详情结构体修改
+
+	//获取跟销售建立绑定关系的用户并记录切片
+	listUserSeller, e := models.GetUserSellerRelationUserList()
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetUserSellerRelationUserList, Err: " + e.Error())
+		return
+	}
+	for _, v := range listUserSeller {
+		mapComapnyInteractionSeller[v.UserId] = true
+	}
+
+	var condition string
+	//condition = ` AND h.create_time < '%s'  AND h.company_id IN ( 398,17773)  `
+	condition = ` AND h.create_time < '%s'  `
+	condition = fmt.Sprintf(condition, time.Now().Format(utils.FormatDate)) // 截止昨天的所有数据
+
+	//fmt.Println(condition)
+	//报告阅读记录1
+	{
+		listArticleHistoryRecord, e := models.GetCygxArticleHistoryRecordInteractionNum(condition)
+		if e != nil {
+			err = errors.New("GetCygxArticleHistoryRecordInteractionNum, Err: " + e.Error())
+			return
+		}
+		for _, v := range listArticleHistoryRecord {
+			mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+			if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+				mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+			}
+			if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+				mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+			}
+			mapComapnyInteractionNumItem[v.CompanyId].ArticleHistoryNum += v.InteractionNum
+		}
+
+	}
+
+	//报告收藏记录2
+	{
+		listArticleCollect, e := models.GetCygxArticleCollectInteractionNum(condition)
+		if e != nil {
+			err = errors.New("GetCygxArticleCollectInteractionNum, Err: " + e.Error())
+			return
+		}
+		for _, v := range listArticleCollect {
+			mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+			if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+				mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+			}
+
+			if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+				mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+			}
+			mapComapnyInteractionNumItem[v.CompanyId].ArticleCountNum += v.InteractionNum
+		}
+	}
+
+	//图表收藏记录3
+	{
+		listChartCollect, e := models.GetCygxChartCollectInteractionNum(condition)
+		if e != nil {
+			err = errors.New("GetCygxChartCollectInteractionNum, Err: " + e.Error())
+			return
+		}
+		for _, v := range listChartCollect {
+			mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+			if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+				mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+			}
+			if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+				mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+			}
+			mapComapnyInteractionNumItem[v.CompanyId].ChartCountNum += v.InteractionNum
+		}
+	}
+
+	//用户关注产业数量4
+	{
+		listIndustryFllow, e := models.GetCygxIndustryFllowInteractionNum(condition)
+		if e != nil {
+			err = errors.New("GetCygxIndustryFllowInteractionNum, Err: " + e.Error())
+			return
+		}
+		for _, v := range listIndustryFllow {
+			mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+			if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+				mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+			}
+			if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+				mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+			}
+			mapComapnyInteractionNumItem[v.CompanyId].IndustryFllowNum += v.InteractionNum
+		}
+	}
+
+	//用户搜索关键词数量5
+	{
+		listSearchKeyWord, e := models.GetCygxSearchKeyWordInteractionNum(condition)
+		if e != nil {
+			err = errors.New("GetCygxSearchKeyWordInteractionNum, Err: " + e.Error())
+			return
+		}
+		for _, v := range listSearchKeyWord {
+			mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+			if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+				mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+			}
+			if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+				mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+			}
+			mapComapnyInteractionNumItem[v.CompanyId].KeyWordNum += v.InteractionNum
+		}
+	}
+
+	//用户活动报名参会数量6
+	{
+		listActivitySignup, e := models.GetCygxActivitySignupInteractionNum(condition)
+		if e != nil {
+			err = errors.New("GetCygxActivitySignupInteractionNum, Err: " + e.Error())
+			return
+		}
+		for _, v := range listActivitySignup {
+			mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+			if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+				mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+			}
+			if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+				mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+			}
+			mapComapnyInteractionNumItem[v.CompanyId].ActivityNum += v.InteractionNum
+		}
+	}
+
+	//用户专项调研活动报名参会数量7
+	{
+		listActivitySpecialSignup, e := models.GetCygxActivitySpecialSignupInteractionNum(condition)
+		if e != nil {
+			err = errors.New("GetCygxActivitySpecialSignupInteractionNum, Err: " + e.Error())
+			return
+		}
+		for _, v := range listActivitySpecialSignup {
+			mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+			if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+				mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+			}
+			if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+				mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+			}
+			mapComapnyInteractionNumItem[v.CompanyId].TripNum += v.InteractionNum
+		}
+	}
+
+	//用户路演精华播放数量8
+	{
+		listMicroRoadshowVideoHistory, e := models.GetCygxMicroRoadshowVideoHistoryInteractionNum(condition)
+		if e != nil {
+			err = errors.New("GetCygxMicroRoadshowVideoHistoryInteractionNum, Err: " + e.Error())
+			return
+		}
+		for _, v := range listMicroRoadshowVideoHistory {
+			mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+			if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+				mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+			}
+			if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+				mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+			}
+			mapComapnyInteractionNumItem[v.CompanyId].RoadshowNum += v.InteractionNum
+		}
+	}
+
+	//用户活动视频播放数量9
+	{
+		listActivityVideoHistory, e := models.GetCygxActivityVideoHistoryInteractionNum(condition)
+		if e != nil {
+			err = errors.New("GetCygxActivityVideoHistoryInteractionNum, Err: " + e.Error())
+			return
+		}
+		for _, v := range listActivityVideoHistory {
+			mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+			if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+				mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+			}
+			if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+				mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+			}
+			mapComapnyInteractionNumItem[v.CompanyId].ActivityVideoNum += v.InteractionNum
+		}
+	}
+
+	//用户活动音频播放数量10
+	{
+		listActivityVoiceHistory, e := models.GetCygxActivityVoiceHistoryInteractionNum(condition)
+		if e != nil {
+			err = errors.New("GetCygxActivityVoiceHistoryInteractionNum, Err: " + e.Error())
+			return
+		}
+		for _, v := range listActivityVoiceHistory {
+			mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+			if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+				mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+			}
+			if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+				mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+			}
+			mapComapnyInteractionNumItem[v.CompanyId].ActivityVoiceNum += v.InteractionNum
+		}
+	}
+
+	//用户首页标签点击量数量11
+	{
+		listTagHistory, e := models.GetCygxTagHistoryInteractionNum(condition)
+		if e != nil {
+			err = errors.New("GetCygxTagHistoryInteractionNum, Err: " + e.Error())
+			return
+		}
+		for _, v := range listTagHistory {
+			mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+			if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+				mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+			}
+			if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+				mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+			}
+			mapComapnyInteractionNumItem[v.CompanyId].TagNum += v.InteractionNum
+		}
+	}
+
+	//用户关注文章作者数量12
+	{
+		listArticleDepartmentFollow, e := models.GetCygxArticleDepartmentFollowInteractionNum(condition)
+		if e != nil {
+			err = errors.New("GetCygxArticleDepartmentFollowInteractionNum, Err: " + e.Error())
+			return
+		}
+		for _, v := range listArticleDepartmentFollow {
+			mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+			if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+				mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+			}
+			if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+				mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+			}
+			mapComapnyInteractionNumItem[v.CompanyId].DepartmentFollowNum += v.InteractionNum
+		}
+	}
+
+	//用户收藏研选专栏数量13
+	//{
+	//	listYanxuanSpecialCollect, e := models.GetCygxYanxuanSpecialCollectInteractionNum(condition)
+	//	if e != nil {
+	//		err = errors.New("GetCygxYanxuanSpecialCollectInteractionNum, Err: " + e.Error())
+	//		return
+	//	}
+	//	for _, v := range listYanxuanSpecialCollect {
+	//		mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+	//		if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+	//			mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+	//		}
+	//
+	//		if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+	//			mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+	//		}
+	//		mapComapnyInteractionNumItem[v.CompanyId].YanxuanSpecialCollectNum += v.InteractionNum
+	//	}
+	//}
+
+	//用户关注研选专栏作者数量统计14
+	//{
+	//	listYanxuanSpecialFollow, e := models.GetCygxYanxuanSpecialFollowInteractionNum(condition)
+	//	if e != nil {
+	//		err = errors.New("GetCygxYanxuanSpecialFollowInteractionNum, Err: " + e.Error())
+	//		return
+	//	}
+	//	for _, v := range listYanxuanSpecialFollow {
+	//		mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+	//		if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+	//			mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+	//		}
+	//		if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+	//			mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+	//		}
+	//		mapComapnyInteractionNumItem[v.CompanyId].YanxuanSpecialFollowNum += v.InteractionNum
+	//	}
+	//}
+
+	//用户研选专栏阅读数量数量15
+	{
+		listYanxuanSpecialFollow, e := models.GetCygxYanxuanSpecialRecordInteractionNum(condition)
+		if e != nil {
+			err = errors.New("GetCygxYanxuanSpecialRecordInteractionNum, Err: " + e.Error())
+			return
+		}
+		for _, v := range listYanxuanSpecialFollow {
+			mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
+			if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
+				mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
+			}
+
+			if mapComapnyInteractionNumItem[v.CompanyId] == nil {
+				mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
+			}
+			mapComapnyInteractionNumItem[v.CompanyId].YanxuanSpecialNum += v.InteractionNum
+		}
+	}
+
+	mapCompanyInteraction := make(map[int]bool)
+	mapCompanyInteractionItem := make(map[int]*models.CygxCompanyInteractionNum)
+	listCompanyInteractionNum, e := models.GetCygxCompanyInteractionNumList() // 有过互动记录的公司
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCygxCompanyInteractionNumList, Err: " + e.Error())
+		return
+	}
+
+	for _, v := range listCompanyInteractionNum {
+		mapCompanyInteraction[v.CompanyId] = true
+		mapCompanyInteractionItem[v.CompanyId] = v
+
+	}
+
+	var itemsCompanyInteractionNums []*models.CompanyInteractionNumReq // 公司总的互动量结构体
+
+	companyInteractionNumList, e := models.GetCompanyInteractionNumList() // 获取有机构互动的公司
+	mapInteractionNumOld := make(map[int]int)                             //历史公司总的互动量
+	mapInteractionNumSellerOld := make(map[int]int)                       //历史公司关联销售所能查看的互动量
+	for _, v := range companyInteractionNumList {
+		mapInteractionNumOld[v.CompanyId] = v.InteractionNum
+		mapInteractionNumSellerOld[v.CompanyId] = v.InteractionNumSeller
+	}
+
+	for k, v := range mapComapnyInteractionNumItem {
+		v.CompanyId = k
+		if mapCompanyInteraction[k] {
+			itemOld := mapCompanyInteractionItem[v.CompanyId]
+
+			//ArticleHistoryNum        int       `description:"文章浏览数量"`
+			//ArticleCountNum          int       `description:"文章收藏数量"`
+			//ChartCountNum            int       `description:"图表收藏"`
+			//IndustryFllowNum         int       `description:"产业关注数量"`
+			//DepartmentFollowNum      int       `description:"作者关注数量"`
+			//KeyWordNum               int       `description:"关键词搜索次数"`
+			//ActivityOnLineNum        int       `description:"线上活动报名次数"`
+			//ActivityOfficeNum        int       `description:"线下活动报名次数"`
+			//ActivityNum              int       `description:"活动报名次数"`
+			//TripNum                  int       `description:"专项产业调研数量"`
+			//RoadshowVideoNum         int       `description:"产业视频播放量"`
+			//ActivityVideoNum         int       `description:"活动视频播放量"`
+			//ActivityVoiceNum         int       `description:"活动音频播放量"`
+			//RoadshowNum              int       `description:"路演播放总数量"`
+			//TagNum                   int       `description:"标签点击次数"`
+			//YanxuanSpecialNum        int       `description:"研选专栏阅读数量"`
+			//YanxuanSpecialCollectNum int       `description:"研选专栏收藏数量"`
+			//YanxuanSpecialFollowNum  int       `description:"研选专栏作者关注数量"`
+
+			//如果这些数据对比不一样,那么就对这条数据进行更新
+			//if itemOld != nil && (itemOld.ArticleHistoryNum != v.ArticleHistoryNum || itemOld.ArticleCountNum != v.ArticleCountNum || itemOld.ChartCountNum != v.ChartCountNum || itemOld.IndustryFllowNum != v.IndustryFllowNum || itemOld.DepartmentFollowNum != v.DepartmentFollowNum || itemOld.KeyWordNum != v.KeyWordNum || itemOld.ActivityNum != v.ActivityNum || itemOld.TripNum != v.TripNum || itemOld.RoadshowVideoNum != v.RoadshowVideoNum || itemOld.ActivityVideoNum != v.ActivityVideoNum || itemOld.ActivityVoiceNum != v.ActivityVoiceNum || itemOld.RoadshowNum != v.RoadshowNum || itemOld.TagNum != v.TagNum || itemOld.YanxuanSpecialNum != v.YanxuanSpecialNum || itemOld.YanxuanSpecialCollectNum != v.YanxuanSpecialCollectNum || itemOld.YanxuanSpecialFollowNum != v.YanxuanSpecialFollowNum) {
+			if itemOld != nil && (itemOld.ArticleHistoryNum != v.ArticleHistoryNum || itemOld.ArticleCountNum != v.ArticleCountNum || itemOld.ChartCountNum != v.ChartCountNum || itemOld.IndustryFllowNum != v.IndustryFllowNum || itemOld.DepartmentFollowNum != v.DepartmentFollowNum || itemOld.KeyWordNum != v.KeyWordNum || itemOld.ActivityNum != v.ActivityNum || itemOld.TripNum != v.TripNum || itemOld.RoadshowVideoNum != v.RoadshowVideoNum || itemOld.ActivityVideoNum != v.ActivityVideoNum || itemOld.ActivityVoiceNum != v.ActivityVoiceNum || itemOld.RoadshowNum != v.RoadshowNum || itemOld.TagNum != v.TagNum) {
+				comapnyInteractionNumItemUpdate = append(comapnyInteractionNumItemUpdate, v)
+			}
+
+		} else {
+			v.CreateTime = time.Now()
+			v.ModifyTime = time.Now()
+			comapnyInteractionNumItemAdd = append(comapnyInteractionNumItemAdd, v)
+		}
+
+		//对比历史数据如果不一样就进行修改
+		if mapInteractionNumOld[v.CompanyId] != mapComapnyInteractionNum[v.CompanyId] || mapInteractionNumSellerOld[v.CompanyId] != mapComapnyInteractionNumSeller[v.CompanyId] {
+			itemCompanyInteractionNums := new(models.CompanyInteractionNumReq)
+			itemCompanyInteractionNums.CompanyId = k
+			itemCompanyInteractionNums.InteractionNum = mapComapnyInteractionNum[v.CompanyId]
+			itemCompanyInteractionNums.InteractionNumSeller = mapComapnyInteractionNumSeller[v.CompanyId]
+			itemsCompanyInteractionNums = append(itemsCompanyInteractionNums, itemCompanyInteractionNums)
+		}
+
+	}
+
+	//for _, v := range comapnyInteractionNumItemUpdate {
+	//	fmt.Println(v)
+	//}
+
+	//return
+
+	//批量插入公司互动详情
+	if len(comapnyInteractionNumItemAdd) > 0 {
+		_, e = models.AddCygxCompanyInteractionNumList(comapnyInteractionNumItemAdd)
+		if e != nil {
+			err = errors.New("AddCygxCompanyInteractionNumList, Err: " + e.Error())
+			return
+		}
+	}
+
+	// 批量修改公司互动详情
+	if len(comapnyInteractionNumItemUpdate) > 0 {
+		e = models.UpdateCygxCompanyInteractionNumMulti(comapnyInteractionNumItemUpdate)
+		if e != nil {
+			err = errors.New("UpdateCygxCompanyInteractionNumMulti, Err: " + e.Error())
+			return
+		}
+	}
+
+	// 批量修改公司互动总量
+	if len(itemsCompanyInteractionNums) > 0 {
+		e = models.UpdateCompanyInteractionNumMulti(itemsCompanyInteractionNums)
+		if e != nil {
+			err = errors.New("UpdateCompanyInteractionNumMulti, Err: " + e.Error())
+			return
+		}
+	}
+
+	//CompanyInteractionNumReq
+	fmt.Println("add", len(comapnyInteractionNumItemAdd))
+	fmt.Println("edit", len(comapnyInteractionNumItemUpdate))
+	fmt.Println("Update", len(itemsCompanyInteractionNums))
+
+	//fmt.Println(mapComapnyInteractionNum)
+	return
+}

+ 63 - 8
utils/config.go

@@ -21,10 +21,11 @@ var (
 
 // 微信配置信息
 var (
-	WxId        string //微信原始ID
-	WxAppId     string //查研观向小程序
-	WxAppSecret string //查研观向小程序
-
+	WxId              string //微信原始ID
+	WxAppId           string //查研观向小程序
+	WxAppSecret       string //查研观向小程序
+	WxMfyxAppId       string //买方研选小程序APPID
+	WxMfyxAppSecret   string //买方研选小程序 秘钥
 	WxPublicIdXzs     string //查研观向小助手公众号
 	WxPublicSecretXzs string //查研观向小助手公众号
 
@@ -46,6 +47,19 @@ var (
 	WxMsgTemplateIdArticleUserRemindXzs   string //用户阅读报告通知-模板ID(小助手)
 	WxMsgTemplateIdActivityChangeApplyXzs string //查研观向活动即将开始时会前60/15分钟的通知-模板ID(小助手)
 	WxMsgTemplateIdActivitySign           string //查研观向活动签到通知-模板ID(小助手)
+
+	// 类目模板
+	WxCategoryMsgTemplateIdApplyXzs                  string //申请待处理(买方研选)
+	WxCategoryMsgTemplateIdActivitySign              string //买方研选活动签到通知-类目模板ID(买方研选)
+	WxMsgCategoryTemplateIdCompanyApprovalMessageRai string //权益销售签约成功通知买方研选类目模版消息通知-类目模板ID
+	WxMsgCategoryTemplateIdActivityPublishApply      string //买方研选关注的产业下,单个活动/研选报告发布通知-类目模板ID
+	WxMsgCategoryTemplateIdArticleUserRemind         string //用户阅读报告通知-类目模板ID
+
+	//权益内容组手机号
+	RAI_MOBILE_GAO_YI_WEN    string // 权益高亦文手机号
+	RAI_MOBILE_DONG_HENG     string // 权益董衡手机号
+	RAI_MOBILE_WU_ANG_DI_WEN string // 权益吴昂迪手机号
+	RAI_MOBILE_GE_LIN_WEN    string // 权益葛琳手机号
 )
 
 // 微信公众号配置信息
@@ -85,11 +99,14 @@ var (
 	YiDongHuaWeiYunUrl        string //易董 华为云请求域名
 	YiDonggetOriginalLink     string //易董 短连接转为长链接
 	ShangHaiCrmApiLink        string //上海CRM用户同步api调用地址
+
+	ZHOU_QI_ID int // 行业周期的ID
 )
 
 // 模板消息推送
 var (
-	SendWxTemplateMsgUrl string
+	SendWxTemplateMsgUrl         string
+	SendWxCategoryTemplateMsgUrl string
 )
 
 func init() {
@@ -145,13 +162,17 @@ func init() {
 	SummaryArticleId = 1000000         //手动添加的纪要库开始ID
 	YanxSummaryPermissionId = 1001     //研选纪要分类ID
 	YanxViewpointPermissionId = 1002   //研选观点分类ID
-	WxMsgTemplateIdAskMsgMobileAll = "15557270714,18767183922,18621268829,18955528215"
-	WxMsgTemplateIdAskMsgMobilePublic = "15557270714,18767183922,18621268829"
+	WxMsgTemplateIdAskMsgMobileAll = "15557270714,18767183922,18621268829"
+	WxMsgTemplateIdAskMsgMobilePublic = "15557270714,18767183922,18621268829" // 王芳沈涛张传星
+
 	HtgjDefaultSaleName = "王芳"
 	HtgjSalt = "HTGJ&HZ"
 	HtgjName = "海通国际"
 	HtgjPublicMobile = "18767183955"
 	StrategyPlatform = "https://vmp.hzinsights.com/v2/articles/"
+	// 买方研选
+	WxMfyxAppId = "wx5e3240ab90c247ac"
+	WxMfyxAppSecret = "6b1316b46dc9c63429f5c1df6f51b4ac"
 	if RunMode == "release" {
 		WxAppId = "wxcc32b61f96720d2f"
 		WxAppSecret = "06894933fafb24dafead7eaae09c08e0"
@@ -180,11 +201,13 @@ func init() {
 		WxMsgTemplateIdArticleUserRemind = "fxnlsjx-gm3dAZVJf6f3w27wA7anETl42kexXLP8FDs"
 		WxMsgTemplateIdAskMsgMobile = ""
 		//ActSendMsgMobile = "15618524605"
-		ActSendMsgMobile = "18955528215" // 汪洋手机号
+		ActSendMsgMobile = "15557270714" // 汪洋手机号
 		ArticleTaskClassMobile = "15557270714,18767183922,15216736473,15000123056,18701809782,17706316791,18652179672"
 
 		ShangHaiCrmApiLink = "https://crm.hzinsights.com/"
 		SendWxTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_template_msg"
+		SendWxCategoryTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_category_template_msg"
+
 	} else {
 		WxAppId = "wxcc32b61f96720d2f"
 		WxAppSecret = "06894933fafb24dafead7eaae09c08e0"
@@ -220,6 +243,8 @@ func init() {
 
 		ShangHaiCrmApiLink = "http://106.15.192.100:8100/"
 		SendWxTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_template_msg"
+		SendWxCategoryTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_category_template_msg"
+		//SendWxCategoryTemplateMsgUrl = "http://8.136.199.33:8086/v1/wechat/send_category_template_msg"
 	}
 
 	//查研观向小助手
@@ -234,6 +259,13 @@ func init() {
 		TemplateIdByProductXzs = "-YjuPOB7Fqd-S3ilabYa6wvjDY9aXmeEfPN6DCiy-EY"                //产品运行报告通知-模板ID(小助手)
 		WxMsgTemplateIdActivityChangeApplyXzs = "4fwzgJ-2xUiyQqNkFCPd8vsGpOnNWWE2inZO4BXjfio" //查研观向活动变更通知-模板ID(小助手)
 		WxMsgTemplateIdActivitySign = "3l5cxpqH6c9kkLe9ow7qzqd0uYEOdY3A_PB8wRWkiHk"           //查研观向活动签到通知-模板ID(小助手)
+
+		// 类目模版
+		WxCategoryMsgTemplateIdApplyXzs = "IemWOTzbnLBqJ2ozSiFqm13WjaotoC3V4uXaxTij08I"
+		WxCategoryMsgTemplateIdActivitySign = "aczgUYZASO97UJiCD_nDmD1eNWZAWudzw3JYcvjJ2x4"
+		WxMsgCategoryTemplateIdCompanyApprovalMessageRai = "wU4x_c5XruwuA44VZelyklRNOfq4XrU9ILckTtDs6hg" //权益销售签约成功通知买方研选类目模版消息通知-类目模板ID
+		WxMsgCategoryTemplateIdActivityPublishApply = "wLeV7tVK4ZJBoAvsmfXkHveVW8yefGAkwnVKQWRi8uQ"
+		WxMsgCategoryTemplateIdArticleUserRemind = "4fwzgJ-2xUiyQqNkFCPd8vsGpOnNWWE2inZO4BXjfio"
 	} else {
 		//新的模板ID
 		WxPublicIdXzs = "wxb7cb8a15abad5b8e"                                                  //查研观向小助手
@@ -245,10 +277,24 @@ func init() {
 		TemplateIdByProductXzs = "tNcCUiK_uUkuxaFF7M9NP2RwLkw8uHFjG-TDIxGUKxo"                //产品运行报告通知-模板ID(小助手)
 		WxMsgTemplateIdActivityChangeApplyXzs = "Q03y1p7epHx8jnz-mHTwm8O5XEfd-XnrQB01Goldmqo" //查研观向活动变更通知-模板ID(小助手)
 		WxMsgTemplateIdActivitySign = "GIcOqewJql4rQ_dvhUna2knWIVogKulaqRxtZKnWZeo"           //查研观向活动签到通知-模板ID(小助手)
+
+		// 类目模版
+		WxCategoryMsgTemplateIdApplyXzs = "HKD03oZfSv8LJgeoHz0pynai3G2Ls4h8zZ6BfOpZmIA"
+		WxCategoryMsgTemplateIdActivitySign = "11rITVC5Gl8qwetxl92NqY887Uk14kg3nPtEA_i_zLo"
+		WxMsgCategoryTemplateIdCompanyApprovalMessageRai = "t1CcxcOkoZkWZrDRs6zYUlceBGYMV3mhkBYUa8a6Mx0" //权益销售签约成功通知买方研选类目模版消息通知-类目模板ID
+		WxMsgCategoryTemplateIdActivityPublishApply = "IBMqiE61lVgUfFM4rsH0XCH57R_G3PbWvRbnzg9JHPI"
+		WxMsgCategoryTemplateIdArticleUserRemind = "4fwzgJ-YQndzH5OJWLkd0grvftgqhvP285t_oXUboi7DaaIhMI"
+
+		//权益内容组手机号测试环境没什么用,配合测试切换他们的手机号
+		RAI_MOBILE_GAO_YI_WEN = "17706316791"    //权益高亦文手机号
+		RAI_MOBILE_DONG_HENG = "15557270714"     // 权益董衡手机号
+		RAI_MOBILE_WU_ANG_DI_WEN = "15557270714" // 权益吴昂迪手机号
+		RAI_MOBILE_GE_LIN_WEN = "15557270714"    // 权益葛琳手机号
 	}
 
 	//易董开放api配置
 	YiDongApiConfig()
+	ChartPermissionId()
 }
 
 // YiDongApiConfig 易董开放api配置
@@ -268,6 +314,15 @@ func YiDongApiConfig() {
 	}
 }
 
+// 行业ID信息 易董开放api配置
+func ChartPermissionId() {
+	if RunMode == "release" {
+		ZHOU_QI_ID = 62
+	} else {
+		ZHOU_QI_ID = 138
+	}
+}
+
 //
 //YiDongZhengTongYunUrl     string //易董 证通云请求域名
 //YiDongZhengTongYunAppid   string //易董 证通云请求appid

+ 16 - 6
utils/constants.go

@@ -9,6 +9,7 @@ const (
 	FormatTime             = "15:04:05"                //时间格式
 	FormatDate             = "2006-01-02"              //日期格式
 	FormatDateTime         = "2006-01-02 15:04:05"     //完整时间格式
+	FormatDateTimeMinute2  = "2006-01-02 15:04"        //时间格式 年-月-日 时:分
 	HlbFormatDateTime      = "2006-01-02_15:04:05.999" //完整时间格式
 	FormatDateTimeNoSecond = "2006-01-02 15:04"        //完整时间格式
 	FormatDateTimeUnSpace  = "20060102150405"          //完整时间格式
@@ -78,6 +79,7 @@ const (
 )
 
 const (
+	ZHOU_QI_NAME                     string = "周期"
 	CHART_PERMISSION_NAME_YANXUAN    string = "研选"
 	MAI_FANG_YAN_XUAN_NAME           string = "买方研选"
 	CHART_PERMISSION_NAME_MF_YANXUAN string = "研选订阅"
@@ -182,7 +184,7 @@ const (
 	WX_MSG_PATH_PRODUCTINTERIOR_DETAIL   = "reportPages/internalDetials/internalDetials?id="              //产品内测详情模板消息地址
 	WX_MSG_PATH_THIS_WEEK_DETAIL         = "reportPages/reportSecretDetail/reportSecretDetail?type=2&id=" //本周研究汇总详情模板消息地址
 	WX_MSG_PATH_LAST_WEEK_DETAIL         = "reportPages/reportSecretDetail/reportSecretDetail?type=3&id=" //上周纪要汇总详情模板消息地址
-	WX_MSG_PATH_KEY_COMPANY_DETAIL       = "reportPages/keyCompany/keyCompany"                            //重点公司详情模板消息地址
+	WX_MSG_PATH_KEY_COMPANY_DETAIL       = "reportPages/keyCompany/keyCompany?id="                        //重点公司详情模板消息地址
 	WX_MSG_PATH_RESEARCHTHEME_DETAIL     = "reportPages/researchTheme/researchTheme?id="                  //主题详情模板消息地址
 	WX_MSG_PATH_ACTIVITY_SIGN            = "pages-message/activityTemplate/activityTemplate?id="          //活动模板消息地址
 	WX_MSG_PATH_APPLY_DETAIL             = "pages-message/applyFor/applyFor?id="                          //潜在用户试用权限申请
@@ -191,6 +193,10 @@ const (
 	WX_MSG_PATH_YX_SPECIAL_DETAIL        = "pages-purchaser/noteAndViewpoint/noteAndViewpoint?id="        //研选专栏详情
 	WX_MSG_PATH_YX_SPECIAL_ENABLE_DETAIL = "pages-purchaser/toExamine/toExamine?isMessage=模板&id="         //研选专栏审核详情页面
 	WX_MSG_PATH_YX_SPECIAL_CENTER        = "pages-purchaser/contentAllPage/contentAllPage?Status=4"       //研选专栏内容中心
+	WX_MSG_PATH_YX_COMMENT_DETAIL        = "pages-activity/generationAsk/generationAsk?id="               //研选报告留言详情
+	WX_MSG_PATH_YX_ACTIVITY_DETAIL       = "pages-activity/activityDetail/activityDetail?id="             //研选活动详情
+	WX_MSG_PATH_YX_SIGNUP_DETAIL         = "pages-message/activityTemplate/activityTemplate?id="          //研选报名详情
+	WX_MSG_PATH_YX_ARTICLE_DETAIL        = "pages-user/reportDetail/reportDetail?id="                     //研选纪要详情
 )
 
 //2:文章详情  https://web.hzinsights.com/material/info/8436  小程序路径:/pageMy/reportDetail/reportDetail?id=
@@ -221,11 +227,12 @@ const (
 )
 
 const (
-	TPL_MSG_WANG_YANG                  = "tpl_msg_wang_yang"           //汪洋手机号地址参数
-	TPL_MSG_WANG_FANG_WANG_YANG        = "tpl_msg_wang_fang_wang_yang" //权限模板消息接收人,王芳,汪洋
-	TPL_MSG                            = "tpl_msg"                     //王芳手机号地址参数
-	TPL_MSG_NEI_RONG_ZU                = "tpl_msg_nei_rong_zu"         //内容组四人
-	CYGX_TAG_HOT_ACTIVITY_ID    string = "cygx_tag_hot_activity_id"    //标签管理自定义的热门活动ID
+	TPL_MSG_WANG_YANG                        = "tpl_msg_wang_yang"                 //汪洋手机号地址参数
+	TPL_MSG_WANG_FANG_WANG_YANG              = "tpl_msg_wang_fang_wang_yang"       //权限模板消息接收人,王芳,汪洋
+	TPL_MSG_YAN_XUAN_SPECIAL_APPROVAL        = "tpl_msg_yan_xuan_special_approval" //研选专栏修改之后给这些手机号推送审核模版消息
+	TPL_MSG                                  = "tpl_msg"                           //王芳手机号地址参数
+	TPL_MSG_NEI_RONG_ZU                      = "tpl_msg_nei_rong_zu"               //内容组四人
+	CYGX_TAG_HOT_ACTIVITY_ID          string = "cygx_tag_hot_activity_id"          //标签管理自定义的热门活动ID
 )
 
 const (
@@ -233,6 +240,7 @@ const (
 	MobileZhangChuanXin = "15557270714" // 张传星手机号
 	MobileWangFang      = "18621268829" // 王芳手机号
 	MobileWuAngDi       = "18701809782" // 吴昂迪手机号
+	MobileDongHeng      = "15216736473" // 董衡手机号
 )
 
 const (
@@ -291,3 +299,5 @@ const (
 	COMPANY_STATUS_POTENTIAL = "潜在"
 	COMPANY_STATUS_CLOSE     = "关闭"
 )
+
+var ACTIVITY_SPECIAL_TRIP_PERMISSION_NAME_OTHER = []string{"策略", "固收", "周期"} //专项调研活动带扣点的行业