瀏覽代碼

Merge branch 'cygx_4.1' of hongze/hongze_cygx into master

hongze 3 年之前
父節點
當前提交
b3b22805f1

+ 452 - 0
controllers/article.go

@@ -8,6 +8,7 @@ import (
 
 	"bufio"
 	"io"
+	"io/ioutil"
 
 	//"bufio"
 	"encoding/json"
@@ -276,6 +277,11 @@ Loop:
 	resp.HaveResearch = haveResearch
 	resp.HasFree = hasFree
 	resp.Detail = detail
+	if user.Mobile != "" {
+		resp.Mobile = user.Mobile
+	} else {
+		resp.Mobile = user.Email
+	}
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
@@ -893,3 +899,449 @@ type PublishPdfResult struct {
 	FileOldPath string `json:"file_old_path"`
 	Pdfpath     string `json:"pdfpath"`
 }
+
+// @Title 同步策略报告内容
+// @Description 同步策略报告内容接口
+// @Param   ArticleIdMd5   query   int  true       "报告ID"
+// @Success 200 {object} models.ArticleDetailResp
+// @router /look/listApi [get]
+func (this *ArticleCommonController) ListApi() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	url := "https://vmp.hzinsights.com/v2api/articles/mp?take=20&skip=0&publish_status=1"
+	url = ""
+	method := "GET"
+	client := &nhttp.Client{}
+	req, err := nhttp.NewRequest(method, url, nil)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	req.Header.Add("Authorization", "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkiLCJwaG9uZV9udW1iZXIiOiIxMjM0NTY3ODkiLCJuYW1lIjoi5YW25LuWIiwiZW50cmFuY2UiOiJwYXNzd3dvcmQiLCJpYXQiOjE2MzQ4NzA1OTQsImV4cCI6MTYzNDg3NDE5NH0.tho2L9jsbDPn8ltEGUVDve_nHsh0Kzf6ZrSz0RcZ0ag")
+	res, err := client.Do(req)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	defer res.Body.Close()
+	body, err := ioutil.ReadAll(res.Body)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	var pdfResult models.ArticleResultApi
+	err = json.Unmarshal(body, &pdfResult)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "Unmarshal,Err:" + err.Error()
+		return
+	}
+	exitMap := make(map[int]int)
+	listMap, err := models.GetArticleApiMap()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取映射关系失败,Err:" + err.Error()
+		return
+	}
+	//新旧分类 反向隐射
+	for _, v := range listMap {
+		exitMap[v.Id] = v.OldId
+	}
+	listData := pdfResult.Data
+	var list []*models.Tactics2
+	var listAuthor []*models.CygxArticleAuthor
+	for _, v := range listData {
+		if exitMap[v.SeriesId] > 0 {
+			item := new(models.Tactics2)
+			itemAuthor := new(models.CygxArticleAuthor)
+			item.ArticleId = v.ArticleId
+			item.Title = v.Title
+			item.TitleEn = v.TitleEn
+			if v.Frequency == "日度" {
+				item.UpdateFrequency = "daily"
+			} else if v.Frequency == "周度" {
+				item.UpdateFrequency = "weekly"
+			} else if v.Frequency == "月度" {
+				item.UpdateFrequency = "monthly"
+			} else if v.Frequency == "季度" {
+				item.UpdateFrequency = "quarterly"
+			} else if v.Frequency == "年度" {
+				item.UpdateFrequency = "yearly"
+			} else {
+				item.UpdateFrequency = "unknow"
+			}
+			item.CreateDate = v.CreateDate
+			item.PublishDate = v.PublishDate
+			item.PublishStatus = v.PublishStatus
+			item.Body = v.Content.Body
+			item.Abstract = v.Content.Abstract
+			item.CategoryName = v.Industry.Name
+			item.CategoryId = exitMap[v.SeriesId]
+			item.SubCategoryName = v.Series.Name
+			list = append(list, item)
+			itemAuthor.ArticleId = v.ArticleId
+			itemAuthor.Name = v.Author.Name
+			itemAuthor.Mobile = v.Author.PhoneNumber
+			listAuthor = append(listAuthor, itemAuthor)
+		}
+	}
+
+	//同步作者
+	for _, v := range listAuthor {
+		count, err := models.GetActivityAuthorCount(v.ArticleId, v.Mobile)
+		if err != nil {
+			fmt.Println("GetCount Err:", err.Error())
+			return
+		}
+		if count == 0 {
+			_, err := models.AddCygxActivityAuthor(v)
+			if err != nil {
+				fmt.Println("AddCygxActivityAuthor Err:", err.Error())
+				return
+			}
+		}
+	}
+	fmt.Println("同步文章条数:", len(list))
+	listCustomArticle, err := models.GetCustomArticleId() //手动归类的文章,不替换文章类型
+	if err != nil {
+		fmt.Println("GetTacticsList Err:", err.Error())
+		return
+	}
+	listGetMatchTypeName, errMatch := models.GetMatchTypeNamenNotNull() //手动归类的文章,不替换文章类型
+	if errMatch != nil {
+		fmt.Println("GetTacticsList Err:", errMatch.Error())
+		return
+	}
+
+	fmt.Println("list len:", len(list))
+	summaryCategoryIds := "28,32,45,50,57,62,72,74,79,84,86,88,90,93,95,96" //纪要库的文章类型categoty_id
+	listSummary := strings.Split(summaryCategoryIds, ",")
+	noSummaryArticleIds := "3454,3456,3457,3459,2449,2450,2453,2454,2459,2530,2583,2663,2670,2699,2715,2732,2748,2759,2399,2356,2870,3173,2978,2826,3470" //非纪要库类型的文章ID
+	listNoSummaryArticleIds := strings.Split(noSummaryArticleIds, ",")
+	listPermission, errper := models.GetPermissionMappingCategoryID()
+	if errper != nil {
+		fmt.Println("GetTacticsList Err:", errper.Error())
+		return
+	}
+	summaryMap := make(map[int]int)
+	for _, vSum := range listSummary {
+		vSumInt, _ := strconv.Atoi(vSum)
+		summaryMap[vSumInt] = 1
+	}
+	for k, v := range list {
+		//同步匹配类型
+		matchTypeName := ""
+		for _, vMatch := range listGetMatchTypeName {
+			if v.CategoryId == vMatch.CategoryId {
+				matchTypeName = vMatch.MatchTypeName
+			}
+		}
+		//是否属于纪要库的数据
+		if _, has := summaryMap[v.CategoryId]; has {
+			v.IsSummary = 1
+		}
+		//排除不属于纪要库类型的文章
+		for _, vArt := range listNoSummaryArticleIds {
+			vArtInt, _ := strconv.Atoi(vArt)
+			if v.ArticleId == vArtInt {
+				v.IsSummary = 0
+			}
+		}
+		for _, vPer := range listPermission {
+			if v.CategoryId == vPer.CategoryId {
+				v.IsReport = 1
+			}
+		}
+		if v.IsReport > 0 {
+			//是否属于策略 策略自动归类
+			//是否属于行业报告 行业报告自动归类
+			if v.CategoryId == 7 || v.CategoryId == 9 || v.CategoryId == 11 || v.CategoryId == 51 || v.CategoryId == 52 || v.CategoryId == 64 || v.CategoryId == 80 || v.CategoryId == 87 {
+				v.IsClass = 1
+				v.ReportType = 1 //是否属于行业报告
+			} else {
+				v.ReportType = 2 //是否属于产业报告
+			}
+		}
+		v.Department = "弘则权益研究"
+		fmt.Println(k, v.ArticleId)
+		hh, _ := time.ParseDuration("8h")
+		//pDate := publishDate.Add(hh)
+		v.PublishDate = v.PublishDate.Add(hh)
+		//判断是否已经存在
+		if v.ArticleId < 0 {
+			fmt.Println("AddCygxArticle Err:")
+			return
+		}
+		count, err := models.GetArticleCountById(v.ArticleId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			fmt.Println("AddCygxArticle Err:", err.Error())
+			return
+		}
+		v.Body = strings.Replace(v.Body, "http://vmp.hzinsights.com", "https://vmp.hzinsights.com", -1)
+		expertNumStr, expertContentStr, interviewDateStr, fileLink, bodyReturn := services.BodyAnalysis2(v.Body)
+		if strings.Index(v.Body, "报告全文(") > 0 && strings.Index(v.Body, "PDF格式报告下载.pdf") > 0 {
+			v.Body = strings.Replace(v.Body, "报告全文(", "", -1)
+			v.Body = strings.Replace(v.Body, "PDF格式报告下载.pdf", "", -1)
+			v.Body = strings.Replace(v.Body, "):", "", -1)
+		}
+		var titleNew string
+		titleNew = v.Title
+		// 7资金流向 、11大类资产 、51每日复盘 、80医药周报、9估值研究
+		if v.CategoryId == 7 || v.CategoryId == 11 || v.CategoryId == 51 || v.CategoryId == 9 {
+			if v.UpdateFrequency == "daily" {
+				var daystr string
+				daystr = strconv.Itoa(v.PublishDate.Day())
+				if len(daystr) == 1 {
+					daystr = "0" + daystr
+				}
+				titleNew = v.Title + "(" + strconv.Itoa(v.PublishDate.Year())[2:len(strconv.Itoa(v.PublishDate.Year()))-0] + v.PublishDate.Format("01") + daystr + ")"
+			} else if v.UpdateFrequency == "weekly" {
+				titleNew = v.Title + utils.WeekByDate(v.PublishDate)
+			}
+		}
+		if v.CategoryId == 80 {
+			titleNew = v.Title + utils.WeekByDate(v.PublishDate)
+		}
+		if count > 0 {
+			fmt.Println(k, v.ArticleId, "edit")
+			var isCustom bool
+			bodyText, _ := services.GetReportContentTextSub(v.Body)
+			updateParams := make(map[string]interface{})
+			//updateParams["Title"] = v.Title
+			updateParams["Title"] = titleNew
+			updateParams["TitleEn"] = v.TitleEn
+			updateParams["UpdateFrequency"] = v.UpdateFrequency
+			updateParams["CreateDate"] = v.CreateDate
+			updateParams["PublishDate"] = v.PublishDate
+			//updateParams["Body"] = html.EscapeString(v.Body)
+			updateParams["Body"] = html.EscapeString(bodyReturn)
+			updateParams["BodyText"] = bodyText
+			updateParams["Abstract"] = html.EscapeString(v.Abstract)
+			updateParams["CategoryName"] = v.CategoryName
+
+			for _, vCustom := range listCustomArticle {
+				if v.ArticleId == vCustom.ArticleId {
+					fmt.Println("手动归类的文章:" + strconv.Itoa(v.ArticleId))
+					isCustom = true
+				}
+			}
+			if isCustom == false {
+				updateParams["CategoryId"] = v.CategoryId
+				updateParams["MatchTypeName"] = matchTypeName
+				updateParams["IsSummary"] = v.IsSummary
+				updateParams["IsReport"] = v.IsReport
+				updateParams["ReportType"] = v.ReportType
+				updateParams["SubCategoryName"] = v.SubCategoryName
+			}
+			//updateParams["CategoryId"] = v.CategoryId
+			updateParams["PublishStatus"] = v.PublishStatus
+			updateParams["ExpertBackground"] = expertContentStr
+			updateParams["ExpertNumber"] = expertNumStr
+			updateParams["InterviewDate"] = interviewDateStr
+			//updateParams["IsClass"] = v.IsClass
+
+			if v.Department != "弘则权益研究" {
+				v.Department = "弘则权益研究"
+			}
+			updateParams["Department"] = v.Department
+			updateParams["FileLink"] = fileLink
+			whereParam := map[string]interface{}{"article_id": v.ArticleId}
+			err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
+			if err != nil {
+				fmt.Println("UpdateByExpr Err:" + err.Error())
+			}
+		} else {
+			fmt.Println(k, v.ArticleId, "add")
+			item := new(models.CygxArticle)
+			articleIdInt := v.ArticleId
+			item.ArticleId = articleIdInt
+			//item.Title = v.Title
+			item.Title = titleNew
+			item.TitleEn = v.TitleEn
+			item.UpdateFrequency = v.UpdateFrequency
+			item.CreateDate = v.CreateDate
+			item.PublishDate = v.PublishDate.Format(utils.FormatDateTime)
+			//item.Body = html.EscapeString(v.Body)
+			item.Body = html.EscapeString(bodyReturn)
+			item.Abstract = html.EscapeString(v.Abstract)
+			item.CategoryName = v.CategoryName
+			item.SubCategoryName = v.SubCategoryName
+			item.CategoryId = v.CategoryId
+			item.PublishStatus = v.PublishStatus
+			item.ExpertBackground = expertContentStr
+			item.ExpertNumber = expertNumStr
+			item.InterviewDate = interviewDateStr
+			item.Department = v.Department
+			item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleIdInt))
+			item.IsClass = v.IsClass
+			item.IsSummary = v.IsSummary
+			item.IsReport = v.IsReport
+			item.ReportType = v.ReportType
+			item.FileLink = fileLink
+			item.MatchTypeName = matchTypeName
+			_, err = models.AddCygxArticles(item)
+			if err != nil {
+				fmt.Println("AddCygxArticle Err:", err.Error())
+				return
+			}
+		}
+
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = string(body)
+}
+
+// @Title 同步参会记录
+// @Description 获取报告详情接口
+// @Param   ArticleIdMd5   query   int  true       "报告ID"
+// @Success 200 {object} models.ArticleDetailResp
+// @router /look/detaisl [get]
+func (this *ArticleCommonController) Detaisl() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	var condition string
+	fmt.Println(condition)
+
+	//list, err := models.GetOfflineMeetingDetailList()
+	//if err != nil {
+	//	br.Msg = "获取失败"
+	//	br.ErrMsg = "获取失败,Err:" + err.Error()
+	//	return
+	//}
+	//
+	//for _, v := range list {
+	//	item := new(models.CygxActivityMeetDetailLog)
+	//	item.ActivityId = v.ActivityId
+	//	item.RealName = v.RealName
+	//	item.Mobile = v.Mobile
+	//	item.CompanyName = v.CompanyName
+	//	item.CompanyId = v.CompanyId
+	//	item.CreateTime = v.CreateTime
+	//	newId, err := models.AddCygxActivityMeetDetailLog(item)
+	//	if err != nil {
+	//		br.Msg = "同步失败"
+	//		br.ErrMsg = "新增优化建议失败,Err:" + err.Error()
+	//		return
+	//	}
+	//	fmt.Println(newId)
+	//}
+
+	//list, err := models.GetActivityMeetDetailLog()
+	//if err != nil {
+	//	br.Msg = "获取失败"
+	//	br.ErrMsg = "获取失败,Err:" + err.Error()
+	//	return
+	//}
+	//for _, v := range list {
+	//	condition = ` AND company_name = '` + v.CompanyName + `' `
+	//	total, err := models.GetActivityMeetDetailLogCount(condition)
+	//	if err != nil {
+	//		br.Msg = "获取失败"
+	//		br.ErrMsg = "获取失败,Err:" + err.Error()
+	//		return
+	//	}
+	//	fmt.Println(v.CompanyName, total)
+	//	err = models.UpdateActivityMeetDetailLog(v.CompanyName, total)
+	//	if err != nil {
+	//		br.Msg = "获取失败"
+	//		br.ErrMsg = "获取失败,Err:" + err.Error()
+	//		return
+	//	}
+	//}
+
+	//list, err := models.GetActivityMeetDetailLogByMobile()
+	//if err != nil {
+	//	br.Msg = "获取失败"
+	//	br.ErrMsg = "获取失败,Err:" + err.Error()
+	//	return
+	//}
+	//for _, v := range list {
+	//	condition = ` AND mobile = '` + v.Mobile + `' `
+	//	total, err := models.GetActivityMeetDetailLogCount(condition)
+	//	if err != nil {
+	//		br.Msg = "获取失败"
+	//		br.ErrMsg = "获取失败,Err:" + err.Error()
+	//		return
+	//	}
+	//	fmt.Println(v.Mobile, total)
+	//	err = models.UpdateActivityMeetDetailLogByUser(v.Mobile, total)
+	//	if err != nil {
+	//		br.Msg = "获取失败"
+	//		br.ErrMsg = "获取失败,Err:" + err.Error()
+	//		return
+	//	}
+	//}
+
+	resp := new(models.ArticleDetailResp)
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 同步策略报告分类
+// @Description 同步策略报告内容接口
+// @Param   ArticleIdMd5   query   int  true       "报告ID"
+// @Success 200 {object} models.ArticleDetailResp
+// @router /look/industry [get]
+func (this *ArticleCommonController) Industry() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	url := "https://vmp.hzinsights.com/v2api/articles/industry"
+	method := "GET"
+	client := &nhttp.Client{}
+	req, err := nhttp.NewRequest(method, url, nil)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	req.Header.Add("Authorization", "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkiLCJwaG9uZV9udW1iZXIiOiIxMjM0NTY3ODkiLCJuYW1lIjoi5YW25LuWIiwiZW50cmFuY2UiOiJwYXNzd3dvcmQiLCJpYXQiOjE2MzQ4NzA1OTQsImV4cCI6MTYzNDg3NDE5NH0.tho2L9jsbDPn8ltEGUVDve_nHsh0Kzf6ZrSz0RcZ0ag")
+	res, err := client.Do(req)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	defer res.Body.Close()
+	body, err := ioutil.ReadAll(res.Body)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	var pdfResult models.ArticleIndustryApi
+	err = json.Unmarshal(body, &pdfResult)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "Unmarshal,Err:" + err.Error()
+		return
+	}
+	listData := pdfResult.Data
+	//var list []*models.Tactics2
+	for _, v := range listData {
+		item := new(models.Tactics2)
+		for _, v2 := range v.Series {
+			fmt.Println(v2.Name)
+			item.Body = v2.Name
+			//fmt.Println(v.Name, "+", v2.Name, "+", v2.Id)
+			//fmt.Println(v.Name, "+", v2.Name, "+", v2.Id)
+			//fmt.Println(v.Name, "+", v2.Name, "+", v2.Id)
+		}
+		//list = append(list, item)
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = string(body)
+}

