Просмотр исходного кода

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into cygx_12.8.1

xingzai 1 год назад
Родитель
Сommit
e530ad31cf
49 измененных файлов с 2954 добавлено и 649 удалено
  1. 4 3
      controllers/activity.go
  2. 2 0
      controllers/activity_special.go
  3. 1 1
      controllers/base_auth.go
  4. 2 2
      controllers/home.go
  5. 32 9
      controllers/report.go
  6. 20 1
      controllers/research.go
  7. 2 1
      controllers/search.go
  8. 239 63
      controllers/yanxuan_special.go
  9. 23 0
      models/activity_signup_detail.go
  10. 19 18
      models/activity_special_trip_bill.go
  11. 28 0
      models/admin.go
  12. 2 0
      models/article.go
  13. 33 0
      models/article_and_yanxuan_record.go
  14. 49 0
      models/article_history_record_all.go
  15. 0 20
      models/article_history_record_newpv.go
  16. 13 1
      models/chart.go
  17. 3 3
      models/company.go
  18. 111 46
      models/cygx_yanxuan_special.go
  19. 34 0
      models/cygx_yanxuan_special_approval_log.go
  20. 32 13
      models/cygx_yanxuan_special_collect.go
  21. 24 13
      models/cygx_yanxuan_special_follow.go
  22. 82 2
      models/cygx_yanxuan_special_record.go
  23. 103 0
      models/cygx_yanxuan_special_user.go
  24. 3 0
      models/db.go
  25. 8 1
      models/industrial_article_group_management.go
  26. 29 0
      models/industrial_management.go
  27. 27 0
      models/industry_fllow.go
  28. 159 29
      models/report.go
  29. 19 1
      models/resource_data.go
  30. 14 3
      models/wx_user.go
  31. 1 1
      services/activity.go
  32. 14 14
      services/activity_special.go
  33. 31 0
      services/admin.go
  34. 6 4
      services/article.go
  35. 125 0
      services/article_history.go
  36. 2 1
      services/chart.go
  37. 23 0
      services/config.go
  38. 183 75
      services/cygx_yanxuan_special.go
  39. 98 21
      services/cygx_yanxuan_special_company.go
  40. 3 3
      services/elasticsearch.go
  41. 152 33
      services/es_comprehensive.go
  42. 49 0
      services/industrial_management.go
  43. 277 0
      services/init12.8.go
  44. 277 10
      services/resource_data.go
  45. 5 1
      services/task.go
  46. 2 2
      services/user.go
  47. 537 240
      services/wx_user.go
  48. 26 1
      utils/common.go
  49. 26 13
      utils/constants.go

+ 4 - 3
controllers/activity.go

@@ -2602,13 +2602,14 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 	}
 	//研选互动不展示专项产业调研
 	if !isResearch {
-		conditionActivitySpecial := services.ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState)
-		//查询专项产业调研展示权限 仅对大套餐客户跟永续客户展示
-		//if whichDay == "" {
 		//专项产业调研未开始状态不查询
 		if activeState == "1" {
 			activeState = ""
 		}
