|
@@ -0,0 +1,142 @@
|
|
|
+package models
|
|
|
+
|
|
|
+import (
|
|
|
+ "fmt"
|
|
|
+ "github.com/beego/beego/v2/client/orm"
|
|
|
+ "hongze/hongze_clpt/utils"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+type CygxArticleHistoryRecordNewpv struct {
|
|
|
+ Id int `orm:"column(id);pk"`
|
|
|
+ ArticleId int
|
|
|
+ UserId int
|
|
|
+ CreateTime time.Time
|
|
|
+ ModifyTime time.Time
|
|
|
+ Mobile string `description:"手机号"`
|
|
|
+ Email string `description:"邮箱"`
|
|
|
+ CompanyId int `description:"公司id"`
|
|
|
+ CompanyName string `description:"公司名称"`
|
|
|
+ StopTime int `description:"停留时间"`
|
|
|
+ OutType int `description:"退出方式,1正常退出,2强制关闭"`
|
|
|
+ Source string `description:"来源,MOBILE:手机端,PC:电脑端"`
|
|
|
+}
|
|
|
+
|
|
|
+type CygxArticleHistoryRecord 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:"修改时间"`
|
|
|
+ StopTime int `description:"停留时间"`
|
|
|
+ OutType int `description:"退出方式,1正常退出,2强制关闭"`
|
|
|
+}
|
|
|
+
|
|
|
+// 添加阅读记录信息
|
|
|
+func AddCygxArticleViewRecordNewpv(item *CygxArticleHistoryRecordNewpv) (lastId int64, err error) {
|
|
|
+ o, err := orm.NewOrm().Begin()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer func() {
|
|
|
+ fmt.Println(err)
|
|
|
+ if err == nil {
|
|
|
+ o.Commit()
|
|
|
+ } else {
|
|
|
+ o.Rollback()
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ lastId, err = o.Insert(item)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ historyRecord := new(CygxArticleHistoryRecord)
|
|
|
+ historyRecord.UserId = item.UserId
|
|
|
+ historyRecord.ArticleId = item.ArticleId
|
|
|
+ historyRecord.CreateTime = time.Now()
|
|
|
+ historyRecord.Mobile = item.Mobile
|
|
|
+ historyRecord.Email = item.Email
|
|
|
+ historyRecord.CompanyId = item.CompanyId
|
|
|
+ historyRecord.CompanyName = item.CompanyName
|
|
|
+ lastId, err = o.Insert(historyRecord)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //写入记录到总的统计表
|
|
|
+ record := new(CygxArticleHistoryRecordAll)
|
|
|
+ record.UserId = item.UserId
|
|
|
+ record.ArticleId = item.ArticleId
|
|
|
+ record.CreateTime = item.CreateTime.Format(utils.FormatDateTime)
|
|
|
+ record.ModifyTime = item.ModifyTime
|
|
|
+ record.Mobile = item.Mobile
|
|
|
+ record.Email = item.Email
|
|
|
+ record.CompanyId = item.CompanyId
|
|
|
+ record.CompanyName = item.CompanyName
|
|
|
+ record.StopTime = item.StopTime
|
|
|
+ record.OutType = item.OutType
|
|
|
+ record.Source = item.Source
|
|
|
+ record.Platfor = 1
|
|
|
+ lastId, err = o.Insert(record)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 软删除当天策略平台的文章阅读记录
|
|
|
+ if item.Mobile != "" {
|
|
|
+ sql := `UPDATE cygx_article_history_record_all
|
|
|
+ SET is_del = 1
|
|
|
+ WHERE
|
|
|
+ article_id = ?
|
|
|
+ AND mobile = ?
|
|
|
+ AND platfor = 2
|
|
|
+ AND create_time >= date(NOW()) `
|
|
|
+ _, err = o.Raw(sql, record.ArticleId, record.Mobile).Exec()
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+type CygxArticleHistoryRecordAll struct {
|
|
|
+ Id int `orm:"column(id);pk"`
|
|
|
+ ArticleId int
|
|
|
+ UserId int
|
|
|
+ CreateTime string
|
|
|
+ ModifyTime time.Time
|
|
|
+ Mobile string `description:"手机号"`
|
|
|
+ Email string `description:"邮箱"`
|
|
|
+ CompanyId int `description:"公司id"`
|
|
|
+ CompanyName string `description:"公司名称"`
|
|
|
+ StopTime int `description:"停留时间"`
|
|
|
+ OutType int `description:"退出方式,1正常退出,2强制关闭"`
|
|
|
+ Source string `description:"来源,MOBILE:手机端,PC:电脑端"`
|
|
|
+ RealName string `description:"用户实际名称"`
|
|
|
+ CreateDateApi time.Time `description:"同步创建时间"`
|
|
|
+ CelueHistoryId int `description:"策略平台记录的ID"`
|
|
|
+ Platfor int `description:"PV阅读记录来源,1:查研观向,2:策略平台"`
|
|
|
+ IsDel int `description:"是否删除"`
|
|
|
+}
|
|
|
+
|
|
|
+type EsUserInteraction struct {
|
|
|
+ Id int `description:"主键ID"`
|
|
|
+ ArticleId int `description:"文章id"`
|
|
|
+ ArticleType int `description:"文章类型 1:查研观向, 2:策略平台"`
|
|
|
+ Title string `description:"标题"`
|
|
|
+ PublishDate string `description:"发布时间"`
|
|
|
+ CreateTime string `description:"创建时间"`
|
|
|
+ StopTime string `description:"阅读停留时间"`
|
|
|
+ RealName string `description:"姓名"`
|
|
|
+ CompanyName string `description:"公司名称"`
|
|
|
+ CompanyId int `description:"公司ID"`
|
|
|
+ SellerName string `description:"所属销售"`
|
|
|
+ SellerId int `description:"所属销售ID"`
|
|
|
+ Mobile string `description:"手机号"`
|
|
|
+ Email string `description:"邮箱"`
|
|
|
+ UserId int `description:"用户ID"`
|
|
|
+ UserArticleHistoryNum int `description:"用户阅读数量"`
|
|
|
+ CompanyArticleHistoryNum int `description:"机构阅读数量"`
|
|
|
+}
|