+ 559 - 0
controllers/report.go

@@ -6,6 +6,7 @@ import (
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
+	"html"
 	"rdluck_tools/paging"
 	"strconv"
 	"strings"
@@ -434,6 +435,9 @@ func (this *ReportController) List() {
 		if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
 			list[k].IsRed = true
 		}
+		if v.VideoUrl != "" {
+			list[k].IsHaveVideo = true
+		}
 	}
 	resp.List = list
 	resp.Paging = page
@@ -1109,3 +1113,558 @@ func (this *ReportController) ReportListNew() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 是否展示绝密内参
+// @Description 获取是否展示绝密内参接口
+// @Param	request	body models.IsShow true "type json string"
+// @Success 200
+// @router /isShow [get]
+func (this *ReportController) IsShow() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	var resp models.IsShow
+	mobile := user.Mobile
+	if mobile == "" {
+		br.Ret = 200
+		br.Success = true
+		br.Data = resp
+		return
+	}
+	total, _ := models.GetUserIsAdminCount(mobile)
+	if total > 0 {
+		resp.IsShow = true
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}
+
+// @Title 报告精选、本周研究汇总、上周纪要汇总列表
+// @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   ReportType   string   query     true       "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
+// @Success 200 {object} models.CygxReportSelectionListPublicRep
+// @router /reportList/byType [get]
+func (this *ReportController) ReportListByType() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	reportType := this.GetString("ReportType")
+	var condition string
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+	var pars []interface{}
+	var total int
+	resp := new(models.CygxReportSelectionListPublicRep)
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	var tbdb string
+	var readSql string
+	var reportTypeStr string
+	if reportType == "1" {
+		tbdb = "cygx_report_selection"
+		reportTypeStr = "bgjx"
+	} else if reportType == "2" {
+		tbdb = "cygx_research_summary"
+		reportTypeStr = "bzyjhz"
+	} else if reportType == "3" {
+		tbdb = "cygx_minutes_summary"
+		reportTypeStr = "szjyhz"
+	} else {
+		br.Msg = "请选择报告类型"
+		return
+	}
+	fmt.Println(tbdb)
+	condition = ` AND publish_status = 1`
+	total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
+		return
+	}
+	readSql = ` (SELECT COUNT(1) AS  count  FROM cygx_report_history_record AS h WHERE h.article_id = art.article_id AND  report_type ='` + reportTypeStr + `' AND h.user_id = ` + strconv.Itoa(uid) + `) as read_num`
+	page = paging.GetPaging(currentIndex, pageSize, total)
+	list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	for k, v := range list {
+		if reportType == "1" {
+			list[k].Abstract = v.UpdateDescription
+		}
+		list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
+		if v.ReadNum == 0 {
+			list[k].IsRed = true
+		}
+	}
+
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 获取报告精选详情
+// @Description 获取报告精选详情接口
+// @Param   ArticleId   query   int  true       "报告ID"
+// @Success 200 {object} models.ReportSelectionLetailResp
+// @router /reportSelection/detail [get]
+func (this *ReportController) Detail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	articleId, _ := this.GetInt("ArticleId")
+	if articleId < 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误"
+		return
+	}
+	resp := new(models.ReportSelectionLetailResp)
+	//判断用户权限
+	hasPermission, err := services.GetUserhasPermission(user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
+	}
+	resp.HasPermission = hasPermission
+	if hasPermission != 1 {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+	detail, err := models.GetCygxReportSelectionInfoById(articleId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
+		return
+	}
+	detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
+	existMap := make(map[int]int)
+	var items []*models.ReportSelectionChartPermission
+	listLog, err := models.GetReportSelectionlogListAll(articleId)
+	detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
+		return
+	}
+	//var itemLogs []*models.CygxReportSelectionLogDetail
+	for _, v := range listLog {
+		item := new(models.ReportSelectionChartPermission)
+		if existMap[v.ChartPermissionId] == 0 {
+			item.PermissionName = v.PermissionName + "领域深度调研和报告"
+			item.IcoLink = v.IcoLink
+			listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取信息失败,Err:" + err.Error()
+				return
+			}
+			for k2, v2 := range listSonLog {
+				if v2.IndustrialManagementId != "" {
+					listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						br.Msg = "获取信息失败"
+						br.ErrMsg = "获取信息失败,Err:" + err.Error()
+						return
+					}
+					listSonLog[k2].List = listIndustrial
+				}
+			}
+			item.List = listSonLog
+			items = append(items, item)
+			//itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
+		}
+		existMap[v.ChartPermissionId] = v.ChartPermissionId
+	}
+	historyRecord := new(models.CygxReportHistoryRecord)
+	historyRecord.UserId = uid
+	historyRecord.ArticleId = articleId
+	historyRecord.CreateTime = time.Now()
+	historyRecord.Mobile = user.Mobile
+	historyRecord.Email = user.Email
+	historyRecord.CompanyId = user.CompanyId
+	historyRecord.CompanyName = user.CompanyName
+	historyRecord.ReportType = "bgjx"
+	go models.AddCygxReportHistoryRecord(historyRecord)
+	resp.List = items
+	resp.Detail = detail
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 获取本周研究汇总详情
+// @Description 获取本周研究汇总详情接口
+// @Param   ArticleId   query   int  true       "报告ID"
+// @Success 200 {object} models.ResearchSummaryLetailResp
+// @router /researchSummary/detail [get]
+func (this *ReportController) ResearchDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	articleId, _ := this.GetInt("ArticleId")
+	if articleId < 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误"
+		return
+	}
+	resp := new(models.ResearchSummaryLetailResp)
+	//判断用户权限
+	hasPermission, err := services.GetUserhasPermission(user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
+	}
+	resp.HasPermission = hasPermission
+	if hasPermission != 1 {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+	detail, err := models.GetCygxResearchSummaryInfoById(articleId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
+		return
+	}
+	detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
+	detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
+	listFirst, err := models.GetResearchSummarylogListFirst(articleId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range listFirst {
+		listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		for k2, v2 := range listSecond {
+			listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取信息失败,Err:" + err.Error()
+				return
+			}
+			if len(listThird) > 0 {
+				listSecond[k2].List = listThird
+				for k3, v3 := range listThird {
+					if v3.VideoUrl != "" {
+						listThird[k3].IsHaveVideo = true
+					}
+					if v3.ReportLink == "0" {
+						listThird[k3].ReportLink = ""
+					}
+				}
+			}
+		}
+		if len(listSecond) > 0 {
+			listFirst[k].List = listSecond
+		}
+		//`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
+		if v.Type == "SDBG" {
+			listFirst[k].ListName = "深度报告"
+			listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
+		} else if v.Type == "BZCHJH" {
+			listFirst[k].ListName = "本周晨会精华"
+			listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
+		} else if v.Type == "CYDYJY" {
+			listFirst[k].ListName = "产业调研纪要"
+			listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
+		} else {
+			listFirst[k].ListName = "事件点评"
+			listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
+		}
+
+	}
+	historyRecord := new(models.CygxReportHistoryRecord)
+	historyRecord.UserId = uid
+	historyRecord.ArticleId = articleId
+	historyRecord.CreateTime = time.Now()
+	historyRecord.Mobile = user.Mobile
+	historyRecord.Email = user.Email
+	historyRecord.CompanyId = user.CompanyId
+	historyRecord.CompanyName = user.CompanyName
+	historyRecord.ReportType = "bzyjhz"
+	go models.AddCygxReportHistoryRecord(historyRecord)
+	resp.List = listFirst
+	resp.Detail = detail
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 上周纪要汇总内容详情
+// @Description 获取上周纪要汇总内容详情接口
+// @Param   ArticleId   query   int  true       "报告ID"
+// @Success 200 {object} models.MinutesSummaryLetailResp
+// @router /minutesSummary/detail [get]
+func (this *ReportController) MinutesDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	articleId, _ := this.GetInt("ArticleId")
+	if articleId < 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误"
+		return
+	}
+	resp := new(models.MinutesSummaryLetailResp)
+	//判断用户权限
+	hasPermission, err := services.GetUserhasPermission(user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
+	}
+	resp.HasPermission = hasPermission
+	if hasPermission != 1 {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+	detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
+		return
+	}
+	detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
+	detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
+	listLog, err := models.GetMinutesSummarylogListAll(articleId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range listLog {
+		listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		if len(listSonLog) > 0 {
+			listLog[k].List = listSonLog
+			for k2, v2 := range listSonLog {
+				if v2.ReportLink == "0" {
+					listSonLog[k2].ReportLink = ""
+				}
+			}
+		}
+	}
+	historyRecord := new(models.CygxReportHistoryRecord)
+	historyRecord.UserId = uid
+	historyRecord.ArticleId = articleId
+	historyRecord.CreateTime = time.Now()
+	historyRecord.Mobile = user.Mobile
+	historyRecord.Email = user.Email
+	historyRecord.CompanyId = user.CompanyId
+	historyRecord.CompanyName = user.CompanyName
+	historyRecord.ReportType = "szjyhz"
+	go models.AddCygxReportHistoryRecord(historyRecord)
+	resp.List = listLog
+	resp.Detail = detail
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 获取路演精华详情
+// @Description 获取路演精华详情接口
+// @Param   ArticleId   query   int  true       "报告ID"
+// @Success 200 {object} models.RoadshowDetailResp
+// @router /roadshowEssence/detail [get]
+func (this *ReportController) RoadshowDetail() {
+	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
+	}
+	uid := user.UserId
+	articleId, err := this.GetInt("ArticleId")
+	if articleId <= 0 {
+		br.Msg = "文章不存在"
+		br.ErrMsg = "文章不存在,文章ID错误"
+		return
+	}
+	detail := new(models.ReportDetailRoadshow)
+	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.GetReportRoadshowDetailById(articleId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		detail.Body = html.UnescapeString(detail.Body)
+		detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
+		detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
+		detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
+		if detail.ReportLink == "0" {
+			detail.ReportLink = ""
+		}
+		if companyPermission == "" {
+			if applyCount > 0 {
+				hasPermission = 5
+			} else {
+				hasPermission = 2
+			}
+			hasFree = 2
+			goto Loop
+		} else {
+			hasFree = 1
+			var articlePermissionPermissionName string
+			articlePermissionPermissionName = detail.CategoryName
+			var hasPersion bool
+			slice := strings.Split(articlePermissionPermissionName, ",")
+			for _, v := range slice {
+				if strings.Contains(companyPermission, v) {
+					hasPersion = true
+				}
+			}
+			if hasPersion {
+				hasPermission = 1
+				historyRecord := new(models.CygxArticleHistoryRecord)
+				historyRecord.UserId = uid
+				historyRecord.ArticleId = articleId
+				historyRecord.CreateTime = time.Now()
+				historyRecord.Mobile = user.Mobile
+				historyRecord.Email = user.Email
+				historyRecord.CompanyId = user.CompanyId
+				historyRecord.CompanyName = user.CompanyName
+				go models.AddCygxArticleHistoryRecord(historyRecord)
+			} else { //无该行业权限
+				hasPermission = 3
+			}
+			if hasPermission == 1 {
+				key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
+				if !utils.Rc.IsExist(key) {
+					//新增浏览记录
+					record := new(models.CygxArticleViewRecord)
+					record.UserId = uid
+					record.ArticleId = articleId
+					record.CreateTime = time.Now()
+					record.Mobile = user.Mobile
+					record.Email = user.Email
+					record.CompanyId = user.CompanyId
+					record.CompanyName = user.CompanyName
+					go models.AddCygxArticleViewRecord(record)
+					utils.Rc.Put(key, 1, 5*time.Second)
+					models.ModifyReportLastViewTime(uid)
+				}
+			}
+		}
+	} else { //潜在客户
+		if applyCount > 0 {
+			hasPermission = 5
+		} else {
+			hasPermission = 4
+		}
+	}
+Loop:
+	if hasPermission != 1 {
+		detail.Body = ""
+		detail.Abstract = ""
+	}
+	resp := new(models.RoadshowDetailResp)
+	resp.HasPermission = hasPermission
+	resp.HasFree = hasFree
+	resp.Detail = detail
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 4 - 0
models/activity.go

@@ -92,6 +92,10 @@ type ActivityDetail struct {
 	CustomerTypeIds         string `description:"活动可见的客户类型,多个ID用 , 隔开"`
 	IsShowSustainable       bool   `description:"是否展示限免标签"`
 	Description             string `description:"研选内容说明"`
+	IsResearch              bool   `description:"是否属于研选"`
+	LinkParticipants        string `description:"链接参会"`
+	AppAttendance           string `description:"App参会"`
+	ConferencePassword      string `description:"会议密码"`
 }
 
 type CygxActivityResp struct {

+ 72 - 0
models/activity_meet_detail_log.go

@@ -0,0 +1,72 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+	"time"
+)
+
+//报名
+type CygxActivityMeetDetailLog struct {
+	AttendanceId int       `orm:"column(attendance_id);pk;"description:"主键ID"`
+	ActivityId   int       `description:"活动ID"`
+	RealName     string    `description:"姓名"`
+	Mobile       string    `description:"手机号"`
+	CompanyName  string    `description:"公司名称"`
+	CompanyId    int       `description:"公司id 不在数据库的用户为0"`
+	CreateTime   time.Time `description:"创建时间"`
+}
+
+func GetOfflineMeetingDetailList() (item []*CygxActivityMeetDetailLog, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_offline_meeting_detail WHERE is_meeting = 1`
+	_, err = o.Raw(sql).QueryRows(&item)
+	return
+}
+
+//添加优化建议
+func AddCygxActivityMeetDetailLog(item *CygxActivityMeetDetailLog) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+func GetActivityMeetDetailLog() (item []*CygxActivityMeetDetailLog, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM  cygx_activity_meet_detail_log WHERE company_name !='' GROUP BY company_name `
+	_, err = o.Raw(sql).QueryRows(&item)
+	return
+}
+
+func GetActivityMeetDetailLogByMobile() (item []*CygxActivityMeetDetailLog, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM  cygx_activity_meet_detail_log WHERE mobile !='' GROUP BY mobile `
+	_, err = o.Raw(sql).QueryRows(&item)
+	return
+}
+
+//获取数量
+func GetActivityMeetDetailLogCount(condition string) (count int, err error) {
+	o := orm.NewOrm()
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_activity_meet_detail_log WHERE 1=1 `
+	if condition != "" {
+		sqlCount += condition
+	}
+	err = o.Raw(sqlCount).QueryRow(&count)
+	return
+}
+
+//修改公司参会数量
+func UpdateActivityMeetDetailLog(companyName string, num int) (err error) {
+	sql := ` UPDATE cygx_activity_meet_detail_log SET  company_meet_num= ?  WHERE company_name = ?`
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, num, companyName).Exec()
+	return
+}
+
+//修改个人参会数量
+func UpdateActivityMeetDetailLogByUser(mobile string, num int) (err error) {
+	sql := ` UPDATE cygx_activity_meet_detail_log SET  user_meet_num= ?  WHERE mobile = ?`
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, num, mobile).Exec()
+	return
+}

