Parcourir la source

重点公司添加阅读时间记录

xingzai il y a 1 an
Parent
commit
a8215f0a22

+ 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 = "操作成功"
+}

+ 1 - 0
models/db.go

@@ -146,6 +146,7 @@ func init() {
 		new(CygxAboutUsVideoHistory),
 		new(CygxActivitySignupBreak),
 		new(CygxBannerHistory),
+		new(CygxReportHistoryRecordLog),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 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:上周纪要汇总"`
+}

+ 9 - 0
routers/commentsRouter.go

@@ -1042,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",

+ 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]