+		conditionActivitySpecial := services.ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState)
+		//查询专项产业调研展示权限 仅对大套餐客户跟永续客户展示
+		//if whichDay == "" {
+
 		//speciaItem, err := services.GetActivityLabelSpecialList(user, isPower, chartPermissionIds, permissionNameStr)
 		speciaItem, err := services.GetActivityLabelSpecialList(user, conditionActivitySpecial, activeState)
 		if err != nil {

+ 2 - 0
controllers/activity_special.go

@@ -249,6 +249,7 @@ func (this *ActivitySpecialCoAntroller) SpecialTripAdd() {
 			itemBill.BillDetailed = -1 // 流水减一
 			itemBill.RegisterPlatform = 1
 			itemBill.ChartPermissionId = activityInfo.ChartPermissionId
+			itemBill.ChartPermissionName = activityInfo.ChartPermissionName
 
 			var itemMeeting = new(models.CygxActivitySpecialMeetingDetail)
 			itemMeeting.UserId = user.UserId
@@ -428,6 +429,7 @@ func (this *ActivitySpecialCoAntroller) Tripcancel() {
 	itemBill.BillDetailed = 1 // 流水加一
 	itemBill.RegisterPlatform = 1
 	itemBill.ChartPermissionId = activityInfo.ChartPermissionId
+	itemBill.ChartPermissionName = activityInfo.ChartPermissionName
 	resultTime := utils.StrTimeToTime(activityInfo.ActivityTime)
 	//48小时之内的取消也扣除一次参会记录
 	var isValid int

+ 1 - 1
controllers/base_auth.go

@@ -32,7 +32,7 @@ type BaseAuthController struct {
 }
 
 func (this *BaseAuthController) Prepare() {
-	fmt.Println("enter prepare")
+	//fmt.Println("enter prepare")
 	method := this.Ctx.Input.Method()
 	uri := this.Ctx.Input.URI()
 	fmt.Println("Url:", uri)

+ 2 - 2
controllers/home.go

@@ -649,7 +649,7 @@ func (this *HomeController) NewList() {
 	//conditionInit += `  AND source IN ('newchart')`
 	if user.CompanyId <= 1 || totalRai == 0 {
 		//condition += " AND source IN ('roadshow','article') "
-		condition += " AND source NOT IN ('activityspecial') "
+		condition += " AND source NOT IN ('activityspecial','industrialsourceHz','industrialsourceYx') "
 		listActivityYiDong, err := models.GetActivityListHomeNew("  AND art.yidong_activity_id != '' ", 0, 1000)
 		if err != nil {
 			br.Msg = "获取失败"
@@ -665,7 +665,7 @@ func (this *HomeController) NewList() {
 		condition += `  AND IF ( source = 'activity' , source_id  NOT IN (` + utils.GetOrmInReplace(lenyiDongactivityIds) + `) ,1=1 ) `
 		pars = append(pars, yiDongactivityIds)
 	} else {
-		condition += ` AND source NOT IN ('activity','activityspecial','newchart') ` + conditionInit
+		condition += ` AND source NOT IN ('activity','activityspecial','newchart','industrialsourceHz','industrialsourceYx') ` + conditionInit
 		//conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "1,2,3", "", 0, 0, "", 0, 1)
 		conditionActivity, err := services.ActivityConditioninitSql(user, "", 0)
 		if err != nil && err.Error() != utils.ErrNoRow() {

+ 32 - 9
controllers/report.go

@@ -2943,7 +2943,8 @@ func (this *ReportController) SearchReportAndResource() {
 		return
 	}
 	//匹配报告标题、
-	condition = `AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
+	//condition = `AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
+	condition = `AND ( a.title LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
 	sqlGroup = ` GROUP BY  a.article_id  ORDER BY a.publish_date DESC  `
 	if pageSize > 0 {
 		sqlGroup += ` LIMIT 5 `
@@ -2983,7 +2984,8 @@ func (this *ReportController) SearchReportAndResource() {
 		} else {
 			sqlGroupIk += ` LIMIT 20 `
 		}
-		conditionIk += ` AND ( a.title NOT LIKE '%` + keyWord + `%' AND  a.body NOT LIKE '%` + keyWord + `%' AND  a.annotation NOT LIKE '%` + keyWord + `%' AND  a.abstract NOT LIKE '%` + keyWord + `%') `
+		//conditionIk += ` AND ( a.title NOT LIKE '%` + keyWord + `%' AND  a.body NOT LIKE '%` + keyWord + `%' AND  a.annotation NOT LIKE '%` + keyWord + `%' AND  a.abstract NOT LIKE '%` + keyWord + `%') `
+		conditionIk += ` AND ( a.title NOT LIKE '%` + keyWord + `%'  AND  a.annotation NOT LIKE '%` + keyWord + `%' AND  a.abstract NOT LIKE '%` + keyWord + `%') `
 		//研选的联想词列表
 		ListYxReportIk, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+articleTypeIds+`) `+conditionIk+sqlGroupIk, user.UserId)
 		if err != nil && err.Error() != utils.ErrNoRow() {
@@ -3009,16 +3011,25 @@ func (this *ReportController) SearchReportAndResource() {
 			}
 		}
 	}
+
+	var articleIdsArr []int
+	var articleIdsSpecialArr []int // 研选专栏ID
 	for k, v := range ListHzReport {
 		ListHzReport[k].Source = 1
-		if v.MyCollectNum > 0 {
-			ListHzReport[k].IsCollect = true
-		}
+		//if v.MyCollectNum > 0 {
+		//	ListHzReport[k].IsCollect = true
+		//}
+		articleIdsArr = append(articleIdsArr, v.ArticleId)
 	}
 	for k, v := range ListYxReport {
 		ListYxReport[k].Source = 2
-		if v.MyCollectNum > 0 {
-			ListYxReport[k].IsCollect = true
+		//if v.MyCollectNum > 0 {
+		//	ListYxReport[k].IsCollect = true
+		//}
+		if v.ArticleTypeId == -1 {
+			articleIdsSpecialArr = append(articleIdsSpecialArr, v.ArticleId)
+		} else {
+			articleIdsArr = append(articleIdsArr, v.ArticleId)
 		}
 	}
 
@@ -3026,13 +3037,22 @@ func (this *ReportController) SearchReportAndResource() {
 	for _, v := range ListHzReport {
 		articleIds += strconv.Itoa(v.ArticleId) + ","
 	}
+
+	articleMapPv := services.GetArticleHistoryByArticleId(articleIdsArr)                       //文章Pv
+	articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)                     //用户收藏的文章
+	articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIdsArr) //文章收藏的数量
+	articleCollectYanxuanSpecialMap, _ := services.GetYanxuanSpecialCollectMap(user.UserId)    //用户收藏的研选专栏
+
 	for i, v := range ListYxReport {
 		articleIds += strconv.Itoa(v.ArticleId) + ","
-
 		if v.ArticleTypeId == -1 {
-			ListYxReport[i].ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
+			v.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
+			v.IsCollect = articleCollectYanxuanSpecialMap[v.ArticleId]
 		} else if v.ArticleTypeId > 0 {
 			ListYxReport[i].ArticleTypeName = utils.CYGX_YANXUAN_ARTICLE
+			ListYxReport[i].Pv = articleMapPv[v.ArticleId]
+			ListYxReport[i].CollectNum = articleCollectNumMap[v.ArticleId]
+			ListYxReport[i].IsCollect = articleCollectMap[v.ArticleId]
 		}
 		if v.SpecialType == 1 {
 			ListYxReport[i].Title = "【笔记】" + ListYxReport[i].Title
@@ -3081,6 +3101,9 @@ func (this *ReportController) SearchReportAndResource() {
 		} else {
 			ListHzReport[k].List = make([]*models.IndustrialManagementResp, 0)
 		}
+		v.Pv = articleMapPv[v.ArticleId]
+		v.CollectNum = articleCollectNumMap[v.ArticleId]
+		v.IsCollect = articleCollectMap[v.ArticleId]
 	}
 	for k, v := range ListYxReport {
 		if len(industrialMap[v.ArticleId]) > 0 {

+ 20 - 1
controllers/research.go

@@ -767,12 +767,24 @@ func (this *ResearchController) ArticleNewList() {
 		return
 	}
 	var articleIds []int
+	//var articleIdsArr []int
+	var articleIdsSpecialArr []int // 研选专栏ID
 	for k, v := range list {
 		if v.MyCollectNum > 0 {
 			list[k].IsCollect = true
 		}
-		articleIds = append(articleIds, v.ArticleId)
+		if v.IsSpecial == 1 {
+			articleIdsSpecialArr = append(articleIdsSpecialArr, v.ArticleId)
+		} else {
+			articleIds = append(articleIds, v.ArticleId)
+		}
 	}
+
+	articleMapPv := services.GetArticleHistoryByArticleId(articleIds)                       //文章Pv
+	articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)                  //用户收藏的文章
+	articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
+	articleCollectYanxuanSpecialMap, _ := services.GetYanxuanSpecialCollectMap(user.UserId) //用户收藏的研选专栏
+
 	//处理关联的产业
 	industrialMap, err := services.GetArticleIndustrialByArticleId(articleIds)
 	if err != nil {
@@ -781,6 +793,13 @@ func (this *ResearchController) ArticleNewList() {
 		return
 	}
 	for k, v := range list {
+		if v.IsSpecial == 1 {
+			v.IsCollect = articleCollectYanxuanSpecialMap[v.ArticleId]
+		} else {
+			v.Pv = articleMapPv[v.ArticleId]
+			v.CollectNum = articleCollectNumMap[v.ArticleId]
+			v.IsCollect = articleCollectMap[v.ArticleId]
+		}
 		if len(industrialMap[v.ArticleId]) > 0 {
 			list[k].List = industrialMap[v.ArticleId]
 		} else {

+ 2 - 1
controllers/search.go

@@ -743,7 +743,8 @@ func (this *SearchController) ComprehensiveList() {
 		return
 	}
 	resp := new(models.HomeResourceDataListResp)
-	tmpResult, tmpTotalResult, err := services.EsComprehensiveSearch(keyWord, startSize, pageSize)
+
+	tmpResult, tmpTotalResult, err := services.SqlComprehensiveSearch(keyWord, startSize, pageSize)
 	if err != nil {
 		br.Msg = "检索失败"
 		br.ErrMsg = "检索失败,Err:" + err.Error()

+ 239 - 63
controllers/yanxuan_special.go

@@ -6,6 +6,7 @@ import (
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
+	"strconv"
 	"strings"
 	"time"
 )
@@ -19,6 +20,7 @@ type YanxuanSpecialController struct {
 // @Param   UserId   query   int  true       "用户ID"
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   Status   query   int  false       "研选专栏装态"
 // @Success 200 {object} models.SpecialListResp
 // @router /list [get]
 func (this *YanxuanSpecialController) List() {
@@ -37,6 +39,7 @@ func (this *YanxuanSpecialController) List() {
 	userId, _ := this.GetInt("UserId", 0)
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
+	status, _ := this.GetInt("Status")
 
 	var startSize int
 	if pageSize <= 0 {
@@ -54,7 +57,12 @@ func (this *YanxuanSpecialController) List() {
 		condition += ` AND a.user_id = ? `
 		pars = append(pars, userId)
 	}
-	condition += ` AND a.status = 3 `
+	if status == 2 {
+		condition += ` AND a.status = 2 `
+	} else {
+		condition += ` AND a.status = 3 `
+	}
+
 	total, err := models.GetCygxYanxuanSpecialCount(condition, pars)
 	if err != nil {
 		br.Msg = "获取失败"
@@ -183,7 +191,7 @@ func (this *YanxuanSpecialController) Detail() {
 			resp.Tags += ","
 		}
 		resp.Tags += item.IndustryTags
-		resp.IndustryTags = append(resp.IndustryTags, item.IndustryTags)
+		resp.IndustryTags = strings.Split(item.IndustryTags, ",")
 	}
 
 	//如果状态未审核通过,而且查看的不是本人,不是审核人员,就无法查看详情
@@ -206,7 +214,18 @@ func (this *YanxuanSpecialController) Detail() {
 		resp.HasPermission = 2
 	}
 
-	go services.AddSpecialRecord(this.User, specialId)
+	//如果在web端有样式或者上传了文件,小程序就禁止编辑修改内容
+	hasStyle, err := utils.ArticleHasStyle(item.Content)
+	if err != nil {
+		return
+	}
+	hasImg, err := utils.ArticleHasImgUrl(item.Content)
+	if err != nil {
+		return
+	}
+	if hasStyle || strings.Contains(item.DocUrl, "http") || hasImg {
+		resp.ContentHasStyle = true
+	}
 
 	br.Data = resp
 	br.Ret = 200
@@ -328,7 +347,7 @@ func (this *YanxuanSpecialController) Save() {
 		br.Msg = "请至少输入一个标签"
 		return
 	}
-
+	isApprovalPersonnel := req.IsApprovalPersonnel
 	item := models.CygxYanxuanSpecial{
 		Id:           req.Id,
 		UserId:       sysUser.UserId,
@@ -348,6 +367,27 @@ func (this *YanxuanSpecialController) Save() {
 	} else {
 		item.Status = 2
 	}
+	var authorUserId int
+	// 如果是审批人员操作的那么就是修改内容,加审批通过
+	if isApprovalPersonnel {
+		item.Status = 3
+		//校验是否属于审核人员
+		if !services.CheckYxSpecialIsApprovalPersonnel(sysUser.Mobile) {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,该账号不属于审核人员:" + sysUser.Mobile
+			return
+		}
+
+		specialItem, err := models.GetYanxuanSpecialItemById(req.Id)
+		if err != nil {
+			br.Msg = "保存失败"
+			br.ErrMsg = "保存失败,Err:" + err.Error()
+			return
+		}
+		item.UserId = specialItem.UserId // 专栏userid还是原有userId
+		authorUserId = specialItem.UserId
+		item.AdminName = sysUser.RealName //审核人员姓名
+	}
 
 	specialId := 0
 
@@ -369,10 +409,18 @@ func (this *YanxuanSpecialController) Save() {
 		specialId = req.Id
 	}
 
-	if req.DoType == 2 {
-		go services.SendReviewTemplateMsgAdmin(specialId)
-		go services.UpdateYanxuanSpecialResourceData(specialId) //  写入首页最新  cygx_resource_data 表
-		go services.EsAddYanxuanSpecial(specialId)              //  写入es 综合搜索
+	if isApprovalPersonnel {
+		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.UdpateYanxuanSpecialauthorArticleNum(authorUserId) //  更新作者发布文章的数量
+	} else {
+		if req.DoType == 2 {
+			go services.SendReviewTemplateMsgAdmin(specialId)
+			go services.UpdateYanxuanSpecialResourceData(specialId) //  写入首页最新  cygx_resource_data 表
+			go services.EsAddYanxuanSpecial(specialId)              //  写入es 综合搜索
+		}
 	}
 
 	br.Ret = 200
@@ -427,8 +475,8 @@ func (this *YanxuanSpecialController) Enable() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	sysUser := this.User
-	if sysUser == nil {
+	user := this.User
+	if user == nil {
 		br.Msg = "请登录"
 		br.ErrMsg = "请登录,SysUser Is Empty"
 		br.Ret = 408
@@ -456,7 +504,13 @@ func (this *YanxuanSpecialController) Enable() {
 	} else {
 		status = 4
 	}
-	if tmpErr := models.EnableYanxuanSpecial(req.Id, status, req.Reason); tmpErr != nil {
+	detail, err := models.GetYanxuanSpecialItemById(req.Id)
+	if err != nil {
+		br.Msg = "审批失败"
+		br.ErrMsg = "审批失败, Err:" + err.Error()
+		return
+	}
+	if tmpErr := models.EnableYanxuanSpecial(req.Id, status, req.Reason, user.RealName); tmpErr != nil {
 		br.Msg = "审批失败"
 		br.ErrMsg = "审批失败, Err:" + tmpErr.Error()
 		return
@@ -465,8 +519,10 @@ func (this *YanxuanSpecialController) Enable() {
 		go services.SendWxMsgSpecialFollow(req.Id)
 	}
 	go services.SendWxMsgSpecialAuthor(req.Id, req.Status)
-	go services.UpdateYanxuanSpecialResourceData(req.Id) //  写入首页最新  cygx_resource_data 表
-	go services.EsAddYanxuanSpecial(req.Id)              //  写入es 综合搜索
+	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)                       //  更新作者发布文章的数量
 	br.Msg = "审批成功"
 	br.Ret = 200
 	br.Success = true
@@ -483,8 +539,8 @@ func (this *YanxuanSpecialController) Collect() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	sysUser := this.User
-	if sysUser == nil {
+	user := this.User
+	if user == nil {
 		br.Msg = "请登录"
 		br.ErrMsg = "请登录,SysUser Is Empty"
 		br.Ret = 408
@@ -507,20 +563,21 @@ func (this *YanxuanSpecialController) Collect() {
 		return
 	}
 	var sellerName string
-	sellerName, err = models.GetCompanySellerName(sysUser.CompanyId)
+	sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
 	if err != nil {
-		br.Msg = "报名失败!"
-		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		br.Msg = "查询栏目详情失败!"
+		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
 		return
 	}
+	sellerName = sellerItemQy.RealName
 	if req.Status == 1 {
 		item := models.CygxYanxuanSpecialCollect{
-			UserId:           sysUser.UserId,
-			Mobile:           sysUser.Mobile,
-			Email:            sysUser.Email,
-			CompanyId:        sysUser.CompanyId,
-			CompanyName:      sysUser.CompanyName,
-			RealName:         sysUser.RealName,
+			UserId:           user.UserId,
+			Mobile:           user.Mobile,
+			Email:            user.Email,
+			CompanyId:        user.CompanyId,
+			CompanyName:      user.CompanyName,
+			RealName:         user.RealName,
 			SellerName:       sellerName,
 			CreateTime:       time.Now(),
 			ModifyTime:       time.Now(),
@@ -535,7 +592,7 @@ func (this *YanxuanSpecialController) Collect() {
 		}
 		br.Msg = "收藏成功"
 	} else {
-		err = models.DelCygxYanxuanSpecialCollect(sysUser.UserId, req.Id)
+		err = models.DelCygxYanxuanSpecialCollect(user.UserId, req.Id)
 		if err != nil {
 			br.Msg = "删除失败"
 			br.ErrMsg = "删除失败,Err:" + err.Error()
@@ -543,7 +600,7 @@ func (this *YanxuanSpecialController) Collect() {
 		}
 		br.Msg = "取消收藏成功"
 	}
-
+	go services.UdpateYanxuanSpecialCollect(req.Id)
 	br.Ret = 200
 	br.Success = true
 }
@@ -615,7 +672,7 @@ func (this *YanxuanSpecialController) Center() {
 
 // @Title 专栏点击记录
 // @Description 专栏点击记录
-// @Param	request	body models.AddCygxReportSelectionSubjectHistoryReq true "type json string"
+// @Param	request	body models.AddCygxYanxuanSpecialRecordReq true "type json string"
 // @router /record [post]
 func (this *YanxuanSpecialController) Record() {
 	br := new(models.BaseResponse).Init()
@@ -636,32 +693,14 @@ func (this *YanxuanSpecialController) Record() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
+	specialId := req.SpecialId
+	stopTime := req.StopTime
 	if req.SpecialId <= 0 {
 		br.Msg = "文章不存在"
 		br.ErrMsg = "文章不存在,文章ID错误"
 		return
 	}
-	var sellerName string
-	sellerName, err = models.GetCompanySellerName(user.CompanyId)
-	if err != nil {
-		br.Msg = "报名失败!"
-		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
-		return
-	}
-	item := models.CygxYanxuanSpecialRecord{
-		UserId:           user.UserId,
-		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.AddCygxYanxuanSpecialRecord(&item)
+	err = services.AddSpecialRecord(this.User, specialId, stopTime)
 	if err != nil {
 		br.Msg = "记录失败"
 		br.ErrMsg = "记录失败,Err:" + err.Error()
@@ -683,8 +722,8 @@ func (this *YanxuanSpecialController) Follow() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	sysUser := this.User
-	if sysUser == nil {
+	user := this.User
+	if user == nil {
 		br.Msg = "请登录"
 		br.ErrMsg = "请登录,SysUser Is Empty"
 		br.Ret = 408
@@ -707,21 +746,22 @@ func (this *YanxuanSpecialController) Follow() {
 		return
 	}
 	var sellerName string
-	sellerName, err = models.GetCompanySellerName(sysUser.CompanyId)
+	sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
 	if err != nil {
-		br.Msg = "报名失败!"
-		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		br.Msg = "查询栏目详情失败!"
+		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
 		return
 	}
+	sellerName = sellerItemQy.RealName
 	if req.Status == 1 {
 		item := models.CygxYanxuanSpecialFollow{
-			UserId:           sysUser.UserId,
+			UserId:           user.UserId,
 			FollowUserId:     req.FollowUserId,
-			Mobile:           sysUser.Mobile,
-			Email:            sysUser.Email,
-			CompanyId:        sysUser.CompanyId,
-			CompanyName:      sysUser.CompanyName,
-			RealName:         sysUser.RealName,
+			Mobile:           user.Mobile,
+			Email:            user.Email,
+			CompanyId:        user.CompanyId,
+			CompanyName:      user.CompanyName,
+			RealName:         user.RealName,
 			SellerName:       sellerName,
 			CreateTime:       time.Now(),
 			ModifyTime:       time.Now(),
@@ -736,7 +776,7 @@ func (this *YanxuanSpecialController) Follow() {
 		}
 		br.Msg = "关注成功"
 	} else {
-		err = models.DelCygxYanxuanSpecialFollow(sysUser.UserId, req.FollowUserId)
+		err = models.DelCygxYanxuanSpecialFollow(user.UserId, req.FollowUserId)
 		if err != nil {
 			br.Msg = "删除失败"
 			br.ErrMsg = "删除失败,Err:" + err.Error()
@@ -744,7 +784,7 @@ func (this *YanxuanSpecialController) Follow() {
 		}
 		br.Msg = "取消关注成功"
 	}
-
+	go services.UdpateYanxuanSpecialFansNum(req.FollowUserId)
 	br.Ret = 200
 	br.Success = true
 }
@@ -853,16 +893,25 @@ func (this *YanxuanSpecialController) Cancel() {
 		return
 	}
 
+	specialItem, err := models.GetYanxuanSpecialItemById(req.Id)
+	if err != nil {
+		br.Msg = "专栏取消发布失败"
+		br.ErrMsg = "专栏取消发布失败,Err:" + err.Error()
+		return
+	}
+
 	if tmpErr := models.CancelPublishYanxuanSpecial(req.Id); tmpErr != nil {
 		br.Msg = "取消发布失败"
 		br.ErrMsg = "取消发布失败, Err:" + tmpErr.Error()
 		return
 	}
-	go services.UpdateYanxuanSpecialResourceData(req.Id) //  写入首页最新  cygx_resource_data 表
-	go services.EsAddYanxuanSpecial(req.Id)              //  写入es 综合搜索
+	go services.UpdateYanxuanSpecialResourceData(req.Id)                 //  写入首页最新  cygx_resource_data 表
+	go services.EsAddYanxuanSpecial(req.Id)                              //  写入es 综合搜索
+	go services.UdpateYanxuanSpecialauthorArticleNum(specialItem.UserId) //  更新作者发布文章的数量
 	br.Msg = "取消发布成功"
 	br.Ret = 200
 	br.Success = true
+
 }
 
 // @Title 作者列表
@@ -1117,3 +1166,130 @@ func (this *YanxuanSpecialController) Check() {
 	br.Success = true
 	br.Msg = "校验成功"
 }
+
+// @Title 上传文章阅读时间
+// @Description 上传文章阅读时间接口
+// @Param  request	body models.AddStopTimeRep true "type json string"
+// @Success 200 {object} models.ArticleDetailResp
+// @router /addStopTimedel [post]
+func (this *YanxuanSpecialController) AddStopTime() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	var req models.AddStopTimeRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	uid := user.UserId
+	articleId := req.ArticleId
+	stopTime := req.StopTime
+	outType := req.OutType
+	source := req.Source
+	if articleId <= 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误"
+		return
+	}
+	if stopTime == 0 {
+		stopTime = 1
+	}
+	if outType != 2 {
+		outType = 1
+	}
+	if source != "PC" {
+		source = "MOBILE"
+	}
+
+	detail := new(models.ArticleDetail)
+	hasPermission := 0
+	hasFree := 0
+
+	//判断是否已经申请过
+	applyCount, err := models.GetApplyRecordCount(uid)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+		return
+	}
+	//`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
+	if user.CompanyId > 1 {
+		companyPermission, err := models.GetCompanyPermission(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+			return
+		}
+		detail, err = models.GetArticleDetailById(articleId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取文章信息失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+			return
+		}
+		if companyPermission == "" {
+			if applyCount > 0 {
+				hasPermission = 5
+			} else {
+				hasPermission = 2
+			}
+			hasFree = 2
+			goto Loop
+		} else {
+			hasFree = 1
+			var articlePermissionPermissionName string
+			if detail.CategoryId > 0 {
+				articlePermission, err := models.GetArticlePermission(detail.CategoryId)
+				if err != nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+					return
+				}
+				if articlePermission == nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+					return
+				}
+				articlePermissionPermissionName = articlePermission.PermissionName
+			} else {
+				articlePermissionPermissionName = detail.CategoryName
+			}
+			var hasPersion bool
+			slice := strings.Split(articlePermissionPermissionName, ",")
+			for _, v := range slice {
+				if strings.Contains(companyPermission, v) {
+					hasPersion = true
+				}
+			}
+			if hasPersion {
+				go services.ArticleHistoryStopTime(articleId, stopTime, outType, user)
+			} else { //无该行业权限
+				hasPermission = 3
+			}
+		}
+	} else { //潜在客户
+		if applyCount > 0 {
+			hasPermission = 5
+		} else {
+			hasPermission = 4
+		}
+	}
+Loop:
+	resp := new(models.ArticleDetailAddStopTimeRep)
+	resp.HasPermission = hasPermission
+	resp.HasFree = hasFree
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+	br.Data = resp
+}

+ 23 - 0
models/activity_signup_detail.go

@@ -201,3 +201,26 @@ func UpdateActivitySignupDetailMultiMobileAndUserId(items []*CygxActivitySignupD
 	}
 	return
 }
+
+// UpdateActivitySignupDetailMulti 批量修改用户报名信息且报名的人
+func UpdateActivitySignupDetailMultiUserId(items []*CygxActivitySignupDetail) (err error) {
+	o := orm.NewOrm()
+	p, err := o.Raw(` UPDATE cygx_activity_signup_detail SET 
+							user_id = ?
+							WHERE mobile = ?  `).Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close() // 别忘记关闭 statement
+	}()
+	for _, v := range items {
+		_, err = p.Exec(
+			v.UserId,
+			v.Mobile)
+		if err != nil {
+			return
+		}
+	}
+	return
+}

+ 19 - 18
models/activity_special_trip_bill.go

@@ -6,24 +6,25 @@ import (
 )
 
 type CygxActivitySpecialTripBill struct {
-	Id                int       `orm:"column(id);pk"`
-	UserId            int       `description:"用户id,多个用,隔开"`
-	ActivityId        int       `description:"活动ID"`
-	CreateTime        time.Time `description:"创建时间"`
-	Mobile            string    `description:"手机号"`
-	Email             string    `description:"邮箱号"`
-	CompanyId         int       `description:"公司ID"`
-	CompanyName       string    `description:"公司名称"`
-	RealName          string    `description:"用户实际名称"`
-	AdminId           int       `description:"销售/管理员ID"`
-	Source            int       `description:"来源,1小程序,2后台添加, 3开发人员手动添加"`
-	BillDetailed      int       `description:"流水明细,判断是进账还是出账"`
-	DoType            int       `description:"操作方式,1报名,2取消报名"`
-	RegisterPlatform  int       `description:"来源 1小程序,2:网页"`
-	ChartPermissionId int       `description:"行业id"`
-	Way               int       `description:"1报名,取消报名。2到会取消到会 3转正或清零 4取消活动"`
-	Content           string    `description:"内容"`
-	Total             string    `description:"总和"`
+	Id                  int       `orm:"column(id);pk"`
+	UserId              int       `description:"用户id,多个用,隔开"`
+	ActivityId          int       `description:"活动ID"`
+	CreateTime          time.Time `description:"创建时间"`
+	Mobile              string    `description:"手机号"`
+	Email               string    `description:"邮箱号"`
+	CompanyId           int       `description:"公司ID"`
+	CompanyName         string    `description:"公司名称"`
+	RealName            string    `description:"用户实际名称"`
+	AdminId             int       `description:"销售/管理员ID"`
+	Source              int       `description:"来源,1小程序,2后台添加, 3开发人员手动添加"`
+	BillDetailed        int       `description:"流水明细,判断是进账还是出账"`
+	DoType              int       `description:"操作方式,1报名,2取消报名"`
+	RegisterPlatform    int       `description:"来源 1小程序,2:网页"`
+	ChartPermissionId   int       `description:"行业id"`
+	ChartPermissionName string    `description:"行业名称"`
+	Way                 int       `description:"1报名,取消报名。2到会取消到会 3转正或清零 4取消活动"`
+	Content             string    `description:"内容"`
+	Total               string    `description:"总和"`
 }
 
 // 添加

+ 28 - 0
models/admin.go

@@ -86,8 +86,23 @@ WHERE
 	return
 }
 
+// 获取IT人员手机号
+func GetRaiAdminIt() (items []*AdminMobileResp, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := ` SELECT
+	mobile 
+FROM
+	admin 
+WHERE
+	department_id = 3 
+	AND enabled = 1 `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 type GetSellerUserMobileResp struct {
 	Mobile string `description:"手机号"`
+	UserId int    `description:"用户ID"`
 }
 
 // 获取销售所能查看到的手机号
@@ -97,3 +112,16 @@ func GetSellerUserMobile(adminId int) (items []*GetSellerUserMobileResp, err err
 	_, err = o.Raw(sql, adminId).QueryRows(&items)
 	return
 }
+
+// GetUserSellerRelationUserList 获取跟销售绑定了关系的权益用户
+func GetUserSellerRelationUserList() (items []*GetSellerUserMobileResp, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := ` SELECT
+			a.user_id 
+		FROM
+			user_seller_relation AS a
+			INNER JOIN company_product AS b ON b.company_id = a.company_id 
+			AND b.product_id = 2 `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 2 - 0
models/article.go

@@ -645,6 +645,8 @@ type ArticleApiMap struct {
 	IsClass   int `description:"是否自动归类,1是,0否"`
 	IsReport  int `description:"是否属于报告,1是,0否"`
 	IsSummary int `description:"是否属于纪要,1是,0否"`
+	SeriesId  int `description:"策略平台那边的报告分类ID"`
+	OldIdMap  int `description:"策略平台老的分类ID样式map映射"`
 }
 
 func GetArticleApiMap() (item []*ArticleApiMap, err error) {

+ 33 - 0
models/article_and_yanxuan_record.go

@@ -0,0 +1,33 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxArticleAndYanxuanRecord struct {
+	Id               int       `orm:"column(id);pk"`
+	SourceId         int       `description:"资源ID"`
+	Source           string    `description:"资源I类型  文章、研选专栏"`
+	UserId           int       `description:"用户ID"`
+	CreateTime       string    `description:"创建时间"`
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司id"`
+	CompanyName      string    `description:"公司名称"`
+	ModifyTime       time.Time `description:"修改时间"`
+	RealName         string    `description:"用户实际名称"`
+	SellerName       string    `description:"所属销售"`
+	StopTime         int       `description:"停留时间"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+}
+
+// 批量添加
+func AddCygxArticleAndYanxuanRecordMulti(items []*CygxArticleAndYanxuanRecord) (err error) {
+	o := orm.NewOrm()
+	if len(items) > 0 {
+		//批量添加
+		_, err = o.InsertMulti(len(items), items)
+	}
+	return
+}

+ 49 - 0
models/article_history_record_all.go

@@ -0,0 +1,49 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxArticleHistoryRecordAll struct {
+	Id             int `orm:"column(id);pk"`
+	ArticleId      int
+	UserId         int
+	CreateTime     string
+	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:电脑端"`
+	RealName       string    `description:"用户实际名称"`
+	CreateDateApi  time.Time `description:"同步创建时间"`
+	CelueHistoryId int       `description:"策略平台记录的ID"`
+	Platfor        int       `description:"PV阅读记录来源,1:查研观向,2:策略平台"`
+	IsDel          int       `description:"是否删除"`
+}
+
+// 获取数量
+func GetCygxArticleHistoryRecordAllCountBycondition(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_history_record_all as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 列表
+func GetCygxArticleHistoryRecordAllList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxArticleHistoryRecordAll, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article_history_record_all as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 0 - 20
models/article_history_record_newpv.go

@@ -128,26 +128,6 @@ func UpdateCygxArticleViewRecordNewpvList(itemRep *CygxArticleHistoryRecordNewpv
 	return
 }
 
-type CygxArticleHistoryRecordAll struct {
-	Id             int `orm:"column(id);pk"`
-	ArticleId      int
-	UserId         int
-	CreateTime     string
-	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:电脑端"`
-	RealName       string    `description:"用户实际名称"`
-	CreateDateApi  time.Time `description:"同步创建时间"`
-	CelueHistoryId int       `description:"策略平台记录的ID"`
-	Platfor        int       `description:"PV阅读记录来源,1:查研观向,2:策略平台"`
-	IsDel          int       `description:"是否删除"`
-}
-
 // 获取当天总表的阅读记录
 func GetArticleHistoryRecordAllList() (items []*CygxArticleHistoryRecordNewpv, err error) {
 	o := orm.NewOrm()

+ 13 - 1
models/chart.go

@@ -95,6 +95,7 @@ type CygxChartDetail struct {
 	IsCollection  bool   `description:"是否收藏 "`
 	CollectionNum int    `description:"本人收藏数量 "`
 	HttpUrl       string `orm:"column(iframe)";description:"文章链接跳转地址"`
+	CreateDate    string `description:"本地创建时间"`
 }
 
 func GetChartCountById(chartId int) (count int, err error) {
@@ -234,7 +235,7 @@ func GetChartListCollectionNew(condition string, pars []interface{}, userId, sta
 			( SELECT COUNT(*) FROM cygx_chart_top AS t WHERE t.chart_id = a.chart_id AND t.user_id = ? ) AS is_top,
 			( SELECT COUNT(*) FROM cygx_chart_collect AS c WHERE c.chart_id = a.chart_id AND c.user_id = ? ) AS num_c 
 		FROM
-			cygx_chart_all AS a
+			cygx_chart AS a
 			LEFT JOIN cygx_chart_top AS t ON t.chart_id = a.chart_id
 			LEFT JOIN cygx_chart_collect AS c ON c.chart_id = a.chart_id 
 		WHERE
@@ -319,6 +320,17 @@ func GetChartDetailById(chartId, uid int) (item *CygxChartDetail, err error) {
 	return
 }
 
+func GetChartDetailByChartId(chartId int) (item *CygxChartDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * 
+		FROM
+			cygx_chart  as a 
+		WHERE
+			a.chart_id =? `
+	err = o.Raw(sql, chartId).QueryRow(&item)
+	return
+}
+
 // 删除
 func DeleteCygxChart(chartId int) (err error) {
 	o, err := orm.NewOrm().Begin()

+ 3 - 3
models/company.go

@@ -269,9 +269,9 @@ func GetCompanyByThirdName(tripartiteCompanyCode string) (item *Company, err err
 }
 
 // 更新机构互动量
-func UpdateComapanyInteractionNum(interactionNum, companyId int) (err error) {
+func UpdateComapanyInteractionNum(interactionNum, interactionNumSeller, companyId int) (err error) {
 	o := orm.NewOrmUsingDB("weekly_report")
-	sql := `UPDATE company SET interaction_num = ? WHERE company_id=? `
-	_, err = o.Raw(sql, interactionNum, companyId).Exec()
+	sql := `UPDATE company SET interaction_num = ? ,  interaction_num_seller = ?  WHERE company_id=? `
+	_, err = o.Raw(sql, interactionNum, interactionNumSeller, companyId).Exec()
 	return
 }

+ 111 - 46
models/cygx_yanxuan_special.go

@@ -22,37 +22,41 @@ type CygxYanxuanSpecial struct {
 	Type         int       // 类型1:笔记,2:观点
 	CompanyTags  string    // 公司标签
 	IndustryTags string    // 行业标签
+	AdminName    string    // 审核人员姓名
 }
 
 type CygxYanxuanSpecialItem struct {
-	Id            int    `orm:"column(id);pk"`
-	UserId        int    // 用户ID
-	CreateTime    string // 创建时间
-	ModifyTime    string // 修改时间
-	PublishTime   string // 提审过审或驳回时间
-	Content       string // 内容
-	Tags          string // 标签
-	Status        int    // 1:未发布,2:审核中 3:已发布 4:驳回
-	ImgUrl        string // 图片链接
-	DocUrl        string // 文档链接
-	SpecialName   string // 专栏名称
-	Introduction  string // 介绍
-	Label         string // 标签
-	NickName      string // 昵称
-	RealName      string // 姓名
-	Mobile        string // 手机号
-	HeadImg       string // 头像
-	BgImg         string // 背景图
-	Reason        string // 理由
-	Title         string // 标题
-	Type          int    // 类型1:笔记,2:观点
-	CollectNum    int
-	MyCollectNum  int
-	IsCollect     int
-	CompanyTags   string
-	IndustryTags  string
-	ContentHasImg int //正文是否包含图片 1包含 0不包含
-	Docs          []Doc
+	Id              int    `orm:"column(id);pk"`
+	UserId          int    // 用户ID
+	CreateTime      string // 创建时间
+	ModifyTime      string // 修改时间
+	PublishTime     string // 提审过审或驳回时间
+	Content         string // 内容
+	Tags            string // 标签
+	Status          int    // 1:未发布,2:审核中 3:已发布 4:驳回
+	ImgUrl          string // 图片链接
+	DocUrl          string // 文档链接
+	SpecialName     string // 专栏名称
+	Introduction    string // 介绍
+	Label           string // 标签
+	NickName        string // 昵称
+	RealName        string // 姓名
+	Mobile          string // 手机号
+	HeadImg         string // 头像
+	BgImg           string // 背景图
+	Reason          string // 理由
+	Title           string // 标题
+	Type            int    // 类型1:笔记,2:观点
+	CollectNum      int
+	MyCollectNum    int
+	IsCollect       int
+	CompanyTags     string
+	IndustryTags    string
+	ContentHasImg   int  //正文是否包含图片 1包含 0不包含
+	ContentHasStyle bool //正文是否包含格式
+	Docs            []Doc
+	Pv              string `description:"Pv"`
+	Uv              string `description:"Uv"`
 }
 
 type CygxYanxuanSpecialResp struct {
@@ -95,9 +99,12 @@ type CygxYanxuanSpecialCenterResp struct {
 	ContentHasImg   int  //正文是否包含图片 1包含 0不包含
 	ContentHasStyle bool //正文是否包含格式
 	Docs            []Doc
-	Annotation      string `description:"核心观点"`
-	Source          string `description:"来源"`
-	PublishDate     string // 提审过审或驳回时间      string `description:"核心观点"`
+	Annotation      string   `description:"核心观点"`
+	Source          string   `description:"来源"`
+	Pv              string   `description:"Pv"`
+	Uv              string   `description:"Uv"`
+	PublishDate     string   // 提审过审或驳回时间      string `description:"核心观点"`
+	BodyHighlight   []string `description:"搜索高亮展示结果"`
 }
 
 type Doc struct {
@@ -150,11 +157,11 @@ type EnableCygxYanxuanSpecialReq struct {
 	Reason string //理由
 }
 
-func EnableYanxuanSpecial(id, status int, reason string) (err error) {
+func EnableYanxuanSpecial(id, status int, reason, adminName string) (err error) {
 	o := orm.NewOrm()
 	sql := ``
-	sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,publish_time=NOW(),modify_time=NOW() WHERE id = ? `
-	_, err = o.Raw(sql, status, reason, id).Exec()
+	sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,admin_name = ? , publish_time=NOW() WHERE id = ? `
+	_, err = o.Raw(sql, status, reason, adminName, id).Exec()
 	return
 }
 
@@ -190,16 +197,17 @@ FROM cygx_yanxuan_special AS a
 }
 
 type CygxYanxuanSpecialReq struct {
-	Id           int    `orm:"column(id);pk"`
-	Content      string // 内容
-	Tags         string // 标签
-	DoType       int    // 1保存 2发布
-	ImgUrl       string // 图片链接
-	DocUrl       string // 文档链接
-	Title        string // 标题
-	Type         int    // 类型1:笔记,2:观点
-	IndustryTags string // 行业标签
-	CompanyTags  string // 公司标签
+	Id                  int    `orm:"column(id);pk"`
+	Content             string // 内容
+	Tags                string // 标签
+	DoType              int    // 1保存 2发布
+	ImgUrl              string // 图片链接
+	DocUrl              string // 文档链接
+	Title               string // 标题
+	Type                int    // 类型1:笔记,2:观点
+	IndustryTags        string // 行业标签
+	CompanyTags         string // 公司标签
+	IsApprovalPersonnel bool   // 是否是审批人员操作
 }
 
 func AddCygxYanxuanSpecial(item *CygxYanxuanSpecial) (lastId int64, err error) {
@@ -212,8 +220,8 @@ func UpdateYanxuanSpecial(item *CygxYanxuanSpecial) (err error) {
 	o := orm.NewOrm()
 	sql := ``
 	sql = `UPDATE cygx_yanxuan_special SET title=?,content=?,company_tags=?,industry_tags=?,img_url=?,doc_url=?,type=?,status=?,
-	modify_time=NOW(),publish_time=NOW() WHERE id = ? `
-	_, err = o.Raw(sql, item.Title, item.Content, item.CompanyTags, item.IndustryTags, item.ImgUrl, item.DocUrl, item.Type, item.Status, item.Id).Exec()
+	modify_time=NOW(),publish_time=NOW(),admin_name = ? WHERE id = ? `
+	_, err = o.Raw(sql, item.Title, item.Content, item.CompanyTags, item.IndustryTags, item.ImgUrl, item.DocUrl, item.Type, item.Status, item.AdminName, item.Id).Exec()
 	return
 }
 
@@ -291,3 +299,60 @@ func GetCygxYanxuanSpecialCount(condition string, pars []interface{}) (count int
 	err = o.Raw(sqlCount, pars).QueryRow(&count)
 	return
 }
+
+// UpdateYanxuanSpecialPv 修改研选专栏的阅读Pv
+func UpdateYanxuanSpecialPv(id int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_yanxuan_special SET pv=pv+1 WHERE id = ? `
+	_, err = o.Raw(sql, id).Exec()
+	return
+}
+
+// UpdateYanxuanSpecialUv 修改研选专栏的阅读Uv
+func UpdateYanxuanSpecialUv(id int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_yanxuan_special SET uv=uv+1 WHERE id = ? `
+	_, err = o.Raw(sql, id).Exec()
+	return
+}
+
+func UpdateYanxuanSpecialPvNUm(pv, id int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_yanxuan_special SET pv = ? WHERE id = ? `
+	_, err = o.Raw(sql, pv, id).Exec()
+	return
+}
+
+func UpdateYanxuanSpecialUvUm(pv, id int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_yanxuan_special SET uv = ? WHERE id = ? `
+	_, err = o.Raw(sql, pv, id).Exec()
+	return
+}
+
+// 增加收藏数量
+func UpdateYanxuanSpecialarticleCollectNumIncrease(id int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET article_collect_num = article_collect_num +1  WHERE id = ? `
+	_, err = o.Raw(sql, id).Exec()
+	return
+}
+
+// 减少收藏数量
+func UpdateYanxuanSpecialarticleCollectNumReduce(id int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET article_collect_num = article_collect_num  - 1  WHERE id = ? `
+	_, err = o.Raw(sql, id).Exec()
+	return
+}
+
+// 更新收藏数量
+func UpdateYanxuanSpecialarticleCollectNum(collectNum, id int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET article_collect_num = ?  WHERE id = ? `
+	_, err = o.Raw(sql, collectNum, id).Exec()
+	return
+}

+ 34 - 0
models/cygx_yanxuan_special_approval_log.go

@@ -0,0 +1,34 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecialApprovalLog struct {
+	ApprovalLogId    int       `orm:"column(approval_log_id);pk"`
+	UserId           int       // 用户ID
+	CreateTime       time.Time // 创建时间
+	ModifyTime       time.Time // 修改时间
+	Content          string    // 内容
+	Tags             string    // 标签
+	ApprovalStatus   int       // 1通过、2驳回
+	ImgUrl           string    // 图片链接
+	DocUrl           string    // 文档链接
+	Reason           string    // 理由
+	Title            string    // 标题
+	Type             int       // 类型1:笔记,2:观点
+	CompanyTags      string    // 公司标签
+	IndustryTags     string    // 行业标签
+	YanxuanSpecialId int       // cygx_yanxuan_special 表主键ID
+	AdminName        string    // 审核人员姓名
+	AdminUserId      int       // 审核人员用户ID
+	SpecialName      string    // 专栏名称
+	NickName         string    // 昵称
+}
+
+func AddCygxYanxuanSpecialApprovalLog(item *CygxYanxuanSpecialApprovalLog) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}

+ 32 - 13
models/cygx_yanxuan_special_collect.go

@@ -7,17 +7,17 @@ import (
 
 type CygxYanxuanSpecialCollect struct {
 	CygxYanxuanSpecialCollectId int       `orm:"column(cygx_yanxuan_special_collect_id);pk"`
-	UserId                      int        // 用户ID
-	Mobile                      string     // 手机号
-	Email                       string     // 邮箱
-	CompanyId                   int        // 公司ID
-	CompanyName                 string     // 公司名称
-	RealName                    string     // 用户实际名称
-	SellerName                  string     // 所属销售
-	CreateTime                  time.Time  // 创建时间
-	ModifyTime                  time.Time  // 修改时间
-	RegisterPlatform            int        // 来源 1小程序,2:网页
-	YanxuanSpecialId            int        // cygx_yanxuan_special 表主键ID
+	UserId                      int       // 用户ID
+	Mobile                      string    // 手机号
+	Email                       string    // 邮箱
+	CompanyId                   int       // 公司ID
+	CompanyName                 string    // 公司名称
+	RealName                    string    // 用户实际名称
+	SellerName                  string    // 所属销售
+	CreateTime                  time.Time // 创建时间
+	ModifyTime                  time.Time // 修改时间
+	RegisterPlatform            int       // 来源 1小程序,2:网页
+	YanxuanSpecialId            int       // cygx_yanxuan_special 表主键ID
 }
 
 func AddCygxYanxuanSpecialCollect(item *CygxYanxuanSpecialCollect) (lastId int64, err error) {
@@ -27,8 +27,8 @@ func AddCygxYanxuanSpecialCollect(item *CygxYanxuanSpecialCollect) (lastId int64
 }
 
 type CollectCygxYanxuanSpecialReq struct {
-	Id     int    // 文章id
-	Status int    // 1收藏2取消收藏
+	Id     int // 文章id
+	Status int // 1收藏2取消收藏
 }
 
 func DelCygxYanxuanSpecialCollect(userId, articleId int) (err error) {
@@ -37,3 +37,22 @@ func DelCygxYanxuanSpecialCollect(userId, articleId int) (err error) {
 	_, err = o.Raw(sql, userId, articleId).Exec()
 	return
 }
+
+// 获取数量
+func GetCygxYanxuanSpecialCollectCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_yanxuan_special_collect as a  WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// GetCygxYanxuanSpecialCollectByUser 根据用户ID获取所有文章收藏
+func GetCygxYanxuanSpecialCollectByUser(userId int) (items []*CygxYanxuanSpecialCollect, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_yanxuan_special_collect  WHERE 1 =1  AND  user_id =?  `
+	_, err = o.Raw(sql, userId).QueryRows(&items)
+	return
+}

+ 24 - 13
models/cygx_yanxuan_special_follow.go

@@ -6,19 +6,19 @@ import (
 )
 
 type CygxYanxuanSpecialFollow struct {
-	CygxYanxuanSpecialFollowId int        `orm:"column(cygx_yanxuan_special_follow_id);pk"`
-	UserId                     int        // 用户ID
-	FollowUserId               int        // 被关注用户ID
-	Mobile                     string     // 手机号
-	Email                      string     // 邮箱
-	CompanyId                  int        // 公司ID
-	CompanyName                string     // 公司名称
-	RealName                   string     // 用户实际名称
-	SellerName                 string     // 所属销售
-	CreateTime                 time.Time  // 创建时间
-	ModifyTime                 time.Time  // 修改时间
-	RegisterPlatform           int        // 来源 1小程序,2:网页
-	YanxuanSpecialId           int        // cygx_yanxuan_special 表主键ID
+	CygxYanxuanSpecialFollowId int       `orm:"column(cygx_yanxuan_special_follow_id);pk"`
+	UserId                     int       // 用户ID
+	FollowUserId               int       // 被关注用户ID
+	Mobile                     string    // 手机号
+	Email                      string    // 邮箱
+	CompanyId                  int       // 公司ID
+	CompanyName                string    // 公司名称
+	RealName                   string    // 用户实际名称
+	SellerName                 string    // 所属销售
+	CreateTime                 time.Time // 创建时间
+	ModifyTime                 time.Time // 修改时间
+	RegisterPlatform           int       // 来源 1小程序,2:网页
+	YanxuanSpecialId           int       // cygx_yanxuan_special 表主键ID
 }
 
 type FollowCygxYanxuanSpecialReq struct {
@@ -55,3 +55,14 @@ WHERE
 	_, err = o.Raw(sql, followUserId).QueryRows(&items)
 	return
 }
+
+// 获取数量
+func GetCygxYanxuanSpecialFollowCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_yanxuan_special_follow as a  WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}

+ 82 - 2
models/cygx_yanxuan_special_record.go

@@ -21,6 +21,22 @@ type CygxYanxuanSpecialRecord struct {
 	StopTime                   int       // 停留时间
 }
 
+type CygxYanxuanSpecialRecordResp struct {
+	CygxYanxuanSpecialRecordId int       `orm:"column(cygx_yanxuan_special_record_id);pk"`
+	UserId                     int       // 用户ID
+	Mobile                     string    // 手机号
+	Email                      string    // 邮箱
+	CompanyId                  int       // 公司ID
+	CompanyName                string    // 公司名称
+	RealName                   string    // 用户实际名称
+	SellerName                 string    // 所属销售
+	CreateTime                 string    // 创建时间
+	ModifyTime                 time.Time // 修改时间
+	RegisterPlatform           int       // 来源 1小程序,2:网页
+	YanxuanSpecialId           int       // cygx_yanxuan_special 表主键ID
+	StopTime                   int       // 停留时间
+}
+
 func AddCygxYanxuanSpecialRecord(item *CygxYanxuanSpecialRecord) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
@@ -28,5 +44,69 @@ func AddCygxYanxuanSpecialRecord(item *CygxYanxuanSpecialRecord) (lastId int64,
 }
 
 type AddCygxYanxuanSpecialRecordReq struct {
-	SpecialId           int `description:"专栏文章id"`
-}
+	SpecialId int `description:"专栏文章id"`
+	StopTime  int `description:"停留时间"`
+}
+
+// 获取数量
+func GetCygxYanxuanSpecialRecordCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_yanxuan_special_record as art  WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 获取数量
+func GetCygxYanxuanSpecialRecordCountGroup(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT	 count(*) AS count FROM
+	( SELECT COUNT(*) FROM cygx_yanxuan_special_record AS art WHERE 1 = 1 ` + condition + ` GROUP BY user_id ) f `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 判断一个用户是否阅读过 某一篇研选专栏
+func GetCygxYanxuanSpecialRecordCountByUser(userId, yanxuanSpecialId int) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_yanxuan_special_record as a  WHERE user_id= ?    AND yanxuan_special_id  = ? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, userId, yanxuanSpecialId).QueryRow(&count)
+	return
+}
+
+// 详细日志记录,不过滤时长小于 3 秒的那种
+type CygxYanxuanSpecialRecordLog struct {
+	CygxYanxuanSpecialRecordId int       `orm:"column(cygx_yanxuan_special_record_id);pk"`
+	UserId                     int       // 用户ID
+	Mobile                     string    // 手机号
+	Email                      string    // 邮箱
+	CompanyId                  int       // 公司ID
+	CompanyName                string    // 公司名称
+	RealName                   string    // 用户实际名称
+	SellerName                 string    // 所属销售
+	CreateTime                 time.Time // 创建时间
+	ModifyTime                 time.Time // 修改时间
+	RegisterPlatform           int       // 来源 1小程序,2:网页
+	YanxuanSpecialId           int       // cygx_yanxuan_special 表主键ID
+	StopTime                   int       // 停留时间
+}
+
+func AddCygxYanxuanSpecialRecordLog(item *CygxYanxuanSpecialRecordLog) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+// 列表
+func GetCygxYanxuanSpecialRecordRespList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialRecordResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_yanxuan_special_record as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 103 - 0
models/cygx_yanxuan_special_user.go

@@ -94,6 +94,14 @@ FROM
 	return
 }
 
+// 根据用户ID获取专栏详情
+func GetCygxYanxuanSpecialAuthorByUserId(userId int) (item *CygxYanxuanSpecialAuthorItem, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_yanxuan_special_author  WHERE user_id = ? `
+	err = o.Raw(sql, userId).QueryRow(&item)
+	return
+}
+
 type SaveCygxYanxuanSpecialAuthorReq struct {
 	UserId       int    // 用户ID
 	SpecialName  string // 专栏名称
@@ -158,3 +166,98 @@ func UpdateYanxuanSpecialAuthorHeadImg(item *CygxYanxuanSpecialAuthor) (err erro
 	_, err = o.Raw(sql, item.HeadImg, item.UserId).Exec()
 	return
 }
+
+// UpdateCygxYanxuanSpecialAuthorPv 修改研选专栏作者的阅读Pv
+func UpdateCygxYanxuanSpecialAuthorPv(userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET pv=pv+1 WHERE user_id = ? `
+	_, err = o.Raw(sql, userId).Exec()
+	return
+}
+
+// UpdateCygxYanxuanSpecialAuthorUv 修改研选专栏作者的阅读Uv
+func UpdateCygxYanxuanSpecialAuthorUv(userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET uv=uv+1 WHERE user_id = ? `
+	_, err = o.Raw(sql, userId).Exec()
+	return
+}
+
+// 增加收藏数量
+func UpdateYanxuanSpecialAuthorArticleCollectNumIncrease(userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET article_collect_num = article_collect_num +1  WHERE id = ? `
+	_, err = o.Raw(sql, userId).Exec()
+	return
+}
+
+// 减少收藏数量
+func UpdateYanxuanSpecialAuthorArticleCollectNumReduce(userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET article_collect_num = article_collect_num  - 1  WHERE id = ? `
+	_, err = o.Raw(sql, userId).Exec()
+	return
+}
+
+// 更新收藏数量
+func UpdateYanxuanSpecialAuthorArticleCollectNum(collectNum, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET article_collect_num = ?  WHERE user_id = ? `
+	_, err = o.Raw(sql, collectNum, userId).Exec()
+	return
+}
+
+// 增加粉丝数量
+func UpdateYanxuanSpecialAuthorFansNumIncrease(userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET fans_num = fans_num +1  WHERE id = ? `
+	_, err = o.Raw(sql, userId).Exec()
+	return
+}
+
+// 减少粉丝数量
+func UpdateYanxuanSpecialAuthorFansNumReduce(userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET fans_num = fans_num  - 1  WHERE id = ? `
+	_, err = o.Raw(sql, userId).Exec()
+	return
+}
+
+// 更新粉丝数量
+func UpdateYanxuanSpecialAuthorFansNum(fansNum, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET fans_num = ?  WHERE user_id = ? `
+	_, err = o.Raw(sql, fansNum, userId).Exec()
+	return
+}
+
+// 更新作者发布文章的数量
+func UdpateYanxuanSpecialauthorArticleNum(articleNum, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET article_num = ? WHERE user_id = ? `
+	_, err = o.Raw(sql, articleNum, userId).Exec()
+	return
+}
+
+func UpdateYanxuanSpecialauthorPvNUm(pv, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_yanxuan_special_author SET pv = ? WHERE user_id = ? `
+	_, err = o.Raw(sql, pv, userId).Exec()
+	return
+}
+
+func UpdateYanxuanSpecialauthorUvUm(pv, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_yanxuan_special_author SET uv = ? WHERE user_id = ? `
+	_, err = o.Raw(sql, pv, userId).Exec()
+	return
+}

+ 3 - 0
models/db.go

@@ -173,10 +173,12 @@ func init() {
 		new(CygxResourceDataIndustrialGroupSubject),
 		new(CygxIndustryFllowLog),
 		new(CygxYanxuanSpecialRecord),
+		new(CygxYanxuanSpecialRecordLog),
 		new(CygxYanxuanSpecialCollect),
 		new(CygxYanxuanSpecial),
 		new(CygxYanxuanSpecialFollow),
 		new(CygxYanxuanSpecialCompany),
+		new(CygxYanxuanSpecialApprovalLog),
 		new(CygxQuestionnaireVote),
 		new(CygxQuestionnaireVoteOtherTheme),
 		new(CygxMorningMeetingReviewChapterHistory),
@@ -184,6 +186,7 @@ func init() {
 		new(CygxAskserieVideoCollection),
 		new(CygxAskserieVideoCollect),
 		new(CygxVoiceAndVideoHistory),
+		new(CygxArticleAndYanxuanRecord),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 8 - 1
models/industrial_article_group_management.go

@@ -79,8 +79,15 @@ func GetIndustrialArticleGroupManagementList(condition string, pars []interface{
 	return
 }
 
+type IndustrialActivityGroupManagementRep struct {
+	IndustrialManagementId int    `description:"cygx_industrial_management表的主键ID"`
+	IndustryName           string `description:"产业名称"`
+	ChartPermissionId      int    `description:"权限id"`
+	PermissionName         string `description:"行业名称"`
+}
+
 // 列表
-func GetIndustrialArticleGroupManagementListByArticleId(articleId int) (items []*CygxIndustrialArticleGroupManagement, err error) {
+func GetIndustrialArticleGroupManagementListByArticleId(articleId int) (items []*IndustrialActivityGroupManagementRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			m.chart_permission_id,

+ 29 - 0
models/industrial_management.go

@@ -845,3 +845,32 @@ func UpdateIndustrialManagementArticleNewPublishData(items map[int]string) (err
 	}
 	return
 }
+
+// UpdateIndustrialManagementInit 初始化每月产业用户关注数量
+func UpdateIndustrialManagementInit() (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_industrial_management SET one_month_follow_num = 0 `
+	_, err = o.Raw(sql).Exec()
+	return
+}
+
+// UpdateIndustrialManagementOneMonthFollowNumMulti  批量修改每月产业用户关注数量
+func UpdateIndustrialManagementOneMonthFollowNumMulti(items []*CygxIndustryFllowNumResp) (err error) {
+	o := orm.NewOrm()
+	p, err := o.Raw(` UPDATE cygx_industrial_management SET one_month_follow_num = ? WHERE industrial_management_id = ?  `).Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close() // 别忘记关闭 statement
+	}()
+	for _, v := range items {
+		_, err = p.Exec(
+			v.Total,
+			v.IndustrialManagementId)
+		if err != nil {
+			return
+		}
+	}
+	return
+}

+ 27 - 0
models/industry_fllow.go

@@ -1,7 +1,9 @@
 package models
 
 import (
+	"fmt"
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_cygx/utils"
 	"time"
 )
 
@@ -213,3 +215,28 @@ func GetCygxIndustryFllowListByCon(condition string, pars []interface{}, startSi
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+type CygxIndustryFllowNumResp struct {
+	IndustrialManagementId int `description:"产业D"`
+	Total                  int `description:"关注数量"`
+}
+
+// 获取用户关注的产业列表
+func GetIndustrialManagementOneMonthFollowNum() (items []*CygxIndustryFllowNumResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) AS total,
+			industrial_management_id 
+		FROM
+			cygx_industry_fllow AS idf 
+		WHERE
+			1 = 1 
+			AND create_time > '%s' 
+			AND create_time < '%s' 
+			AND source != 3
+		GROUP BY
+			industrial_management_id `
+	sql = fmt.Sprintf(sql, time.Now().AddDate(0, -1, 0).Format(utils.FormatDate), time.Now().Format(utils.FormatDate))
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 159 - 29
models/report.go

@@ -588,6 +588,63 @@ func GetArticleCollectionList(condition string, userId int) (items []*ArticleCol
 	return
 } //end
 
+// 资源包研选跟研选专栏的搜索
+//func GetArticleAndYxSpecialList(condition, conditionSpecial string, userId int) (items []*ArticleCollectionResp, err error) {
+//	o := orm.NewOrm()
+//	sql := `SELECT
+//			a.article_id,
+//			a.title,
+//			date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
+//			d.nick_name,
+//			d.department_id,
+//			a.article_type_id,
+//			0 AS is_special,
+//			"" AS special_tags,
+//			"" AS company_tags,
+//			"" AS industry_tags,
+//			( 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 user_id = ? ) AS my_collect_num,
+//			'' AS special_type,
+//			'' AS user_id,
+//			'' AS create_time
+//		FROM
+//			cygx_article AS a
+//			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
+//			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
+//			INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
+//		WHERE
+//			1 = 1
+//			AND a.publish_status = 1 ` + condition + `  GROUP BY article_id
+//			UNION ALL
+//		SELECT
+//			a.id AS article_id,
+//			a.title AS title,
+//			date_format( a.publish_time, '%Y-%m-%d' ) AS publish_date,
+//			"" AS nick_name,
+//			0 AS department_id,
+//			- 1 AS article_type_id,
+//			1 AS is_special,
+//			a.tags AS special_tags,
+//			a.company_tags,
+//			a.industry_tags,
+//			( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
+//			( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
+//			( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num,
+//			a.type AS special_type,
+//			a.user_id AS user_id,
+//			a.create_time AS create_time
+//		FROM
+//			cygx_yanxuan_special AS a
+//			JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
+//		WHERE
+//			1 = 1
+//			AND a.STATUS = 3 ` + conditionSpecial + ` ORDER BY publish_date DESC  LIMIT 30`
+//
+//	_, err = o.Raw(sql, userId, userId).QueryRows(&items)
+//	return
+//} //end
+
 // 资源包研选跟研选专栏的搜索
 func GetArticleAndYxSpecialList(condition, conditionSpecial string, userId int) (items []*ArticleCollectionResp, err error) {
 	o := orm.NewOrm()
@@ -599,19 +656,16 @@ func GetArticleAndYxSpecialList(condition, conditionSpecial string, userId int)
 			d.department_id,
 			a.article_type_id,
 			0 AS is_special,
+			0 AS pv,
+			0 AS collect_num,
 			"" AS special_tags,
 			"" AS company_tags,
 			"" AS industry_tags,
-			( 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 user_id = ? ) AS my_collect_num,
 			'' AS special_type,
 			'' AS user_id,
 			'' AS create_time 
 		FROM
 			cygx_article AS a
-			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
-			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
 			INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id 
 		WHERE
 			1 = 1 
@@ -625,12 +679,11 @@ func GetArticleAndYxSpecialList(condition, conditionSpecial string, userId int)
 			0 AS department_id,
 			- 1 AS article_type_id,
 			1 AS is_special,
+			a.pv,
+			a.article_collect_num as collect_num,
 			a.tags AS special_tags,
 			a.company_tags,
 			a.industry_tags,
-			( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
-			( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
-			( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num,
 			a.type AS special_type,
 			a.user_id AS user_id,
 			a.create_time AS create_time 
@@ -641,7 +694,7 @@ func GetArticleAndYxSpecialList(condition, conditionSpecial string, userId int)
 			1 = 1 
 			AND a.STATUS = 3 ` + conditionSpecial + ` ORDER BY publish_date DESC  LIMIT 30`
 
-	_, err = o.Raw(sql, userId, userId).QueryRows(&items)
+	_, err = o.Raw(sql).QueryRows(&items)
 	return
 } //end
 
@@ -688,6 +741,69 @@ func GetArticleResearchCount(condition string, pars []interface{}, needYanxuanSp
 	return
 }
 
+//func GetArticleResearchList(condition string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (items []*ArticleCollectionResp, err error) {
+//	o := orm.NewOrm()
+//	sql := `SELECT
+//			a.article_id,
+//			a.title,
+//			a.publish_date AS publish_time,
+//			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 collect_num_order,
+//			( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id  AND user_id = ? ) AS my_collect_num,
+//			0 AS is_special,
+//			0 AS special_type,
+//			0 AS user_id,
+//			'' AS company_tags,
+//			'' AS industry_tags
+//		FROM
+//			cygx_article AS a
+//			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
+//			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
+//			INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
+//		WHERE
+//			1 = 1  AND a.publish_status = 1
+//		  `
+//	if condition != "" {
+//		sql += condition
+//	}
+//	sql += ` GROUP BY a.article_id  `
+//	if needYanxuanSpecial {
+//		sql += `UNION ALL
+//	SELECT
+//		a.id AS article_id,
+//		a.title AS title,
+//		a.publish_time AS publish_time,
+//		-1 AS article_type_id,
+//		b.nick_name AS nick_name,
+//		a.user_id AS department_id,
+//		( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
+//		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac  WHERE ac.yanxuan_special_id = a.id  ) AS collect_num,
+//		0 AS collect_num_order,
+//		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  AND user_id = ? ) AS my_collect_num,
+//		1 AS is_special,
+//		a.type AS special_type,
+//		a.user_id AS user_id,
+//		a.company_tags AS company_tags,
+//		a.industry_tags AS industry_tags
+//	FROM
+//	cygx_yanxuan_special AS a
+//	JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
+//	WHERE
+//	1 = 1  AND a.status = 3 `
+//		sql += ` ORDER  BY publish_time DESC  LIMIT ?,? `
+//		_, err = o.Raw(sql, userId, userId, pars, startSize, pageSize).QueryRows(&items)
+//	} else {
+//		sql += ` ORDER  BY publish_time DESC  LIMIT ?,? `
+//		_, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
+//	}
+//
+//	return
+//}
+
 func GetArticleResearchList(condition string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (items []*ArticleCollectionResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -697,11 +813,9 @@ func GetArticleResearchList(condition string, pars []interface{}, startSize, pag
 			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 collect_num_order, 
-			( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id  AND user_id = ? ) AS my_collect_num,
 			0 AS is_special,
+			0 as pv,
+			0 as collect_num,
 			0 AS special_type,
 			0 AS user_id,
 			'' AS company_tags, 
@@ -709,8 +823,6 @@ func GetArticleResearchList(condition string, pars []interface{}, startSize, pag
 			a.top_time
 		FROM
 			cygx_article AS a
-			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
-			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
 			INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id 
 		WHERE
 			1 = 1  AND a.publish_status = 1
@@ -728,11 +840,9 @@ func GetArticleResearchList(condition string, pars []interface{}, startSize, pag
 		-1 AS article_type_id,
 		b.nick_name AS nick_name,
 		a.user_id AS department_id,
-		( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
-		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac  WHERE ac.yanxuan_special_id = a.id  ) AS collect_num,
-		0 AS collect_num_order,
-		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  AND user_id = ? ) AS my_collect_num,
 		1 AS is_special,
+		a.pv,
+		a.article_collect_num as collect_num,
 		a.type AS special_type,
 		a.user_id AS user_id,
 		a.company_tags AS company_tags, 
@@ -743,13 +853,11 @@ func GetArticleResearchList(condition string, pars []interface{}, startSize, pag
 	JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
 	WHERE
 	1 = 1  AND a.status = 3 `
-		sql += ` ORDER  BY top_time DESC,  publish_time DESC  LIMIT ?,? `
-		_, err = o.Raw(sql, userId, userId, pars, startSize, pageSize).QueryRows(&items)
-	} else {
-		sql += ` ORDER  BY top_time DESC, publish_time DESC  LIMIT ?,? `
-		_, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
 	}
 
+	sql += ` ORDER  BY top_time DESC, publish_time DESC  LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+
 	return
 }
 
@@ -1059,6 +1167,31 @@ type ReoprtSearchResp struct {
 	ListHz []*ArticleCollectionResp `description:"弘则报告"`
 }
 
+//// 列表
+//func GetReoprtSearchList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
+//	o := orm.NewOrm()
+//	sql := `SELECT
+//			a.article_id,
+//			a.title,
+//			date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
+//			m.industry_name,
+//			m.industrial_management_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 user_id = ?) AS my_collect_num
+//		FROM
+//			cygx_article AS a
+//			LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
+//			LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
+//		WHERE
+//			1 = 1 `
+//	if condition != "" {
+//		sql += condition
+//	}
+//	_, err = o.Raw(sql, userId).QueryRows(&items)
+//	return
+//} //end
+
 // 列表
 func GetReoprtSearchList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
 	o := orm.NewOrm()
@@ -1067,10 +1200,7 @@ func GetReoprtSearchList(condition string, userId int) (items []*ArticleCollecti
 			a.title,
 			date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
 			m.industry_name,
-			m.industrial_management_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 user_id = ?) AS my_collect_num
+			m.industrial_management_id
 		FROM
 			cygx_article AS a
 			LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
@@ -1080,7 +1210,7 @@ func GetReoprtSearchList(condition string, userId int) (items []*ArticleCollecti
 	if condition != "" {
 		sql += condition
 	}
-	_, err = o.Raw(sql, userId).QueryRows(&items)
+	_, err = o.Raw(sql).QueryRows(&items)
 	return
 } //end
 

+ 19 - 1
models/resource_data.go

@@ -17,6 +17,9 @@ type CygxResourceData struct {
 	PublishDate       string    `description:"发布时间"`
 	Abstract          string    `description:"摘要"`
 	SearchTag         string    `description:"搜索标签"`
+	SearchTitle       string    `description:"搜索匹配用的标题"`
+	SearchContent     string    `description:"搜索匹配用的内容"`
+	SearchOrderTime   string    `description:"搜索排序时间"`
 }
 
 type CygxResourceDataResp struct {
@@ -61,7 +64,19 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 	return
 }
 
-// 获取用户报名成功数量
+// 列表
+func GetResourceDataListCondition(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxResourceData, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT	 *   FROM cygx_resource_data  WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `  ORDER BY search_order_time DESC   LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+// 获取数量
 func GetResourceDataCount(condition string, pars []interface{}) (count int, err error) {
 	sqlCount := `SELECT COUNT(1) AS count FROM cygx_resource_data    WHERE 1= 1 ` + condition
 	o := orm.NewOrm()
@@ -98,6 +113,9 @@ func UpdateResourceDataByItem(item *CygxResourceData) (err error) {
 	updateParams := make(map[string]interface{})
 	updateParams["PublishDate"] = item.PublishDate
 	updateParams["SearchTag"] = item.SearchTag
+	updateParams["SearchTitle"] = item.SearchTitle
+	updateParams["SearchContent"] = item.SearchContent
+	updateParams["SearchOrderTime"] = item.SearchOrderTime
 	ptrStructOrTableName := "cygx_resource_data"
 	whereParam := map[string]interface{}{"source_id": item.SourceId, "source": item.Source}
 	qs := o.QueryTable(ptrStructOrTableName)

+ 14 - 3
models/wx_user.go

@@ -377,7 +377,7 @@ func GetUserRegisterList() (items []*WxUser, err error) {
 			WHERE
 				user_id > 0 
 				AND company_id > 0 
-				AND create_time > DATE_SUB( DATE( NOW()), INTERVAL 1 DAY ) 
+				AND create_time > DATE_SUB( DATE( NOW()), INTERVAL 1 DAY ) OR  mobile = 18767183922
 			GROUP BY user_id `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
@@ -560,8 +560,7 @@ func GetCygxCompanyUserUserInteraction(userIds string) (items []*CygxUserInterac
 			WHERE
 				man.activity_id IN ( SELECT activity_id FROM cygx_activity_signup AS f WHERE f.user_id = u.user_id  AND label != '') 
 			) AS activity_label
-		FROM
-			cygx_user_label AS u WHERE  u.user_id IN( ` + userIds + `)  	GROUP BY u.user_id  `
+		FROM ` + utils.GetWeeklyDatabase() + `.wx_user AS u  WHERE  u.user_id IN( ` + userIds + `)  	GROUP BY u.user_id  `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
@@ -620,3 +619,15 @@ func GetWxUserOutboundMobiles(mobiles []string) (item []*WxUserOutboundMobile, e
 	_, err = o.Raw(sql, mobiles, mobiles).QueryRows(&item)
 	return
 }
+
+// 获取所有注册的权益用户
+func GetUserRegisterListinit() (items []*WxUser, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+				* 
+			FROM
+				cygx_user_label
+			GROUP BY user_id `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 1 - 1
services/activity.go

@@ -1219,7 +1219,7 @@ func ActivityConditioninitSql(user *models.WxUserItem, condition string, isPower
 	condition += `   AND art.publish_status = 1 `
 	conditionActivity = condition
 	//弘则可以查看所有活动
-	if (GetBelongingRai(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID) || user.UserId == 0 {
+	if (GetBelongingRaiIt(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID) || user.UserId == 0 {
 		return
 	}
 	adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)

+ 14 - 14
services/activity_special.go

@@ -1396,10 +1396,10 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
 			listTripBill[k].ChartPermissionName = PermissionNameMap[v.ChartPermissionId]
 		}
 		// 获取继承点数
-		inheritList, e := models.GetCygxActivitySpecialInheritPointsByCompanyId(companyId)
-		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("GetCygxActivitySpecialInheritPointsByCompanyId, Err: " + e.Error())
-		}
+		//inheritList, e := models.GetCygxActivitySpecialInheritPointsByCompanyId(companyId)
+		//if e != nil && e.Error() != utils.ErrNoRow() {
+		//	err = errors.New("GetCygxActivitySpecialInheritPointsByCompanyId, Err: " + e.Error())
+		//}
 		if userType == 2 {
 
 			var tripBillNum int
@@ -1409,13 +1409,13 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
 				//}
 				tripBillNum += v.BillDetailed
 			}
-			if len(inheritList) > 0 {
-				for _, v := range inheritList {
-					if v.ChartPermissionId == 0 {
-						tripBillNum += v.Points
-					}
-				}
-			}
+			//if len(inheritList) > 0 {
+			//	for _, v := range inheritList {
+			//		if v.ChartPermissionId == 0 {
+			//			tripBillNum += v.Points
+			//		}
+			//	}
+			//}
 
 			tripRemaining = tripBillNum
 			if tripRemaining < 0 {
@@ -1471,9 +1471,9 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
 				}
 			}
 			// 通过继承获得的加点
-			for _, v := range inheritList {
-				mapInheritChartName[v.ChartPermissionName] = v.Points
-			}
+			//for _, v := range inheritList {
+			//	mapInheritChartName[v.ChartPermissionName] = v.Points
+			//}
 			for k, _ := range chartNameMap {
 				if _, ok := mapChartName[k]; ok {
 					if inherit, ok2 := mapInheritChartName[k]; ok2 {

+ 31 - 0
services/admin.go

@@ -56,6 +56,28 @@ func GetRaiAdminMobileMap() (mapItem map[string]string) {
 	return
 }
 
+// GetRaiAdminMobileItMap 获取it内部人员手机号
+func GetRaiAdminMobileItMap() (mapItem map[string]string) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("获取权益内部人员手机号失败 ErrMsg:"+err.Error(), 2)
+
+		}
+	}()
+	adminList, e := models.GetRaiAdminIt()
+	if e != nil {
+		err = e
+		return
+	}
+	mapMobile := make(map[string]string)
+	for _, v := range adminList {
+		mapMobile[v.Mobile] = v.Mobile
+	}
+	mapItem = mapMobile
+	return
+}
+
 // 根据手机号判断是否属于权益
 func GetBelongingRai(mobile string) (isBelong bool) {
 	mapItem := GetRaiAdminMobileMap()
@@ -65,6 +87,15 @@ func GetBelongingRai(mobile string) (isBelong bool) {
 	return
 }
 
+// 根据手机号判断是否属于IT人员
+func GetBelongingRaiIt(mobile string) (isBelong bool) {
+	mapItem := GetRaiAdminMobileItMap()
+	if mapItem[mobile] != "" {
+		isBelong = true
+	}
+	return
+}
+
 // GetAdminCheckUserMobileMap  获取对应销售所能查看的用户手机号
 func GetAdminCheckUserMobileMap(user *models.WxUserItem) (mapItem map[string]string, err error) {
 	admin, e := models.GetSysAdminByMobile(user.Mobile)

+ 6 - 4
services/article.go

@@ -750,6 +750,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 	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)
@@ -766,7 +767,8 @@ func HandleArticleListByApi(artcleId int) (err error) {
 	fmt.Println(openIdList)
 	//新旧分类 反向隐射,是否归类,是否是报告,是否是纪要库
 	for _, v := range listMap {
-		exitMap[v.Id] = v.OldId
+		exitMap[v.SeriesId] = v.OldId
+		categoryIdMap[v.SeriesId] = v.OldIdMap
 		if v.IsClass == 1 {
 			classMap[v.OldId] = 1
 		}
@@ -827,7 +829,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 		item.Abstract = articleResult.Content.Abstract
 		item.Annotation = articleResult.Content.Annotation
 		item.CategoryName = articleResult.Industry.Name
-		item.CategoryId = exitMap[articleResult.SeriesId]
+		item.CategoryId = categoryIdMap[articleResult.SeriesId]
 		item.CategoryIdTwo = exitMap[articleResult.SeriesId]
 		item.SubCategoryName = articleResult.Series.Name
 		item.Cover = cover
@@ -917,9 +919,9 @@ func HandleArticleListByApi(artcleId int) (err error) {
 				v.IsSummary = 0
 			}
 		}
-		if _, has := reportMap[v.CategoryId]; has {
+		if _, has := reportMap[v.CategoryIdTwo]; has {
 			v.IsReport = 1
-			if _, ok := classMap[v.CategoryId]; ok {
+			if _, ok := classMap[v.CategoryIdTwo]; ok {
 				v.IsClass = 1
 				v.ReportType = 1 //是否属于行业报告
 			} else {

+ 125 - 0
services/article_history.go

@@ -1,6 +1,7 @@
 package services
 
 import (
+	"context"
 	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
@@ -148,3 +149,127 @@ func ArticleHistoryStopTime(articleId, stopTime, outType int, user *models.WxUse
 	go ArticleHistoryUserLabelLogAdd(articleId, uid)
 	return
 }
+
+//func init() {
+//	AddAllArticleAndYanxuanHistory()
+//}
+
+// 定时任务更新文章和研选专栏记录
+func AddAllArticleAndYanxuanHistory(cont context.Context) (err error) {
+	//func AddAllArticleAndYanxuanHistory() (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("同步阅读记录到es失败;AddAllArticleHistory Err:"+err.Error(), 2)
+		}
+	}()
+
+	var pars []interface{}
+	var condition string
+
+	var companyIds []int
+	condition = " AND  product_id = 2  AND STATUS IN ( '正式', '试用', '冻结' ) "
+	list, e := models.GetCompanyProductList(condition, pars)
+	if e != nil {
+		err = errors.New("GetCompanyProductList, Err: " + e.Error())
+		return
+	}
+
+	for _, v := range list {
+		companyIds = append(companyIds, v.CompanyId)
+	}
+
+	//添加文章记录
+	{
+		condition = ""
+		pars = make([]interface{}, 0)
+		condition = " AND art.company_id IN (" + utils.GetOrmInReplace(len(companyIds)) + ") AND   art.is_del = 0  AND art.create_time >= ?   AND art.create_time <= ?  "
+		pars = append(pars, companyIds, time.Now().AddDate(0, 0, -1).Format(utils.FormatDate), time.Now().Format(utils.FormatDate))
+		total, e := models.GetCygxArticleHistoryRecordAllCountBycondition(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxArticleHistoryRecordAllCount, Err: " + e.Error())
+			return
+		}
+		for i := 0; i <= total/2000; i++ {
+			allList, e := models.GetCygxArticleHistoryRecordAllList(condition, pars, 2000*i, 2000)
+			if e != nil {
+				err = errors.New("GetCygxArticleHistoryRecordAllList, Err: " + e.Error())
+				return
+			}
+			var items []*models.CygxArticleAndYanxuanRecord
+			for _, v := range allList {
+				item := new(models.CygxArticleAndYanxuanRecord)
+				item.SourceId = v.ArticleId
+				item.Source = utils.CYGX_OBJ_ARTICLE
+				item.UserId = v.UserId
+				item.RealName = v.RealName
+				item.Mobile = v.Mobile
+				item.Email = v.Email
+				item.CompanyId = v.CompanyId
+				item.CompanyName = v.CompanyName
+				item.CompanyId = v.CompanyId
+				item.CreateTime = v.CreateTime
+				item.ModifyTime = v.ModifyTime
+				item.StopTime = v.StopTime
+				if v.Source == "CELUE" {
+					item.RegisterPlatform = 3
+				} else if v.Source == "WEB" {
+					item.RegisterPlatform = 2
+				} else {
+					item.RegisterPlatform = 1
+				}
+				items = append(items, item)
+			}
+			e = models.AddCygxArticleAndYanxuanRecordMulti(items)
+			if e != nil {
+				err = errors.New("AddCygxArticleAndYanxuanRecordMulti, Err: " + e.Error())
+				return
+			}
+		}
+	}
+
+	//添加研选专栏记录
+	{
+		condition = ""
+		pars = make([]interface{}, 0)
+		condition = " AND   art.create_time >= ?   AND art.create_time <= ?   AND  user_id > 0 "
+		pars = append(pars, time.Now().AddDate(0, 0, -1).Format(utils.FormatDate), time.Now().Format(utils.FormatDate))
+		totalYanxuanSpecial, e := models.GetCygxYanxuanSpecialRecordCount(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxYanxuanSpecialRecordCount, Err: " + e.Error())
+			return
+		}
+		for i := 0; i <= totalYanxuanSpecial/2000; i++ {
+			listYanxuanSpecialRecord, e := models.GetCygxYanxuanSpecialRecordRespList(condition, pars, 2000*i, 2000)
+			if e != nil {
+				err = errors.New("GetCygxYanxuanSpecialRecordRespList, Err: " + e.Error())
+				return
+			}
+			var items []*models.CygxArticleAndYanxuanRecord
+			for _, v := range listYanxuanSpecialRecord {
+				item := new(models.CygxArticleAndYanxuanRecord)
+				item.SourceId = v.YanxuanSpecialId
+				item.Source = utils.CYGX_OBJ_YANXUANSPECIAL
+				item.UserId = v.UserId
+				item.RealName = v.RealName
+				item.Mobile = v.Mobile
+				item.Email = v.Email
+				item.CompanyId = v.CompanyId
+				item.CompanyName = v.CompanyName
+				item.CompanyId = v.CompanyId
+				item.CreateTime = v.CreateTime
+				item.ModifyTime = v.ModifyTime
+				item.StopTime = v.StopTime
+				item.RegisterPlatform = v.RegisterPlatform
+				items = append(items, item)
+			}
+			e = models.AddCygxArticleAndYanxuanRecordMulti(items)
+			if e != nil {
+				err = errors.New("AddCygxArticleAndYanxuanRecordMulti, Err: " + e.Error())
+				return
+			}
+		}
+	}
+
+	return
+}

+ 2 - 1
services/chart.go

@@ -588,7 +588,8 @@ func GetChartDetailByApi(chartId int) (err error) {
 		}
 	}
 
-	go AddComprehensiveChart(chartId) //同步图表到综合页面的搜索
+	go AddComprehensiveChart(chartId)      //同步图表到综合页面的搜索
+	go UpdateNewchartResourceData(chartId) ////把数据写入 cygx_resource_data 表
 	return
 
 }

+ 23 - 0
services/config.go

@@ -6,6 +6,7 @@ import (
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -108,3 +109,25 @@ func AddCygxAboutUsVideoHistory(user *models.WxUserItem) (err error) {
 	_, err = models.AddCygxAboutUsVideoHistory(historyRecord)
 	return
 }
+
+// CheckYxSpecialIsApprovalPersonnel 校验手机号是否属于研选专栏的审核人员
+func CheckYxSpecialIsApprovalPersonnel(mobile string) (isApprovalPersonnel bool) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("CheckYxSpecialIsApprovalPersonnel 校验手机号是否属于研选专栏的审核人员失败, mobile:", mobile, "ErrMsg", err.Error()), 2)
+		}
+	}()
+	var configCode string
+	//获取配置项里面审核人员的手机号
+	configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
+	cnf, e := models.GetConfigByCode(configCode)
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
+		return
+	}
+	if strings.Contains(cnf.ConfigValue, mobile) {
+		isApprovalPersonnel = true
+	}
+	return
+}

+ 183 - 75
services/cygx_yanxuan_special.go

@@ -226,83 +226,9 @@ func SendWxMsgSpecialAuthor(specialId, status int) (err error) {
 }
 
 //func init() {
-//
-//	var condition string
-//	var pars []interface{}
-//
-//	condition = " AND   a.user_id = 103354  "
-//	list, tmpErr := models.GetYanxuanSpecialList(0, condition, pars)
-//
-//	fmt.Println(len(list))
-//	fmt.Println(tmpErr)
-//
-//	for _, v := range list {
-//		fmt.Println(v.Id)
-//		EsAddYanxuanSpecial(v.Id)
-//	}
+//	UpdateYanxuanSpecialResourceData(229)
 //}
 
-// 更新研选专栏  写入首页最新  cygx_resource_data 表
-func UpdateYanxuanSpecialResourceData(sourceId int) {
-	var err error
-	defer func() {
-		if err != nil {
-			go utils.SendAlarmMsg(fmt.Sprint("更新研选专栏失败sourceId: ", sourceId, "ErrMsg", err.Error()), 2)
-		}
-	}()
-	var source = utils.CYGX_OBJ_YANXUANSPECIAL
-	var condition string
-	var pars []interface{}
-	condition = ` AND status = 3  AND  id = ?  `
-	pars = append(pars, sourceId)
-	total, e := models.GetCygxYanxuanSpecialCount(condition, pars)
-	if e != nil {
-		err = errors.New("GetCygxYanxuanSpecialCount, Err: " + e.Error())
-		return
-	}
-	//如果取消发布了就做删除处理
-	if total == 0 {
-		e = models.DeleteResourceData(sourceId, source)
-		if e != nil {
-			err = errors.New("DeleteResourceData, Err: " + e.Error())
-			return
-		}
-	} else {
-		//判断是否存在,如果不存在就新增,存在就更新
-		totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
-		if e != nil {
-			err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
-			return
-		}
-
-		detail, e := models.GetYanxuanSpecialBySpecialId(sourceId)
-		if e != nil {
-			err = errors.New("GetYanxuanSpecialBySpecialId, Err: " + e.Error())
-			return
-		}
-		publishDate := detail.PublishTime
-		item := new(models.CygxResourceData)
-		item.SourceId = sourceId
-		item.Source = source
-		item.PublishDate = publishDate
-		item.CreateTime = time.Now()
-		if totalData == 0 {
-			_, e := models.AddCygxResourceData(item)
-			if e != nil {
-				err = errors.New("AddCygxResourceData, Err: " + e.Error())
-				return
-			}
-		} else {
-			e = models.UpdateResourceDataByItem(item)
-			if e != nil {
-				err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
-				return
-			}
-		}
-	}
-	return
-}
-
 // 获取研选专栏用户信息
 func GetYanxuanSpecialAuthorInfo(user *models.WxUserItem) (isAuthor, isImproveInformation bool) {
 	var err error
@@ -361,3 +287,185 @@ func GetBestNewYanxuanSpecialByUserId(userIds []int) (mapResp map[int]*models.Cy
 	}
 	return
 }
+
+// 研选专栏审批记录
+func AddAddCygxYanxuanSpecialApprovalLog(user *models.WxUserItem, specialId, status int, reason string) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("获取研选专栏用户信息失败,GetYanxuanSpecialAuthorInfo Err ", err, "userId", user.UserId), 2)
+		}
+	}()
+	detail, e := models.GetYanxuanSpecialBySpecialId(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialBySpecialId, Err: " + e.Error())
+		return
+	}
+
+	specialAuthor, e := models.GetCygxYanxuanSpecialAuthorByUserId(detail.UserId)
+	if e != nil {
+		err = errors.New("GetCygxYanxuanSpecialAuthorByUserId, Err: " + e.Error())
+		return
+	}
+
+	item := new(models.CygxYanxuanSpecialApprovalLog)
+	item.UserId = detail.UserId
+	item.Content = detail.Content
+	item.Tags = detail.Tags
+	item.ApprovalStatus = status
+	item.ImgUrl = detail.ImgUrl
+	item.DocUrl = detail.DocUrl
+	item.Reason = reason
+	item.Title = detail.Title
+	item.Type = detail.Type
+	item.CompanyTags = detail.CompanyTags
+	item.IndustryTags = detail.IndustryTags
+	item.YanxuanSpecialId = specialId
+	item.AdminName = user.RealName
+	item.AdminUserId = user.UserId
+	item.SpecialName = specialAuthor.SpecialName
+	item.NickName = specialAuthor.NickName
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+
+	e = models.AddCygxYanxuanSpecialApprovalLog(item)
+	if e != nil {
+		err = errors.New("AddCygxYanxuanSpecialApprovalLog, Err: " + e.Error())
+		return
+	}
+	return
+}
+
+// 更新文章收藏数量
+func UdpateYanxuanSpecialCollect(specialId int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("更新文章收藏数量失败,UdpateYanxuanSpecialCollect Err ", err, "specialId:", specialId), 2)
+		}
+	}()
+	detail, e := models.GetYanxuanSpecialBySpecialId(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialBySpecialId, Err: " + e.Error())
+		return
+	}
+
+	specialAuthor, e := models.GetCygxYanxuanSpecialAuthorByUserId(detail.UserId)
+	if e != nil {
+		err = errors.New("GetCygxYanxuanSpecialAuthorByUserId, Err: " + e.Error())
+		return
+	}
+
+	var condition string
+	var pars []interface{}
+	condition = "  AND yanxuan_special_id = ? "
+	pars = append(pars, specialId)
+	//专栏被收藏的数量
+	totalSpecial, e := models.GetCygxYanxuanSpecialCollectCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxYanxuanSpecialCollectCount, Err: " + e.Error())
+		return
+	}
+
+	pars = make([]interface{}, 0)
+	condition = "  AND yanxuan_special_id  IN (SELECT id FROM cygx_yanxuan_special AS a WHERE user_id = ?)  "
+	pars = append(pars, specialAuthor.UserId)
+	//作者被收藏的数量
+	totalAuthor, e := models.GetCygxYanxuanSpecialCollectCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxYanxuanSpecialCollectCount, Err: " + e.Error())
+		return
+	}
+
+	//更新文章被收藏数量
+	e = models.UpdateYanxuanSpecialarticleCollectNum(totalSpecial, specialId)
+	if e != nil {
+		err = errors.New("UpdateYanxuanSpecialarticleCollectNum, Err: " + e.Error())
+		return
+	}
+
+	//更新作者文章被收藏数量
+	e = models.UpdateYanxuanSpecialAuthorArticleCollectNum(totalAuthor, specialAuthor.UserId)
+	if e != nil {
+		err = errors.New("UpdateYanxuanSpecialAuthorArticleCollectNum, Err: " + e.Error())
+		return
+	}
+	return
+}
+
+// 更新作者粉丝数量
+func UdpateYanxuanSpecialFansNum(specialUserIdId int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("更新作者粉丝数量失败,UdpateYanxuanSpecialFansNum Err ", err, "specialUserIdId", specialUserIdId), 2)
+		}
+	}()
+
+	var condition string
+	var pars []interface{}
+	condition = "  AND follow_user_id = ? "
+	pars = append(pars, specialUserIdId)
+	//作者粉丝数量
+	total, e := models.GetCygxYanxuanSpecialFollowCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxYanxuanSpecialFollowCount, Err: " + e.Error())
+		return
+	}
+	e = models.UpdateYanxuanSpecialAuthorFansNum(total, specialUserIdId)
+	if e != nil {
+		err = errors.New("UpdateYanxuanSpecialAuthorFansNum, Err: " + e.Error())
+		return
+	}
+	return
+}
+
+// UdpateYanxuanSpecialauthorArticleNum 更新作者发布文章的数量
+func UdpateYanxuanSpecialauthorArticleNum(authoruserId int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("更新作者发布文章的数量失败,UdpateYanxuanSpecialauthorArticleNum Err ", err, "userId", authoruserId), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	condition = ` AND status = 3  AND  user_id = ?  `
+	pars = append(pars, authoruserId)
+	total, e := models.GetCygxYanxuanSpecialCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxYanxuanSpecialCount, Err: " + e.Error())
+		return
+	}
+	e = models.UdpateYanxuanSpecialauthorArticleNum(total, authoruserId)
+	if e != nil {
+		err = errors.New("UdpateYanxuanSpecialauthorArticleNum, Err: " + e.Error())
+		return
+	}
+	return
+}
+
+// GetYanxuanSpecialCollectMap 根据用户ID获取所有研选专栏的收藏
+func GetYanxuanSpecialCollectMap(userId int) (mapResp map[int]bool, err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("GetYanxuanSpecialCollectMap 根据用户ID获取所有研选专栏的收藏失败 ErrMsg:"+err.Error(), 2)
+
+		}
+	}()
+	list, e := models.GetCygxYanxuanSpecialCollectByUser(userId)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("根据用户ID获取所有文章收藏,GetCygxYanxuanSpecialCollectByUser " + e.Error())
+		return
+	}
+	mapResp = make(map[int]bool, 0)
+	if len(list) > 0 {
+		for _, v := range list {
+			mapResp[v.YanxuanSpecialId] = true
+		}
+	}
+	return
+}

+ 98 - 21
services/cygx_yanxuan_special_company.go

@@ -3,6 +3,7 @@ package services
 import (
 	"context"
 	"encoding/json"
+	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
@@ -44,11 +45,10 @@ func GetStocksFromVmp(cont context.Context) (err error) {
 
 	items := make([]*models.CygxYanxuanSpecialCompany, 0)
 
-
 	for i, _ := range resp.Data {
 		items = append(items, &resp.Data[i])
 		if len(items) > 5000 {
-			err  = models.AddCygxYanxuanSpecialCompanyMulti(items)
+			err = models.AddCygxYanxuanSpecialCompanyMulti(items)
 			if err != nil {
 				fmt.Println("AddCygxYanxuanSpecialCompanyMulti Err:%s", err.Error())
 				return
@@ -57,7 +57,7 @@ func GetStocksFromVmp(cont context.Context) (err error) {
 		}
 	}
 
-	err  = models.AddCygxYanxuanSpecialCompanyMulti(items)
+	err = models.AddCygxYanxuanSpecialCompanyMulti(items)
 	if err != nil {
 		fmt.Println("AddCygxYanxuanSpecialCompanyMulti Err:%s", err.Error())
 		return
@@ -65,27 +65,104 @@ func GetStocksFromVmp(cont context.Context) (err error) {
 	return
 }
 
-func AddSpecialRecord(user *models.WxUserItem, specialId int) {
+// 记录用户阅读时长
+func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err error) {
+	if user.UserId == 0 {
+		return
+	}
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("记录用户阅读时长 失败 AddSpecialRecord Err:"+err.Error(), "userId:", user.UserId, "specialId:", specialId), 2)
+		}
+	}()
 	var sellerName string
-	sellerName, err := models.GetCompanySellerName(user.CompanyId)
-	if err != nil {
+	//获取销售信息
+	sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if e != nil {
+		err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
 		return
 	}
-	item := models.CygxYanxuanSpecialRecord{
-		UserId:           user.UserId,
-		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: specialId,
+	sellerName = sellerItem.RealName
+
+	if stopTime >= 3 {
+
+		//判断一个用户是否阅读过 某一篇研选专栏
+		totalRecord, e := models.GetCygxYanxuanSpecialRecordCountByUser(user.UserId, specialId)
+		if e != nil {
+			err = errors.New("GetCygxYanxuanSpecialRecordCountByUser, Err: " + e.Error())
+			return
+		}
+
+		item := new(models.CygxYanxuanSpecialRecord)
+		item.UserId = user.UserId
+		item.Mobile = user.Mobile
+		item.Email = user.Email
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		item.RealName = user.RealName
+		item.SellerName = sellerName
+		item.CreateTime = time.Now().Add(-time.Duration(stopTime) * time.Second) // 往前推迟的时间就是他的阅读时间
+		item.ModifyTime = time.Now()
+		item.RegisterPlatform = utils.REGISTER_PLATFORM
+		item.YanxuanSpecialId = specialId
+		item.StopTime = stopTime
+		_, e = models.AddCygxYanxuanSpecialRecord(item) // 添加历史记录
+		if e != nil {
+			err = errors.New("AddCygxYanxuanSpecialRecord, Err: " + e.Error())
+			return
+		}
+		//如果不是弘则研究的人员阅读的,就修改Pv、Uv数量
+		if user.CompanyId != utils.HZ_COMPANY_ID {
+
+			//专栏Pv数量进行加一
+			e = models.UpdateYanxuanSpecialPv(specialId)
+			if e != nil {
+				err = errors.New("UpdateYanxuanSpecialPv, Err: " + e.Error())
+				return
+			}
+
+			//专栏作者Pv数量进行加一
+			e = models.UpdateCygxYanxuanSpecialAuthorPv(user.UserId)
+			if e != nil {
+				err = errors.New("UpdateCygxYanxuanSpecialAuthorPv, Err: " + e.Error())
+				return
+			}
+
+			//如果没有阅读过,那么就给专栏文章的UV、作者的UV进行加一
+			if totalRecord == 0 {
+				e = models.UpdateYanxuanSpecialUv(specialId)
+				if e != nil {
+					err = errors.New("UpdateYanxuanSpecialUv, Err: " + e.Error())
+					return
+				}
+
+				//专栏作者Uv数量进行加一
+				e = models.UpdateCygxYanxuanSpecialAuthorUv(user.UserId)
+				if e != nil {
+					err = errors.New("UpdateCygxYanxuanSpecialAuthorUv, Err: " + e.Error())
+					return
+				}
+			}
+		}
 	}
-	_, err = models.AddCygxYanxuanSpecialRecord(&item)
-	if err != nil {
+
+	itemLog := new(models.CygxYanxuanSpecialRecordLog)
+	itemLog.UserId = user.UserId
+	itemLog.Mobile = user.Mobile
+	itemLog.Email = user.Email
+	itemLog.CompanyId = user.CompanyId
+	itemLog.CompanyName = user.CompanyName
+	itemLog.RealName = user.RealName
+	itemLog.SellerName = sellerName
+	itemLog.CreateTime = time.Now().Add(-time.Duration(stopTime) * time.Second) // 往前推迟的时间就是他的阅读时间
+	itemLog.ModifyTime = time.Now()
+	itemLog.RegisterPlatform = utils.REGISTER_PLATFORM
+	itemLog.YanxuanSpecialId = specialId
+	itemLog.StopTime = stopTime
+	_, e = models.AddCygxYanxuanSpecialRecordLog(itemLog) // 添加历史记录
+	if e != nil {
+		err = errors.New("AddCygxYanxuanSpecialRecordLog, Err: " + e.Error())
 		return
 	}
-}
+	return
+}

+ 3 - 3
services/elasticsearch.go

@@ -151,7 +151,7 @@ func SaveData() {
 
 type tracelog struct{}
 
-//实现输出
+// 实现输出
 func (tracelog) Printf(format string, v ...interface{}) {
 	fmt.Printf(format, v...)
 }
@@ -397,7 +397,7 @@ func RemoveDuplicatesAndEmpty(a []string) (ret []string) {
 	return
 }
 
-//KeyWordArrSqlRegexp 预处理ik联想词的模糊查询语句
+// KeyWordArrSqlRegexp 预处理ik联想词的模糊查询语句
 func KeyWordArrSqlRegexp(a []string) (ret string) {
 	a_len := len(a)
 	for i := 0; i < a_len; i++ {
@@ -410,7 +410,7 @@ func KeyWordArrSqlRegexp(a []string) (ret string) {
 	return
 }
 
-//KeyWordArrSqlRegexp 预处理ik联想词的模糊查询语句
+// KeyWordArrSqlRegexp 预处理ik联想词的模糊查询语句
 func KeyWordArrSqlRegexpAll(a []string) (ret string) {
 	a_len := len(a)
 	for i := 0; i < a_len; i++ {

+ 152 - 33
services/es_comprehensive.go

@@ -167,6 +167,10 @@ func AddComprehensiveChart(chartId int) {
 	}
 }
 
+//func init() {
+//	AddComprehensiveIndustrialSource("Hz", 9433)
+//}
+
 // 添加产业资源包
 func AddComprehensiveIndustrialSource(sourceType string, articleId int) {
 	var err error
@@ -212,7 +216,7 @@ func AddComprehensiveIndustrialSource(sourceType string, articleId int) {
 	}
 	//indexName := utils.IndexNameComprehensive
 	for _, v := range list {
-		time.Sleep(200 * time.Millisecond)
+		//time.Sleep(200 * time.Millisecond)
 		item := new(ElasticComprehensiveDetail)
 		item.SourceId = v.IndustrialManagementId
 		item.Source = industrialsource
@@ -228,6 +232,7 @@ func AddComprehensiveIndustrialSource(sourceType string, articleId int) {
 		}
 		fmt.Println(item)
 		EsAddOrEditComprehensiveData(item)
+		UpdateComprehensiveIndustrialResourceData(item)
 	}
 }
 
@@ -611,6 +616,9 @@ func EsAddYanxuanSpecial(sourceId int) {
 	item.Title = detail.Title
 	item.PublishDate = detail.PublishTime
 	item.BodyText = bodyText
+	item.Abstract = bodyText
+	item.IndustryName = detail.IndustryTags
+	item.SubjectNames = detail.CompanyTags + detail.Tags
 	if detail.Status == 3 {
 		EsAddOrEditComprehensiveData(item) //如果发布了就新增
 	} else {
@@ -965,6 +973,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 	uid := user.UserId
 	titleHighlight := make(map[int]string)
 	bodyHighlight := make(map[int][]string)
+	yanXuanbodyHighlight := make(map[int][]string)
 	//var bodyHighlight []string
 	mapItems := make(map[string]*models.CygxResourceDataResp)
 	for _, v := range list {
@@ -999,6 +1008,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 	var industrialResourceIdsYx []int // 研选产业资源包
 	var yanxuanSpecialIds []int       // 研选专栏
 	var askserieVideoIds []string     //问答系列视频
+	var reportselectionIds []int      //报告精选
 	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt "`
 	for _, v := range list {
 		if v.Source == "article" {
@@ -1029,8 +1039,11 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 			industrialResourceIdsYx = append(industrialResourceIdsYx, v.SourceId)
 		} else if v.Source == utils.CYGX_OBJ_YANXUANSPECIAL {
 			yanxuanSpecialIds = append(yanxuanSpecialIds, v.SourceId)
+			yanXuanbodyHighlight[v.SourceId] = v.Body
 		} else if v.Source == utils.CYGX_OBJ_ASKSERIEVIDEO {
 			askserieVideoIds = append(askserieVideoIds, strconv.Itoa(v.SourceId))
+		} else if v.Source == "reportselection" {
+			reportselectionIds = append(reportselectionIds, v.SourceId)
 		}
 	}
 	//处理文章
@@ -1136,6 +1149,27 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 		}
 	}
 
+	//处理报告精选
+	lenreportselectionIds := len(reportselectionIds)
+	if lenreportselectionIds > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND article_id IN (` + utils.GetOrmInReplace(lenreportselectionIds) + `)`
+		pars = append(pars, reportselectionIds)
+		listreportselection, e := models.GetReportSelectionList(condition, pars, 0, lenreportselectionIds)
+		if e != nil {
+			err = errors.New("GetReportSelectionList, Err: " + e.Error())
+			return
+		}
+		mapPv := GetCygxReportHistoryRecordListMap(reportselectionIds, "bgjx")
+		for _, v := range listreportselection {
+			v.Title += "(第" + v.Periods + "期)"
+			v.MarketStrategy = AnnotationHtml(v.MarketStrategy)
+			v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
+			v.Pv = mapPv[v.ArticleId]
+			mapItems[fmt.Sprint("reportselection", v.ArticleId)].ReportSelection = v
+		}
+	}
+
 	detail, e := models.GetConfigByCode("city_img_url")
 	if e != nil {
 		err = errors.New("GetResourceDataList, Err: " + e.Error())
@@ -1448,6 +1482,12 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 		for _, v := range listyanxuanSpecial {
 			v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
 			v.Annotation, _ = GetReportContentTextSubNew(v.Content)
+			if len(yanXuanbodyHighlight[v.Id]) > 0 {
+				v.BodyHighlight = yanXuanbodyHighlight[v.Id]
+			} else {
+				v.BodyHighlight = append(v.BodyHighlight, v.Annotation)
+			}
+			v.Annotation = "" //强制置空,兼容前端优先级
 			// Source  PublishDate 字段兼容前端样式
 			v.Source = utils.CYGX_OBJ_YANXUANSPECIAL
 			v.PublishDate = v.PublishTime
@@ -1458,43 +1498,47 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 	for _, vList := range list {
 		for _, v := range mapItems {
 			//如果这些类型都为空,那么就不合并
-			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.YanxuanSpecial == nil && v.AskserieVideo == nil {
+			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.YanxuanSpecial == nil && v.AskserieVideo == nil && v.ReportSelection == nil {
 				continue
 			}
-			if v.Article != nil && v.SourceId == vList.SourceId {
-				v.Article.Title = vList.Title
-			}
-			if v.Newchart != nil && v.SourceId == vList.SourceId {
-				v.Newchart.Title = vList.Title
-			}
-			if v.Roadshow != nil && v.SourceId == vList.SourceId {
-				v.Roadshow.Title = vList.Title
-			}
-			if v.Activity != nil && v.SourceId == vList.SourceId {
-				v.Activity.ActivityName = vList.Title
-			}
-			if v.Activityvideo != nil && v.SourceId == vList.SourceId {
-				v.Activityvideo.Title = vList.Title
-			}
-			if v.Activityvoice != nil && v.SourceId == vList.SourceId {
-				v.Activityvoice.Title = vList.Title
-			}
-
-			if v.Activityspecial != nil && v.SourceId == vList.SourceId {
-				v.Activityspecial.ResearchTheme = vList.Title
-			}
-			if v.Researchsummary != nil && v.SourceId == vList.SourceId {
-				v.Researchsummary.Title = vList.Title
-			}
-			if v.Minutessummary != nil && v.SourceId == vList.SourceId {
-				v.Minutessummary.Title = vList.Title
-			}
-			if v.ProductInterior != nil && v.SourceId == vList.SourceId {
-				v.ProductInterior.Title = vList.Title
-			}
+			//if v.Article != nil && v.SourceId == vList.SourceId {
+			//	v.Article.Title = vList.Title
+			//}
+			//if v.Newchart != nil && v.SourceId == vList.SourceId {
+			//	v.Newchart.Title = vList.Title
+			//}
+			//if v.Roadshow != nil && v.SourceId == vList.SourceId {
+			//	v.Roadshow.Title = vList.Title
+			//}
+			//if v.Activity != nil && v.SourceId == vList.SourceId {
+			//	v.Activity.ActivityName = vList.Title
+			//}
+			//if v.Activityvideo != nil && v.SourceId == vList.SourceId {
+			//	v.Activityvideo.Title = vList.Title
+			//}
+			//if v.Activityvoice != nil && v.SourceId == vList.SourceId {
+			//	v.Activityvoice.Title = vList.Title
+			//}
+			//
+			//if v.Activityspecial != nil && v.SourceId == vList.SourceId {
+			//	v.Activityspecial.ResearchTheme = vList.Title
+			//}
+			//if v.Researchsummary != nil && v.SourceId == vList.SourceId {
+			//	v.Researchsummary.Title = vList.Title
+			//}
+			//if v.Minutessummary != nil && v.SourceId == vList.SourceId {
+			//	v.Minutessummary.Title = vList.Title
+			//}
+			//if v.ProductInterior != nil && v.SourceId == vList.SourceId {
+			//	v.ProductInterior.Title = vList.Title
+			//}
 			//if v.IndustrialResource != nil && v.SourceId == vList.SourceId {
 			//	v.IndustrialResource.UpdateTime = vList.PublishDate
 			//}
+
+			//if v.YanxuanSpecial != nil && v.SourceId == vList.SourceId {
+			//	v.YanxuanSpecial.Title = vList.Title
+			//}
 			if v.SourceId == vList.SourceId && v.Source == vList.Source {
 				items = append(items, v)
 			}
@@ -1507,3 +1551,78 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 	}
 	return
 }
+
+func SqlComprehensiveSearch(keyWord string, startSize, pageSize int) (result []*SearchComprehensiveItem, total int, err error) {
+	keyWord = "%" + keyWord + "%"
+	var conditionTitle string
+	var parsTitle []interface{}
+	conditionTitle = " AND search_title LIKE ? "
+	parsTitle = append(parsTitle, keyWord)
+	totalTitle, e := models.GetResourceDataCount(conditionTitle, parsTitle)
+	if e != nil {
+		err = errors.New("GetResourceDataCount, Err: " + e.Error())
+		return
+	}
+
+	var conditionContent string
+	var parsContent []interface{}
+
+	conditionContent = " AND search_content LIKE ? AND search_title  NOT LIKE ?  "
+	parsContent = append(parsContent, keyWord, keyWord)
+	totalContent, e := models.GetResourceDataCount(conditionContent, parsContent)
+	if e != nil {
+		err = errors.New("AddCygxArticleViewRecord, Err: " + e.Error())
+		return
+	}
+	var searchTotal int
+	searchTotal = (startSize/pageSize + 1) * pageSize
+	var list []*models.CygxResourceData
+	fmt.Println("totalTitle", totalTitle)
+	fmt.Println("totalContent", totalContent)
+	fmt.Println(searchTotal)
+	if totalTitle >= searchTotal {
+		fmt.Println("1")
+		//全部都是标题搜索
+		list, e = models.GetResourceDataListCondition(conditionTitle, parsTitle, startSize, pageSize)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetResourceDataListCondition, Err: " + e.Error())
+			return
+		}
+	} else if totalTitle <= searchTotal-pageSize {
+		fmt.Println("2")
+		//全部都是内容搜索
+		startSize = startSize - totalTitle
+
+		list, e = models.GetResourceDataListCondition(conditionContent, parsContent, startSize, pageSize)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetResourceDataListCondition, Err: " + e.Error())
+			return
+		}
+	} else {
+		fmt.Println("3")
+		//一半标题搜索,一半内容搜索
+
+		list, e = models.GetResourceDataListCondition(conditionTitle, parsTitle, startSize, pageSize)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetResourceDataListCondition, Err: " + e.Error())
+			return
+		}
+		listContent, e := models.GetResourceDataListCondition(conditionContent, parsContent, 0, pageSize-totalContent%pageSize)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetResourceDataListCondition, Err: " + e.Error())
+			return
+		}
+		for _, v := range listContent {
+			list = append(list, v)
+		}
+	}
+
+	for _, v := range list {
+		item := new(SearchComprehensiveItem)
+		item.SourceId = v.SourceId
+		item.Source = v.Source
+		result = append(result, item)
+	}
+	total = totalTitle + totalContent
+	return
+}

+ 49 - 0
services/industrial_management.go

@@ -801,3 +801,52 @@ func GetCygxIndustrialSubjectMap() (itemMap map[int]string, err error) {
 	}
 	return
 }
+
+//func init() {
+//	UpdateIndustrialManagementOneMonthFollowNum()
+//}
+
+// UpdateIndustrialManagementOneMonthFollowNum 更新产业近一个月被关注的数量
+func UpdateIndustrialManagementOneMonthFollowNum(cont context.Context) (err error) {
+	//var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("UpdateIndustrialManagementOneMonthFollowNum ErrMsg:"+err.Error(), 2)
+		}
+	}()
+	listNum, e := models.GetIndustrialManagementOneMonthFollowNum()
+	if e != nil {
+		err = errors.New("GetIndustrialManagementOneMonthFollowNum, Err: " + e.Error())
+		return
+	}
+
+	e = models.UpdateIndustrialManagementInit() //初始化每月产业用户关注数量
+	if e != nil {
+		err = errors.New("UpdateIndustrialManagementInit, Err: " + e.Error())
+		return
+	}
+	var items []*models.CygxIndustryFllowNumResp
+	for _, v := range listNum {
+		item := new(models.CygxIndustryFllowNumResp)
+		item.IndustrialManagementId = v.IndustrialManagementId
+		item.Total = v.Total
+		items = append(items, item)
+		//一次最多插入五百条
+		if len(items)%500 == 0 {
+			e = models.UpdateIndustrialManagementOneMonthFollowNumMulti(items)
+			if e != nil {
+				err = errors.New("UpdateIndustrialManagementOneMonthFollowNumMulti, Err: " + e.Error())
+				return
+			}
+		}
+	}
+	if len(items) > 0 {
+		e = models.UpdateIndustrialManagementOneMonthFollowNumMulti(items)
+		if e != nil {
+			err = errors.New("UpdateIndustrialManagementOneMonthFollowNumMulti, Err: " + e.Error())
+			return
+		}
+	}
+	return
+}

+ 277 - 0
services/init12.8.go

@@ -0,0 +1,277 @@
+package services
+
+import (
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+)
+
+func init11() {
+	var condition string
+	var pars []interface{}
+	list, tmpErr := models.GetYanxuanSpecialAuthorList(condition, pars, 0, 9999)
+	if tmpErr != nil {
+		fmt.Println(tmpErr)
+		return
+	}
+	for _, v := range list {
+		fmt.Println(v.UserId)
+		UdpateYanxuanSpecialauthorArticleNum(v.UserId)
+	}
+}
+
+func init8882228() {
+	var condition string
+	var pars []interface{}
+	list, tmpErr := models.GetYanxuanSpecialList(0, condition, pars, 0, 99999)
+
+	fmt.Println(len(list))
+	fmt.Println(tmpErr)
+
+	for _, v := range list {
+		fmt.Println(v.Id)
+		EsAddYanxuanSpecial(v.Id)
+	}
+}
+
+func init77() {
+	var condition string
+	var pars []interface{}
+
+	//condition = " AND  is_del = 0 AND company_id > 1 AND article_id IN (SELECT  article_id FROM cygx_article) "
+	//total, err := models.GetCygxArticleHistoryRecordAllCountBycondition(condition, pars)
+	//
+	//if err != nil {
+	//	fmt.Println(err)
+	//	return
+	//}
+	//for i := 0; i <= total/2000; i++ {
+	//	allList, err := models.GetCygxArticleHistoryRecordAllList(condition, pars, 2000*i, 2000)
+	//	if err != nil {
+	//		fmt.Println("GetCygxArticleHistoryRecordByCompanyListNew Err:", err.Error())
+	//
+	//	}
+	//	var items []*models.CygxArticleAndYanxuanRecord
+	//	fmt.Println(len(allList))
+	//	for _, v := range allList {
+	//		item := new(models.CygxArticleAndYanxuanRecord)
+	//		item.SourceId = v.ArticleId
+	//		item.Source = utils.CYGX_OBJ_ARTICLE
+	//		item.UserId = v.UserId
+	//		item.RealName = v.RealName
+	//		item.Mobile = v.Mobile
+	//		item.Email = v.Email
+	//		item.CompanyId = v.CompanyId
+	//		item.CompanyName = v.CompanyName
+	//		item.CompanyId = v.CompanyId
+	//		item.CreateTime = v.CreateTime
+	//		item.ModifyTime = v.ModifyTime
+	//		item.StopTime = v.StopTime
+	//
+	//		if v.Source == "CELUE" {
+	//			item.RegisterPlatform = 3
+	//		} else if v.Source == "WEB" {
+	//			item.RegisterPlatform = 2
+	//		} else {
+	//			item.RegisterPlatform = 1
+	//		}
+	//
+	//		items = append(items, item)
+	//	}
+	//
+	//	err = models.AddCygxArticleAndYanxuanRecordMulti(items)
+	//	if err != nil {
+	//		fmt.Println(err)
+	//	}
+	//
+	//}
+	condition = " AND yanxuan_special_id IN (SELECT  id FROM cygx_yanxuan_special ) "
+	list, err := models.GetCygxYanxuanSpecialRecordRespList(condition, pars, 0, 99999)
+	if err != nil {
+		fmt.Println("GetCygxArticleHistoryRecordByCompanyListNew Err:", err.Error())
+
+	}
+	var items []*models.CygxArticleAndYanxuanRecord
+	fmt.Println(len(list))
+	for _, v := range list {
+		item := new(models.CygxArticleAndYanxuanRecord)
+		item.SourceId = v.YanxuanSpecialId
+		item.Source = utils.CYGX_OBJ_YANXUANSPECIAL
+		item.UserId = v.UserId
+		item.RealName = v.RealName
+		item.Mobile = v.Mobile
+		item.Email = v.Email
+		item.CompanyId = v.CompanyId
+		item.CompanyName = v.CompanyName
+		item.CompanyId = v.CompanyId
+		item.CreateTime = v.CreateTime
+		item.ModifyTime = v.ModifyTime
+		item.StopTime = v.StopTime
+
+		item.RegisterPlatform = v.RegisterPlatform
+
+		items = append(items, item)
+	}
+	fmt.Println(len(items))
+
+	//return
+	err = models.AddCygxArticleAndYanxuanRecordMulti(items)
+	if err != nil {
+		fmt.Println(err)
+	}
+
+}
+
+// 更新文章收藏数量
+func initcc() {
+	var condition string
+	var pars []interface{}
+	list, e := models.GetYanxuanSpecialListBycondition(condition, pars, 0, 9999)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+
+	for _, v := range list {
+		fmt.Println(v.Id)
+		UdpateYanxuanSpecialCollect(v.Id)
+	}
+}
+
+// 更新作者粉丝数量
+func initFansNum() {
+	var condition string
+	var pars []interface{}
+	list, tmpErr := models.GetYanxuanSpecialAuthorList(condition, pars, 0, 9999)
+	if tmpErr != nil {
+		fmt.Println(tmpErr)
+		return
+	}
+	for _, v := range list {
+		fmt.Println(v.UserId)
+		UdpateYanxuanSpecialFansNum(v.UserId)
+	}
+}
+
+// 专栏Pv
+func initPv() {
+	var condition string
+	var pars []interface{}
+	list, tmpErr := models.GetYanxuanSpecialList(0, condition, pars, 0, 99999)
+
+	fmt.Println(len(list))
+	fmt.Println(tmpErr)
+
+	for _, v := range list {
+		condition = ""
+		pars = make([]interface{}, 0)
+		condition = " AND  company_id != 16   AND  user_id > 0  AND yanxuan_special_id = ? "
+		pars = append(pars, v.Id)
+		totalYanxuanSpecial, err := models.GetCygxYanxuanSpecialRecordCount(condition, pars)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+
+		totalYanxuanSpecialUv, err := models.GetCygxYanxuanSpecialRecordCountGroup(condition, pars)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+
+		fmt.Println(totalYanxuanSpecial, "____", totalYanxuanSpecialUv)
+		err = models.UpdateYanxuanSpecialPvNUm(totalYanxuanSpecial, v.Id)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+		err = models.UpdateYanxuanSpecialUvUm(totalYanxuanSpecialUv, v.Id)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+	}
+}
+
+// 作者Pv
+func inituser() {
+	var condition string
+	var pars []interface{}
+	list, tmpErr := models.GetYanxuanSpecialAuthorList(condition, pars, 0, 9999)
+
+	fmt.Println(len(list))
+	fmt.Println(tmpErr)
+
+	for _, v := range list {
+		condition = ""
+		pars = make([]interface{}, 0)
+		condition = " AND  company_id != 16   AND  user_id > 0  AND yanxuan_special_id IN ( SELECT  id  FROM cygx_yanxuan_special WHERE user_id = ?   ) "
+		pars = append(pars, v.UserId)
+		totalYanxuanSpecial, err := models.GetCygxYanxuanSpecialRecordCount(condition, pars)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+
+		totalYanxuanSpecialUv, err := models.GetCygxYanxuanSpecialRecordCountGroup(condition, pars)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+
+		fmt.Println(totalYanxuanSpecial, "____", totalYanxuanSpecialUv)
+		err = models.UpdateYanxuanSpecialauthorPvNUm(totalYanxuanSpecial, v.UserId)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+		err = models.UpdateYanxuanSpecialauthorUvUm(totalYanxuanSpecialUv, v.UserId)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+	}
+}
+
+func initbug111() {
+	var condition string
+	var pars []interface{}
+	condition = " AND company_id = 5593  AND  mobile  != '' GROUP BY mobile  ORDER BY mobile DESC  LIMIT 0,5000 "
+	signUpDetailList, err := models.GetSignupDetailList(condition, pars)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		fmt.Println(err)
+		return
+	}
+
+	var mobiles []string
+	for _, v := range signUpDetailList {
+		mobiles = append(mobiles, v.Mobile)
+	}
+
+	listUser, e := models.GetWxUserByMobiles(mobiles)
+	if e != nil {
+		fmt.Println(e)
+		return
+	}
+
+	mapMobile := make(map[string]int)
+	var itemsUpdate []*models.CygxActivitySignupDetail
+	for _, v := range listUser {
+		if v.Mobile == "" {
+			continue
+		}
+		mapMobile[v.Mobile] = v.UserId
+		var itemDetail = new(models.CygxActivitySignupDetail)
+		itemDetail.Mobile = v.Mobile
+		itemDetail.UserId = v.UserId
+		itemsUpdate = append(itemsUpdate, itemDetail)
+	}
+	fmt.Println(len(itemsUpdate))
+
+	err = models.UpdateActivitySignupDetailMultiUserId(itemsUpdate)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+}

+ 277 - 10
services/resource_data.go

@@ -483,6 +483,91 @@ func UpdateResourceData(sourceId int, source, doType, publishDate string) (err e
 	return
 }
 
+//func init130() {
+//	//UpdateNewchartResourceData(5509)
+//
+//	var condition string
+//	var pars []interface{}
+//	condition += ` AND publish_status  = 1 `
+//
+//	list, e := models.GetChartList(condition, pars, 0, 1000000)
+//	if e != nil {
+//		fmt.Println(e)
+//		return
+//	}
+//
+//	for _, v := range list {
+//		fmt.Println(v.ChartId)
+//		UpdateNewchartResourceData(v.ChartId)
+//	}
+//}
+
+// 更新图表
+func UpdateNewchartResourceData(sourceId int) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("更新图表同步到最新数据表失败,Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId)+"资源类型", 3)
+		}
+	}()
+	var source = utils.CYGX_OBJ_NEWCHART
+	var condition string
+	var pars []interface{}
+	condition = ` AND chart_id = ?  `
+	pars = append(pars, sourceId)
+	total, e := models.GetChartCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetChartCount, Err: " + e.Error())
+		return
+	}
+	//如果取消发布了就做删除处理
+	if total == 0 {
+		e = models.DeleteResourceData(sourceId, source)
+		if e != nil {
+			err = errors.New("DeleteResourceData, Err: " + e.Error())
+			return
+		}
+	} else {
+		//判断是否存在,如果不存在就新增,存在就更新
+		totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
+		if e != nil {
+			err = errors.New("GetCygxResourceDataBySourceAndIdCount, Err: " + e.Error())
+			return
+		}
+		detail, e := models.GetChartDetailByChartId(sourceId)
+		if e != nil {
+			err = errors.New("GetArticleDetailById, Err: " + e.Error())
+			return
+		}
+		publishDate := detail.CreateDate
+		item := new(models.CygxResourceData)
+
+		item.SourceId = sourceId
+		item.Source = source
+		item.PublishDate = publishDate
+		item.CreateTime = time.Now()
+		item.SearchTitle = detail.Title
+		item.SearchContent = ""
+		item.SearchOrderTime = detail.CreateDate
+
+		if totalData == 0 {
+			_, e = models.AddCygxResourceData(item)
+			if e != nil {
+				err = errors.New("AddCygxResourceData, Err: " + e.Error())
+				return
+			}
+
+		} else {
+			e = models.UpdateResourceDataByItem(item)
+			if e != nil {
+				err = errors.New("UpdateResourceData, Err: " + e.Error())
+				return
+			}
+		}
+	}
+	return
+}
+
 // 批量删除最新图表数据
 func Deletenewchart(chartIdsDelete []int) (err error) {
 	defer func() {
@@ -564,10 +649,47 @@ func UpdateArticleResourceData(sourceId int) {
 				item.ChartPermissionId = detailCategory.ChartPermissionId
 			}
 		}
+		var industrialName string
+		var subjectName string
+		//建立首页资源表,与产业的关系
+		industrialList, e := models.GetIndustrialArticleGroupManagementListByArticleId(sourceId)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetIndustrialArticleGroupManagementListByArticleId, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+
+		for _, v := range industrialList {
+			industrialName += v.IndustryName
+		}
+
+		//建立首页资源表,与标的 的关系
+		subjectList, e := models.GetSubjectArticleGroupManagementListByArtcileId(sourceId)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+
+		for _, v := range subjectList {
+			subjectName += v.SubjectName
+		}
 		item.SourceId = sourceId
 		item.Source = source
 		item.PublishDate = publishDate
 		item.CreateTime = time.Now()
+		item.SearchTitle = detail.Title
+		annotation, e := utils.GetHtmlContentText(detail.Annotation)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+		abstract, e := utils.GetHtmlContentText(detail.Abstract)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+		item.SearchContent = annotation + abstract + detail.FieldName + detail.Stock + industrialName + subjectName
+		item.SearchOrderTime = detail.PublishDate
+
 		if totalData == 0 {
 			newId, e := models.AddCygxResourceData(item)
 			if e != nil {
@@ -590,11 +712,6 @@ func UpdateArticleResourceData(sourceId int) {
 		}
 
 		//建立首页资源表,与产业的关系
-		industrialList, e := models.GetIndustrialArticleGroupManagementListByArticleId(sourceId)
-		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
-			return
-		}
 		var industrialItems []*models.CygxResourceDataIndustrialGroupManagement
 		for _, v := range industrialList {
 			var industrialItem = new(models.CygxResourceDataIndustrialGroupManagement)
@@ -607,11 +724,6 @@ func UpdateArticleResourceData(sourceId int) {
 		}
 
 		//建立首页资源表,与标的 的关系
-		subjectList, e := models.GetSubjectArticleGroupManagementListByArtcileId(sourceId)
-		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
-			return
-		}
 		var subjectItems []*models.CygxResourceDataIndustrialGroupSubject
 		for _, v := range subjectList {
 			var subjectItem = new(models.CygxResourceDataIndustrialGroupSubject)
@@ -632,3 +744,158 @@ func UpdateArticleResourceData(sourceId int) {
 	}
 	return
 }
+
+// 更新产业资源包
+func UpdateComprehensiveIndustrialResourceData(itemSource *ElasticComprehensiveDetail) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("更新产业资源包到最新数据表失败,Err:"+err.Error()+"资源ID"+strconv.Itoa(itemSource.SourceId), 3)
+		}
+	}()
+	sourceId := itemSource.SourceId
+	var source = itemSource.Source
+
+	//判断是否存在,如果不存在就新增,存在就更新
+	totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
+	if e != nil {
+		err = errors.New("GetCygxResourceDataBySourceAndIdCount, Err: " + e.Error())
+		return
+	}
+
+	item := new(models.CygxResourceData)
+	item.SourceId = sourceId
+	item.Source = source
+	item.PublishDate = itemSource.PublishDate
+	item.CreateTime = time.Now()
+	item.SearchTitle = itemSource.IndustryName + itemSource.SubjectNames
+	item.SearchContent = ""
+	item.SearchOrderTime = itemSource.PublishDate
+
+	if totalData == 0 {
+		_, e = models.AddCygxResourceData(item)
+		if e != nil {
+			err = errors.New("AddCygxResourceData, Err: " + e.Error())
+			return
+		}
+	} else {
+		e = models.UpdateResourceDataByItem(item)
+		if e != nil {
+			err = errors.New("UpdateResourceData, Err: " + e.Error())
+			return
+		}
+	}
+	return
+}
+
+// 更新研选专栏  写入首页最新  cygx_resource_data 表
+func UpdateYanxuanSpecialResourceData(sourceId int) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("更新研选专栏失败sourceId: ", sourceId, "ErrMsg", err.Error()), 2)
+		}
+	}()
+	var source = utils.CYGX_OBJ_YANXUANSPECIAL
+	var condition string
+	var pars []interface{}
+	condition = ` AND status = 3  AND  id = ?  `
+	pars = append(pars, sourceId)
+	total, e := models.GetCygxYanxuanSpecialCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxYanxuanSpecialCount, Err: " + e.Error())
+		return
+	}
+	//如果取消发布了就做删除处理
+	if total == 0 {
+		e = models.DeleteResourceData(sourceId, source)
+		if e != nil {
+			err = errors.New("DeleteResourceData, Err: " + e.Error())
+			return
+		}
+	} else {
+		//判断是否存在,如果不存在就新增,存在就更新
+		totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
+		if e != nil {
+			err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
+			return
+		}
+
+		detail, e := models.GetYanxuanSpecialBySpecialId(sourceId)
+		if e != nil {
+			err = errors.New("GetYanxuanSpecialBySpecialId, Err: " + e.Error())
+			return
+		}
+		publishDate := detail.PublishTime
+		item := new(models.CygxResourceData)
+		item.SourceId = sourceId
+		item.Source = source
+		item.PublishDate = publishDate
+		item.CreateTime = time.Now()
+		item.SearchTitle = detail.Title
+		item.SearchContent = ""
+		item.SearchOrderTime = publishDate
+		if totalData == 0 {
+			_, e := models.AddCygxResourceData(item)
+			if e != nil {
+				err = errors.New("AddCygxResourceData, Err: " + e.Error())
+				return
+			}
+		} else {
+			e = models.UpdateResourceDataByItem(item)
+			if e != nil {
+				err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
+				return
+			}
+		}
+	}
+	return
+}
+
+func initsql12_17() {
+	listIndustrialResourceIds, e := models.GetSearchResourceList(0, " AND article_type_id > 0 ", 0, 9999)
+	if e != nil {
+		fmt.Println(e)
+		return
+	}
+	var industrialResourceIdsHz []int
+	for _, v := range listIndustrialResourceIds {
+		industrialResourceIdsHz = append(industrialResourceIdsHz, v.IndustrialManagementId)
+	}
+	//date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date,
+
+	//合并产业关联的标的
+	listSubjcet, e := models.GetIndustrialSubjectAllByIndustrialId(industrialResourceIdsHz)
+	if e != nil {
+		fmt.Println(e)
+		return
+	}
+	mapIndustrial := make(map[string]int)
+	for _, v := range listSubjcet {
+		for k2, v2 := range listIndustrialResourceIds {
+			if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
+				listIndustrialResourceIds[k2].IndustrialSubjectList = append(listIndustrialResourceIds[k2].IndustrialSubjectList, v)
+			}
+		}
+	}
+	//industrialsource := "industrialsourceHz"
+	industrialsource := "industrialsourceYx"
+	for _, v := range listIndustrialResourceIds {
+
+		item := new(ElasticComprehensiveDetail)
+		item.SourceId = v.IndustrialManagementId
+		item.Source = industrialsource
+		item.IndustryName = v.IndustryName
+
+		var SubjectName []string
+
+		for _, vN := range v.IndustrialSubjectList {
+			SubjectName = append(SubjectName, vN.SubjectName)
+		}
+		item.SubjectNames = strings.Join(SubjectName, ",")
+		item.PublishDate = v.PublishDate
+		fmt.Println(item)
+		UpdateComprehensiveIndustrialResourceData(item)
+	}
+	return
+}

+ 5 - 1
services/task.go

@@ -84,7 +84,7 @@ func Task() {
 		updateWxUserLabel := task.NewTask("updateWxUserLabel", "0 01 0 * * *", UpdateWxUserLabel) //更新用户的标签
 		task.AddTask("updateWxUserLabel", updateWxUserLabel)
 
-		addAllArticleHistory := task.NewTask("addAllArticleHistory", "0 30 2 * * *", AddAllArticleHistory) //把前一天的用户阅读记录同步到ES
+		addAllArticleHistory := task.NewTask("addAllArticleHistory", "0 30 2 * * *", AddAllArticleAndYanxuanHistory) //把前一天的用户阅读记录同步到ES
 		task.AddTask("addAllArticleHistory", addAllArticleHistory)
 
 		getCeLueArticlePv := task.NewTask("getCeLueArticlePv", "0 */10 * * * *", GetCeLueArticlePv) //通过三方接口获取策略平台上的阅读记录
@@ -122,6 +122,10 @@ func Task() {
 
 		getStocksFromVmp := task.NewTask("getStocksFromVmp", "0 40 3 * * *", GetStocksFromVmp)
 		task.AddTask("getStocksFromVmp", getStocksFromVmp) //定时任务更新上市公司表
+
+		updateIndustrialManagementOneMonthFollowNum := task.NewTask("updateIndustrialManagementOneMonthFollowNum", "0 10 1 * * *", UpdateIndustrialManagementOneMonthFollowNum)
+		task.AddTask("updateIndustrialManagementOneMonthFollowNum", updateIndustrialManagementOneMonthFollowNum) //更新产业近一个月被关注的数量
+
 	}
 	if utils.RunMode != "release" {
 		getArticleListByApi := task.NewTask("getArticleListByApi", "0 */60 * * * *", GetArticleListByApi) //通过三方接口获取策略平台上的文章

+ 2 - 2
services/user.go

@@ -21,7 +21,7 @@ var ERR_USER_NOT_BIND = errors.New("用户没有绑定")
 func GetWxUserItemByOpenId(openid string) (item *models.WxUserItem, err error) {
 	//通过openid获取用户关联信息
 	userRecord, userRecordErr := models.GetUserRecordByOpenId(openid)
-	fmt.Println("userRecordErr", userRecordErr)
+	//fmt.Println("userRecordErr", userRecordErr)
 	if userRecordErr != nil {
 		if userRecordErr.Error() == utils.ErrNoRow() {
 			err = ERR_NO_USER_RECORD
@@ -49,7 +49,7 @@ func GetWxUserItemByOpenId(openid string) (item *models.WxUserItem, err error) {
 
 	//获取用户信息
 	item, wxUserErr := models.GetWxUserItemByUserId(userRecord.UserId)
-	fmt.Println("wxUserErr", wxUserErr)
+	//fmt.Println("wxUserErr", wxUserErr)
 	if wxUserErr != nil {
 		err = wxUserErr
 		//如果是找不到数据,那么可能是该用户被删除了,但是user_record没有删除对应的关系

+ 537 - 240
services/wx_user.go

@@ -74,263 +74,264 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 
 		//处理图表关注后的用户
 		{
-
-			listChartCollect, err := models.GetCygxChartCollectByMobileList()
-			if err != nil {
-				fmt.Println("GetCygxChartCollectByMobileList ,Err" + err.Error())
-			}
-			for k, v := range listChartCollect {
-				if v.Mobile != "" {
-					user, err := models.GetWxUserItemByMobile(v.Mobile)
-					if err != nil && err.Error() != utils.ErrNoRow() {
-						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
-					}
-					if user != nil {
-						fmt.Println(user.RealName, k)
-						err = models.UpdateCygxChartCollect(user)
-						if err != nil {
-							fmt.Println("UpdateCygxChartCollect ,Err" + err.Error())
-						}
-					}
-				}
-			}
-		}
-	}
-
-	//处理 前一天移动之后的用户的公司记录信息
-
-	{
-		startDate := time.Now().AddDate(0, 0, -1).Format(utils.FormatDate)
-		endDate := time.Now().Format(utils.FormatDate)
-		listUpdateUser, err := models.GetWxUserOpLogList(startDate, endDate)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			return err
-		}
-		var userIds string
-		var mobiles string
-		if len(listUpdateUser) > 0 {
-			for _, v := range listUpdateUser {
-				userIds += strconv.Itoa(v.UserId) + ","
-				mobiles += "'" + v.Mobile + "',"
-			}
-		}
-		userIds = strings.TrimRight(userIds, ",")
-		mobiles = strings.TrimRight(mobiles, ",")
-
-		//如果用户ID不为空那么就处理这些用户的记录信息
-		if userIds != "" {
-			var condition string
-			//condition = ` AND user_id IN (` + userIds + `)`
-			condition = ` AND mobile IN (` + mobiles + `)`
-			//处理用户的文章收藏
-			listCollect, err := models.GetCygxArticleCollectList(condition)
-			if err != nil && err.Error() != utils.ErrNoRow() {
-				fmt.Println("GetAddCygxArticleCollectList ,Err" + err.Error())
-			}
-			if len(listCollect) > 0 {
-				for _, v := range listCollect {
-					user, err := models.GetWxUserItemByUserId(v.UserId)
-					if err != nil && err.Error() != utils.ErrNoRow() {
-						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
-					}
-					if user != nil {
-						fmt.Println(user.RealName)
-						err = models.UpdateCygxArticleCollect(user)
-						if err != nil {
-							fmt.Println("UpdateCygxArticleCollect ,Err" + err.Error())
-						}
-					}
-				}
-			}
-			//处理用户的文章收藏 end
-
-			//修改用户关注的产业
-			listIndustryFllow, err := models.GetCygxIndustryFllowList(condition)
-			if err != nil {
-				fmt.Println("GetCygxIndustryFllowList ,Err" + err.Error())
-			}
-			for k, v := range listIndustryFllow {
-				if v.Mobile != "" {
-					user, err := models.GetWxUserItemByUserId(v.UserId)
-					if err != nil && err.Error() != utils.ErrNoRow() {
-						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
-					}
-					if user != nil {
-						fmt.Println(user.RealName, k)
-						err = models.UpdateCygxIndustryFllow(user)
-						if err != nil {
-							fmt.Println("UpdateCygxIndustryFllow ,Err" + err.Error())
-						}
-					}
-				}
-			}
-
-			//修改用户产业关注的产业end
-
-			//修改用户的阅读记录
-			listArticlePv, err := models.GetArticleHistoryRecordAllByMobileList(condition)
-			if err != nil {
-				fmt.Println("GetArticleHistoryRecordAllByMobileList ,Err" + err.Error())
-			}
-			for k, v := range listArticlePv {
-				if v.Mobile != "" {
-					user, err := models.GetWxUserItemByMobile(v.Mobile)
-					if err != nil && err.Error() != utils.ErrNoRow() {
-						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
-					}
-					if user != nil {
-						fmt.Println(user.RealName, k)
-						err = models.UpdateCygxArticleHistoryRecordAll(user)
-						if err != nil {
-							fmt.Println("UpdateCygxArticleCollect ,Err" + err.Error())
-						}
-					}
-				}
-			}
-			//修改用户的阅读记录end
-
-			//处理用户的搜索记录
-			listSearch, err := models.GetCygxSearchKeyWordList(condition)
-			if err != nil {
-				fmt.Println("GetArticleHistoryRecordAllByMobileList ,Err" + err.Error())
-			}
-
-			for k, v := range listSearch {
-				if v.Mobile != "" {
-					user, err := models.GetWxUserItemByUserId(v.UserId)
-					if err != nil && err.Error() != utils.ErrNoRow() {
-						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
-					}
-					if user != nil {
-						fmt.Println(user.RealName, k)
-						err = models.UpdateCygxSearchKeyWord(user)
-						if err != nil {
-							fmt.Println("UpdateCygxSearchKeyWord ,Err" + err.Error())
-						}
-					}
-				}
-			}
-
-			// 处理用户的作者关注
-			lisDepartmentF, err := models.GetArticleDepartmentFollowByMobileList(condition)
-			if err != nil {
-				fmt.Println("GetArticleDepartmentFollowByMobileList ,Err" + err.Error())
-				return err
-			}
-			for k, v := range lisDepartmentF {
-				if v.Mobile != "" {
-					user, err := models.GetWxUserItemByUserId(v.UserId)
-					if err != nil && err.Error() != utils.ErrNoRow() {
-						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
-					}
-					if user != nil {
-						fmt.Println(user.RealName, k)
-						err = models.UpdateCygxArticleDepartmentFollow(user)
-						if err != nil {
-							fmt.Println("UpdateCygxArticleDepartmentFollow ,Err" + err.Error())
-						}
-					}
-				}
-			}
-			// 处理用户的作者关注end
-
-			// 处理用户的活动视频播放
-			listActivityVideo, err := models.GetActivityVideoHistoryByMobileList(condition)
-			if err != nil {
-				fmt.Println("GetArticleDepartmentFollowByMobileList ,Err" + err.Error())
-				return err
-			}
-			for k, v := range listActivityVideo {
-				if v.Mobile != "" {
-					user, err := models.GetWxUserItemByUserId(v.UserId)
-					if err != nil && err.Error() != utils.ErrNoRow() {
-						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
-					}
-					if user != nil {
-						fmt.Println(user.RealName, k)
-						err = models.UpdateCygxActivityVideoHistory(user)
-						if err != nil {
-							fmt.Println("UpdateCygxActivityVideoHistory ,Err" + err.Error())
-						}
-					}
-				}
-			}
-			// 处理用户的活动视频播放end
-
-			// 处理用户的活动音频播放
-			listActivityVoice, err := models.GetActivityVoiceHistoryByMobileList(condition)
-			if err != nil {
-				fmt.Println("GetActivityVoiceHistoryByMobileList ,Err" + err.Error())
-				return err
-			}
-			for k, v := range listActivityVoice {
-				if v.Mobile != "" {
-					user, err := models.GetWxUserItemByUserId(v.UserId)
-					if err != nil && err.Error() != utils.ErrNoRow() {
-						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
-					}
-					if user != nil {
-						fmt.Println(user.RealName, k)
-						err = models.UpdateCygxActivityVoiceHistory(user)
-						if err != nil {
-							fmt.Println("UpdateCygxActivityVoiceHistory ,Err" + err.Error())
-						}
-					}
-				}
-			}
-			// 处理用户的活动音频播放end
-
-			// 处理用户产业视频的播放记录
-			listMicroRoadshow, err := models.GetMicroRoadshowVideoHistoryByMobileList(condition)
-			if err != nil {
-				fmt.Println("GetMicroRoadshowVideoHistoryByMobileList ,Err" + err.Error())
-				return err
-			}
-			for k, v := range listMicroRoadshow {
-				if v.Mobile != "" {
-					user, err := models.GetWxUserItemByUserId(v.UserId)
-					if err != nil && err.Error() != utils.ErrNoRow() {
-						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
-					}
-					if user != nil {
-						fmt.Println(user.RealName, k)
-						err = models.UpdateCygxMicroRoadshowVideoHistory(user)
-						if err != nil {
-							fmt.Println("UpdateCygxMicroRoadshowVideoHistory ,Err" + err.Error())
-						}
-					}
-				}
-			}
-			// 处理用户产业视频的播放记录 end
-
-			//如果手机号不为空,则更新用户的报名信息
-			if mobiles != "" {
-				condition = ` AND mobile IN (` + mobiles + `)`
-				listSingUp, err := models.GetCygxActivitySignupByMobileList(condition)
+			if utils.RunMode == "release" {
+				listChartCollect, err := models.GetCygxChartCollectByMobileList()
 				if err != nil {
 					fmt.Println("GetCygxChartCollectByMobileList ,Err" + err.Error())
 				}
-				//fmt.Println("更新用户的报名信息长度", len(listSingUp))
-				for _, v := range listSingUp {
+				for k, v := range listChartCollect {
 					if v.Mobile != "" {
 						user, err := models.GetWxUserItemByMobile(v.Mobile)
 						if err != nil && err.Error() != utils.ErrNoRow() {
 							fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
 						}
 						if user != nil {
-							err = models.UpdateCygxActivitySignup(user)
+							fmt.Println(user.RealName, k)
+							err = models.UpdateCygxChartCollect(user)
 							if err != nil {
-								fmt.Println("UpdateCygxActivitySignup ,Err" + err.Error())
-								//return err
+								fmt.Println("UpdateCygxChartCollect ,Err" + err.Error())
 							}
 						}
 					}
 				}
 			}
-
 		}
 	}
 
+	//处理 前一天移动之后的用户的公司记录信息
+
+	//{
+	//	startDate := time.Now().AddDate(0, 0, -1).Format(utils.FormatDate)
+	//	endDate := time.Now().Format(utils.FormatDate)
+	//	listUpdateUser, err := models.GetWxUserOpLogList(startDate, endDate)
+	//	if err != nil && err.Error() != utils.ErrNoRow() {
+	//		return err
+	//	}
+	//	var userIds string
+	//	var mobiles string
+	//	if len(listUpdateUser) > 0 {
+	//		for _, v := range listUpdateUser {
+	//			userIds += strconv.Itoa(v.UserId) + ","
+	//			mobiles += "'" + v.Mobile + "',"
+	//		}
+	//	}
+	//	userIds = strings.TrimRight(userIds, ",")
+	//	mobiles = strings.TrimRight(mobiles, ",")
+	//
+	//	//如果用户ID不为空那么就处理这些用户的记录信息
+	//	if userIds != "" {
+	//		var condition string
+	//		//condition = ` AND user_id IN (` + userIds + `)`
+	//		condition = ` AND mobile IN (` + mobiles + `)`
+	//		//处理用户的文章收藏
+	//		listCollect, err := models.GetCygxArticleCollectList(condition)
+	//		if err != nil && err.Error() != utils.ErrNoRow() {
+	//			fmt.Println("GetAddCygxArticleCollectList ,Err" + err.Error())
+	//		}
+	//		if len(listCollect) > 0 {
+	//			for _, v := range listCollect {
+	//				user, err := models.GetWxUserItemByUserId(v.UserId)
+	//				if err != nil && err.Error() != utils.ErrNoRow() {
+	//					fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//				}
+	//				if user != nil {
+	//					fmt.Println(user.RealName)
+	//					err = models.UpdateCygxArticleCollect(user)
+	//					if err != nil {
+	//						fmt.Println("UpdateCygxArticleCollect ,Err" + err.Error())
+	//					}
+	//				}
+	//			}
+	//		}
+	//		//处理用户的文章收藏 end
+	//
+	//		//修改用户关注的产业
+	//		listIndustryFllow, err := models.GetCygxIndustryFllowList(condition)
+	//		if err != nil {
+	//			fmt.Println("GetCygxIndustryFllowList ,Err" + err.Error())
+	//		}
+	//		for k, v := range listIndustryFllow {
+	//			if v.Mobile != "" {
+	//				user, err := models.GetWxUserItemByUserId(v.UserId)
+	//				if err != nil && err.Error() != utils.ErrNoRow() {
+	//					fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//				}
+	//				if user != nil {
+	//					fmt.Println(user.RealName, k)
+	//					err = models.UpdateCygxIndustryFllow(user)
+	//					if err != nil {
+	//						fmt.Println("UpdateCygxIndustryFllow ,Err" + err.Error())
+	//					}
+	//				}
+	//			}
+	//		}
+	//
+	//		//修改用户产业关注的产业end
+	//
+	//		//修改用户的阅读记录
+	//		listArticlePv, err := models.GetArticleHistoryRecordAllByMobileList(condition)
+	//		if err != nil {
+	//			fmt.Println("GetArticleHistoryRecordAllByMobileList ,Err" + err.Error())
+	//		}
+	//		for k, v := range listArticlePv {
+	//			if v.Mobile != "" {
+	//				user, err := models.GetWxUserItemByMobile(v.Mobile)
+	//				if err != nil && err.Error() != utils.ErrNoRow() {
+	//					fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//				}
+	//				if user != nil {
+	//					fmt.Println(user.RealName, k)
+	//					err = models.UpdateCygxArticleHistoryRecordAll(user)
+	//					if err != nil {
+	//						fmt.Println("UpdateCygxArticleCollect ,Err" + err.Error())
+	//					}
+	//				}
+	//			}
+	//		}
+	//		//修改用户的阅读记录end
+	//
+	//		//处理用户的搜索记录
+	//		listSearch, err := models.GetCygxSearchKeyWordList(condition)
+	//		if err != nil {
+	//			fmt.Println("GetArticleHistoryRecordAllByMobileList ,Err" + err.Error())
+	//		}
+	//
+	//		for k, v := range listSearch {
+	//			if v.Mobile != "" {
+	//				user, err := models.GetWxUserItemByUserId(v.UserId)
+	//				if err != nil && err.Error() != utils.ErrNoRow() {
+	//					fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//				}
+	//				if user != nil {
+	//					fmt.Println(user.RealName, k)
+	//					err = models.UpdateCygxSearchKeyWord(user)
+	//					if err != nil {
+	//						fmt.Println("UpdateCygxSearchKeyWord ,Err" + err.Error())
+	//					}
+	//				}
+	//			}
+	//		}
+	//
+	//		// 处理用户的作者关注
+	//		lisDepartmentF, err := models.GetArticleDepartmentFollowByMobileList(condition)
+	//		if err != nil {
+	//			fmt.Println("GetArticleDepartmentFollowByMobileList ,Err" + err.Error())
+	//			return err
+	//		}
+	//		for k, v := range lisDepartmentF {
+	//			if v.Mobile != "" {
+	//				user, err := models.GetWxUserItemByUserId(v.UserId)
+	//				if err != nil && err.Error() != utils.ErrNoRow() {
+	//					fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//				}
+	//				if user != nil {
+	//					fmt.Println(user.RealName, k)
+	//					err = models.UpdateCygxArticleDepartmentFollow(user)
+	//					if err != nil {
+	//						fmt.Println("UpdateCygxArticleDepartmentFollow ,Err" + err.Error())
+	//					}
+	//				}
+	//			}
+	//		}
+	//		// 处理用户的作者关注end
+	//
+	//		// 处理用户的活动视频播放
+	//		listActivityVideo, err := models.GetActivityVideoHistoryByMobileList(condition)
+	//		if err != nil {
+	//			fmt.Println("GetArticleDepartmentFollowByMobileList ,Err" + err.Error())
+	//			return err
+	//		}
+	//		for k, v := range listActivityVideo {
+	//			if v.Mobile != "" {
+	//				user, err := models.GetWxUserItemByUserId(v.UserId)
+	//				if err != nil && err.Error() != utils.ErrNoRow() {
+	//					fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//				}
+	//				if user != nil {
+	//					fmt.Println(user.RealName, k)
+	//					err = models.UpdateCygxActivityVideoHistory(user)
+	//					if err != nil {
+	//						fmt.Println("UpdateCygxActivityVideoHistory ,Err" + err.Error())
+	//					}
+	//				}
+	//			}
+	//		}
+	//		// 处理用户的活动视频播放end
+	//
+	//		// 处理用户的活动音频播放
+	//		listActivityVoice, err := models.GetActivityVoiceHistoryByMobileList(condition)
+	//		if err != nil {
+	//			fmt.Println("GetActivityVoiceHistoryByMobileList ,Err" + err.Error())
+	//			return err
+	//		}
+	//		for k, v := range listActivityVoice {
+	//			if v.Mobile != "" {
+	//				user, err := models.GetWxUserItemByUserId(v.UserId)
+	//				if err != nil && err.Error() != utils.ErrNoRow() {
+	//					fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//				}
+	//				if user != nil {
+	//					fmt.Println(user.RealName, k)
+	//					err = models.UpdateCygxActivityVoiceHistory(user)
+	//					if err != nil {
+	//						fmt.Println("UpdateCygxActivityVoiceHistory ,Err" + err.Error())
+	//					}
+	//				}
+	//			}
+	//		}
+	//		// 处理用户的活动音频播放end
+	//
+	//		// 处理用户产业视频的播放记录
+	//		listMicroRoadshow, err := models.GetMicroRoadshowVideoHistoryByMobileList(condition)
+	//		if err != nil {
+	//			fmt.Println("GetMicroRoadshowVideoHistoryByMobileList ,Err" + err.Error())
+	//			return err
+	//		}
+	//		for k, v := range listMicroRoadshow {
+	//			if v.Mobile != "" {
+	//				user, err := models.GetWxUserItemByUserId(v.UserId)
+	//				if err != nil && err.Error() != utils.ErrNoRow() {
+	//					fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//				}
+	//				if user != nil {
+	//					fmt.Println(user.RealName, k)
+	//					err = models.UpdateCygxMicroRoadshowVideoHistory(user)
+	//					if err != nil {
+	//						fmt.Println("UpdateCygxMicroRoadshowVideoHistory ,Err" + err.Error())
+	//					}
+	//				}
+	//			}
+	//		}
+	//		// 处理用户产业视频的播放记录 end
+	//
+	//		//如果手机号不为空,则更新用户的报名信息
+	//		if mobiles != "" {
+	//			condition = ` AND mobile IN (` + mobiles + `)`
+	//			listSingUp, err := models.GetCygxActivitySignupByMobileList(condition)
+	//			if err != nil {
+	//				fmt.Println("GetCygxChartCollectByMobileList ,Err" + err.Error())
+	//			}
+	//			//fmt.Println("更新用户的报名信息长度", len(listSingUp))
+	//			for _, v := range listSingUp {
+	//				if v.Mobile != "" {
+	//					user, err := models.GetWxUserItemByMobile(v.Mobile)
+	//					if err != nil && err.Error() != utils.ErrNoRow() {
+	//						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//					}
+	//					if user != nil {
+	//						err = models.UpdateCygxActivitySignup(user)
+	//						if err != nil {
+	//							fmt.Println("UpdateCygxActivitySignup ,Err" + err.Error())
+	//							//return err
+	//						}
+	//					}
+	//				}
+	//			}
+	//		}
+	//
+	//	}
+	//}
+
 	//处理用户标签
 	//for _, vUser := range listUser {
 	//	labels, err := models.GetCygxCompanyUserListSplit(strconv.Itoa(vUser.UserId))
@@ -504,6 +505,8 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 		mapUserInteraction := make(map[int]int)
 		mapCompanyInteraction := make(map[int]int)
 		mapCompanyInteractionItem := make(map[int]*models.CygxCompanyInteractionNum)
+		mapComapnyInteractionSeller := make(map[int]int)
+		mapComapnyInteractionNumSeller := make(map[int]int) // 销售可查看的互动量
 		//获取已经处理记录的用户并记录切片
 		listUserInteractionNum, err := models.GetCygxUserInteractionNumList()
 		if err != nil && err.Error() != utils.ErrNoRow() {
@@ -514,6 +517,16 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 			mapUserInteraction[v.UserId] = v.UserId
 		}
 
+		//获取跟销售建立绑定关系的用户并记录切片
+		listUserSeller, err := models.GetUserSellerRelationUserList()
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			fmt.Println("GetUserSellerRelationUserList Err", err)
+			return err
+		}
+		for _, v := range listUserSeller {
+			mapComapnyInteractionSeller[v.UserId] = v.UserId
+		}
+
 		listCompanyInteractionNum, err := models.GetCygxCompanyInteractionNumList()
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			fmt.Println("GetCygxUserInteractionNumList Err", err)
@@ -648,6 +661,10 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 						}
 						mapComapnyInteractionNum[vsplit.CompanyId] += interactionNum
 
+						if mapComapnyInteractionSeller[int(vsplit.UserId)] > 0 {
+							mapComapnyInteractionNumSeller[vsplit.CompanyId] += interactionNum //如果销售可以看到这个人,那么就对销售可见的数量进行添加
+						}
+
 						itemInteraction := new(models.CygxUserInteractionNum)
 						itemInteraction.UserId = int(vsplit.UserId)
 						itemInteraction.ArticleHistoryNum = vsplit.HistoryNum
@@ -723,12 +740,18 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 				}
 			}
 		}
+		fmt.Println("修改机构互动量信息")
 		////修改机构互动量信息
 		if len(mapComapnyInteractionNum) > 0 {
 			for k, v := range mapComapnyInteractionNum {
-				err = models.UpdateComapanyInteractionNum(v, k)
+				companyId := k
+				err = models.UpdateComapanyInteractionNum(v, mapComapnyInteractionNumSeller[companyId], companyId)
+				if err != nil {
+					fmt.Println(" AddCygxUserInteractionNumList Err", err)
+				}
 			}
 		}
+
 		// 批量添加用户互动量信息
 		if len(itemsInteraction) > 0 {
 			_, err = models.AddCygxUserInteractionNumList(itemsInteraction)
@@ -761,3 +784,277 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 	go UpdateUserLabelWeight()
 	return
 }
+
+func init123123() {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("更新用户标签失败;Err:"+err.Error(), 2)
+		}
+	}()
+	var interactionNum int
+	mapComapnyInteractionNum := make(map[int]int)
+
+	listUser, err := models.GetUserRegisterListinit()
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		fmt.Println("GetUserSellerRelationUserList Err", err)
+		return
+	}
+
+	fmt.Println(len(listUser))
+	//return
+	//处理用户、机构互动量数据
+	{
+		var userIds string
+		var itemsInteraction []*models.CygxUserInteractionNum
+		mapUserInteraction := make(map[int]int)
+		mapCompanyInteraction := make(map[int]int)
+		mapCompanyInteractionItem := make(map[int]*models.CygxCompanyInteractionNum)
+		mapComapnyInteractionSeller := make(map[int]int)
+		mapComapnyInteractionNumSeller := make(map[int]int) // 销售可查看的互动量
+		//获取已经处理记录的用户并记录切片
+		listUserInteractionNum, err := models.GetCygxUserInteractionNumList()
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			fmt.Println("GetCygxUserInteractionNumList Err", err)
+			return
+		}
+		for _, v := range listUserInteractionNum {
+			mapUserInteraction[v.UserId] = v.UserId
+		}
+
+		//获取跟销售建立绑定关系的用户并记录切片
+		listUserSeller, err := models.GetUserSellerRelationUserList()
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			fmt.Println("GetUserSellerRelationUserList Err", err)
+			return
+		}
+		for _, v := range listUserSeller {
+			mapComapnyInteractionSeller[v.UserId] = v.UserId
+		}
+
+		listCompanyInteractionNum, err := models.GetCygxCompanyInteractionNumList()
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			fmt.Println("GetCygxUserInteractionNumList Err", err)
+			return
+		}
+		for _, v := range listCompanyInteractionNum {
+			mapCompanyInteraction[v.CompanyId] = v.CompanyId
+		}
+
+		//处理用户互动量数据
+		for kUser, vUser := range listUser {
+			userIds += strconv.Itoa(vUser.UserId) + ","
+			//一次查询一百个避免用户过多
+			if kUser%100 == 0 {
+				userIds = strings.TrimRight(userIds, ",")
+				userUserInteractionList, err := models.GetCygxCompanyUserUserInteraction(userIds)
+				if err != nil {
+					fmt.Println("GetCygxCompanyUserUserInteraction Err", err)
+					return
+				}
+				//处理用户的互动量
+				if len(userUserInteractionList) > 0 {
+					for _, vsplit := range userUserInteractionList {
+						interactionNum = vsplit.HistoryNum + vsplit.CountNum + vsplit.IndustryFllowNum + vsplit.DepartmentFollowNum + vsplit.KeyWordNum + vsplit.OnLineNum + vsplit.OfficeNum + vsplit.ChartCountNum + vsplit.TripNum + vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum + vsplit.TagNum
+						if interactionNum > 0 {
+							//更改用户的互动量
+							err = models.UpdateUserInteractionNum(interactionNum, int(vsplit.UserId))
+							if err != nil {
+								fmt.Println("UpdateUserInteractionNum Err", err)
+								return
+							}
+							mapComapnyInteractionNum[vsplit.CompanyId] += interactionNum
+
+							itemInteraction := new(models.CygxUserInteractionNum)
+							itemInteraction.UserId = int(vsplit.UserId)
+							itemInteraction.ArticleHistoryNum = vsplit.HistoryNum
+							itemInteraction.ArticleCountNum = vsplit.CountNum
+							itemInteraction.ChartCountNum = vsplit.ChartCountNum
+							itemInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
+							itemInteraction.DepartmentFollowNum = vsplit.DepartmentFollowNum
+							itemInteraction.KeyWordNum = vsplit.KeyWordNum
+							itemInteraction.ActivityOnLineNum = vsplit.OnLineNum
+							itemInteraction.ActivityOfficeNum = vsplit.OfficeNum
+							itemInteraction.ActivityNum = vsplit.OnLineNum + vsplit.OfficeNum
+							itemInteraction.TripNum = vsplit.TripNum
+							itemInteraction.RoadshowVideoNum = vsplit.RoadshowVideoNum
+							itemInteraction.ActivityVideoNum = vsplit.ActivityVideoNum
+							itemInteraction.ActivityVoiceNum = vsplit.ActivityVoiceNum
+							itemInteraction.TagNum = vsplit.TagNum
+							itemInteraction.RoadshowNum = vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
+							itemInteraction.CreateTime = time.Now()
+							itemInteraction.ModifyTime = time.Now()
+
+							//如果这个切片下的结构体没有值就给他初始值,如果有就跟后面的相加
+							if mapCompanyInteractionItem[vsplit.CompanyId] == nil {
+								itemCompanyInteraction := new(models.CygxCompanyInteractionNum)
+								itemCompanyInteraction.CompanyId = vsplit.CompanyId
+								itemCompanyInteraction.ArticleHistoryNum = vsplit.HistoryNum
+								itemCompanyInteraction.ArticleCountNum = vsplit.CountNum
+								itemCompanyInteraction.ChartCountNum = vsplit.ChartCountNum
+								itemCompanyInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
+								itemCompanyInteraction.DepartmentFollowNum = vsplit.DepartmentFollowNum
+								itemCompanyInteraction.KeyWordNum = vsplit.KeyWordNum
+								itemCompanyInteraction.ActivityOnLineNum = vsplit.OnLineNum
+								itemCompanyInteraction.ActivityOfficeNum = vsplit.OfficeNum
+								itemCompanyInteraction.ActivityNum = vsplit.OnLineNum + vsplit.OfficeNum
+								itemCompanyInteraction.TripNum = vsplit.TripNum
+								itemCompanyInteraction.RoadshowVideoNum = vsplit.RoadshowVideoNum
+								itemCompanyInteraction.ActivityVideoNum = vsplit.ActivityVideoNum
+								itemCompanyInteraction.ActivityVoiceNum = vsplit.ActivityVoiceNum
+								itemCompanyInteraction.TagNum = vsplit.TagNum
+								itemCompanyInteraction.RoadshowNum = vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
+								mapCompanyInteractionItem[vsplit.CompanyId] = itemCompanyInteraction
+								mapCompanyInteractionItem[vsplit.CompanyId].CreateTime = time.Now()
+								mapCompanyInteractionItem[vsplit.CompanyId].ModifyTime = time.Now()
+							} else {
+								fmt.Println("公司ID", vsplit.CompanyId)
+								mapCompanyInteractionItem[vsplit.CompanyId].CompanyId = vsplit.CompanyId
+								mapCompanyInteractionItem[vsplit.CompanyId].ArticleHistoryNum += vsplit.HistoryNum
+								mapCompanyInteractionItem[vsplit.CompanyId].ArticleCountNum += vsplit.CountNum
+								mapCompanyInteractionItem[vsplit.CompanyId].ChartCountNum += vsplit.ChartCountNum
+								mapCompanyInteractionItem[vsplit.CompanyId].IndustryFllowNum += vsplit.IndustryFllowNum
+								mapCompanyInteractionItem[vsplit.CompanyId].DepartmentFollowNum += vsplit.DepartmentFollowNum
+								mapCompanyInteractionItem[vsplit.CompanyId].KeyWordNum += vsplit.KeyWordNum
+								mapCompanyInteractionItem[vsplit.CompanyId].ActivityOnLineNum += vsplit.OnLineNum
+								mapCompanyInteractionItem[vsplit.CompanyId].ActivityOfficeNum += vsplit.OfficeNum
+								mapCompanyInteractionItem[vsplit.CompanyId].ActivityNum += vsplit.OnLineNum + vsplit.OfficeNum
+								mapCompanyInteractionItem[vsplit.CompanyId].TripNum += vsplit.TripNum
+								mapCompanyInteractionItem[vsplit.CompanyId].RoadshowVideoNum += vsplit.RoadshowVideoNum
+								mapCompanyInteractionItem[vsplit.CompanyId].ActivityVideoNum += vsplit.ActivityVideoNum
+								mapCompanyInteractionItem[vsplit.CompanyId].ActivityVoiceNum += vsplit.ActivityVoiceNum
+								mapCompanyInteractionItem[vsplit.CompanyId].TagNum += vsplit.TagNum
+								mapCompanyInteractionItem[vsplit.CompanyId].RoadshowNum += vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
+
+							}
+
+							//如果存在就修改不存在就新增
+							if mapUserInteraction[int(vsplit.UserId)] == 0 {
+								itemsInteraction = append(itemsInteraction, itemInteraction)
+							} else {
+								err = models.UpdateCygxUserInteractionNum(itemInteraction)
+								if err != nil {
+									fmt.Println("UpdateCygxUserInteractionNum Err", err)
+									return
+								}
+								fmt.Println(itemInteraction.UserId)
+							}
+						}
+					}
+				}
+				userIds = ""
+			}
+		}
+
+		userIds = strings.TrimRight(userIds, ",")
+		if userIds != "" {
+			userUserInteractionList, err := models.GetCygxCompanyUserUserInteraction(userIds)
+			if err != nil {
+				fmt.Println("GetCygxCompanyUserUserInteraction Err", err)
+				return
+			}
+			//fmt.Println("处理用户剩余的")
+			//处理用户的互动量
+			if len(userUserInteractionList) > 0 {
+				for _, vsplit := range userUserInteractionList {
+					interactionNum = vsplit.HistoryNum + vsplit.CountNum + vsplit.IndustryFllowNum + vsplit.DepartmentFollowNum + vsplit.KeyWordNum + vsplit.OnLineNum + vsplit.OfficeNum + vsplit.ChartCountNum + vsplit.TripNum + vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum + vsplit.TagNum
+					if interactionNum > 0 {
+						err = models.UpdateUserInteractionNum(interactionNum, int(vsplit.UserId))
+						if err != nil {
+							fmt.Println("UpdateUserInteractionNum Err", err)
+							return
+						}
+						mapComapnyInteractionNum[vsplit.CompanyId] += interactionNum
+
+						if mapComapnyInteractionSeller[int(vsplit.UserId)] > 0 {
+							mapComapnyInteractionNumSeller[vsplit.CompanyId] += interactionNum //如果销售可以看到这个人,那么就对销售可见的数量进行添加
+						}
+
+						itemInteraction := new(models.CygxUserInteractionNum)
+						itemInteraction.UserId = int(vsplit.UserId)
+						itemInteraction.ArticleHistoryNum = vsplit.HistoryNum
+						itemInteraction.ArticleCountNum = vsplit.CountNum
+						itemInteraction.ChartCountNum = vsplit.ChartCountNum
+						itemInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
+						itemInteraction.DepartmentFollowNum = vsplit.DepartmentFollowNum
+						itemInteraction.KeyWordNum = vsplit.KeyWordNum
+						itemInteraction.ActivityOnLineNum = vsplit.OnLineNum
+						itemInteraction.ActivityOfficeNum = vsplit.OfficeNum
+						itemInteraction.ActivityNum = vsplit.OnLineNum + vsplit.OfficeNum
+						itemInteraction.TripNum = vsplit.TripNum
+						itemInteraction.RoadshowVideoNum = vsplit.RoadshowVideoNum
+						itemInteraction.ActivityVideoNum = vsplit.ActivityVideoNum
+						itemInteraction.ActivityVoiceNum = vsplit.ActivityVoiceNum
+						itemInteraction.TagNum = vsplit.TagNum
+						itemInteraction.RoadshowNum = vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
+
+						//如果这个切片下的结构体没有值就给他初始值,如果有就跟后面的相加
+						if mapCompanyInteractionItem[vsplit.CompanyId] == nil {
+							itemCompanyInteraction := new(models.CygxCompanyInteractionNum)
+							itemCompanyInteraction.CompanyId = vsplit.CompanyId
+							itemCompanyInteraction.ArticleHistoryNum = vsplit.HistoryNum
+							itemCompanyInteraction.ArticleCountNum = vsplit.CountNum
+							itemCompanyInteraction.ChartCountNum = vsplit.ChartCountNum
+							itemCompanyInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
+							itemCompanyInteraction.DepartmentFollowNum = vsplit.DepartmentFollowNum
+							itemCompanyInteraction.KeyWordNum = vsplit.KeyWordNum
+							itemCompanyInteraction.ActivityOnLineNum = vsplit.OnLineNum
+							itemCompanyInteraction.ActivityOfficeNum = vsplit.OfficeNum
+							itemCompanyInteraction.ActivityNum = vsplit.OnLineNum + vsplit.OfficeNum
+							itemCompanyInteraction.TripNum = vsplit.TripNum
+							itemCompanyInteraction.RoadshowVideoNum = vsplit.RoadshowVideoNum
+							itemCompanyInteraction.ActivityVideoNum = vsplit.ActivityVideoNum
+							itemCompanyInteraction.ActivityVoiceNum = vsplit.ActivityVoiceNum
+							itemCompanyInteraction.TagNum = vsplit.TagNum
+							itemCompanyInteraction.RoadshowNum = vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
+							mapCompanyInteractionItem[vsplit.CompanyId] = itemCompanyInteraction
+							mapCompanyInteractionItem[vsplit.CompanyId].CreateTime = time.Now()
+							mapCompanyInteractionItem[vsplit.CompanyId].ModifyTime = time.Now()
+						} else {
+							mapCompanyInteractionItem[vsplit.CompanyId].CompanyId = vsplit.CompanyId
+							mapCompanyInteractionItem[vsplit.CompanyId].ArticleHistoryNum += vsplit.HistoryNum
+							mapCompanyInteractionItem[vsplit.CompanyId].ArticleCountNum += vsplit.CountNum
+							mapCompanyInteractionItem[vsplit.CompanyId].ChartCountNum += vsplit.ChartCountNum
+							mapCompanyInteractionItem[vsplit.CompanyId].IndustryFllowNum += vsplit.IndustryFllowNum
+							mapCompanyInteractionItem[vsplit.CompanyId].DepartmentFollowNum += vsplit.DepartmentFollowNum
+							mapCompanyInteractionItem[vsplit.CompanyId].KeyWordNum += vsplit.KeyWordNum
+							mapCompanyInteractionItem[vsplit.CompanyId].ActivityOnLineNum += vsplit.OnLineNum
+							mapCompanyInteractionItem[vsplit.CompanyId].ActivityOfficeNum += vsplit.OfficeNum
+							mapCompanyInteractionItem[vsplit.CompanyId].ActivityNum += vsplit.OnLineNum + vsplit.OfficeNum
+							mapCompanyInteractionItem[vsplit.CompanyId].TripNum += vsplit.TripNum
+							mapCompanyInteractionItem[vsplit.CompanyId].RoadshowVideoNum += vsplit.RoadshowVideoNum
+							mapCompanyInteractionItem[vsplit.CompanyId].ActivityVideoNum += vsplit.ActivityVideoNum
+							mapCompanyInteractionItem[vsplit.CompanyId].ActivityVoiceNum += vsplit.ActivityVoiceNum
+							mapCompanyInteractionItem[vsplit.CompanyId].TagNum += vsplit.TagNum
+							mapCompanyInteractionItem[vsplit.CompanyId].RoadshowNum += vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
+						}
+
+						////如果存在就修改不存在就新增
+						//if mapUserInteraction[int(vsplit.UserId)] == 0 {
+						//	itemsInteraction = append(itemsInteraction, itemInteraction)
+						//} else {
+						//	err = models.UpdateCygxUserInteractionNum(itemInteraction)
+						//	if err != nil {
+						//		fmt.Println("UpdateCygxUserInteractionNum Err", err)
+						//		return
+						//	}
+						//	fmt.Println(itemInteraction.UserId)
+						//	err = models.UpdateCygxUserInteractionNum(itemInteraction)
+						//}
+					}
+				}
+			}
+		}
+		fmt.Println("修改机构互动量信息")
+		////修改机构互动量信息
+		if len(mapComapnyInteractionNum) > 0 {
+			for k, v := range mapComapnyInteractionNum {
+				companyId := k
+				err = models.UpdateComapanyInteractionNum(v, mapComapnyInteractionNumSeller[companyId], companyId)
+				if err != nil {
+					fmt.Println(" AddCygxUserInteractionNumList Err", err)
+				}
+			}
+		}
+	}
+}

+ 26 - 1
utils/common.go

@@ -8,6 +8,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"github.com/PuerkitoBio/goquery"
+	"html"
 	"image"
 	"image/png"
 	"math"
@@ -894,10 +895,16 @@ func ArticleHasStyle(body string) (hasStyle bool, err error) {
 	doc.Find("class").Each(func(i int, s *goquery.Selection) {
 		hasStyle = true
 	})
+	doc.Find("strong").Each(func(i int, s *goquery.Selection) {
+		hasStyle = true // 加粗
+	})
+	doc.Find("u").Each(func(i int, s *goquery.Selection) {
+		hasStyle = true // 下划线
+	})
 	return
 }
 
-func ArticleRemoveImgUrl(body string) (result string){
+func ArticleRemoveImgUrl(body string) (result string) {
 	// 使用正则表达式去除img标签
 	re := regexp.MustCompile(`<img[^>]*>`)
 	result = re.ReplaceAllString(body, "")
@@ -929,3 +936,21 @@ func ExtractText(body string) (result string, err error) {
 
 	return
 }
+
+// 提取的纯文本内容
+func GetHtmlContentText(content string) (contentSub string, err error) {
+	if content == "" {
+		return
+	}
+	content = html.UnescapeString(content)
+	doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
+	if err != nil {
+		return
+	}
+	docText := doc.Text()
+	bodyRune := []rune(docText)
+	bodyRuneLen := len(bodyRune)
+	body := string(bodyRune[:bodyRuneLen])
+	contentSub = body
+	return
+}

+ 26 - 13
utils/constants.go

@@ -231,19 +231,22 @@ const (
 )
 
 const (
-	CYGX_OBJ_ARTICLE            string = "article"            // 对象类型:文章
-	CYGX_OBJ_ACTIVITY           string = "activity"           // 对象类型:活动
-	CYGX_OBJ_ACTIVITYVIDEO      string = "activityvideo"      // 对象类型:活动视频
-	CYGX_OBJ_ACTIVITYVOICE      string = "activityvoice"      // 对象类型:活动音频
-	CYGX_OBJ_ACTIVITYSPECIAL    string = "activityspecial"    // 对象类型:专项调研活动
-	CYGX_OBJ_MEETINGREVIEWCHAPT string = "meetingreviewchapt" // 对象类型:晨会精华
-	CYGX_OBJ_ROADSHOW           string = "roadshow"           // 对象类型:路演
-	CYGX_OBJ_REPORTSELECTION    string = "reportselection"    // 对象类型:报告精选(重点公司)
-	CYGX_OBJ_PRODUCTINTERIOR    string = "productinterior"    // 对象类型:产品内测
-	CYGX_OBJ_RESEARCHSUMMARY    string = "researchsummary"    // 对象类型:本周研究汇总
-	CYGX_OBJ_MINUTESSUMMARY     string = "minutessummary"     // 对象类型:上周纪要汇总
-	CYGX_OBJ_YANXUANSPECIAL     string = "yanxuanspecial"     // 对象类型:研选专栏
-	CYGX_OBJ_ASKSERIEVIDEO      string = "askserievideo"      // 对象类型:问答系列视频
+	CYGX_OBJ_ARTICLE             string = "article"            // 对象类型:文章
+	CYGX_OBJ_ACTIVITY            string = "activity"           // 对象类型:活动
+	CYGX_OBJ_ACTIVITYVIDEO       string = "activityvideo"      // 对象类型:活动视频
+	CYGX_OBJ_ACTIVITYVOICE       string = "activityvoice"      // 对象类型:活动音频
+	CYGX_OBJ_ACTIVITYSPECIAL     string = "activityspecial"    // 对象类型:专项调研活动
+	CYGX_OBJ_MEETINGREVIEWCHAPT  string = "meetingreviewchapt" // 对象类型:晨会精华
+	CYGX_OBJ_ROADSHOW            string = "roadshow"           // 对象类型:路演
+	CYGX_OBJ_REPORTSELECTION     string = "reportselection"    // 对象类型:报告精选(重点公司)
+	CYGX_OBJ_PRODUCTINTERIOR     string = "productinterior"    // 对象类型:产品内测
+	CYGX_OBJ_RESEARCHSUMMARY     string = "researchsummary"    // 对象类型:本周研究汇总
+	CYGX_OBJ_MINUTESSUMMARY      string = "minutessummary"     // 对象类型:上周纪要汇总
+	CYGX_OBJ_YANXUANSPECIAL      string = "yanxuanspecial"     // 对象类型:研选专栏
+	CYGX_OBJ_ASKSERIEVIDEO       string = "askserievideo"      // 对象类型:问答系列视频
+	CYGX_OBJ_NEWCHART            string = "newchart"           // 对象类型:图表
+	CYGX_OBJ_INDUSTRIALSOURCE_HZ string = "industrialsourceHz" // 对象类型:弘则资源包
+	CYGX_OBJ_INDUSTRIALSOURCE_YX string = "industrialsourceYx" // 对象类型:研选资源包
 )
 
 const (
@@ -261,3 +264,13 @@ const (
 const (
 	DISCLAIMERS string = "<div style=\"padding:20px\"><p>本报告仅供弘则弥道(上海)投资咨询有限公司正式签约的机构客户使用,不会因接收人/接收机构收到本报告而将其视为客户。本报告根据国际和行业通行的准则,以合法渠道获得这些信息,尽可能保证可靠、准确和完整,但并不保证报告所述信息的准确性和完整性,也不保证本报告所包含的信息或建议在本报告发出后不会发生任何变更。本报告中所提供的信息仅供参考。报告中的内容不对投资者做出的最终操作建议做任何的担保,也没有任何形式的分享投资收益或者分担投资损失的书面或口头承诺。不作为客户在投资、法律、会计或税务等方面的最终操作建议,也不作为道义的、责任的和法律的依据或者凭证,无论是否已经明示或者暗示。在任何情况下,本公司不对客户/接收人/接收机构因使用报告中内容所引致的一切损失负责任,客户/接收人/接收机构需自行承担全部风险。</p></div>"
 )
+
+// GetWeeklyDatabase 获取 weekly_report 库名
+func GetWeeklyDatabase() (databaseName string) {
+	if RunMode == "release" {
+		databaseName = `weekly_report`
+	} else {
+		databaseName = `test_v2_weekly_report`
+	}
+	return
+}