Browse Source

Merge branch 'master' of http://8.136.199.33:3000/cxzhang/hongze_clpt into cygx4.2_web

xingzai 1 year ago
parent
commit
1e510eb658

+ 14 - 0
controllers/report.go

@@ -55,6 +55,20 @@ func (this *MobileReportController) TradeList() {
 		listTrade, errTrade := models.GetReportMappingStrategyHomeAllByCygx(user.UserId, ChartPermissionId)
 		list = listTrade
 		err = errTrade
+		if ChartPermissionId == utils.CE_LUE_ID {
+			cf, err := models.GetConfigByCode(utils.CYGX_TACTICS_TIME_LINE_STATUS)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取数据失败,Err:" + err.Error()
+				return
+			}
+			if cf.ConfigValue == "1" || user.CompanyId == utils.HZ_COMPANY_ID {
+				item := new(models.TradeReportMapping)
+				item.CategoryId = utils.TIME_LINE_ID
+				item.MatchTypeName = utils.TIME_LINE_NAME
+				list = append(list, item)
+			}
+		}
 
 		if user.Mobile != "" {
 			//策略的处理

+ 139 - 0
controllers/tactics.go

@@ -0,0 +1,139 @@
+package controllers
+
+import (
+	"encoding/json"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+	"time"
+)
+
+type MobileTacticsController struct {
+	BaseAuthMobileController
+}
+
+// @Title 时间线列表
+// @Description 时间线列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success 200 {object} models.GetCygxTacticsTimeLineResp
+// @router /tacticsTimeLine/list [get]
+func (this *MobileTacticsController) TacticsTimeLineList() {
+	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
+	}
+	resp := new(models.GetCygxTacticsTimeLineResp)
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	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{}
+	condition += ` AND art.status = 1 `
+	total, err := models.GetCygxTacticsTimeLineCount(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 := models.GetCygxTacticsTimeLineList(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	for _, v := range list {
+		v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
+	}
+	if len(list) == 0 {
+		list = make([]*models.CygxTacticsTimeLineResp, 0)
+	}
+	cf, err := models.GetConfigByCode(utils.CYGX_TACTICS_TIME_LINE_STATUS)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	//如果不是弘则用户,并且设置了内部可见,那么数据就隐藏
+	if user.CompanyId != utils.HZ_COMPANY_ID && cf.ConfigValue != "1" {
+		list = make([]*models.CygxTacticsTimeLineResp, 0)
+	}
+	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	request	body models.TacticsTimeLineTimeLineIdReq true "type json string"
+// @Success Ret=200 新增成功
+// @router /tacticsTimeLine/history [post]
+func (this *MobileTacticsController) History() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	var req models.TacticsTimeLineTimeLineIdReq
+	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 = "时间线ID错误"
+		return
+	}
+	var sellerName string
+	sellerName, err = models.GetCompanySellerName(user.CompanyId)
+	if err != nil {
+		br.Msg = "报名失败!"
+		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		return
+	}
+	item := models.CygxTacticsTimeLineHistory{
+		TimeLineId:  timeLineId,
+		UserId:      user.UserId,
+		Mobile:      user.Mobile,
+		Email:       user.Email,
+		CompanyId:   user.CompanyId,
+		CompanyName: user.CompanyName,
+		RealName:    user.RealName,
+		SellerName:  sellerName,
+		CreateTime:  time.Now(),
+		ModifyTime:  time.Now(),
+	}
+	err = models.AddCygxTacticsTimeLineHistory(&item)
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}

+ 1 - 0
models/db.go

@@ -67,6 +67,7 @@ func init() {
 		new(CygxResearchSummaryVoiceHistory),
 		new(CygxProductInteriorHistory),
 		new(CygxAboutUsVideoHistory),
+		new(CygxTacticsTimeLineHistory),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 80 - 0
models/tactics_time_line.go

@@ -0,0 +1,80 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+type CygxTacticsTimeLine 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 AddTacticsTimeLineReq struct {
+	TimeLineId  int    `orm:"column(time_line_id);pk"`
+	PublishTime string `description:"发布日期"`
+	Content     string `description:"内容"`
+	Link        string `description:"文章或图表链接"`
+}
+type TacticsTimeLineTimeLineIdReq struct {
+	TimeLineId int `description:"ID"`
+}
+
+type GetCygxTacticsTimeLineResp struct {
+	Paging *paging.PagingItem `description:"分页数据"`
+	List   []*CygxTacticsTimeLineResp
+}
+
+type CygxTacticsTimeLineResp struct {
+	TimeLineId  int    `description:"ID"`
+	PublishTime string `description:"发布日期"`
+	Status      int    `description:"0:未发布,1:已发布"`
+	Content     string `description:"内容"`
+	ArticleId   int    `description:"文章ID"`
+	ChartId     int    `description:"图表ID"`
+	Link        string `description:"文章或图表链接"`
+}
+
+// 获取数量
+func GetCygxTacticsTimeLineCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_tactics_time_line as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 列表
+func GetCygxTacticsTimeLineList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxTacticsTimeLineResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_tactics_time_line as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+type GetCygxTacticsTimeLineDetailResp struct {
+	Detail *CygxTacticsTimeLineResp
+}
+
+// 通过ID获取详情
+func GetCygxTacticsTimeLineDetail(timeLineId int) (item *CygxTacticsTimeLineResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_tactics_time_line  WHERE time_line_id=? `
+	err = o.Raw(sql, timeLineId).QueryRow(&item)
+	return
+}

+ 38 - 0
models/tactics_time_line_history.go

@@ -0,0 +1,38 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxTacticsTimeLineHistory 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 GetCygxTacticsTimeLineHistoryList(condition string, pars []interface{}) (items []*CygxTacticsTimeLineHistory, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_tactics_time_line_history as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+// 添加
+func AddCygxTacticsTimeLineHistory(item *CygxTacticsTimeLineHistory) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}

+ 18 - 0
routers/commentsRouter.go

@@ -538,6 +538,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileTacticsController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileTacticsController"],
+        beego.ControllerComments{
+            Method: "History",
+            Router: `/tacticsTimeLine/history`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileTacticsController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileTacticsController"],
+        beego.ControllerComments{
+            Method: "TacticsTimeLineList",
+            Router: `/tacticsTimeLine/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileWechatController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileWechatController"],
         beego.ControllerComments{
             Method: "WechatBindMobile",

+ 5 - 0
routers/router.go

@@ -126,6 +126,11 @@ func init() {
 				&controllers.ConfigController{},
 			),
 		),
+		web.NSNamespace("/tactics",
+			web.NSInclude(
+				&controllers.MobileTacticsController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 4 - 1
utils/constants.go

@@ -96,8 +96,11 @@ const (
 	REOURCE_YX                       string = "Yx"
 	REOURCE_HZ                       string = "Hz"
 	GU_SHOU_NAME                     string = "固收"
-	HONG_GUAN_NAME                   string = "宏观"
 	GU_SHOU_ID                       int    = 100000 // 自定义权限类型ID ,十万起步
+	HONG_GUAN_NAME                   string = "宏观"
+	CYGX_TACTICS_TIME_LINE_STATUS    string = "cygx_tactics_time_line_status" // 策略时间线是否对外开放
+	TIME_LINE_ID                     int    = 99999                           // 策略时间线的值
+	TIME_LINE_NAME                   string = "时间线"                           // 策略时间线的名称
 )
 
 // 模板消息推送类型