|
@@ -4,36 +4,39 @@ import (
|
|
|
"fmt"
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
"hongze/hongze_clpt/utils"
|
|
|
+ "strconv"
|
|
|
"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:电脑端"`
|
|
|
+ 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:电脑端"`
|
|
|
+ RegisterPlatform int `description:"来源 1小程序,2:网页"`
|
|
|
}
|
|
|
|
|
|
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强制关闭"`
|
|
|
+ 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强制关闭"`
|
|
|
+ RegisterPlatform int `description:"来源 1小程序,2:网页"`
|
|
|
}
|
|
|
|
|
|
// 添加阅读记录信息
|
|
@@ -102,23 +105,24 @@ func AddCygxArticleViewRecordNewpv(item *CygxArticleHistoryRecordNewpv) (lastId
|
|
|
}
|
|
|
|
|
|
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:"是否删除"`
|
|
|
+ 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:"是否删除"`
|
|
|
+ RegisterPlatform int `description:"来源 1小程序,2:网页"`
|
|
|
}
|
|
|
|
|
|
type EsUserInteraction struct {
|
|
@@ -154,3 +158,39 @@ func GetArticleHistoryRecord(condition string, pars []interface{}) (item []*Cygx
|
|
|
_, err = o.Raw(sql, pars).QueryRows(&item)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// 把十分钟之内的阅读记录进行累加
|
|
|
+func UpdateCygxArticleViewRecordNewpv(itemRep *CygxArticleHistoryRecordNewpv, stopTime int) (err error) {
|
|
|
+ o, err := orm.NewOrm().Begin()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer func() {
|
|
|
+ fmt.Println(err)
|
|
|
+ if err == nil {
|
|
|
+ o.Commit()
|
|
|
+ } else {
|
|
|
+ o.Rollback()
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ sql := `UPDATE cygx_article_history_record_newpv
|
|
|
+ SET modify_time = NOW(), stop_time = stop_time + ` + strconv.Itoa(stopTime) + `
|
|
|
+ WHERE
|
|
|
+ article_id = ?
|
|
|
+ AND user_id = ?
|
|
|
+ AND out_type = 2
|
|
|
+ AND timestampdiff(MINUTE,modify_time,NOW()) < 10`
|
|
|
+ _, err = o.Raw(sql, itemRep.ArticleId, itemRep.UserId).Exec()
|
|
|
+
|
|
|
+ // 修改总表的停留时间
|
|
|
+ sql = `UPDATE cygx_article_history_record_all
|
|
|
+ SET modify_time = NOW(), stop_time = stop_time + ` + strconv.Itoa(stopTime) + `
|
|
|
+ WHERE
|
|
|
+ article_id = ?
|
|
|
+ AND user_id = ?
|
|
|
+ AND out_type = 2
|
|
|
+ AND timestampdiff(MINUTE,modify_time,NOW()) < 10`
|
|
|
+ _, err = o.Raw(sql, itemRep.ArticleId, itemRep.UserId).Exec()
|
|
|
+
|
|
|
+ return
|
|
|
+}
|