Ver Fonte

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into cygx_10.5.1

xingzai há 1 ano atrás
pai
commit
eadc7e36e2

+ 97 - 0
controllers/banner.go

@@ -0,0 +1,97 @@
+package controllers
+
+import (
+	"encoding/json"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/services"
+)
+
+// Banner
+type BannerController struct {
+	BaseAuthController
+}
+
+// @Title 列表
+// @Description 列表接口
+// @Success Ret=200 {object} cygx.CygxBannerListResp
+// @router /list [get]
+func (this *BannerController) List() {
+	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.CygxBannerListResp)
+	var condition string
+	var pars []interface{}
+	condition += "	 AND art.status = 1 ORDER BY art. list_type ASC   , art.sort ASC  "
+	list, err := models.GetCygxBannerList(condition, pars, 0, 99999)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	bannerImgList, err := models.GetCygxBannerImgList()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	mapImg := make(map[int]string)
+	for _, v := range bannerImgList {
+		mapImg[v.ImgId] = v.IndexImg
+	}
+	for _, v := range list {
+		v.IndexImg = mapImg[v.ImgId]
+		v.BannerUrlResp = services.GetBannerUrlBody(v.Link)
+	}
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 记录点击信息
+// @Description 记录点击信息
+// @Param	request	body cygx.CygxBannerIdReq true "type json string"
+// @Success 200 Ret=200 发布成功
+// @router /add/history [post]
+func (this *BannerController) 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.CygxBannerIdReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	bannerId := req.BannerId
+	if bannerId == 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,id不可为空"
+		return
+	}
+	go services.AddCygxBannerHistory(user, bannerId)
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "记录成功"
+}

+ 85 - 85
controllers/report.go

