فهرست منبع

Merge branch 'master' of http://8.136.199.33:3000/cxzhang/hongze_clpt into cygx_12.8.1

xingzai 1 سال پیش
والد
کامیت
add0238202

+ 3 - 0
controllers/activity_special.go

@@ -263,6 +263,7 @@ func (this *ActivitySpecialController) SpecialTripAdd() {
 			itemBill.BillDetailed = -1 // 流水减一
 			itemBill.RegisterPlatform = 1
 			itemBill.ChartPermissionId = activityInfo.ChartPermissionId
+			itemBill.ChartPermissionName = activityInfo.ChartPermissionName
 
 			var itemMeeting = new(models.CygxActivitySpecialMeetingDetail)
 			itemMeeting.UserId = user.UserId
@@ -275,6 +276,7 @@ func (this *ActivitySpecialController) SpecialTripAdd() {
 			itemMeeting.RealName = user.RealName
 
 			go services.ActivitySpecialUserRmind(user, activityId, 2)
+			go services.ActivitySpecialUserAddTrip(user, activityId)
 			//判断是删除还是添加
 			if total == 0 {
 				//获取销售信息
@@ -443,6 +445,7 @@ func (this *ActivitySpecialController) 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/home.go

@@ -321,7 +321,7 @@ func (this *MobileHomeController) NewList() {
 		startSize = 0
 		pageSize = utils.PageSize5
 	} 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() {

+ 29 - 29
controllers/report.go

@@ -286,11 +286,11 @@ func (this *MobileReportController) IndustryList() {
 			condition += ` AND man.industrial_management_id IN (` + utils.GetOrmInReplace(activeIndustryLen) + `)`
 			parsBd = append(parsBd, activeIndustryIds)
 		}
-		nowTime := time.Now().Local()
-		startTime := nowTime.AddDate(0, -1, 0)
-		endTime := nowTime.AddDate(0, 0, -1)
-		condition += ` AND idf.create_time BETWEEN ? AND ?`
-		parsBd = append(parsBd, startTime, endTime)
+		//nowTime := time.Now().Local()
+		//startTime := nowTime.AddDate(0, -1, 0)
+		//endTime := nowTime.AddDate(0, 0, -1)
+		//condition += ` AND idf.create_time BETWEEN ? AND ?`
+		//parsBd = append(parsBd, startTime, endTime)
 		list, e = models.GetTopIndustryFollowData(0, pageSize, condition, parsBd)
 		if e != nil {
 			br.Msg = "获取失败"
@@ -1354,35 +1354,35 @@ func (this *MobileReportController) Timeline() {
 	}
 
 	//查询用户今天是否看过时间线
-	count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
-	if err != nil {
-		br.Msg = "查询浏览记录数量失败"
-		br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
-		return
-	}
-	var recordItem *models.CygxPageHistoryRecord
-	if count > 1 {
-		recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
-		if err != nil {
-			br.Msg = "查询浏览记录失败"
-			br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
-			return
-		}
-	}
+	//count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
+	//if err != nil {
+	//	br.Msg = "查询浏览记录数量失败"
+	//	br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
+	//	return
+	//}
+	//var recordItem *models.CygxPageHistoryRecord
+	//if count > 1 {
+	//	recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
+	//	if err != nil {
+	//		br.Msg = "查询浏览记录失败"
+	//		br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
+	//		return
+	//	}
+	//}
 
 	for k, v := range list {
 		if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
 			list[k].IsRed = true
 		}
-		timeLineRed := false
-		if count < 2 && v.SubCategoryName == "时间线" {
-			timeLineRed = true
-		} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishDate)) {
-			timeLineRed = true
-		}
-		if v.SubCategoryName == "时间线" && timeLineRed {
-			list[k].IsRed = true
-		}
+		//timeLineRed := false
+		//if count < 2 && v.SubCategoryName == "时间线" {
+		//	timeLineRed = true
+		//} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishDate)) {
+		//	timeLineRed = true
+		//}
+		//if v.SubCategoryName == "时间线" && timeLineRed {
+		list[k].IsRed = true
+		//}
 		if v.VideoUrl != "" {
 			list[k].IsHaveVideo = true
 		}

+ 3 - 1
controllers/research.go

@@ -123,18 +123,20 @@ func (this *MobileResearchController) ArticleNewList() {
 		br.ErrMsg = "GetArticleResearchCount,Err:" + err.Error()
 		return
 	}
-	list, err := models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId, needYanxuanSpecial)
+	list, err := models.GetArticleResearchListYx(condition, pars, startSize, pageSize, user.UserId, needYanxuanSpecial)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
+
 	list, err = services.HandleArticleCategoryImg(list, user)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
 		return
 	}
+
 	//处理对应的文章类型标签按钮
 	nameMap, styleMap, err := services.GetArticleTypeMap()
 	if err != nil {

+ 1 - 1
controllers/search.go

@@ -390,7 +390,7 @@ func (this *MobileSearchController) ComprehensiveList() {
 		return
 	}
 	resp := new(models.HomeResourceDataListNewResp)
-	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()

+ 5 - 0
controllers/tag.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/services"
+	"hongze/hongze_clpt/utils"
 )
 
 type TagController struct {
@@ -81,6 +82,10 @@ func (this *TagController) TagCustomizeList() {
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
+	item := new(models.ChartPermissionResp)
+	item.ChartPermissionId = utils.GU_SHOU_ID
+	item.PermissionName = utils.GU_SHOU_NAME
+	listPermission = append(listPermission, item)
 
 	resp.List = list
 	resp.ListPermission = listPermission

+ 120 - 63
controllers/yanxuan_special.go

@@ -234,7 +234,13 @@ func (this *YanxuanSpecialController) Detail() {
 		resp.HasPermission = 2
 	}
 
-	go services.AddSpecialRecord(this.User, specialId)
+	//判断是否属于审核人员
+	mobileSlice := strings.Split(cnf.ConfigValue, ",")
+	for _, v := range mobileSlice {
+		if v == sysUser.Mobile {
+			resp.IsApprovalAdmin = true
+		}
+	}
 
 	br.Data = resp
 	br.Ret = 200
@@ -372,6 +378,7 @@ func (this *YanxuanSpecialController) Save() {
 	imgUrls := strings.Join(req.ImgUrl, ",")
 	cTags := strings.Join(req.CompanyTags, ",")
 	iTags := strings.Join(req.IndustryTags, ",")
+	isApprovalPersonnel := req.IsApprovalPersonnel
 	item := models.CygxYanxuanSpecial{
 		Id:           req.Id,
 		UserId:       sysUser.UserId,
@@ -393,33 +400,75 @@ func (this *YanxuanSpecialController) Save() {
 		item.Status = 2
 		br.Msg = "已提交审核"
 	}
+	var authorUserId int
+	// 如果是审批人员操作的那么就是修改内容,加审批通过
+	if isApprovalPersonnel {
+		item.Status = 3
+		//校验是否属于审核人员
+		if !services.CheckYxSpecialIsApprovalPersonnel(sysUser.Mobile) {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,该账号不属于审核人员:" + sysUser.Mobile
+			return
+		}
 
-	var newId int64
+		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 //审核人员姓名
+		br.Msg = "审批成功"
+	}
+
+	specialId := 0
 	if req.Id == 0 {
-		newId, err = models.AddCygxYanxuanSpecial(&item)
+		id, err := models.AddCygxYanxuanSpecial(&item)
 		if err != nil {
 			br.Msg = "新增失败"
 			br.ErrMsg = "新增失败,Err:" + err.Error()
 			return
 		}
+		specialId = int(id)
 	} else {
+		detail, tmpErr := models.GetYanxuanSpecialById(req.Id, sysUser.UserId)
+		if tmpErr != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+			return
+		}
+		if detail.Status == 2 && !isApprovalPersonnel {
+			br.Msg = "请勿重复提交"
+			br.ErrMsg = "保存失败,专栏内容正在审核"
+			return
+		}
 		err = models.UpdateYanxuanSpecial(&item)
 		if err != nil {
 			br.Msg = "保存失败"
 			br.ErrMsg = "保存失败,Err:" + err.Error()
 			return
 		}
-		newId = int64(req.Id)
+		specialId = req.Id
 	}
 
-	if req.DoType == 2 {
-		go services.SendReviewTemplateMsgAdmin(int(newId))
-		go services.UpdateYanxuanSpecialResourceData(int(newId)) //  写入首页最新  cygx_resource_data 表
-		go services.EsAddYanxuanSpecial(int(newId))              //  写入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
 	br.Success = true
-	br.Data = newId
+	br.Data = specialId
 }
 
 // @Title 专栏作者详情
@@ -467,8 +516,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
@@ -496,16 +545,25 @@ 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
 	}
-	//if req.Status == 1 {
-	//	go services.SendWxMsgSpecialFollow(req.Id)
-	//}
-	go services.UpdateYanxuanSpecialResourceData(req.Id) //  写入首页最新  cygx_resource_data 表
-	go services.EsAddYanxuanSpecial(req.Id)              //  写入es 综合搜索
+	if req.Status == 1 {
+		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.AddAddCygxYanxuanSpecialApprovalLog(user, req.Id, req.Status, req.Reason) //  写入es 综合搜索
+	go services.UdpateYanxuanSpecialauthorArticleNum(detail.UserId)                       //  更新作者发布文章的数量
 	br.Msg = "审批成功"
 	br.Ret = 200
 	br.Success = true
@@ -522,8 +580,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
@@ -548,19 +606,20 @@ func (this *YanxuanSpecialController) Collect() {
 	var sellerName string
 
 	if req.Status == 1 {
-		sellerName, err = models.GetCompanySellerName(sysUser.CompanyId)
+		sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
 		if err != nil {
 			br.Msg = "报名失败!"
 			br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
 			return
 		}
+		sellerName = sellerItem.RealName
 		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(),
@@ -575,7 +634,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()
@@ -584,6 +643,7 @@ func (this *YanxuanSpecialController) Collect() {
 		br.Msg = "取消收藏成功"
 	}
 
+	go services.UdpateYanxuanSpecialCollect(req.Id)
 	br.Ret = 200
 	br.Success = true
 }
@@ -666,27 +726,14 @@ func (this *YanxuanSpecialController) Record() {
 		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)
+	specialId := req.SpecialId
+	stopTime := req.StopTime
+	if req.SpecialId <= 0 {
+		br.Msg = "文章不存在"
+		br.ErrMsg = "文章不存在,文章ID错误"
+		return
+	}
+	err = services.AddSpecialRecord(this.User, specialId, stopTime)
 	if err != nil {
 		br.Msg = "记录失败"
 		br.ErrMsg = "记录失败,Err:" + err.Error()
@@ -708,8 +755,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
@@ -732,12 +779,14 @@ 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
 	authorItem, err := models.GetYanxuanSpecialAuthorById(req.FollowSpecialColumnId)
 	if err != nil {
 		br.Msg = "查询栏目详情失败!"
@@ -747,13 +796,13 @@ func (this *YanxuanSpecialController) Follow() {
 
 	if req.Status == 1 {
 		item := models.CygxYanxuanSpecialFollow{
-			UserId:           sysUser.UserId,
+			UserId:           user.UserId,
 			FollowUserId:     authorItem.UserId,
-			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(),
@@ -768,7 +817,7 @@ func (this *YanxuanSpecialController) Follow() {
 		}
 		br.Msg = "关注成功"
 	} else {
-		err = models.DelCygxYanxuanSpecialFollow(sysUser.UserId, authorItem.UserId)
+		err = models.DelCygxYanxuanSpecialFollow(user.UserId, authorItem.UserId)
 		if err != nil {
 			br.Msg = "删除失败"
 			br.ErrMsg = "删除失败,Err:" + err.Error()
@@ -776,7 +825,7 @@ func (this *YanxuanSpecialController) Follow() {
 		}
 		br.Msg = "取消关注成功"
 	}
-
+	go services.UdpateYanxuanSpecialFansNum(authorItem.UserId)
 	br.Ret = 200
 	br.Success = true
 }
@@ -885,13 +934,21 @@ 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

+ 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:"总和"`
 }
 
 // 添加

+ 14 - 0
models/admin.go

@@ -72,6 +72,20 @@ func GetRaiAdmin() (items []*AdminMobileResp, err error) {
 	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
+}
+
 // 根据角色名称获取手机号
 func GetAdminByRoleName(roleName string) (items []*AdminMobileResp, err error) {
 	o := orm.NewOrmUsingDB("weekly_report")

+ 9 - 9
models/chart.go

@@ -98,14 +98,14 @@ func GetChartCountById(chartId int) (count int, err error) {
 	return
 }
 
-//新增图表
+// 新增图表
 func AddCygxChart(item *CygxChart) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
 	return
 }
 
-//标签分类
+// 标签分类
 type ChartPtagResultApi struct {
 	Data []ChartPtagResultApidate `json:"data"`
 	Code int                      `json:"code"`
@@ -149,7 +149,7 @@ type ChartCollectReq struct {
 	ChartId int `description:"图表ID"`
 }
 
-//获取图表列表
+// 获取图表列表
 func GetChartList(condition string, pars []interface{}, startSize, pageSize int) (items []*HomeChartListResp, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT * FROM cygx_chart AS a WHERE a.publish_status=1 `
@@ -161,7 +161,7 @@ func GetChartList(condition string, pars []interface{}, startSize, pageSize int)
 	return
 }
 
-//获取所有同步过来的图表
+// 获取所有同步过来的图表
 func GetChartListAll() (items []*HomeChartListResp, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT chart_id FROM cygx_chart  `
@@ -177,7 +177,7 @@ func GetChartListAll() (items []*HomeChartListResp, err error) {
 //	return
 //}
 
-//获取图表列表
+// 获取图表列表
 func GetChartListCollection(condition string, pars []interface{}, userId, startSize, pageSize int) (items []*HomeChartListResp, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT a.*,
@@ -186,7 +186,7 @@ func GetChartListCollection(condition string, pars []interface{}, userId, startS
 			( 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
@@ -201,7 +201,7 @@ func GetChartListCollection(condition string, pars []interface{}, userId, startS
 	return
 }
 
-//获取图表列表本地
+// 获取图表列表本地
 func GetChartListCollectionWithCygx(userId, startSize, pageSize int) (items []*HomeChartListResp, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT
@@ -233,7 +233,7 @@ func GetChartListConfig() (items []*HomeChartListResp, err error) {
 	return
 }
 
-//获取图表数量
+// 获取图表数量
 func GetChartCount(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT COUNT(1) AS count
@@ -246,7 +246,7 @@ func GetChartCount(condition string, pars []interface{}) (count int, err error)
 	return
 }
 
-//获取图表数量
+// 获取图表数量
 func GetChartCollentCount(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT COUNT(1) AS count

+ 78 - 19
models/cygx_yanxuan_special.go

@@ -21,6 +21,7 @@ type CygxYanxuanSpecial struct {
 	Reason       string    // 理由
 	Title        string    // 标题
 	Type         int       // 类型1:笔记,2:观点
+	AdminName    string    // 审核人员姓名
 }
 
 type CygxYanxuanSpecialItem struct {
@@ -56,15 +57,19 @@ type CygxYanxuanSpecialItem struct {
 	CompanyTags     string
 	IndustryTags    string
 	Docs            []Doc
-	Annotation      string `description:"核心观点"`
+	Annotation      string   `description:"核心观点"`
+	Pv              string   `description:"Pv"`
+	Uv              string   `description:"Uv"`
+	BodyHighlight   []string `description:"搜索高亮展示结果"`
 }
 
 type CygxYanxuanSpecialResp struct {
 	CygxYanxuanSpecialItem
-	Docs          []Doc
-	CompanyTags   []string
-	IndustryTags  []string
-	HasPermission int `description:"1:正常展示,2:不展示"`
+	Docs            []Doc
+	CompanyTags     []string
+	IndustryTags    []string
+	HasPermission   int  `description:"1:正常展示,2:不展示"`
+	IsApprovalAdmin bool // 是否是审批人员
 }
 
 type Doc struct {
@@ -108,11 +113,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() 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
 }
 
@@ -153,15 +158,16 @@ func GetYanxuanSpecialListBycondition(condition string, pars []interface{}, star
 }
 
 type CygxYanxuanSpecialReq struct {
-	Id           int      `orm:"column(id);pk"`
-	Content      string   // 内容
-	IndustryTags []string // 行业标签
-	CompanyTags  []string // 公司标签
-	DoType       int      // 1保存 2发布
-	ImgUrl       []string // 图片链接
-	Docs         []Doc    // 文档链接
-	Title        string   // 标题
-	Type         int      // 类型1:笔记,2:观点
+	Id                  int      `orm:"column(id);pk"`
+	Content             string   // 内容
+	IndustryTags        []string // 行业标签
+	CompanyTags         []string // 公司标签
+	DoType              int      // 1保存 2发布
+	ImgUrl              []string // 图片链接
+	Docs                []Doc    // 文档链接
+	Title               string   // 标题
+	Type                int      // 类型1:笔记,2:观点
+	IsApprovalPersonnel bool     // 是否是审批人员操作
 }
 
 func AddCygxYanxuanSpecial(item *CygxYanxuanSpecial) (lastId int64, err error) {
@@ -174,8 +180,18 @@ 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
+}
+
+func GetYanxuanSpecialBySpecialId(specialId int) (item *CygxYanxuanSpecialItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT a.*
+FROM cygx_yanxuan_special AS a
+ WHERE a.id=? `
+	err = o.Raw(sql, specialId).QueryRow(&item)
 	return
 }
 
@@ -253,3 +269,46 @@ 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 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
+}

+ 11 - 0
models/cygx_yanxuan_special_follow.go

@@ -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
+}

+ 34 - 2
models/cygx_yanxuan_special_record.go

@@ -28,5 +28,37 @@ func AddCygxYanxuanSpecialRecord(item *CygxYanxuanSpecialRecord) (lastId int64,
 }
 
 type AddCygxYanxuanSpecialRecordReq struct {
-	SpecialId           int `description:"专栏文章id"`
-}
+	SpecialId int `description:"专栏文章id"`
+	StopTime  int `description:"停留时间"`
+}
+
+// 判断一个用户是否阅读过 某一篇研选专栏
+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
+}

+ 89 - 0
models/cygx_yanxuan_special_user.go

@@ -92,6 +92,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
+}
+
 func GetYanxuanSpecialAuthorBySpecialColumnId(specialColumnId, sysUserId int) (item *CygxYanxuanSpecialAuthorItem, err error) {
 	o := orm.NewOrm()
 	sql := ``
@@ -192,3 +200,84 @@ func GetYanxuanSpecialAuthorById(specialColumnId int) (item *CygxYanxuanSpecialA
 	err = o.Raw(sql, specialColumnId).QueryRow(&item)
 	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 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 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 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
+}

+ 2 - 0
models/db.go

@@ -91,10 +91,12 @@ func init() {
 		new(CygxReportSelectionLogApply),
 		new(CygxIndustryFllowLog),
 		new(CygxYanxuanSpecialRecord),
+		new(CygxYanxuanSpecialRecordLog),
 		new(CygxYanxuanSpecialCollect),
 		new(CygxYanxuanSpecial),
 		new(CygxYanxuanSpecialFollow),
 		new(CygxYanxuanSpecialCompany),
+		new(CygxYanxuanSpecialApprovalLog),
 		new(CygxResourceData),
 		new(CygxMorningMeetingReviewChapterHistory),
 		new(CygxAskserieVideoHistoryRecord),

+ 24 - 6
models/industrial_management.go

@@ -326,22 +326,40 @@ func GetTopOneMonthArtReadNumIndustryAll(condition string, pars []interface{}) (
 	return
 }
 
+//// GetTopIndustryFollowData 获取关注度最高的产业关注数据
+//func GetTopIndustryFollowData(startSize, pageSize int, condition string, pars []interface{}) (list []*IndustrialManagement, err error) {
+//	sql := `SELECT
+//				COUNT(1) AS one_month_follow_num,
+//				man.*
+//			FROM
+//				cygx_industry_fllow AS idf
+//			JOIN cygx_industrial_management AS man ON idf.industrial_management_id = man.industrial_management_id
+//			WHERE 1 = 1 `
+//	if condition != "" {
+//		sql += condition
+//	}
+//	sql += ` GROUP BY
+//				idf.industrial_management_id
+//			ORDER BY
+//				one_month_follow_num DESC
+//			LIMIT ?,?`
+//	_, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
+//	return
+//}
+
 // GetTopIndustryFollowData 获取关注度最高的产业关注数据
 func GetTopIndustryFollowData(startSize, pageSize int, condition string, pars []interface{}) (list []*IndustrialManagement, err error) {
 	sql := `SELECT
-				COUNT(1) AS one_month_follow_num,
 				man.*
-			FROM
-				cygx_industry_fllow AS idf
-			JOIN cygx_industrial_management AS man ON idf.industrial_management_id = man.industrial_management_id
+			FROM  cygx_industrial_management AS man
 			WHERE 1 = 1 `
 	if condition != "" {
 		sql += condition
 	}
 	sql += ` GROUP BY
-				idf.industrial_management_id
+				man.industrial_management_id
 			ORDER BY
-				one_month_follow_num DESC
+				man.one_month_follow_num DESC
 			LIMIT ?,?`
 	_, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
 	return

+ 61 - 0
models/report.go

@@ -19,6 +19,7 @@ type IndustrialManagement struct {
 	ChartPermissionId      int                  `description:"权限id"`
 	ChartPermissionName    string               `description:"权限名称"`
 	LayoutTime             string               `description:"布局时间"`
+	PublishDate            string               `description:"发布时间"`
 	UpdateTime             string               `description:"更新时间"`
 	IsRed                  bool                 `description:"是否标记红点"`
 	IsHot                  bool                 `description:"是否是热门"`
@@ -940,6 +941,66 @@ func GetArticleResearchList(condition string, pars []interface{}, startSize, pag
 	return
 }
 
+func GetArticleResearchListYx(condition string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (items []*ArticleListResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			a.article_id,
+			a.title,
+			a.body,
+			a.annotation,
+			a.abstract,
+			a.publish_date,
+			a.article_type_id,
+			d.nick_name,
+			d.department_id,
+			0 AS is_special,
+			0 as pv,
+			0 as collect_num,
+			0 AS special_type,
+			0 AS special_column_id,
+			'' AS company_tags, 
+			'' AS industry_tags
+		FROM
+			cygx_article AS a
+			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
+	}
+	if needYanxuanSpecial {
+		sql += `UNION ALL
+	SELECT
+		a.id AS article_id,
+		a.title AS title,
+		'' AS body,
+		a.content AS annotation,
+		'' AS abstract,
+		a.publish_time AS publish_date,
+		-1 AS article_type_id,
+		b.nick_name AS nick_name,
+		0 AS department_id,
+		1 AS is_special,
+		a.pv,
+		a.article_collect_num as collect_num,
+		a.type AS special_type,
+		b.id AS special_column_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 += ` GROUP BY article_id ORDER  BY publish_date DESC  LIMIT ?,? `
+		_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	} else {
+		sql += ` GROUP BY a.article_id ORDER  BY a.publish_date DESC  LIMIT ?,? `
+		_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	}
+	return
+}
+
 func GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (total int, items []*ArticleListResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT

+ 24 - 9
models/resource_data.go

@@ -7,15 +7,18 @@ import (
 )
 
 type CygxResourceData struct {
-	Id          int       `orm:"column(id);pk"`
-	SourceId    int       `description:"资源ID"`
-	Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
-	Title       string    `description:"标题"`
-	Annotation  string    `description:"核心观点"`
-	CreateTime  time.Time `description:"创建时间"`
-	PublishDate string    `description:"发布时间"`
-	Abstract    string    `description:"摘要"`
-	SearchTag   string    `description:"搜索标签"`
+	Id              int       `orm:"column(id);pk"`
+	SourceId        int       `description:"资源ID"`
+	Source          string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+	Title           string    `description:"标题"`
+	Annotation      string    `description:"核心观点"`
+	CreateTime      time.Time `description:"创建时间"`
+	PublishDate     string    `description:"发布时间"`
+	Abstract        string    `description:"摘要"`
+	SearchTag       string    `description:"搜索标签"`
+	SearchTitle     string    `description:"搜索匹配用的标题"`
+	SearchContent   string    `description:"搜索匹配用的内容"`
+	SearchOrderTime string    `description:"搜索排序时间"`
 }
 
 type CygxResourceDataResp struct {
@@ -122,6 +125,18 @@ 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

+ 1 - 1
services/activity.go

@@ -323,7 +323,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 {
+	if GetBelongingRaiIt(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID {
 		return
 	}
 	adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)

+ 80 - 15
services/activity_special_trip.go

@@ -269,11 +269,11 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
 			err = errors.New("GetActivitySpecialTripCountByActivitySpecial, Err: " + e.Error())
 			return
 		}
-		// 获取继承点数
-		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
@@ -283,13 +283,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 {
@@ -345,9 +345,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 {
@@ -366,3 +366,68 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
 	}
 	return
 }
+
+// 确定行程用户报名模版消息推送
+func ActivitySpecialUserAddTrip(user *models.WxUserItem, activityId int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("确定行程用户报名模版消息推送,模板消息推送失败"+err.Error(), 2)
+		}
+	}()
+	var first string
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+	//获取销售手机号
+	sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+	cnf, _ := models.GetConfigByCode("tpl_msg")
+
+	if cnf != nil && sellerItemQy != nil {
+		openIdList, e := models.GetWxOpenIdByMobileList(cnf.ConfigValue + "," + sellerItemQy.Mobile)
+		if e != nil {
+			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+			return
+		}
+		activityInfo, e := models.GetCygxActivitySpecialDetailById(user.UserId, activityId)
+		if e != nil {
+			err = errors.New("GetCygxActivitySpecialDetailById, Err: " + e.Error())
+			return
+		}
+		if activityInfo == nil {
+			return
+		}
+		keyword1 = fmt.Sprint(user.RealName, "--", user.CompanyName, "(所属销售:", sellerItemQy.RealName, ")")
+		keyword2 = user.Mobile
+		keyword3 = time.Now().Format(utils.FormatDateTime)
+		keyword4 = "报名专项调研【" + activityInfo.ResearchTheme + "】 "
+		remark = ""
+		openIdArr := make([]string, 0)
+		for _, v := range openIdList {
+			openIdArr = append(openIdArr, v.OpenId)
+		}
+		redirectUrl := utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(activityId)
+		sendInfo := new(SendWxTemplate)
+		sendInfo.First = first
+		sendInfo.Keyword1 = keyword1
+		sendInfo.Keyword2 = keyword2
+		sendInfo.Keyword3 = keyword3
+		sendInfo.Keyword4 = keyword4
+		sendInfo.Remark = remark
+		sendInfo.TemplateId = utils.WxMsgTemplateIdApplyXzs
+		sendInfo.RedirectUrl = redirectUrl
+		sendInfo.RedirectTarget = 3
+		sendInfo.Resource = strconv.Itoa(activityId)
+		sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+		sendInfo.OpenIdArr = openIdArr
+		err = PublicSendTemplateMsg(sendInfo)
+		if err != nil {
+			return
+		}
+	}
+	return
+}

+ 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()
@@ -64,3 +86,12 @@ func GetBelongingRai(mobile string) (isBelong bool) {
 	}
 	return
 }
+
+// 根据手机号判断是否属于IT人员
+func GetBelongingRaiIt(mobile string) (isBelong bool) {
+	mapItem := GetRaiAdminMobileItMap()
+	if mapItem[mobile] != "" {
+		isBelong = true
+	}
+	return
+}

+ 3 - 1
services/article.go

@@ -206,7 +206,7 @@ func HandleArticleCategoryImg(list []*models.ArticleListResp, user *models.WxUse
 	articleMapPv := GetArticleHistoryByArticleId(articleIds)                       //文章Pv
 	articleCollectMap, _ := GetCygxArticleCollectMap(user.UserId)                  //用户收藏的文章
 	articleCollectNumMap, _ := GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
-
+	articleCollectYanxuanSpecialMap, _ := GetYanxuanSpecialCollectMap(user.UserId) //用户收藏的研选专栏
 	for k, v := range list {
 		if len(industryMap[v.ArticleId]) > 0 {
 			list[k].List = industryMap[v.ArticleId]
@@ -220,6 +220,8 @@ func HandleArticleCategoryImg(list []*models.ArticleListResp, user *models.WxUse
 			list[k].Pv = articleMapPv[v.ArticleId]
 			list[k].IsCollect = articleCollectMap[v.ArticleId]
 			list[k].CollectNum = articleCollectNumMap[v.ArticleId]
+		} else {
+			v.IsCollect = articleCollectYanxuanSpecialMap[v.ArticleId]
 		}
 	}
 

+ 26 - 26
services/article_red.go

@@ -23,42 +23,42 @@ func GetShowTimeLineIsRed(user *models.WxUserItem, industrialManagementId int) (
 		return
 	}
 	//查询用户今天是否看过时间线
-	haveMorningMeeting := false
-	var morningMeetingTime string
-	count, e := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
-	if e != nil {
-		err = errors.New("GetTimeLineRecordCount, Err: " + e.Error())
-		return
-	}
-	var recordItem *models.CygxPageHistoryRecord
-	if count > 1 {
-		recordItem, e = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
-		if e != nil {
-			err = errors.New("GetTimeLineRecordCount, Err: " + e.Error())
-			return
-		}
-	}
+	//haveMorningMeeting := false
+	//var morningMeetingTime string
+	//count, e := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
+	//if e != nil {
+	//	err = errors.New("GetTimeLineRecordCount, Err: " + e.Error())
+	//	return
+	//}
+	//var recordItem *models.CygxPageHistoryRecord
+	//if count > 1 {
+	//	recordItem, e = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
+	//	if e != nil {
+	//		err = errors.New("GetTimeLineRecordCount, Err: " + e.Error())
+	//		return
+	//	}
+	//}
 
 	for _, v := range timeLineList {
 		if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
 			if v.SubCategoryName == "时间线" {
-				haveMorningMeeting = true
-				morningMeetingTime = v.PublishDate
+				//haveMorningMeeting = true
+				//morningMeetingTime = v.PublishDate
 				continue
 			}
 			timeLineItem.IsRed = true
 		}
 	}
 	//因为无法记录用户是否看过晨会点评,所以用用户今天是否看过时间线来判断是否显示小红点,这里是判断分类的小红点
-	timeLineRed := false
-	if count < 2 {
-		timeLineRed = true
-	} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(morningMeetingTime)) {
-		timeLineRed = true
-	}
-	if !timeLineItem.IsRed && timeLineRed && haveMorningMeeting {
-		timeLineItem.IsRed = true
-	}
+	//timeLineRed := false
+	//if count < 2 {
+	//	timeLineRed = true
+	//} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(morningMeetingTime)) {
+	//	timeLineRed = true
+	//}
+	//if !timeLineItem.IsRed && timeLineRed && haveMorningMeeting {
+	//	timeLineItem.IsRed = true
+	//}
 	isRed = timeLineItem.IsRed
 	return
 

+ 22 - 0
services/config.go

@@ -107,3 +107,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
+}

+ 343 - 0
services/cygx_yanxuan_special.go

@@ -6,9 +6,97 @@ import (
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
+// 研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
+func SendWxMsgSpecialFollow(specialId int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息失败", specialId, ", specialId", err.Error()), 2)
+		}
+	}()
+	var first string
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+
+	followers, e := models.GetYanxuanSpecialFollowUserById(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
+		return
+	}
+	if len(followers) == 0 {
+		return
+	}
+	specialItem, e := models.GetYanxuanSpecialItemById(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
+		return
+	}
+	var allInUserId string
+	for _, v := range followers {
+		allInUserId += strconv.Itoa(v) + ","
+	}
+
+	allInUserId = strings.TrimRight(allInUserId, ",")
+
+	userList, err := models.GetWxUserListByUserIds(allInUserId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+
+	mobile := ``
+
+	for _, v := range userList {
+		mobile += v.Mobile + ","
+	}
+
+	mobile = strings.TrimRight(mobile, ",")
+
+	openIdList, e := models.GetWxOpenIdByMobileList(mobile)
+	if e != nil {
+		err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+		return
+	}
+	if len(openIdList) == 0 {
+		return
+	}
+
+	//first =
+	keyword1 = "研选专栏:" + specialItem.SpecialName
+	keyword2 = "发布了新内容,点击查看详情"
+	keyword3 = "-"
+	//keyword4 = "【" + activityInfo.ResearchTheme + "】已有10人预报名"
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	redirectUrl := ""
+	redirectUrl = utils.WX_MSG_PATH_YX_SPECIAL_DETAIL + strconv.Itoa(specialId)
+	sendInfo := new(SendWxTemplate)
+	sendInfo.First = first
+	sendInfo.Keyword1 = keyword1
+	sendInfo.Keyword2 = keyword2
+	sendInfo.Keyword3 = keyword3
+	sendInfo.Keyword4 = keyword4
+	sendInfo.Remark = remark
+	sendInfo.TemplateId = utils.WxMsgTemplateIdAskMsgXzs
+	sendInfo.RedirectUrl = redirectUrl
+	sendInfo.RedirectTarget = 3
+	sendInfo.Resource = strconv.Itoa(specialId)
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	err = PublicSendTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}
+
 // SendReviewTemplateMsgAdmin 提交审核时给王芳,汪洋发消息
 func SendReviewTemplateMsgAdmin(specialId int) (err error) {
 	defer func() {
@@ -73,6 +161,70 @@ func SendReviewTemplateMsgAdmin(specialId int) (err error) {
 	return
 }
 
+// 研选专栏审核完成时,给提交人发送模板消息
+func SendWxMsgSpecialAuthor(specialId, status int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("研选专栏审核完成时,给提交人发送模板消息", specialId, ", specialId", err.Error()), 2)
+		}
+	}()
+	var first string
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+	var redirectUrl string
+
+	specialItem, e := models.GetYanxuanSpecialItemById(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
+		return
+	}
+	user, e := models.GetWxUserItemByUserId(specialItem.UserId)
+	if e != nil {
+		err = errors.New("GetWxUserItemByUserId, Err: " + e.Error())
+		return err
+	}
+
+	openIdList, err := models.GetUserRecordListByMobile(4, user.Mobile)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+
+	keyword1 = "研选专栏内容审核"
+	if status == 1 {
+		keyword2 = "已通过审核,点击查看详情"
+		redirectUrl = utils.WX_MSG_PATH_YX_SPECIAL_DETAIL + strconv.Itoa(specialId)
+	} else {
+		keyword2 = "未通过审核,点击查看驳回原因"
+		redirectUrl = utils.WX_MSG_PATH_YX_SPECIAL_CENTER
+	}
+	keyword3 = "-"
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	sendInfo := new(SendWxTemplate)
+	sendInfo.First = first
+	sendInfo.Keyword1 = keyword1
+	sendInfo.Keyword2 = keyword2
+	sendInfo.Keyword3 = keyword3
+	sendInfo.Keyword4 = keyword4
+	sendInfo.Remark = remark
+	sendInfo.TemplateId = utils.WxMsgTemplateIdArticleUserRemind
+	sendInfo.RedirectUrl = redirectUrl
+	sendInfo.RedirectTarget = 3
+	sendInfo.Resource = strconv.Itoa(specialId)
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	err = PublicSendTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}
+
 // 更新研选专栏  写入首页最新  cygx_resource_data 表
 func UpdateYanxuanSpecialResourceData(sourceId int) {
 	var err error
@@ -105,12 +257,21 @@ func UpdateYanxuanSpecialResourceData(sourceId int) {
 			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 := time.Now().Format(utils.FormatDateTime)
 		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 {
@@ -189,3 +350,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_clpt/models"
 	"hongze/hongze_clpt/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
+}

+ 141 - 35
services/es_comprehensive.go

@@ -280,6 +280,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)
 	mapItems := make(map[string]*models.CygxResourceDataNewResp)
 	for _, v := range list {
 		//预处理文章
@@ -309,6 +310,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  、 产品内测:productinterior
 	for _, v := range list {
 		if v.Source == "article" {
@@ -339,8 +341,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)
 		}
 	}
 	detail, e := models.GetConfigByCode("city_img_url")
@@ -475,6 +480,26 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 			mapItems[fmt.Sprint("productinterior", v.ProductInteriorId)].ProductInterior = v
 		}
 	}
+	//处理报告精选
+	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
+		}
+	}
 
 	//处理活动
 	if len(activityIds) > 0 {
@@ -557,6 +582,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 		//listIndustrialResourceIds, _ = HandleIndustryList(listIndustrialResourceIds, user, "Hz")
 		for _, v := range listIndustrialResourceIds {
 			v.Source = 1
+			v.UpdateTime = v.PublishDate
 			mapItems[fmt.Sprint("industrialsourceHz", v.IndustrialManagementId)].IndustrialResource = v
 		}
 	}
@@ -597,6 +623,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 		//listIndustrialResourceIds, _ = HandleIndustryList(listIndustrialResourceIds, user, "Yx")
 		for _, v := range listIndustrialResourceIds {
 			v.Source = 2
+			v.UpdateTime = v.PublishDate
 			mapItems[fmt.Sprint("industrialsourceYx", v.IndustrialManagementId)].IndustrialResource = v
 		}
 	}
@@ -766,6 +793,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 = "" //强制置空,兼容前端优先级
 			mapItems[fmt.Sprint(utils.CYGX_OBJ_YANXUANSPECIAL, v.Id)].YanxuanSpecial = v
 		}
 	}
@@ -773,43 +806,46 @@ 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.IndustrialResource != nil && v.SourceId == vList.SourceId && v.Source == vList.Source {
-				v.IndustrialResource.UpdateTime = strings.Replace(vList.PublishDate, "00:00:00", "", -1)
-			}
+			//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.Source == vList.Source {
+			//	v.IndustrialResource.UpdateTime = strings.Replace(vList.PublishDate, "00:00:00", "", -1)
+			//}
+			//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)
 			}
@@ -823,6 +859,73 @@ 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
+	if totalTitle >= searchTotal {
+		//全部都是标题搜索
+		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 {
+		//全部都是内容搜索
+		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 {
+		//一半标题搜索,一半内容搜索
+		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
+}
+
 // Es研选专栏
 func EsAddYanxuanSpecial(sourceId int) {
 	var err error
@@ -850,6 +953,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 {