+ 140 - 4
models/article.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"rdluck_tools/orm"
+	"time"
 )
 
 type CygxArticle struct {
@@ -30,6 +31,16 @@ type CygxArticle struct {
 	ReportType       int    `description:"报告类型,1行业报告,2产业报告,0无"`
 	FileLink         string `description:"下载预览链接"`
 	MatchTypeName    string `description:"匹配类型"`
+
+	Periods          string `description:"期数"`
+	ReportLink       string `description:"报告链接"`
+	ArticleType      string `description:"文章类型 文章类型,lyjh:路演精华 "`
+	HavePublish      int    `description:"是否发布过,1是 ,0 否"`
+	Source           int    `description:"来源 0策略平台同步,1小程序后台添加"`
+	SellerAndMobile  string `description:"销售和手机号"`
+	VideoUrl         string `description:"音频文件URL"`
+	VideoName        string `description:"音频文件名称"`
+	VideoPlaySeconds string `description:"音频播放时长"`
 }
 
 type CygxArticleEs struct {
@@ -146,9 +157,16 @@ func GetSellerList(articleId int) (items []*SellerRep, err error) {
 		ac.phone_number as  seller_mobile,
 		ac.name as  seller_name
 		FROM
-		article_author AS au 
+		article_author AS au
 		INNER JOIN account_client as ac ON au.author_id = ac.phone_number
 		WHERE article_id = ?`
+
+	//sql := `SELECT
+	//	au.mobile as  seller_mobile,
+	//	au.name as  seller_name
+	//	FROM
+	//	cygx_article_author AS au
+	//	WHERE article_id = ?`
 	_, err = o.Raw(sql, articleId).QueryRows(&items)
 	return
 }
@@ -192,9 +210,10 @@ func GetArticlePermission(companyId int) (item *ChartPermission, err error) {
 
 type ArticleDetailResp struct {
 	Detail        *ArticleDetail
-	HasPermission int  `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
-	HasFree       int  `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
-	HaveResearch  bool `description:"是否有研选权限"`
+	HasPermission int    `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	HasFree       int    `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
+	HaveResearch  bool   `description:"是否有研选权限"`
+	Mobile        string `description:"用户手机号"`
 }
 
 func ModifyArticleExpert(articleId int, expertNumStr, expertContentStr, interviewDateStr, bodyText string) (err error) {
@@ -336,6 +355,8 @@ type ReportArticle struct {
 	ExpertBackground string `description:"专家背景"`
 	IsRed            bool   `description:"是否标记红点"`
 	Readnum          int    `description:"阅读数量"`
+	VideoUrl         string `description:"链接"`
+	IsHaveVideo      bool   `description:"是否含有音频文件"`
 }
 
 func GetReportPermission(categoryName string) (item []*ChartPermission, err error) {
@@ -419,3 +440,118 @@ WHERE
 	err = o.Raw(sql, uid, uid, articleId).QueryRow(&item)
 	return
 }
+
+//日度点评的数据同步
+type ReportDetail struct {
+	Id                 int    `orm:"column(id)" description:"报告Id"`
+	AddType            int    `description:"新增方式:1:新增报告,2:继承报告"`
+	ClassifyIdFirst    int    `description:"一级分类id"`
+	ClassifyNameFirst  string `description:"一级分类名称"`
+	ClassifyIdSecond   int    `description:"二级分类id"`
+	ClassifyNameSecond string `description:"二级分类名称"`
+	Title              string `description:"标题"`
+	Abstract           string `description:"摘要"`
+	Author             string `description:"作者"`
+	Frequency          string `description:"频度"`
+	CreateTime         string `description:"创建时间"`
+	ModifyTime         string `description:"修改时间"`
+	State              int    `description:"1:未发布,2:已发布"`
+	PublishTime        string `description:"发布时间"`
+	Stage              int    `description:"期数"`
+	MsgIsSend          int    `description:"消息是否已发送,0:否,1:是"`
+	Content            string `description:"内容"`
+	VideoUrl           string `description:"音频文件URL"`
+	VideoName          string `description:"音频文件名称"`
+	VideoPlaySeconds   string `description:"音频播放时长"`
+	ContentSub         string `description:"内容前两个章节"`
+}
+
+func GetReportList() (items []*ReportDetail, err error) {
+	o := orm.NewOrm()
+	o.Using("rddp")
+	sql := `SELECT * FROM report WHERE  classify_id_second = '57'`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+func GetMaxArticleIdInfo() (item *ArticleDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article   ORDER BY article_id desc  LIMIT 1`
+	err = o.Raw(sql).QueryRow(&item)
+	return
+}
+
+type ArticleResultApi struct {
+	Data []ArticleResultApidate `json:"data"`
+	Code int                    `json:"code"`
+	Msg  string                 `json:"msg"`
+}
+
+type ArticleResultApidate struct {
+	ArticleId     int                      `json:"id"`
+	Title         string                   `json:"title"`
+	TitleEn       string                   `json:"title_en"`
+	Frequency     string                   `json:"frequency"`
+	CreateDate    string                   `json:"create_date"`
+	UpdateDate    string                   `json:"update_date"`
+	PublishDate   time.Time                `json:"publish_date"`
+	PublishStatus int                      `json:"publish_status"`
+	IndustrId     int                      `json:"industry_id"`
+	SeriesId      int                      `json:"series_id"`
+	Series        ArticleSeries            `json:"series"`
+	Content       ArticleResultApiContent  `json:"content"`
+	Author        ArticleResultApiAuthor   `json:"author"`
+	Industry      ArticleResultApiIndustry `json:"industry"`
+	Type          ArticleResultApiType     `json:"type"`
+}
+
+type ArticleSeries struct {
+	Name string `json:"name"`
+}
+type ArticleResultApiContent struct {
+	ArticleId int    `json:"id"`
+	Body      string `json:"body"`
+	Abstract  string `json:"abstract"`
+}
+
+type ArticleResultApiAuthor struct {
+	PhoneNumber string `json:"phone_number"`
+	Name        string `json:"name"`
+}
+
+type ArticleResultApiIndustry struct {
+	Name string `json:"name"`
+}
+
+type ArticleResultApiType struct {
+	Name string `json:"name"`
+}
+
+type ArticleIndustryApi struct {
+	Data []ArticleResultApiIndustrdate `json:"data"`
+	Code int                           `json:"code"`
+	Msg  string                        `json:"msg"`
+}
+
+type ArticleResultApiIndustrdate struct {
+	Id     int                          `json:"id"`
+	Name   string                       `json:"name"`
+	Series []ArticleResultApiSeriesdate `json:"series"`
+}
+
+type ArticleResultApiSeriesdate struct {
+	Id   int    `json:"id"`
+	Name string `json:"name"`
+}
+
+type ArticleApiMap struct {
+	Id    int `description:"新ID"`
+	OldId int `description:"旧Id"`
+}
+
+func GetArticleApiMap() (item []*ArticleApiMap, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT *  FROM	cygx_article_api_map WHERE	old_id > 0  AND is_update = 1 ORDER BY old_id ASC  `
+	_, err = o.Raw(sql).QueryRows(&item)
+	return
+}

+ 27 - 0
models/article_author.go

@@ -0,0 +1,27 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+)
+
+type CygxArticleAuthor struct {
+	Id        int    `orm:"column(id);pk;"description:"主键ID"`
+	ArticleId int    `description:"文章ID"`
+	Mobile    string `description:"手机号"`
+	Name      string `description:"姓名"`
+}
+
+//获取数量
+func GetActivityAuthorCount(articcleId int, mobile string) (count int, err error) {
+	o := orm.NewOrm()
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_author WHERE article_id=? AND mobile = ? `
+	err = o.Raw(sqlCount, articcleId, mobile).QueryRow(&count)
+	return
+}
+
+//添加优化建议
+func AddCygxActivityAuthor(item *CygxArticleAuthor) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}

+ 3 - 0
models/db.go

@@ -61,5 +61,8 @@ func init() {
 		new(CygxArticleDepartmentFollow),
 		new(CygxArticleAsk),
 		new(CygxPageHistoryRecord),
+		new(CygxReportHistoryRecord),
+		new(CygxActivityMeetDetailLog),
+		new(CygxArticleAuthor),
 	)
 }

+ 78 - 0
models/minutesSummary.go

@@ -0,0 +1,78 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+)
+
+type DetailCygxMinutesSummaryRep struct {
+	ArticleId        int    `description:"报告Id"`
+	Title            string `description:"标题"`
+	Department       string `description:"作者"`
+	PublishDate      string `description:"发布时间"`
+	VideoUrl         string `description:"链接"`
+	VideoPlaySeconds string `description:"时长"`
+	VideoName        string `description:"音频名称"`
+	Abstract         string `description:"摘要"`
+}
+
+type MinutesSummaryLetailResp struct {
+	Detail        *DetailCygxMinutesSummaryRep
+	HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	List          []*MinutesSummaryChartPermission
+}
+
+type MinutesSummaryChartPermission struct {
+	PermissionName    string `description:"行业名称"`
+	ChartPermissionId int    `description:"行业ID"`
+	IcoLink           string `orm:"column(image_url)"description:"图标链接"`
+	List              []*CygxMinutesSummaryLogDetail
+}
+
+type CygxMinutesSummaryLogDetail struct {
+	Body        string `description:"内容"`
+	ReportLink  string `orm:"column(link_article_id)"description:"报告链接"`
+	VideoUrl    string `description:"链接"`
+	IsHaveVideo bool   `description:"是否含有音频文件"`
+}
+type IndustriaMinutesSummary struct {
+	IndustrialManagementId int    `description:"产业Id"`
+	IndustryName           string `description:"产业名称"`
+}
+
+type MinutesSummaryId struct {
+	ArticleId int `description:"报告I"`
+}
+
+//通过纪要ID获取详情
+func GetCygxMinutesSummaryInfoById(articleId int) (item *DetailCygxMinutesSummaryRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_minutes_summary  WHERE article_id=? AND publish_status = 1 `
+	err = o.Raw(sql, articleId).QueryRow(&item)
+	return
+}
+
+//列表
+func GetMinutesSummarylogListAll(articleId int) (items []*MinutesSummaryChartPermission, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT c.permission_name ,c.image_url,l.*
+			FROM
+			cygx_minutes_summary_log AS l
+			INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 
+			WHERE l.article_id = ? 
+			GROUP BY l.chart_permission_id
+			ORDER BY l.chart_permission_sort ASC   `
+	_, err = o.Raw(sql, articleId).QueryRows(&items)
+	return
+}
+
+//列表
+func GetMinutesSummarylogSonListAll(articleId, chartPermissionId int) (items []*CygxMinutesSummaryLogDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT   l.link_article_id,l.body ,a.video_url 
+			FROM
+			cygx_minutes_summary_log AS l
+			LEFT JOIN cygx_article as a ON a.article_id = l.link_article_id
+			WHERE l.article_id = ? AND l.chart_permission_id =?`
+	_, err = o.Raw(sql, articleId, chartPermissionId).QueryRows(&items)
+	return
+}

+ 42 - 0
models/report.go

@@ -210,3 +210,45 @@ func GetWhichDepartmentCount(condition string) (count int, err error) {
 	err = o.Raw(sql).QueryRow(&count)
 	return
 }
+
+type IsShow struct {
+	IsShow bool `description:"是否展示"`
+}
+
+//获取用户是否有查看权限
+func GetUserIsAdminCount(mobile string) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) count  FROM admin 
+			WHERE
+ 			mobile = ?
+			AND (group_id IN (11, 13, 14, 15, 16, 17) OR department_id = 3 )   AND  enabled = 1`
+	err = o.Raw(sql, mobile).QueryRow(&count)
+	return
+}
+
+type ReportDetailRoadshow struct {
+	ArticleId        int    `description:"报告Id"`
+	Title            string `description:"标题"`
+	Department       string `orm:"column(seller_and_mobile)"description:"作者"`
+	PublishDate      string `description:"发布时间"`
+	VideoUrl         string `description:"链接"`
+	VideoPlaySeconds string `description:"时长"`
+	VideoName        string `description:"音频名称"`
+	Abstract         string `description:"摘要"`
+	Body             string `description:"内容"`
+	CategoryName     string `description:"行业名称"`
+	ReportLink       string `orm:"column(link_article_id)"description:"报告链接"`
+}
+
+type RoadshowDetailResp struct {
+	Detail        *ReportDetailRoadshow
+	HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	HasFree       int `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
+}
+
+func GetReportRoadshowDetailById(articleId int) (item *ReportDetailRoadshow, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article WHERE article_id = ? AND publish_status = 1  `
+	err = o.Raw(sql, articleId).QueryRow(&item)
+	return
+}

+ 3 - 22
models/report_history_record.go

@@ -1,7 +1,6 @@
 package models
 
 import (
-	"hongze/hongze_cygx/utils"
 	"rdluck_tools/orm"
 	"time"
 )
@@ -16,31 +15,13 @@ type CygxReportHistoryRecord struct {
 	CompanyId   int       `description:"公司id"`
 	CompanyName string    `description:"公司名称"`
 	ModifyTime  time.Time `description:"修改时间"`
+	ReportType  string    `description:"报告类型,bgjx:报告精选、bzyjhz:本周研究汇总、szjyhz:上周纪要汇总"`
 }
 
 //添加历史信息
 func AddCygxReportHistoryRecord(item *CygxReportHistoryRecord) (lastId int64, err error) {
 	o := orm.NewOrm()
-	o.Begin()
-	defer func() {
-		if err == nil {
-			o.Commit()
-		} else {
-			o.Rollback()
-		}
-	}()
-	var count int
-	sql := `SELECT COUNT(1) AS count FROM cygx_article_history_record WHERE user_id=? AND article_id=? `
-	err = o.Raw(sql, item.UserId, item.ArticleId).QueryRow(&count)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		return
-	}
-	if count > 0 {
-		sql := `UPDATE cygx_article_history_record SET modify_time=NOW() WHERE user_id=? AND article_id=? `
-		_, err = o.Raw(sql, item.UserId, item.ArticleId).Exec()
-	} else {
-		item.ModifyTime = time.Now()
-		lastId, err = o.Insert(item)
-	}
+	item.ModifyTime = time.Now()
+	lastId, err = o.Insert(item)
 	return
 }

+ 144 - 0
models/report_selection.go

@@ -0,0 +1,144 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+	"rdluck_tools/paging"
+	"time"
+)
+
+type CygxReportSelectionRep struct {
+	ArticleId         int    `orm:"column(article_id);pk"description:"报告id"`
+	Title             string `description:"标题"`
+	Department        string `description:"作者"`
+	PublishDate       string `description:"发布时间"`
+	CreateTime        string `description:"创建时间"`
+	Abstract          string `description:"摘要/更新说明"`
+	UpdateDescription string `description:"更新说明"`
+	IsRed             bool   `description:"是否标记红点"`
+	ReadNum           int    `description:"阅读次数"`
+}
+
+type CygxReportSelectionListPublicRep struct {
+	Paging *paging.PagingItem `description:"分页数据"`
+	List   []*CygxReportSelectionRep
+}
+
+type DetailCygxReportSelectionRep struct {
+	ArticleId          int    `description:"报告Id"`
+	Title              string `description:"标题"`
+	Department         string `description:"作者"`
+	PublishDate        string `description:"发布时间"`
+	CreateTime         string `description:"创建时间"`
+	LastUpdatedTime    string `description:"最后一次更新时间"`
+	Periods            string `description:"期数"`
+	VideoUrl           string `description:"链接"`
+	VideoPlaySeconds   string `description:"时长"`
+	VideoName          string `description:"音频名称"`
+	ProductDescription string `description:"产品说明"`
+	UpdateDescription  string `description:"更新说明"`
+	FocusOn            string `description:"近期重点关注方向"`
+}
+
+type ReportSelectionLetailResp struct {
+	Detail        *DetailCygxReportSelectionRep
+	HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	List          []*ReportSelectionChartPermission
+}
+
+type ReportSelectionChartPermission struct {
+	PermissionName string `description:"权限名称"`
+	IcoLink        string `orm:"column(image_url)"description:"图标链接"`
+	List           []*CygxReportSelectionLogDetail
+}
+
+type CygxReportSelectionLogDetail struct {
+	IndustrialManagementId string `description:"产业Id"`
+	SubjectName            string `description:"标的名称"`
+	Body                   string `description:"内容"`
+	List                   []*IndustriaReportSelection
+}
+type IndustriaReportSelection struct {
+	IndustrialManagementId int    `description:"产业Id"`
+	IndustryName           string `description:"产业名称"`
+}
+
+type ReportSelectionId struct {
+	ArticleId int `description:"报告I"`
+}
+
+//获取数量
+func GetCygxReportSelectionPublic(condition, tbdb string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1   `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+//通过纪要ID获取活动详情
+func GetCygxReportSelectionInfoById(articleId int) (item *DetailCygxReportSelectionRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_selection  WHERE article_id=? AND publish_status = 1 `
+	err = o.Raw(sql, articleId).QueryRow(&item)
+	return
+}
+
+//列表
+func GetReportSelectionListPublic(condition, readSql, tbdb string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * ,` + readSql + ` FROM  ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY  art.publish_date  DESC  LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+type CygxReportSelectionLog struct {
+	ArticleSunId           int       `description:"子级报告id"`
+	ArticleId              int       `description:"父级报告Id"`
+	ChartPermissionId      int       `description:"行业ID"`
+	PermissionName         string    `description:"行业ID"`
+	CreateTime             time.Time `description:"创建时间"`
+	Body                   string    `description:"内容"`
+	IndustrialSubjectId    string    `description:"标的ID"`
+	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
+	SubjectName            string    `description:"标的名称"`
+	IcoLink                string    `orm:"column(image_url)"description:"图标链接"`
+}
+
+//列表
+func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLog, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT c.permission_name ,c.image_url,s.subject_name , l.* 
+			FROM
+			cygx_report_selection_log AS l
+			INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 
+			INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id 
+			WHERE l.article_id = ? `
+	_, err = o.Raw(sql, articleId).QueryRows(&items)
+	return
+}
+
+//列表
+func GetReportSelectionlogSonListAll(articleId, chartPermissionId int) (items []*CygxReportSelectionLogDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT c.permission_name ,s.subject_name , l.* 
+			FROM
+			cygx_report_selection_log AS l
+			INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 
+			INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id 
+			WHERE l.article_id = ? AND l.chart_permission_id =?`
+	_, err = o.Raw(sql, articleId, chartPermissionId).QueryRows(&items)
+	return
+}
+
+func GetIndustrialByIds(industrialManagementIds string) (items []*IndustriaReportSelection, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_industrial_management  WHERE industrial_management_id IN (` + industrialManagementIds + `)`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 111 - 0
models/researchSummary.go

@@ -0,0 +1,111 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+	"time"
+)
+
+type DetailCygxResearchSummaryRep struct {
+	ArticleId        int    `description:"报告Id"`
+	Title            string `description:"标题"`
+	Department       string `description:"作者"`
+	PublishDate      string `description:"发布时间"`
+	VideoUrl         string `description:"链接"`
+	VideoPlaySeconds string `description:"时长"`
+	VideoName        string `description:"音频名称"`
+	Abstract         string `description:"摘要"`
+}
+
+type ResearchSummaryLetailResp struct {
+	Detail        *DetailCygxResearchSummaryRep
+	HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	List          []*ResearchSummaryChartPermission
+}
+
+type ResearchSummaryChartPermission struct {
+	ListName string `description:"列表名称"`
+	IcoLink  string `orm:"column(image_url)"description:"图标链接"`
+	Type     string `description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
+	List     []*CygxResearchSummaryLogSecond
+}
+
+type CygxResearchSummaryLogSecond struct {
+	PermissionName    string `description:"行业名称"`
+	ChartPermissionId int    `description:"行业ID"`
+	IcoLink           string `orm:"column(image_url)"description:"图标链接"`
+	List              []*CygxResearchSummaryLogThird
+}
+
+type CygxResearchSummaryLogThird struct {
+	Body        string `description:"内容"`
+	ReportLink  string `orm:"column(link_article_id)"description:"报告链接"`
+	VideoUrl    string `description:"链接"`
+	IsHaveVideo bool   `description:"是否含有音频文件"`
+}
+type IndustriaResearchSummary struct {
+	IndustrialManagementId int    `description:"产业Id"`
+	IndustryName           string `description:"产业名称"`
+}
+
+type ResearchSummaryId struct {
+	ArticleId int `description:"报告I"`
+}
+
+//通过纪要ID获取详情
+func GetCygxResearchSummaryInfoById(articleId int) (item *DetailCygxResearchSummaryRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_research_summary  WHERE article_id=?  AND publish_status = 1 `
+	err = o.Raw(sql, articleId).QueryRow(&item)
+	return
+}
+
+type CygxResearchSummaryLog struct {
+	ArticleSunId           int       `description:"子级报告id"`
+	ArticleId              int       `description:"父级报告Id"`
+	ChartPermissionId      int       `description:"行业ID"`
+	PermissionName         string    `description:"行业ID"`
+	CreateTime             time.Time `description:"创建时间"`
+	Body                   string    `description:"内容"`
+	IndustrialSubjectId    string    `description:"标的ID"`
+	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
+	SubjectName            string    `description:"标的名称"`
+	Type                   string    `description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
+}
+
+//列表
+func GetResearchSummarylogListFirst(articleId int) (items []*ResearchSummaryChartPermission, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT l.* 
+			FROM cygx_research_summary_log AS l 
+			WHERE l.article_id = ? 
+			GROUP BY l.type 
+			ORDER BY l.sort ASC`
+	_, err = o.Raw(sql, articleId).QueryRows(&items)
+	return
+}
+
+//列表
+func GetResearchSummarylogSonListSecond(articleId int, artType string) (items []*CygxResearchSummaryLogSecond, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT c.permission_name ,c.chart_permission_id ,c.image_url, l.* 
+			FROM
+			cygx_research_summary_log AS l
+			LEFT JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 
+			WHERE l.article_id = ? AND l.type =?
+			GROUP BY l.chart_permission_id
+			ORDER  BY l.chart_permission_sort ASC`
+	_, err = o.Raw(sql, articleId, artType).QueryRows(&items)
+	return
+}
+
+//列表
+func GetResearchSummarylogSonListThird(articleId, chartPermissionId int, artType string) (items []*CygxResearchSummaryLogThird, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT  l.link_article_id,l.body ,a.video_url
+			FROM cygx_research_summary_log AS l
+			LEFT JOIN cygx_article as a ON a.article_id = l.link_article_id
+			WHERE l.article_id = ? AND l.type =? AND  l.chart_permission_id = ? 
+			ORDER  BY l.chart_permission_sort ASC `
+	_, err = o.Raw(sql, articleId, artType, chartPermissionId).QueryRows(&items)
+	return
+}

+ 2 - 2
services/activity.go

@@ -490,7 +490,7 @@ func SendEmailFileForAskMsgResearch(cont context.Context) (err error) {
 		content := "活动带问详情"
 		fileName := downLoadnFilePath
 		if utils.WxMsgTemplateIdAskMsgMobile == "" {
-			touser = "cxzhang@hzinsights.com;ywang@hzinsights.com"
+			touser = "cxzhang@hzinsights.com;ywang@hzinsights.com;tshen@hzinsights.com"
 		} else {
 			touser = "cxzhang@hzinsights.com;jhwang@hzinsights.com;tshen@hzinsights.com"
 		}
@@ -564,7 +564,7 @@ func SendEmailFileForAskMsg(cont context.Context) (err error) {
 			}
 		}
 		if touser != "" {
-			touser = strings.TrimRight(touser, ";")
+			touser += "tshen@hzinsights.com;cxzhang@hzinsights.com"
 		} else {
 			fmt.Println("没有对应的邮箱")
 			return

+ 288 - 0
services/article.go

@@ -1,11 +1,18 @@
 package services
 
 import (
+	"context"
+	"encoding/json"
 	"fmt"
 	"github.com/PuerkitoBio/goquery"
 	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
 	"html"
+	"io/ioutil"
+	nhttp "net/http"
+	"strconv"
 	"strings"
+	"time"
 )
 
 func GetReportContentSub(content string) (contentSub string, err error) {
@@ -265,3 +272,284 @@ func FixArticleContent(articleId int) {
 		return
 	}
 }
+
+func GetArticleListByApi(cont context.Context) (err error) {
+	url := "https://vmp.hzinsights.com/v2api/articles/mp?take=100&skip=0&publish_status=1"
+	method := "GET"
+	client := &nhttp.Client{}
+	req, err := nhttp.NewRequest(method, url, nil)
+	if err != nil {
+		fmt.Println("GetListApi Err:", err.Error())
+		return
+	}
+	req.Header.Add("Authorization", "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkiLCJwaG9uZV9udW1iZXIiOiIxMjM0NTY3ODkiLCJuYW1lIjoi5YW25LuWIiwiZW50cmFuY2UiOiJwYXNzd3dvcmQiLCJpYXQiOjE2MzQ4NzA1OTQsImV4cCI6MTYzNDg3NDE5NH0.tho2L9jsbDPn8ltEGUVDve_nHsh0Kzf6ZrSz0RcZ0ag")
+	res, err := client.Do(req)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	defer res.Body.Close()
+	body, err := ioutil.ReadAll(res.Body)
+	if err != nil {
+		fmt.Println("Getres.Body Err:", err.Error())
+		return
+	}
+	var pdfResult models.ArticleResultApi
+	err = json.Unmarshal(body, &pdfResult)
+	if err != nil {
+		fmt.Println("Getres.pdfResult Err:", err.Error())
+		return
+	}
+	exitMap := make(map[int]int)
+	listMap, err := models.GetArticleApiMap()
+	if err != nil {
+		fmt.Println("GetlistMap Err:", err.Error())
+		return
+	}
+	//新旧分类 反向隐射
+	for _, v := range listMap {
+		exitMap[v.Id] = v.OldId
+	}
+	listData := pdfResult.Data
+	var list []*models.Tactics2
+	var listAuthor []*models.CygxArticleAuthor
+	for _, v := range listData {
+		if exitMap[v.SeriesId] > 0 {
+			item := new(models.Tactics2)
+			itemAuthor := new(models.CygxArticleAuthor)
+			item.ArticleId = v.ArticleId
+			item.Title = v.Title
+			item.TitleEn = v.TitleEn
+			if v.Frequency == "日度" {
+				item.UpdateFrequency = "daily"
+			} else if v.Frequency == "周度" {
+				item.UpdateFrequency = "weekly"
+			} else if v.Frequency == "月度" {
+				item.UpdateFrequency = "monthly"
+			} else if v.Frequency == "季度" {
+				item.UpdateFrequency = "quarterly"
+			} else if v.Frequency == "年度" {
+				item.UpdateFrequency = "yearly"
+			} else {
+				item.UpdateFrequency = "unknow"
+			}
+			item.CreateDate = v.CreateDate
+			item.PublishDate = v.PublishDate
+			item.PublishStatus = v.PublishStatus
+			item.Body = v.Content.Body
+			item.Abstract = v.Content.Abstract
+			item.CategoryName = v.Industry.Name
+			item.CategoryId = exitMap[v.SeriesId]
+			item.SubCategoryName = v.Series.Name
+			list = append(list, item)
+			itemAuthor.ArticleId = v.ArticleId
+			itemAuthor.Name = v.Author.Name
+			itemAuthor.Mobile = v.Author.PhoneNumber
+			listAuthor = append(listAuthor, itemAuthor)
+		}
+	}
+
+	//同步作者
+	for _, v := range listAuthor {
+		var count int
+		count, err = models.GetActivityAuthorCount(v.ArticleId, v.Mobile)
+		if err != nil {
+			fmt.Println("GetCount Err:", err.Error())
+			return
+		}
+		if count == 0 {
+			_, err = models.AddCygxActivityAuthor(v)
+			if err != nil {
+				fmt.Println("AddCygxActivityAuthor Err:", err.Error())
+				return
+			}
+		}
+	}
+	fmt.Println("同步文章条数:", len(list))
+	listCustomArticle, err := models.GetCustomArticleId() //手动归类的文章,不替换文章类型
+	if err != nil {
+		fmt.Println("GetTacticsList Err:", err.Error())
+		return
+	}
+	listGetMatchTypeName, errMatch := models.GetMatchTypeNamenNotNull() //手动归类的文章,不替换文章类型
+	if errMatch != nil {
+		fmt.Println("GetTacticsList Err:", errMatch.Error())
+		return
+	}
+
+	fmt.Println("list len:", len(list))
+	summaryCategoryIds := "28,32,45,50,57,62,72,74,79,84,86,88,90,93,95,96" //纪要库的文章类型categoty_id
+	listSummary := strings.Split(summaryCategoryIds, ",")
+	noSummaryArticleIds := "3454,3456,3457,3459,2449,2450,2453,2454,2459,2530,2583,2663,2670,2699,2715,2732,2748,2759,2399,2356,2870,3173,2978,2826,3470" //非纪要库类型的文章ID
+	listNoSummaryArticleIds := strings.Split(noSummaryArticleIds, ",")
+	listPermission, errper := models.GetPermissionMappingCategoryID()
+	if errper != nil {
+		fmt.Println("GetTacticsList Err:", errper.Error())
+		return
+	}
+	summaryMap := make(map[int]int)
+	for _, vSum := range listSummary {
+		vSumInt, _ := strconv.Atoi(vSum)
+		summaryMap[vSumInt] = 1
+	}
+	for k, v := range list {
+		//同步匹配类型
+		matchTypeName := ""
+		for _, vMatch := range listGetMatchTypeName {
+			if v.CategoryId == vMatch.CategoryId {
+				matchTypeName = vMatch.MatchTypeName
+			}
+		}
+		//是否属于纪要库的数据
+		if _, has := summaryMap[v.CategoryId]; has {
+			v.IsSummary = 1
+		}
+		//排除不属于纪要库类型的文章
+		for _, vArt := range listNoSummaryArticleIds {
+			vArtInt, _ := strconv.Atoi(vArt)
+			if v.ArticleId == vArtInt {
+				v.IsSummary = 0
+			}
+		}
+		for _, vPer := range listPermission {
+			if v.CategoryId == vPer.CategoryId {
+				v.IsReport = 1
+			}
+		}
+		if v.IsReport > 0 {
+			//是否属于策略 策略自动归类
+			//是否属于行业报告 行业报告自动归类
+			if v.CategoryId == 7 || v.CategoryId == 9 || v.CategoryId == 11 || v.CategoryId == 51 || v.CategoryId == 52 || v.CategoryId == 64 || v.CategoryId == 80 || v.CategoryId == 87 {
+				v.IsClass = 1
+				v.ReportType = 1 //是否属于行业报告
+			} else {
+				v.ReportType = 2 //是否属于产业报告
+			}
+		}
+		v.Department = "弘则权益研究"
+		fmt.Println(k, v.ArticleId)
+		hh, _ := time.ParseDuration("8h")
+		//pDate := publishDate.Add(hh)
+		v.PublishDate = v.PublishDate.Add(hh)
+		//判断是否已经存在
+		if v.ArticleId < 0 {
+			fmt.Println("AddCygxArticle Err:")
+			return
+		}
+		var count int
+		count, err = models.GetArticleCountById(v.ArticleId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			fmt.Println("AddCygxArticle Err:", err.Error())
+			return
+		}
+		v.Body = strings.Replace(v.Body, "http://vmp.hzinsights.com", "https://vmp.hzinsights.com", -1)
+		expertNumStr, expertContentStr, interviewDateStr, fileLink, bodyReturn := BodyAnalysis2(v.Body)
+		if strings.Index(v.Body, "报告全文(") > 0 && strings.Index(v.Body, "PDF格式报告下载.pdf") > 0 {
+			v.Body = strings.Replace(v.Body, "报告全文(", "", -1)
+			v.Body = strings.Replace(v.Body, "PDF格式报告下载.pdf", "", -1)
+			v.Body = strings.Replace(v.Body, "):", "", -1)
+		}
+		var titleNew string
+		titleNew = v.Title
+		// 7资金流向 、11大类资产 、51每日复盘 、80医药周报、9估值研究
+		if v.CategoryId == 7 || v.CategoryId == 11 || v.CategoryId == 51 || v.CategoryId == 9 {
+			if v.UpdateFrequency == "daily" {
+				var daystr string
+				daystr = strconv.Itoa(v.PublishDate.Day())
+				if len(daystr) == 1 {
+					daystr = "0" + daystr
+				}
+				titleNew = v.Title + "(" + strconv.Itoa(v.PublishDate.Year())[2:len(strconv.Itoa(v.PublishDate.Year()))-0] + v.PublishDate.Format("01") + daystr + ")"
+			} else if v.UpdateFrequency == "weekly" {
+				titleNew = v.Title + utils.WeekByDate(v.PublishDate)
+			}
+		}
+		if v.CategoryId == 80 {
+			titleNew = v.Title + utils.WeekByDate(v.PublishDate)
+		}
+		if count > 0 {
+			fmt.Println(k, v.ArticleId, "edit")
+			var isCustom bool
+			bodyText, _ := GetReportContentTextSub(v.Body)
+			updateParams := make(map[string]interface{})
+			//updateParams["Title"] = v.Title
+			updateParams["Title"] = titleNew
+			updateParams["TitleEn"] = v.TitleEn
+			updateParams["UpdateFrequency"] = v.UpdateFrequency
+			updateParams["CreateDate"] = v.CreateDate
+			updateParams["PublishDate"] = v.PublishDate
+			//updateParams["Body"] = html.EscapeString(v.Body)
+			updateParams["Body"] = html.EscapeString(bodyReturn)
+			updateParams["BodyText"] = bodyText
+			updateParams["Abstract"] = html.EscapeString(v.Abstract)
+			updateParams["CategoryName"] = v.CategoryName
+
+			for _, vCustom := range listCustomArticle {
+				if v.ArticleId == vCustom.ArticleId {
+					fmt.Println("手动归类的文章:" + strconv.Itoa(v.ArticleId))
+					isCustom = true
+				}
+			}
+			if isCustom == false {
+				updateParams["CategoryId"] = v.CategoryId
+				updateParams["MatchTypeName"] = matchTypeName
+				updateParams["IsSummary"] = v.IsSummary
+				updateParams["IsReport"] = v.IsReport
+				updateParams["ReportType"] = v.ReportType
+				updateParams["SubCategoryName"] = v.SubCategoryName
+			}
+			//updateParams["CategoryId"] = v.CategoryId
+			updateParams["PublishStatus"] = v.PublishStatus
+			updateParams["ExpertBackground"] = expertContentStr
+			updateParams["ExpertNumber"] = expertNumStr
+			updateParams["InterviewDate"] = interviewDateStr
+			//updateParams["IsClass"] = v.IsClass
+
+			if v.Department != "弘则权益研究" {
+				v.Department = "弘则权益研究"
+			}
+			updateParams["Department"] = v.Department
+			updateParams["FileLink"] = fileLink
+			whereParam := map[string]interface{}{"article_id": v.ArticleId}
+			err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
+			if err != nil {
+				fmt.Println("UpdateByExpr Err:" + err.Error())
+			}
+		} else {
+			fmt.Println(k, v.ArticleId, "add")
+			item := new(models.CygxArticle)
+			articleIdInt := v.ArticleId
+			item.ArticleId = articleIdInt
+			//item.Title = v.Title
+			item.Title = titleNew
+			item.TitleEn = v.TitleEn
+			item.UpdateFrequency = v.UpdateFrequency
+			item.CreateDate = v.CreateDate
+			item.PublishDate = v.PublishDate.Format(utils.FormatDateTime)
+			//item.Body = html.EscapeString(v.Body)
+			item.Body = html.EscapeString(bodyReturn)
+			item.Abstract = html.EscapeString(v.Abstract)
+			item.CategoryName = v.CategoryName
+			item.SubCategoryName = v.SubCategoryName
+			item.CategoryId = v.CategoryId
+			item.PublishStatus = v.PublishStatus
+			item.ExpertBackground = expertContentStr
+			item.ExpertNumber = expertNumStr
+			item.InterviewDate = interviewDateStr
+			item.Department = v.Department
+			item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleIdInt))
+			item.IsClass = v.IsClass
+			item.IsSummary = v.IsSummary
+			item.IsReport = v.IsReport
+			item.ReportType = v.ReportType
+			item.FileLink = fileLink
+			item.MatchTypeName = matchTypeName
+			_, err = models.AddCygxArticles(item)
+			if err != nil {
+				fmt.Println("AddCygxArticle Err:", err.Error())
+				return
+			}
+		}
+	}
+	return
+}

+ 2 - 0
services/tactics.go

@@ -662,6 +662,8 @@ func BodyAnalysis2(body string) (expertNumStr, expertContentStr, interviewDateSt
 		if expertNumStr != "" {
 			expertNumStr = strings.Replace(expertNumStr, "#:", "", -1)
 			expertNumStr = strings.Replace(expertNumStr, "# ", "", -1)
+			expertNumStr = strings.Replace(expertNumStr, " ", "", -1)
+			expertNumStr = strings.Replace(expertNumStr, "\n", "", -1)
 			expertNumStr = strings.Trim(expertNumStr, "")
 		}
 	}

+ 60 - 10
services/task.go

@@ -18,9 +18,12 @@ func Task() {
 	if utils.RunMode == "release" {
 		syncTacticsListAddreport := task.NewTask("syncTacticsListAddreport", "0 */5 * * * *", SyncTacticsListAddreport) //同步文章
 		task.AddTask("syncTacticsListAddreport", syncTacticsListAddreport)
-		//同步纪要库中的Es
+
 		getSummarytoEs := task.NewTask("getSummarytoEs", "0 */30 * * * *", GetSummarytoEs) //同步纪要库内容到Es
 		task.AddTask("getSummarytoEs", getSummarytoEs)
+	} else {
+		getArticleListByApi := task.NewTask("getArticleListByApi", "0 */5 * * * *", GetArticleListByApi) //通过三方接口获取策略平台上的文章
+		task.AddTask("getArticleListByApi", getArticleListByApi)
 	}
 	//修改任务状态
 	updateActivitySattus := task.NewTask("syncTacticsListAddreport", "0 */1 8-22 * * *", UpdateActivitySattus)
@@ -45,10 +48,6 @@ func Task() {
 	sendEmailFileForAskMsg := task.NewTask("sendEmailFileForAskMsg", "0 */5 8-22 * * *", SendEmailFileForAskMsg) //非研选系列专家电话会,根据主持人姓名,会前15分钟将问题列表发送给至该主持人对应邮箱
 	task.AddTask("sendEmailFileForAskMsg", sendEmailFileForAskMsg)
 
-	////白名单发送
-	//sendEmailUserWhiteList := task.NewTask("sendEmailUserWhiteList", "0 27 17 * * *", SendEmailUserWhiteList) //白名单发送
-	//task.AddTask("sendEmailUserWhiteList", sendEmailUserWhiteList)
-
 	//白名单发送2
 	sendEmailUserWhiteListChange := task.NewTask("sendEmailUserWhiteListChange", "0 00 17 * * *", SendEmailUserWhiteListChange) //新增 和冻结的客户白名单
 	task.AddTask("sendEmailUserWhiteListChange", sendEmailUserWhiteListChange)
@@ -57,16 +56,22 @@ func Task() {
 	chageIndustrialArticleNum := task.NewTask("chageIndustrialArticleNum", "0 01 00 * * *", ChageIndustrialArticleNum) //更改对应产业的文章阅读数量
 	task.AddTask("chageIndustrialArticleNum", chageIndustrialArticleNum)
 
-	//editOutboundMobile := task.NewTask("editOutboundMobile", "0 */1 8-22 * * *", EditOutboundMobile) //同步外呼号码与手机号
-	//task.AddTask("sendEmailFileToExpert", editOutboundMobile)
-	//editUserOutboundMobile := task.NewTask("editUserOutboundMobile", "0 27 14 * * *   ", EditUserOutboundMobile) //同步外呼号码与手机号
-	//task.AddTask("editUserOutboundMobile", editUserOutboundMobile)
-
 	//IndustrialArticleNum()
+
+	//GetAddpArticle() //同步日度点评数据
 	task.StartTask()
 	fmt.Println("end")
 }
 
+////白名单发送
+//sendEmailUserWhiteList := task.NewTask("sendEmailUserWhiteList", "0 27 17 * * *", SendEmailUserWhiteList) //白名单发送
+//task.AddTask("sendEmailUserWhiteList", sendEmailUserWhiteList)
+
+//editOutboundMobile := task.NewTask("editOutboundMobile", "0 */1 8-22 * * *", EditOutboundMobile) //同步外呼号码与手机号
+//task.AddTask("sendEmailFileToExpert", editOutboundMobile)
+//editUserOutboundMobile := task.NewTask("editUserOutboundMobile", "0 27 14 * * *   ", EditUserOutboundMobile) //同步外呼号码与手机号
+//task.AddTask("editUserOutboundMobile", editUserOutboundMobile)
+
 func ElasticOption() {
 	//SyncTacticsList()
 	//toolbox.StartTask()
@@ -359,3 +364,48 @@ type ElasticTestArticleDetailV4 struct {
 	IsSummary   int    `description:"是否属于纪要库"`
 	IsReport    int    `description:"是否属于报告"`
 }
+
+func GetAddpArticle() {
+	list, err := models.GetReportList()
+	for _, v := range list {
+		var articleId int
+		maxArticleIdArticleInfo, errMax := models.GetMaxArticleIdInfo()
+		if errMax != nil {
+			fmt.Println(errMax)
+			return
+		}
+		articleId = maxArticleIdArticleInfo.ArticleId + 1
+		item := new(models.CygxArticle)
+		item.Title = v.Title
+		item.ArticleId = articleId
+		item.SellerAndMobile = v.Author
+		item.PublishDate = v.PublishTime
+		item.Abstract = v.Abstract
+		item.Body = html.UnescapeString(v.Content)
+		item.BodyText, _ = GetReportContentTextSub(v.Content)
+		item.IsReport = 1
+		item.Source = 1
+		item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleId))
+		item.Department = "弘则产品组"
+		item.ArticleType = "lyjh"
+		item.IsClass = 1
+		item.CreateDate = v.CreateTime
+		item.UpdateFrequency = "unknow"
+
+		item.CategoryId = 100 // 100是路演精华对应ID
+		item.SubCategoryName = "路演精华"
+		item.HavePublish = 1
+		item.PublishStatus = 1
+		item.Periods = strconv.Itoa(v.Stage)
+		item.VideoUrl = v.VideoUrl
+		item.VideoName = v.VideoName
+		item.VideoPlaySeconds = v.VideoPlaySeconds
+		newId, _ := models.AddCygxArticles(item)
+		fmt.Println(articleId)
+		fmt.Println(newId)
+		fmt.Println(item.ArticleIdMd5)
+	}
+	fmt.Println(err)
+	fmt.Println(list)
+
+}

+ 35 - 0
services/user.go

@@ -10,6 +10,7 @@ import (
 	"os"
 	"path/filepath"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -928,3 +929,37 @@ func SendEmailUserWhiteListChange(cont context.Context) (err error) {
 	fmt.Println("发送附件完成", len(listFrozen))
 	return
 }
+
+//获取用户权限
+func GetUserhasPermission(user *models.WxUserItem) (hasPermission int, err error) {
+	//判断是否已经申请过
+	applyCount, err := models.GetApplyRecordCount(user.UserId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	if applyCount > 0 {
+		hasPermission = 3
+	} else {
+		hasPermission = 4
+	}
+	//HasPermission int  `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	if user.CompanyId > 1 {
+		companyPermission, errPer := models.GetCompanyPermission(user.CompanyId)
+		if errPer != nil {
+			err = errPer
+			return
+		}
+		if companyPermission == "" {
+			if applyCount > 0 {
+				hasPermission = 3
+			} else {
+				hasPermission = 4
+			}
+		} else {
+			if strings.Contains(companyPermission, "医药") || strings.Contains(companyPermission, "科技") || strings.Contains(companyPermission, "消费") || strings.Contains(companyPermission, "智造") {
+				hasPermission = 1
+			}
+		}
+	}
+	return
+}

+ 19 - 0
utils/common.go

@@ -601,3 +601,22 @@ func WeekByDate(t time.Time) string {
 	resultSAtr = "(" + strconv.Itoa(t.Year()) + "年第" + strconv.Itoa(week) + "周" + ")"
 	return resultSAtr
 }
+
+func Mp3Time(videoPlaySeconds string) string {
+	var d int
+	var timeStr string
+	a, _ := strconv.ParseFloat(videoPlaySeconds, 32)
+	b := int(a)
+	c := b % 60
+	d = b / 60
+	if b <= 60 {
+		timeStr = "00:" + strconv.Itoa(b)
+	} else {
+		if d < 10 {
+			timeStr = "0" + strconv.Itoa(d) + ":" + strconv.Itoa(c)
+		} else {
+			timeStr = strconv.Itoa(d) + ":" + strconv.Itoa(c)
+		}
+	}
+	return timeStr
+}