package models import ( "github.com/beego/beego/v2/client/orm" "time" ) type CygxActivityVideoHistory struct { Id int `orm:"column(id);pk"description:"音频id"` VideoId int `description:"微路演音频id"` ActivityId int `description:"活动id"` UserId int `description:"用户id"` Mobile string `description:"手机号"` Email string `description:"邮箱"` CompanyId int `description:"公司Id"` CompanyName string `description:"公司名称"` RealName string `description:"用户实际名称"` SellerName string `description:"所属销售"` PlaySeconds string `description:"播放时间 单位s"` CreateTime time.Time `description:"视频创建时间"` ModifyTime time.Time `description:"视频修改时间"` RegisterPlatform int // 来源 1小程序,2:网页 } // 添加 func AddCygxActivityVideoHistory(item *CygxActivityVideoHistory) (err error) { o := orm.NewOrm() _, err = o.Insert(item) return } // 获取列表信息根据手机号分组 func GetActivityVideoHistoryByMobileList(condition string) (items []*CygxActivityVideoHistory, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_activity_video_history WHERE 1 =1 ` + condition + ` GROUP BY user_id ` _, err = o.Raw(sql).QueryRows(&items) return } // 修改用户浏览活动视频的相关信息 func UpdateCygxActivityVideoHistory(wxUser *WxUserItem) (err error) { o := orm.NewOrm() var sql string if wxUser.Mobile != "" { sql = `UPDATE cygx_activity_video_history SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? ` _, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec() } else if wxUser.Email != "" { sql = `UPDATE cygx_activity_video_history SET mobile=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE email=? ` _, err = o.Raw(sql, wxUser.Mobile, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Email).Exec() } return } func GetLastCygxActivityVideoHistory(activityId, userId int) (item *CygxActivityVoiceHistory, err error) { o := orm.NewOrm() sql := ` SELECT * FROM cygx_activity_video_history WHERE activity_id=? AND user_id=? AND register_platform = 1 ORDER BY create_time DESC limit 1 ` err = o.Raw(sql, activityId, userId).QueryRow(&item) return } //func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) { // o := orm.NewOrm() // sql := ` UPDATE cygx_micro_roadshow_video_history SET play_seconds =? WHERE id=? ` // _, err = o.Raw(sql, playSeconds, lastId).Exec() // return //} func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) { o := orm.NewOrm() sql := ` UPDATE cygx_activity_video_history SET play_seconds = play_seconds +? WHERE id=? ` _, err = o.Raw(sql, playSeconds, lastId).Exec() return }