xingzai преди 2 години
родител
ревизия
3165362a12
променени са 6 файла, в които са добавени 289 реда и са изтрити 0 реда
  1. 232 0
      controllers/report_selection.go
  2. 1 0
      models/db.go
  3. 2 0
      models/report_selection.go
  4. 31 0
      models/report_selection_subject_history.go
  5. 18 0
      routers/commentsRouter.go
  6. 5 0
      routers/router.go

+ 232 - 0
controllers/report_selection.go

@@ -0,0 +1,232 @@
+package controllers
+
+import (
+	"encoding/json"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/services"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+// 报告
+type ReportSelectionController struct {
+	BaseAuthController
+}
+
+// @Title 获取报告精选详情
+// @Description 获取报告精选详情接口
+// @Param   ArticleId   query   int  true       "报告ID"
+// @Param   IsBestNew   query   bool  false       "是否获取最新的一篇报告"
+// @Success 200 {object} models.ReportSelectionLetailResp
+// @router /detail [get]
+func (this *ReportSelectionController) 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")
+	isBestNew, _ := this.GetBool("IsBestNew")
+	if isBestNew {
+		tbdb := "cygx_report_selection"
+		condition := ` AND publish_status = 1  `
+		var pars []interface{}
+		list, err := models.GetReportSelectionListPublic(condition, "1", tbdb, pars, 0, 1)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		for _, v := range list {
+			articleId = v.ArticleId
+		}
+	}
+	if articleId < 1 {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "报告ID错误" + strconv.Itoa(articleId)
+		return
+	}
+	resp := new(models.ReportSelectionLetailResp)
+	//判断用户权限
+	hasPermission, err := services.GetUserhasPermission(user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
+	}
+	detail, err := models.GetCygxReportSelectionInfoById(articleId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
+		return
+	}
+	//未设置全部可见的只能给弘则内部查看
+	if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
+		resp.IsShow = true
+	}
+	fmt.Println(resp.IsShow)
+	resp.HasPermission = hasPermission
+	if hasPermission != 1 || !resp.IsShow {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+	if detail.ReportLink != "" {
+		articleIdLink, _ := services.GetReportLinkToArticleid(detail.ReportLink)
+		detail.CeLueArticleId = articleIdLink
+	}
+	detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
+	existMap := make(map[int]int)
+	var items []*models.ReportSelectionChartPermission
+	var itemsSubject []*models.ReportSelectionChartLogPermission
+	listLog, err := models.GetReportSelectionlogListAll(articleId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
+		return
+	}
+	detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
+	//获取行业核心逻辑汇总
+	listChartLog, err := models.GetCygxReportSelectionChartLogRepList(articleId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	mapChartLog := make(map[string]string)
+	for _, v := range listChartLog {
+		mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
+	}
+	for _, v := range listLog {
+		item := new(models.ReportSelectionChartPermission)
+		itemSubject := new(models.ReportSelectionChartLogPermission)
+		itemSubject.PermissionName = v.PermissionName
+		if existMap[v.ChartPermissionId] == 0 {
+			//item.PermissionName = v.PermissionName + "领域深度报告和调研"
+			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
+					if v2.Label != "" {
+						v2.CompanyLabel = strings.Split(v2.Label, "{|}")
+					}
+				}
+				itemSubject.ListSubject = append(itemSubject.ListSubject, &models.ReportSelectionChartLogSubjectName{SubjectName: v2.SubjectName, IsNew: v2.IsNew, IndustrialSubjectId: v2.IndustrialSubjectId})
+			}
+			item.BodyChartSummary = mapChartLog[v.PermissionName]
+			item.List = listSonLog
+			items = append(items, item)
+			itemsSubject = append(itemsSubject, itemSubject)
+			//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"
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+		return
+	}
+	historyRecord.RealName = user.RealName
+	if sellerItem != nil {
+		historyRecord.SellerName = sellerItem.RealName
+	}
+
+	go models.AddCygxReportHistoryRecord(historyRecord)
+	resp.List = items
+	resp.ListPermissionSubject = itemsSubject
+	resp.Detail = detail
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 标的点击记录
+// @Description 标的点击记录接口
+// @Param	request	body models.AddCygxReportSelectionSubjectHistoryReq true "type json string"
+// @router /click/history [post]
+func (this *ReportSelectionController) ClickHistory() {
+	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 req models.AddCygxReportSelectionSubjectHistoryReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.ArticleId <= 0 {
+		br.Msg = "文章不存在"
+		br.ErrMsg = "文章不存在,文章ID错误"
+		return
+	}
+	if req.IndustrialSubjectId <= 0 {
+		br.Msg = "标的ID不存在"
+		br.ErrMsg = "标的ID不存在,标的ID错误"
+		return
+	}
+	item := models.CygxReportSelectionSubjectHistory{
+		UserId:              user.UserId,
+		ArticleId:           req.ArticleId,
+		CreateTime:          time.Now(),
+		ModifyTime:          time.Now(),
+		Mobile:              user.Mobile,
+		Email:               user.Email,
+		CompanyId:           user.CompanyId,
+		CompanyName:         user.CompanyName,
+		IndustrialSubjectId: req.IndustrialSubjectId,
+	}
+	err = models.AddCygxReportSelectionSubjectHistory(&item)
+	if err != nil {
+		br.Msg = "记录失败"
+		br.ErrMsg = "记录失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "记录成功"
+}

+ 1 - 0
models/db.go

@@ -132,6 +132,7 @@ func init() {
 		new(CygxMinutesSummaryVoiceHistory),
 		new(CygxReportSelectionVoiceHistory),
 		new(CygxXzsChooseCategory),
+		new(CygxReportSelectionSubjectHistory),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 2 - 0
models/report_selection.go

@@ -40,6 +40,7 @@ type DetailCygxReportSelectionRep struct {
 	MarketStrategy     string `description:"市场策略核心逻辑汇总"`
 	ReportLink         string `description:"报告链接"`
 	CeLueArticleId     int    `description:"策略报告详情"`
+	VisibleRange       int    `description:"设置可见范围1全部,0内部"`
 }
 
 type ReportSelectionLetailResp struct {
@@ -47,6 +48,7 @@ type ReportSelectionLetailResp struct {
 	HasPermission         int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
 	List                  []*ReportSelectionChartPermission
 	ListPermissionSubject []*ReportSelectionChartLogPermission `description:"行业列表"`
+	IsShow                bool                                 `description:"是否展示"`
 }
 
 type ReportSelectionChartPermission struct {

+ 31 - 0
models/report_selection_subject_history.go

@@ -0,0 +1,31 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxReportSelectionSubjectHistory struct {
+	Id                  int       `orm:"column(id);pk"`
+	ArticleId           int       `description:"文章ID"`
+	UserId              int       `description:"用户ID"`
+	CreateTime          time.Time `description:"创建时间"`
+	ModifyTime          time.Time `description:"修改时间"`
+	Mobile              string    `description:"手机号"`
+	Email               string    `description:"邮箱"`
+	CompanyId           int       `description:"公司id"`
+	CompanyName         string    `description:"公司名称"`
+	IndustrialSubjectId int       `description:"标的ID"`
+}
+
+type AddCygxReportSelectionSubjectHistoryReq struct {
+	ArticleId           int `description:"文章id"`
+	IndustrialSubjectId int `description:"标的ID"`
+}
+
+// 添加
+func AddCygxReportSelectionSubjectHistory(item *CygxReportSelectionSubjectHistory) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}

+ 18 - 0
routers/commentsRouter.go

@@ -1024,6 +1024,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"],
+        beego.ControllerComments{
+            Method: "ClickHistory",
+            Router: `/click/history`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"],
+        beego.ControllerComments{
+            Method: "Detail",
+            Router: `/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"],
         beego.ControllerComments{
             Method: "ArticleHotList",

+ 5 - 0
routers/router.go

@@ -139,6 +139,11 @@ func init() {
 				&controllers.IndustryController{},
 			),
 		),
+		web.NSNamespace("/report_selection",
+			web.NSInclude(
+				&controllers.ReportSelectionController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }