zhangchuanxing 4 ヶ月 前
コミット
73b1ec0611

+ 476 - 0
controllers/cygx/gushou_time_line.go

@@ -0,0 +1,476 @@
+package cygx
+
+import (
+	"encoding/json"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"github.com/tealeg/xlsx"
+	"hongze/hz_crm_api/controllers"
+	"hongze/hz_crm_api/models"
+	"hongze/hz_crm_api/models/cygx"
+	"hongze/hz_crm_api/models/system"
+	cygxService "hongze/hz_crm_api/services/cygx"
+	"hongze/hz_crm_api/utils"
+	"os"
+	"path/filepath"
+	"strconv"
+	"time"
+)
+
+// 固收时间线
+type GushouTimeLineController struct {
+	controllers.BaseAuthController
+}
+
+// @Title 新增固收时间线
+// @Description 新增固收时间线接口
+// @Param	request	body cygx.AddGushouTimeLineReq true "type json string"
+// @Success 200 {object} "保存成功"
+// @router /gushouTimeLine/preserveAndPublish [post]
+func (this *GushouTimeLineController) PreserveAndPublish() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req cygx.AddGushouTimeLineReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	publishTime := utils.StrDateToDate(req.PublishTime) //时间字符串格式转时间格式
+	timeLineId := req.TimeLineId
+	link := req.Link
+	articleId, chartId := cygxService.HandleTacticsTimeLinLink(link)
+	item := new(cygx.CygxGushouTimeLine)
+	item.PublishTime = publishTime
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+	item.Content = req.Content
+	item.Link = req.Link
+	item.AdminId = sysUser.AdminId
+	if articleId > 0 {
+		item.ArticleId = articleId
+	}
+	if chartId > 0 {
+		item.ChartId = chartId
+	}
+	if timeLineId == 0 {
+		//新增
+		err = cygx.AddCygxGushouTimeLine(item)
+	} else {
+		//更新
+		item.TimeLineId = timeLineId
+		err = cygx.UpdateCygxGushouTimeLine(item)
+	}
+	if err != nil {
+		br.Msg = "保存失败"
+		br.ErrMsg = "保存失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.IsAddLog = true
+	br.Msg = "操作成功"
+}
+
+// @Title 固收时间线列表
+// @Description 固收时间线列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   Status   query   int  false       "发布状态 ,1未发布,1已发布,传2查询所有"
+// @Success Ret=200 {object} cygx.GetCygxGushouTimeLineResp
+// @router /gushouTimeLine/list [get]
+func (this *GushouTimeLineController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	resp := new(cygx.GetCygxGushouTimeLineResp)
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	status, _ := this.GetInt("Status")
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+	var condition string
+	var pars []interface{}
+	if status == 0 || status == 1 {
+		condition += ` AND art.status = ? `
+		pars = append(pars, status)
+	}
+	total, err := cygx.GetCygxGushouTimeLineCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	condition += "	ORDER BY art.publish_time DESC , art.time_line_id DESC "
+	list, err := cygx.GetCygxGushouTimeLineList(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	var TimeLineIds []int
+	var ArticleIds []int
+	var ChartIds []int
+	for _, v := range list {
+		v.PublishTime = utils.TimeRemoveHms(v.PublishTime)
+		TimeLineIds = append(TimeLineIds, v.TimeLineId)
+		if v.ArticleId > 0 {
+			ArticleIds = append(ArticleIds, v.ArticleId)
+		}
+		if v.ChartId > 0 {
+			ChartIds = append(ChartIds, v.ChartId)
+		}
+	}
+	//获取关联的文章map
+	articleTitleMap := make(map[int]string)
+	if len(ArticleIds) > 0 {
+		articleTitleMap = cygxService.GetArticleTitleMapByid(ArticleIds)
+	}
+
+	chartTitleMap := make(map[int]string)
+	if len(ChartIds) > 0 {
+		chartTitleMap = cygxService.GetChartTitleMapByid(ChartIds)
+	}
+	//获取pv/Uv map
+	mapPv, mapUv := cygxService.GetCygxGushouTimeLineHistoryListMap(TimeLineIds)
+	for _, v := range list {
+		v.Pv = mapPv[v.TimeLineId]
+		v.Uv = mapUv[v.TimeLineId]
+		if v.ArticleId > 0 {
+			v.Title = articleTitleMap[v.ArticleId]
+		}
+		if v.ChartId > 0 {
+			v.Title = chartTitleMap[v.ChartId]
+		}
+	}
+	detail, err := cygx.GetCygxConfigDetailByCode(utils.CYGX_GUSHOU_TIME_LINE_STATUS)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	resp.Status, _ = strconv.Atoi(detail.ConfigValue)
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title  详情
+// @Description 获取详情接口
+// @Param   TimeLineId   query   int  true       "时间线ID"
+// @Success Ret=200 {object} cygx.ActivitySpecialDetail
+// @router /gushouTimeLine/detail [get]
+func (this *GushouTimeLineController) Detail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	AdminUser := this.SysUser
+	if AdminUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	resp := new(cygx.GetCygxGushouTimeLineDetailResp)
+	timeLineId, _ := this.GetInt("TimeLineId")
+	if timeLineId < 1 {
+		br.Msg = "请输入详情ID"
+		return
+	}
+	detail, err := cygx.GetCygxGushouTimeLineDetail(timeLineId)
+	if err != nil {
+		br.Msg = "详情不存在"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	detail.PublishTime = utils.TimeRemoveHms(detail.PublishTime)
+	resp.Detail = detail
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title  删除
+// @Description 获取详情接口
+// @Param	request	body cygx.GushouTimeLineTimeLineIdReq true "type json string"
+// @Success 200 {object} "操作成功"
+// @router /gushouTimeLine/delete [POST]
+func (this *GushouTimeLineController) Delete() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	AdminUser := this.SysUser
+	if AdminUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	var req cygx.GushouTimeLineTimeLineIdReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	timeLineId := req.TimeLineId
+	if timeLineId == 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,id不可为空"
+		return
+	}
+	err = cygx.DeleteCygxGushouTimeLine(timeLineId)
+	if err != nil {
+		br.Msg = "详情不存在"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.IsAddLog = true
+	br.Msg = "删除成功"
+}
+
+// @Title 发布/取消发布报告
+// @Description 发布/取消发布报告接口
+// @Param	request	body cygx.GushouTimeLineTimeLineIdReq true "type json string"
+// @Success 200 Ret=200 发布成功
+// @router /gushouTimeLine/publishAndcancel [post]
+func (this *GushouTimeLineController) PublishReport() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	var req cygx.GushouTimeLineTimeLineIdReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	timeLineId := req.TimeLineId
+	if timeLineId == 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,id不可为空"
+		return
+	}
+	detail, err := cygx.GetCygxGushouTimeLineDetail(timeLineId)
+	if err != nil {
+		br.Msg = "详情不存在"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	var status int
+	if detail.Status == 0 {
+		status = 1
+	} else {
+		status = 0
+	}
+	err = cygx.EditCygxGushouTimeLineStatus(status, timeLineId)
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.IsAddLog = true
+	br.Msg = "操作成功"
+}
+
+// @Title 一键发布/取消发布报告接口
+// @Description 一键发布/取消发布报告
+// @Success 200 Ret=200 取消发布成功
+// @router /gushouTimeLine/all/publishAndcancel [post]
+func (this *GushouTimeLineController) PublishCancleReport() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	detail, err := cygx.GetCygxConfigDetailByCode(utils.CYGX_TACTICS_TIME_LINE_STATUS)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	var status int
+	if detail.ConfigValue == "0" {
+		status = 1
+	} else {
+		status = 0
+	}
+	err = cygx.EditCygxGushouTimeLineStatusAll(status)
+	if err != nil {
+		br.Msg = "修改失败"
+		br.ErrMsg = "修改失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.IsAddLog = true
+	br.Msg = "操作成功"
+}
+
+// @Title  下载PV
+// @Description 下载PV接口
+// @Param   TimeLineId   query   int  true       "时间线ID"
+// @router /gushouTimeLine/PvExport [get]
+func (this *GushouTimeLineController) PvExport() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	AdminUser := this.SysUser
+	if AdminUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	timeLineId, _ := this.GetInt("TimeLineId")
+	if timeLineId < 1 {
+		br.Msg = "请输入详情ID"
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND time_line_id = ? `
+	pars = append(pars, timeLineId)
+	var respList []*cygx.CygxGushouTimeLineHistory
+	//respList := new(cygx.CygxGushouTimeLineHistory)
+	list, err := cygx.GetCygxGushouTimeLineHistoryList(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	//超级管理员和权益管理员、权益研究员可以下载所有客户,销售组长能下载本组客户,销售只能下载本人名下客户
+	resp := new(cygx.CanDownload)
+	adminInfo, errAdmin := system.GetSysUserById(AdminUser.AdminId)
+	if errAdmin != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + errAdmin.Error()
+		return
+	}
+	if adminInfo.Role == "admin" || adminInfo.Role == "researcher" {
+		resp.IsCanDownload = true
+	}
+	//销售查看自己客户,销售组长查看组员
+	if resp.IsCanDownload == false {
+		mapMobile, err := cygxService.GetAdminLookUserMobile(adminInfo)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,销售对应权限,Err:" + err.Error()
+			return
+		}
+		for _, v := range list {
+			if _, ok := mapMobile[v.Mobile]; ok {
+				respList = append(respList, v)
+			}
+		}
+	} else {
+		respList = list
+	}
+
+	//创建excel
+	dir, err := os.Executable()
+	exPath := filepath.Dir(dir)
+	downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
+	xlsxFile := xlsx.NewFile()
+	if err != nil {
+		br.Msg = "生成文件失败"
+		br.ErrMsg = "生成文件失败"
+		return
+	}
+	style := xlsx.NewStyle()
+	alignment := xlsx.Alignment{
+		Horizontal: "center",
+		Vertical:   "center",
+		WrapText:   true,
+	}
+	style.Alignment = alignment
+	style.ApplyAlignment = true
+	sheet, err := xlsxFile.AddSheet("阅读明细")
+	if err != nil {
+		br.Msg = "新增Sheet失败"
+		br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
+		return
+	}
+	rowTitle := sheet.AddRow()
+	cellA := rowTitle.AddCell()
+	cellA.Value = "姓名"
+	cellB := rowTitle.AddCell()
+	cellB.Value = "手机号"
+	cellC := rowTitle.AddCell()
+	cellC.Value = "公司名称"
+	cellD := rowTitle.AddCell()
+	cellD.Value = "所属权益销售"
+	cellE := rowTitle.AddCell()
+	cellE.Value = "点击时间"
+
+	for _, item := range respList {
+		row := sheet.AddRow()
+		cellA := row.AddCell()
+		cellA.Value = item.RealName
+		cellB := row.AddCell()
+		cellB.Value = item.Mobile
+		cellC := row.AddCell()
+		cellC.Value = item.CompanyName
+		cellD := row.AddCell()
+		cellD.Value = item.SellerName
+		cellE := row.AddCell()
+		cellE.Value = item.CreateTime.Format(utils.FormatDateTime)
+	}
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		br.Msg = "保存文件失败"
+		br.ErrMsg = "保存文件失败"
+		return
+	}
+	downloadFileName := time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
+	this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
+	defer func() {
+		os.Remove(downLoadnFilePath)
+	}()
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}

+ 152 - 0
models/cygx/gushou_time_line.go

@@ -0,0 +1,152 @@
+package cygx
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hz_crm_api/utils"
+	"time"
+)
+
+type CygxGushouTimeLine struct {
+	TimeLineId  int       `orm:"column(time_line_id);pk"`
+	PublishTime time.Time `description:"发布日期"`
+	CreateTime  time.Time `description:"创建时间"`
+	ModifyTime  time.Time `description:"更新时间"`
+	Status      int       `description:"0:未发布,1:已发布"`
+	Content     string    `description:"内容"`
+	ArticleId   int       `description:"文章ID"`
+	ChartId     int       `description:"图表ID"`
+	Link        string    `description:"文章或图表链接"`
+	AdminId     int       `description:"管理员ID"`
+}
+
+type AddGushouTimeLineReq struct {
+	TimeLineId  int    `orm:"column(time_line_id);pk"`
+	PublishTime string `description:"发布日期"`
+	Content     string `description:"内容"`
+	Link        string `description:"文章或图表链接"`
+}
+type GushouTimeLineTimeLineIdReq struct {
+	TimeLineId int `description:"ID"`
+}
+
+// 添加
+func AddCygxGushouTimeLine(item *CygxGushouTimeLine) (err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	_, err = o.Insert(item)
+	return
+}
+
+// 修改
+func UpdateCygxGushouTimeLine(item *CygxGushouTimeLine) (err error) {
+	to := orm.NewOrmUsingDB("hz_cygx")
+	updateParams := make(map[string]interface{})
+	updateParams["PublishTime"] = item.PublishTime
+	updateParams["ModifyTime"] = item.ModifyTime
+	updateParams["Content"] = item.Content
+	updateParams["ArticleId"] = item.ArticleId
+	updateParams["ChartId"] = item.ChartId
+	updateParams["Link"] = item.Link
+	ptrStructOrTableName := "cygx_gushou_time_line"
+	whereParam := map[string]interface{}{"time_line_id": item.TimeLineId}
+	qs := to.QueryTable(ptrStructOrTableName)
+	for expr, exprV := range whereParam {
+		qs = qs.Filter(expr, exprV)
+	}
+	_, err = qs.Update(updateParams)
+	return
+}
+
+type GetCygxGushouTimeLineResp struct {
+	Status int                `description:"0:内部可见,1:全部可见"`
+	Paging *paging.PagingItem `description:"分页数据"`
+	List   []*CygxGushouTimeLineResp
+}
+
+type CygxGushouTimeLineResp struct {
+	TimeLineId  int    `description:"ID"`
+	PublishTime string `description:"发布日期"`
+	CreateTime  string `description:"创建时间"`
+	ModifyTime  string `description:"更新时间"`
+	Status      int    `description:"0:未发布,1:已发布"`
+	Content     string `description:"内容"`
+	ArticleId   int    `description:"文章ID"`
+	ChartId     int    `description:"图表ID"`
+	Link        string `description:"文章或图表链接"`
+	Pv          int    `description:"PV"`
+	Uv          int    `description:"UV"`
+	Title       string `description:"标题"`
+}
+
+// 获取数量
+func GetCygxGushouTimeLineCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_gushou_time_line as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrmUsingDB("hz_cygx")
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 列表
+func GetCygxGushouTimeLineList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxGushouTimeLineResp, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT * FROM cygx_gushou_time_line as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+type GetCygxGushouTimeLineDetailResp struct {
+	Detail *CygxGushouTimeLineResp
+}
+
+// 通过ID获取详情
+func GetCygxGushouTimeLineDetail(timeLineId int) (item *CygxGushouTimeLineResp, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT * FROM cygx_gushou_time_line  WHERE time_line_id=? `
+	err = o.Raw(sql, timeLineId).QueryRow(&item)
+	return
+}
+
+// 删除数据
+func DeleteCygxGushouTimeLine(timeLineId int) (err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := ` DELETE FROM cygx_gushou_time_line WHERE time_line_id = ?`
+	_, err = o.Raw(sql, timeLineId).Exec()
+	return
+}
+
+// 修改是否展示
+func EditCygxGushouTimeLineStatus(status, timeLineId int) (err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `UPDATE cygx_gushou_time_line SET status=?, modify_time=NOW()   WHERE time_line_id=? `
+	_, err = o.Raw(sql, status, timeLineId).Exec()
+	return
+}
+
+// 一键修改所有的是否展示
+func EditCygxGushouTimeLineStatusAll(status int) (err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	to, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = to.Rollback()
+		} else {
+			_ = to.Commit()
+		}
+	}()
+	sql := ` UPDATE cygx_config SET  config_value=?   WHERE config_code= ?  `
+	_, err = to.Raw(sql, status, utils.CYGX_GUSHOU_TIME_LINE_STATUS).Exec()
+	if err != nil {
+		return
+	}
+	return
+}