@@ -1582,7 +1582,7 @@ func (this *ReportController) Detail() {
 	//	br.IsSendEmail = false
 	//	return
 	//}
-	uid := user.UserId
+	//uid := user.UserId
 	articleId, _ := this.GetInt("ArticleId")
 	isBestNew, _ := this.GetBool("IsBestNew")
 	if isBestNew {
@@ -1731,27 +1731,27 @@ func (this *ReportController) Detail() {
 		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)
+	//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
@@ -1778,7 +1778,7 @@ func (this *ReportController) ResearchDetail() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
+	//uid := user.UserId
 	articleId, _ := this.GetInt("ArticleId")
 	if articleId < 0 {
 		br.Msg = "参数错误"
@@ -1888,26 +1888,26 @@ func (this *ReportController) ResearchDetail() {
 			listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.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"
-	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)
+	//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"
+	//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 = listFirst
 	resp.Detail = detail
 	br.Ret = 200
@@ -1933,7 +1933,7 @@ func (this *ReportController) MinutesDetailV4() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
+	//uid := user.UserId
 	articleId, _ := this.GetInt("ArticleId")
 	if articleId < 0 {
 		br.Msg = "参数错误"
@@ -2022,26 +2022,26 @@ func (this *ReportController) MinutesDetailV4() {
 			listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.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 = "szjyhz"
-	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)
+	//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"
+	//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 = listFirst
 	resp.Detail = detail
 	br.Ret = 200
@@ -2067,7 +2067,7 @@ func (this *ReportController) MinutesDetail() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
+	//uid := user.UserId
 	articleId, _ := this.GetInt("ArticleId")
 	if articleId < 0 {
 		br.Msg = "参数错误"
@@ -2119,26 +2119,26 @@ func (this *ReportController) MinutesDetail() {
 			}
 		}
 	}
-	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"
-	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)
+	//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"
+	//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 = listLog
 	resp.Detail = detail
 	br.Ret = 200

+ 97 - 22
controllers/report_selection.go

@@ -33,7 +33,7 @@ func (this *ReportSelectionController) Detail() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
+	//uid := user.UserId
 	articleId, _ := this.GetInt("ArticleId")
 	isBestNew, _ := this.GetBool("IsBestNew")
 	isBestNew = true
@@ -148,27 +148,27 @@ func (this *ReportSelectionController) Detail() {
 		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)
+	//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
@@ -232,3 +232,78 @@ func (this *ReportSelectionController) ClickHistory() {
 	br.Success = true
 	br.Msg = "记录成功"
 }
+
+// @Title 上传文章阅读时间
+// @Description 上传文章阅读时间接口
+// @Param  request	body models.AddStopTimeRep true "type json string"
+// @Success 200 {object} models.ArticleDetailResp
+// @router /addStopTime [post]
+func (this *ReportSelectionController) AddStopTime() {
+	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.AddReportSelectionStopTimeRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	uid := user.UserId
+	articleId := req.ArticleId
+	stopTime := req.StopTime
+	outType := req.OutType
+	source := req.Source
+	var reportType string
+	if source == 1 {
+		reportType = "bgjx"
+	} else if source == 2 {
+		reportType = "bzyjhz"
+	} else if source == 3 {
+		reportType = "szjyhz"
+	}
+	hasPermission, err := services.GetUserhasPermission(user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
+	}
+
+	if hasPermission == 1 {
+		historyRecord := new(models.CygxReportHistoryRecord)
+		historyRecord.UserId = uid
+		historyRecord.ArticleId = articleId
+		historyRecord.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
+		historyRecord.Mobile = user.Mobile
+		historyRecord.Email = user.Email
+		historyRecord.CompanyId = user.CompanyId
+		historyRecord.CompanyName = user.CompanyName
+		historyRecord.StopTime = stopTime
+		historyRecord.OutType = outType
+		historyRecord.ReportType = reportType
+		historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM
+		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 services.AddCygxReportHistoryRecord(historyRecord)
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+}

+ 81 - 0
models/banner.go

@@ -0,0 +1,81 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type CygxBannerResp struct {
+	BannerId       int            `description:"BannerId等于0新增,大于零修改"`
+	ImgId          int            `description:"cygx_banner_img主键ID"`
+	IndexImg       string         `description:"小程序封面图"`
+	ListType       string         `description:"ABC哪一列"`
+	BannerTypeName string         `description:"添加类型名称"`
+	Title          string         `description:"标题"`
+	Link           string         `description:"链接地址"`
+	Subtitle       string         `description:"副标题"`
+	BannerUrlResp  *BannerUrlResp `description:"跳转地址"`
+}
+
+type CygxBannerIdReq struct {
+	BannerId int `description:"BannerId"`
+}
+
+type GetCygxBannerImgRespDetailResp struct {
+	Detail *CygxBannerResp
+}
+
+// 通过ID获取详情
+func GetCygxBannerDetail(banneId int) (item *CygxBannerResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_banner  WHERE banner_id=? `
+	err = o.Raw(sql, banneId).QueryRow(&item)
+	return
+}
+
+// 获取数量
+func GetCygxBannerCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_banner as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 列表
+func GetCygxBannerList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxBannerResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_banner as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+type CygxBannerListResp struct {
+	List []*CygxBannerResp
+}
+
+type CygxBannerImgResp struct {
+	ImgId    int    `description:"图片ID"`
+	IndexImg string `description:"小程序封面图"`
+}
+
+type BannerUrlResp struct {
+	ChartPermissionId int    `description:"行业id"`
+	SourceId          int    `description:"资源ID"`
+	Type              int    `description:"类型:1普通文本,2:文章、3:活动、4:产业、5:关于我们、6:产品内测"`
+	Body              string `description:"内容"`
+	Path              string `description:"小程序路径"`
+}
+
+// 列表
+func GetCygxBannerImgList() (items []*CygxBannerImgResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_banner_img as art WHERE 1= 1 `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 29 - 0
models/banner_history.go

@@ -0,0 +1,29 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxBannerHistory struct {
+	Id               int `orm:"column(id);pk"`
+	BannerId         int `description:"BannerId等于0新增,大于零修改"`
+	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:"所属销售"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+}
+
+// 添加历史信息
+func AddCygxBannerHistory(item *CygxBannerHistory) (lastId int64, err error) {
+	o := orm.NewOrm()
+	item.ModifyTime = time.Now()
+	lastId, err = o.Insert(item)
+	return
+}

+ 2 - 0
models/db.go

@@ -145,6 +145,8 @@ func init() {
 		new(CygxReportMappingGroup),
 		new(CygxAboutUsVideoHistory),
 		new(CygxActivitySignupBreak),
+		new(CygxBannerHistory),
+		new(CygxReportHistoryRecordLog),
 		new(CygxUserLabel),
 		new(CygxUserLabelActivity),
 		new(CygxUserLabelArticle),

+ 42 - 13
models/report_history_record.go

@@ -6,24 +6,53 @@ import (
 )
 
 type CygxReportHistoryRecord struct {
-	Id          int `orm:"column(id);pk"`
-	ArticleId   int
-	UserId      int
-	CreateTime  time.Time
-	Mobile      string    `description:"手机号"`
-	Email       string    `description:"邮箱"`
-	CompanyId   int       `description:"公司id"`
-	CompanyName string    `description:"公司名称"`
-	ModifyTime  time.Time `description:"修改时间"`
-	ReportType  string    `description:"报告类型,bgjx:报告精选、bzyjhz:本周研究汇总、szjyhz:上周纪要汇总"`
-	RealName    string    `description:"用户实际名称"`
-	SellerName  string    `description:"所属销售"`
+	Id               int `orm:"column(id);pk"`
+	ArticleId        int
+	UserId           int
+	CreateTime       time.Time
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司id"`
+	CompanyName      string    `description:"公司名称"`
+	ModifyTime       time.Time `description:"修改时间"`
+	ReportType       string    `description:"报告类型,bgjx:报告精选、bzyjhz:本周研究汇总、szjyhz:上周纪要汇总"`
+	RealName         string    `description:"用户实际名称"`
+	SellerName       string    `description:"所属销售"`
+	StopTime         int       `description:"停留时间"`
+	OutType          int       `description:"退出方式,1正常退出,2强制关闭"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
 }
 
-//添加历史信息
+type CygxReportHistoryRecordLog struct {
+	Id               int `orm:"column(id);pk"`
+	ArticleId        int
+	UserId           int
+	CreateTime       time.Time
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司id"`
+	CompanyName      string    `description:"公司名称"`
+	ModifyTime       time.Time `description:"修改时间"`
+	ReportType       string    `description:"报告类型,bgjx:报告精选、bzyjhz:本周研究汇总、szjyhz:上周纪要汇总"`
+	RealName         string    `description:"用户实际名称"`
+	SellerName       string    `description:"所属销售"`
+	StopTime         int       `description:"停留时间"`
+	OutType          int       `description:"退出方式,1正常退出,2强制关闭"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+}
+
+// 添加历史信息
 func AddCygxReportHistoryRecord(item *CygxReportHistoryRecord) (lastId int64, err error) {
 	o := orm.NewOrm()
 	item.ModifyTime = time.Now()
 	lastId, err = o.Insert(item)
 	return
 }
+
+// 添加历史信息
+func AddCygxReportHistoryRecordLog(item *CygxReportHistoryRecordLog) (lastId int64, err error) {
+	o := orm.NewOrm()
+	item.ModifyTime = time.Now()
+	lastId, err = o.Insert(item)
+	return
+}

+ 7 - 0
models/report_selection.go

@@ -188,3 +188,10 @@ func GetIndustrialByIds(industrialManagementIds string) (items []*IndustriaRepor
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+type AddReportSelectionStopTimeRep struct {
+	ArticleId int `description:"文章ID"`
+	StopTime  int `description:"停留时间"`
+	OutType   int `description:"退出方式,1正常退出,2强制关闭"`
+	Source    int `description:"来源,1:报告精选、2:本周研究汇总、3:上周纪要汇总"`
+}

+ 2 - 2
models/wx_user.go

@@ -532,9 +532,9 @@ func GetCygxCompanyUserUserInteraction(userIds string) (items []*CygxUserInterac
 			( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h WHERE h.user_id = u.user_id  ) AS industry_fllow_num,
 			( SELECT COUNT( 1 ) FROM cygx_article_department_follow AS h WHERE h.user_id = u.user_id   ) AS department_follow_num,
 			( SELECT COUNT( 1 ) FROM cygx_search_key_word_log AS h WHERE h.user_id = u.user_id  ) AS key_word_num,
-			( SELECT COUNT( 1 ) FROM cygx_activity_signup AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.mobile = u.mobile  
+			( SELECT COUNT( 1 ) FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.mobile = u.mobile  
 					 AND t.activity_type = 1  AND h.do_fail_type = 0 ) AS on_line_num,
-			( SELECT COUNT( 1 ) FROM cygx_activity_signup AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.mobile = u.mobile  
+			( SELECT COUNT( 1 ) FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.mobile = u.mobile  
 					  AND t.activity_type = 0 AND h.do_fail_type = 0 ) AS office_num,
 			( SELECT COUNT( 1 ) FROM cygx_activity_special_trip AS h INNER JOIN cygx_activity_special AS a ON a.activity_id = h.activity_id WHERE h.mobile = u.mobile  AND h.is_cancel = 0 ) AS trip_num,
 						( SELECT COUNT( 1 ) FROM cygx_micro_roadshow_video_history AS h  INNER JOIN cygx_micro_roadshow_video as v ON v.video_id = h.video_id WHERE  h.mobile = u.mobile  ) AS roadshow_video_num,

+ 27 - 0
routers/commentsRouter.go

@@ -385,6 +385,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BannerController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BannerController"],
+        beego.ControllerComments{
+            Method: "History",
+            Router: `/add/history`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BannerController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BannerController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BaseChartController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BaseChartController"],
         beego.ControllerComments{
             Method: "Patg",
@@ -1024,6 +1042,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"],
+        beego.ControllerComments{
+            Method: "AddStopTime",
+            Router: `/addStopTime`,
+            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: "ClickHistory",

+ 5 - 0
routers/router.go

@@ -154,6 +154,11 @@ func init() {
 				&controllers.MorningMeetingController{},
 			),
 		),
+		web.NSNamespace("/banner",
+			web.NSInclude(
+				&controllers.BannerController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 1 - 1
services/article.go

@@ -1086,7 +1086,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 								industrialSubjectIdStr += strconv.Itoa(vIndustrial.IndustrialSubjectId) + ","
 								mapManagementForSubject[vIndustrial.IndustryName] += vIndustrial.SubjectName + "/"
 								if vIndustrial.LayoutTime == "0000-00-00 00:00:00" {
-									go models.UpdateIndustrialManagementLayoutTime(v.PublishDate.Format(utils.FormatDateTime), vIndustrial.IndustrialManagementId)
+									go models.UpdateIndustrialManagementLayoutTime(v.PublishDate.AddDate(0, 0, -10).Format(utils.FormatDateTime), vIndustrial.IndustrialManagementId)
 								}
 							}
 

+ 135 - 0
services/banner.go

@@ -0,0 +1,135 @@
+package services
+
+import (
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+// GetBannerUrlBody 处理banner的连接并做跳转处理
+func GetBannerUrlBody(url string) (itemResp *models.BannerUrlResp) {
+	//2:文章详情  https://web.hzinsights.com/material/info/8436  小程序路径:/pageMy/reportDetail/reportDetail?id=
+	//3:活动详情  https://web.hzinsights.com/activity/detail/2701  小程序路径:/activityPages/activityDetail/activityDetail?id=
+	//4:产业详情  https://web.hzinsights.com/indepth/info/20/79  小程序路径:/reportPages/IndustryReport/IndustryReport?id=
+	//5:关于我们  https://clpttest.hzinsights.com/about
+	//6:产品内测 https://clpttest.hzinsights.com/internal/article/29  小程序路径:/reportPages/internalDetials/internalDetials?id=
+	//7:本周研究汇总 https://clpttest.hzinsights.com/summary/2/152  小程序路径:/reportPages/reportSecretDetail/reportSecretDetail?type=2&id=
+	//8:上周研究汇总 https://clpttest.hzinsights.com/summary/3/112 小程序路径:/reportPages/reportSecretDetail/reportSecretDetail?type=3&id=
+	//9:专项调研活动 https://clpttest.hzinsights.com/activity/info/70  小程序路径:/activityPages/specialDetail/specialDetail?id=
+	//10: 重点公司 https://clpttest.hzinsights.com/recent/67  小程序路径:/reportPages/keyCompany/keyCompany
+	//11: 主题详情 https://clpttest.hzinsights.com/community/theme/117  小程序路径:/reportPages/researchTheme/researchTheme?id=
+	//12: 作者详情 https://clpttest.hzinsights.com/community/author/78 小程序路径:/reportPages/authorPages/authorPages?id=
+
+	mapPath := make(map[int]string)
+	mapPath[2] = utils.WX_MSG_PATH_ARTICLE_DETAIL          //文章详情
+	mapPath[3] = utils.WX_MSG_PATH_ACTIVITY_DETAIL         //活动详情
+	mapPath[4] = utils.WX_MSG_PATH_INDUSTRY_DETAIL         //产业详情
+	mapPath[6] = utils.WX_MSG_PATH_PRODUCTINTERIOR_DETAIL  //产品内测
+	mapPath[7] = utils.WX_MSG_PATH_THIS_WEEK_DETAIL        //本周研究汇总
+	mapPath[8] = utils.WX_MSG_PATH_LAST_WEEK_DETAIL        //上周研究汇总
+	mapPath[9] = utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL //专项调研活动
+	mapPath[10] = utils.WX_MSG_PATH_KEY_COMPANY_DETAIL     //重点公司
+	mapPath[11] = utils.WX_MSG_PATH_RESEARCHTHEME_DETAIL   //主题详情
+	mapPath[12] = utils.WX_MSG_PATH_AUTHOR_DETAIL          //作者详情
+
+	material := "material/info"             //2:文章详情
+	activity := "activity/detail"           //3:活动详情
+	activityVideo := "activity/video"       //3:活动视频页,调活动详情
+	indepth := "indepth/info"               //4:产业详情
+	indepthVideo := "indepth/video"         //4:产业视频页,调详情
+	about := "/about"                       //5:关于我们
+	internal := "internal/article"          //6:产品内测
+	thisWeek := "summary/2/"                //7:本周研究汇总
+	lastWeek := "summary/3/"                //8:上周研究汇总
+	activitySpecial := "activity/info"      //9:专项调研活动
+	recent := "/recent/"                    //10:重点公司
+	communityTheme := "/community/theme/"   //11:主题详情
+	communityAuthor := "/community/author/" //12:作者详情
+	item := new(models.BannerUrlResp)
+	item.Body = url
+	urlSlice := strings.Split(url, "/")
+	lenurlSlice := len(urlSlice)
+	sourceId, _ := strconv.Atoi(urlSlice[lenurlSlice-1])
+
+	if strings.Contains(url, material) {
+		item.Type = 2
+	} else if strings.Contains(url, activity) {
+		item.Type = 3
+	} else if strings.Contains(url, activityVideo) {
+		activityVideo, err := models.GetCygxActivityVideoById(sourceId)
+		if err != nil {
+			go utils.SendAlarmMsg("banner链接解析失败"+err.Error()+url, 2)
+		}
+		if activityVideo != nil {
+			sourceId = activityVideo.ActivityId
+			item.Type = 3
+		}
+	} else if strings.Contains(url, indepth) {
+		if lenurlSlice >= 2 {
+			chartPermissionId, _ := strconv.Atoi(urlSlice[lenurlSlice-2])
+			item.ChartPermissionId = chartPermissionId
+		}
+		item.Type = 4
+	} else if strings.Contains(url, indepthVideo) {
+		if lenurlSlice >= 2 {
+			sourceId, _ = strconv.Atoi(urlSlice[lenurlSlice-2])
+		}
+		item.Type = 4
+	} else if strings.Contains(url, about) {
+		item.Type = 5
+	} else if strings.Contains(url, internal) {
+		item.Type = 6
+	} else if strings.Contains(url, thisWeek) {
+		item.Type = 7
+	} else if strings.Contains(url, lastWeek) {
+		item.Type = 8
+	} else if strings.Contains(url, activitySpecial) {
+		item.Type = 9
+	} else if strings.Contains(url, recent) {
+		item.Type = 10
+	} else if strings.Contains(url, communityTheme) {
+		item.Type = 11
+	} else if strings.Contains(url, communityAuthor) {
+		item.Type = 12
+	} else {
+		item.Type = 1
+	}
+	if mapPath[item.Type] != "" {
+		item.Path = "/" + mapPath[item.Type]
+	}
+	item.SourceId = sourceId
+	itemResp = item
+	return
+}
+
+func AddCygxBannerHistory(user *models.WxUserItem, bannerId int) (err error) {
+	if user.UserId == 0 {
+		return
+	}
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("banner点击信息记录失败"+err.Error()+"bannerId"+strconv.Itoa(bannerId)+"userId:"+strconv.Itoa(user.UserId), 2)
+		}
+	}()
+	historyRecord := new(models.CygxBannerHistory)
+	historyRecord.UserId = user.UserId
+	historyRecord.BannerId = bannerId
+	historyRecord.CreateTime = time.Now()
+	historyRecord.Mobile = user.Mobile
+	historyRecord.Email = user.Email
+	historyRecord.CompanyId = user.CompanyId
+	historyRecord.CompanyName = user.CompanyName
+	historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	historyRecord.RealName = user.RealName
+	if sellerItem != nil {
+		historyRecord.SellerName = sellerItem.RealName
+	}
+	_, err = models.AddCygxBannerHistory(historyRecord)
+	return
+}

+ 41 - 0
services/report_history_record.go

@@ -0,0 +1,41 @@
+package services
+
+import (
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+)
+
+// 添加历史信息
+func AddCygxReportHistoryRecord(item *models.CygxReportHistoryRecord) (err error) {
+	//defer func() {
+	//	if err != nil {
+	//		go utils.SendAlarmMsg("产品内测用户浏览信息记录失败"+err.Error(), 2)
+	//	}
+	//}()
+	if item.StopTime >= 5 {
+		_, err = models.AddCygxReportHistoryRecord(item)
+		if err != nil {
+			go utils.SendAlarmMsg("报告精选用户浏览信息记录失败"+err.Error()+"报告类型"+item.ReportType+"报告ID:"+strconv.Itoa(item.ArticleId), 2)
+		}
+	}
+
+	historyRecordLog := new(models.CygxReportHistoryRecordLog)
+	historyRecordLog.UserId = item.UserId
+	historyRecordLog.ArticleId = historyRecordLog.ArticleId
+	historyRecordLog.CreateTime = historyRecordLog.CreateTime
+	historyRecordLog.Mobile = historyRecordLog.Mobile
+	historyRecordLog.Email = historyRecordLog.Email
+	historyRecordLog.CompanyId = historyRecordLog.CompanyId
+	historyRecordLog.CompanyName = historyRecordLog.CompanyName
+	historyRecordLog.StopTime = historyRecordLog.StopTime
+	historyRecordLog.OutType = historyRecordLog.OutType
+	historyRecordLog.ReportType = historyRecordLog.ReportType
+	historyRecordLog.RegisterPlatform = historyRecordLog.RegisterPlatform
+
+	_, err = models.AddCygxReportHistoryRecordLog(historyRecordLog)
+	if err != nil {
+		go utils.SendAlarmMsg("报告精选用户浏览信息日志记录失败"+err.Error()+"报告类型"+item.ReportType+"报告ID:"+strconv.Itoa(item.ArticleId), 2)
+	}
+	return
+}

+ 1 - 0
services/resource_data.go

@@ -233,6 +233,7 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 				}
 			}
 			v.SourceType = 1
+			v.Expert, _ = GetReportContentTextSub(v.Expert)
 			mapItems[fmt.Sprint("activity", v.ActivityId)].Activity = v
 		}
 	}

+ 0 - 1
utils/common.go

@@ -727,7 +727,6 @@ func StrDateTimeToWeek(strTime string) string {
 		"Sunday":    "周日",
 	}
 	var ctime = StrTimeToTime(strTime).Format("2006-01-02")
-	fmt.Println(ctime)
 	startday, _ := time.Parse("2006-01-02", ctime)
 	staweek_int := startday.Weekday().String()
 	return WeekDayMap[staweek_int]

+ 22 - 2
utils/constants.go

@@ -159,10 +159,30 @@ const (
 // 模板消息地址路由
 const (
 	WX_MSG_PATH_ARTICLE_DETAIL           = "pageMy/reportDetail/reportDetail?id="            //文章详情模板消息地址
+	WX_MSG_PATH_ACTIVITY_DETAIL          = "activityPages/activityDetail/activityDetail?id=" //活动模板消息地址
 	WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL  = "activityPages/specialDetail/specialDetail?id="   //专项调研活动模板消息地址
 	WX_MSG_PATH_ACTIVITY_INDUSTRYR_EPORT = "reportPages/IndustryReport/IndustryReport?id="   //产业文章列表模板消息地址
-	WX_MSG_PATH_ACTIVITY_DETAIL          = "activityPages/activityDetail/activityDetail?id=" //活动模板消息地址
-)
+
+	WX_MSG_PATH_AUTHOR_DETAIL          = "reportPages/authorPages/authorPages?id="                      //作者详情模板消息地址
+	WX_MSG_PATH_INDUSTRY_DETAIL        = "reportPages/IndustryReport/IndustryReport?id="                //产业详情模板消息地址
+	WX_MSG_PATH_PRODUCTINTERIOR_DETAIL = "reportPages/internalDetials/internalDetials?id="              //产品内测详情模板消息地址
+	WX_MSG_PATH_THIS_WEEK_DETAIL       = "reportPages/reportSecretDetail/reportSecretDetail?type=2&id=" //本周研究汇总详情模板消息地址
+	WX_MSG_PATH_LAST_WEEK_DETAIL       = "reportPages/reportSecretDetail/reportSecretDetail?type=3&id=" //上周纪要汇总详情模板消息地址
+	WX_MSG_PATH_KEY_COMPANY_DETAIL     = "reportPages/keyCompany/keyCompany"                            //重点公司详情模板消息地址
+	WX_MSG_PATH_RESEARCHTHEME_DETAIL   = "reportPages/researchTheme/researchTheme?id="                  //主题详情模板消息地址
+)
+
+//2:文章详情  https://web.hzinsights.com/material/info/8436  小程序路径:/pageMy/reportDetail/reportDetail?id=
+//3:活动详情  https://web.hzinsights.com/activity/detail/2701  小程序路径:/activityPages/activityDetail/activityDetail?id=
+//4:产业详情  https://web.hzinsights.com/indepth/info/20/79  小程序路径:/reportPages/IndustryReport/IndustryReport?id=
+//5:关于我们  https://clpttest.hzinsights.com/about
+//6:产品内测 https://clpttest.hzinsights.com/internal/article/29  小程序路径:/reportPages/internalDetials/internalDetials?id=
+//7:本周研究汇总 https://clpttest.hzinsights.com/summary/2/152  小程序路径:/reportPages/reportSecretDetail/reportSecretDetail?type=2&id=
+//8:上周研究汇总 https://clpttest.hzinsights.com/summary/3/112 小程序路径:/reportPages/reportSecretDetail/reportSecretDetail?type=3&id=
+//9:专项调研活动 https://clpttest.hzinsights.com/activity/info/70  小程序路径:/activityPages/specialDetail/specialDetail?id=
+//10: 重点公司 https://clpttest.hzinsights.com/recent/67  小程序路径:/reportPages/keyCompany/keyCompany
+//11: 主题详情 https://clpttest.hzinsights.com/community/theme/117  小程序路径:/reportPages/researchTheme/researchTheme?id=
+//12: 作者详情 https://clpttest.hzinsights.com/community/author/78 小程序路径:/reportPages/authorPages/authorPages?id=
 
 // 模板消息地址路由
 const (