+ 34 - 0
models/cygx/gushou_time_line_history.go

@@ -0,0 +1,34 @@
+package cygx
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"hongze/hz_crm_api/utils"
+	"strconv"
+	"time"
+)
+
+type CygxGushouTimeLineHistory struct {
+	Id          int `orm:"column(id);pk"`
+	TimeLineId  int
+	UserId      int
+	CreateTime  time.Time
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	ModifyTime  time.Time `description:"修改时间"`
+	RealName    string    `description:"用户实际名称"`
+	SellerName  string    `description:"所属销售"`
+}
+
+// 列表
+func GetCygxGushouTimeLineHistoryList(condition string, pars []interface{}) (items []*CygxGushouTimeLineHistory, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT * FROM cygx_gushou_time_line_history as art WHERE 1= 1 `
+	condition += `  AND company_id != ` + strconv.Itoa(utils.HZ_COMPANY_ID) // 过滤弘则来源
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 1 - 0
models/db.go

@@ -485,6 +485,7 @@ func initCygx() {
 		new(cygx.CygxOrder),
 		new(cygx.CygxOrderAction),
 		new(cygx.CygxUserFeedback),
+		new(cygx.CygxGushouTimeLine),
 	)
 }
 

+ 63 - 0
routers/commentsRouter.go

@@ -1519,6 +1519,69 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:GushouTimeLineController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:GushouTimeLineController"],
+        beego.ControllerComments{
+            Method: "PvExport",
+            Router: `/gushouTimeLine/PvExport`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:GushouTimeLineController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:GushouTimeLineController"],
+        beego.ControllerComments{
+            Method: "PublishCancleReport",
+            Router: `/gushouTimeLine/all/publishAndcancel`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:GushouTimeLineController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:GushouTimeLineController"],
+        beego.ControllerComments{
+            Method: "Delete",
+            Router: `/gushouTimeLine/delete`,
+            AllowHTTPMethods: []string{"POST"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:GushouTimeLineController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:GushouTimeLineController"],
+        beego.ControllerComments{
+            Method: "Detail",
+            Router: `/gushouTimeLine/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:GushouTimeLineController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:GushouTimeLineController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/gushouTimeLine/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:GushouTimeLineController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:GushouTimeLineController"],
+        beego.ControllerComments{
+            Method: "PreserveAndPublish",
+            Router: `/gushouTimeLine/preserveAndPublish`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:GushouTimeLineController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:GushouTimeLineController"],
+        beego.ControllerComments{
+            Method: "PublishReport",
+            Router: `/gushouTimeLine/publishAndcancel`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:IndustrialAnalystController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:IndustrialAnalystController"],
         beego.ControllerComments{
             Method: "IndustrialAnalystAdd",

+ 1 - 0
routers/router.go

@@ -164,6 +164,7 @@ func init() {
 				&cygx.OrderController{},
 				&cygx.RaiServeCoAntroller{},
 				&cygx.UserFeedbackController{},
+				&cygx.GushouTimeLineController{},
 			),
 		),
 		web.NSNamespace("/advisory",

+ 33 - 0
services/cygx/tactics_time_line.go

@@ -84,3 +84,36 @@ func GetArticleTitleMapByid(articleIds []int) (mapResp map[int]string) {
 	}
 	return
 }
+
+// 获取固收时间线的阅读数据
+func GetCygxGushouTimeLineHistoryListMap(timeLineIds []int) (mapPv, mapUv map[int]int) {
+	var err error
+	defer func() {
+		if err != nil {
+			go alarm_msg.SendAlarmMsg("获取固收时间线的阅读数据,信息失败,GetCygxGushouTimeLineHistoryListMap Err:"+err.Error(), 3)
+		}
+	}()
+	lentimeLineIds := len(timeLineIds)
+	if lentimeLineIds == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND time_line_id IN (` + utils.GetOrmInReplace(lentimeLineIds) + `)`
+	pars = append(pars, timeLineIds)
+	list, err := cygx.GetCygxGushouTimeLineHistoryList(condition, pars)
+	if err != nil {
+		return
+	}
+	mapPv = make(map[int]int, 0)
+	mapUv = make(map[int]int, 0)
+	mapUvCount := make(map[string]int, 0)
+	for _, v := range list {
+		mapPv[v.TimeLineId]++
+		if _, ok := mapUvCount[fmt.Sprint("UID_", v.UserId, "TimeLineId_", v.TimeLineId)]; !ok {
+			mapUvCount[fmt.Sprint("UID_", v.UserId, "TimeLineId_", v.TimeLineId)] = v.TimeLineId
+			mapUv[v.TimeLineId]++
+		}
+	}
+	return
+}

+ 1 - 0
utils/constants.go

@@ -405,6 +405,7 @@ const (
 	CYGX_LYJH                               string = "路演精华"
 	PERMISSION_ID_UPGRADE                   int    = 100000 //行业权限升级的时候所添加的起步值
 	CYGX_TACTICS_TIME_LINE_STATUS           string = "cygx_tactics_time_line_status"
+	CYGX_GUSHOU_TIME_LINE_STATUS            string = "cygx_gushou_time_line_status"     //固收时间线展示配置
 	CYGX_TAG_HOT_ACTIVITY_ID                string = "cygx_tag_hot_activity_id"         //标签管理自定义的热门活动ID
 	TEMPLATE_MSG_CYGX_ACTIVITY_LIMIT_PEOPLE int    = 1001                               //查研观向修改活动人数限制之后,对于因为人数已满而失败的用户,推送模板消息 1001
 	YI_DONG_ZHENG_TONG_YUN_TOKEN_KEY        string = "YI_DONG_ZHENG_TONG_YUN_TOKEN_KEY" //易董证通云的token,存Redis使用