activity_video_history.go 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxActivityVideoHistory struct {
  7. Id int `orm:"column(id);pk"description:"音频id"`
  8. VideoId int `description:"微路演音频id"`
  9. ActivityId int `description:"活动id"`
  10. UserId int `description:"用户id"`
  11. Mobile string `description:"手机号"`
  12. Email string `description:"邮箱"`
  13. CompanyId int `description:"公司Id"`
  14. CompanyName string `description:"公司名称"`
  15. RealName string `description:"用户实际名称"`
  16. SellerName string `description:"所属销售"`
  17. PlaySeconds string `description:"播放时间 单位s"`
  18. CreateTime time.Time `description:"视频创建时间"`
  19. ModifyTime time.Time `description:"视频修改时间"`
  20. RegisterPlatform int // 来源 1小程序,2:网页
  21. }
  22. // 添加
  23. func AddCygxActivityVideoHistory(item *CygxActivityVideoHistory) (err error) {
  24. o := orm.NewOrm()
  25. _, err = o.Insert(item)
  26. return
  27. }
  28. // 获取列表信息根据手机号分组
  29. func GetActivityVideoHistoryByMobileList(condition string) (items []*CygxActivityVideoHistory, err error) {
  30. o := orm.NewOrm()
  31. sql := `SELECT * FROM cygx_activity_video_history WHERE 1 =1 ` + condition + ` GROUP BY user_id `
  32. _, err = o.Raw(sql).QueryRows(&items)
  33. return
  34. }
  35. // 修改用户浏览活动视频的相关信息
  36. func UpdateCygxActivityVideoHistory(wxUser *WxUserItem) (err error) {
  37. o := orm.NewOrm()
  38. var sql string
  39. if wxUser.Mobile != "" {
  40. sql = `UPDATE cygx_activity_video_history SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
  41. _, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec()
  42. } else if wxUser.Email != "" {
  43. sql = `UPDATE cygx_activity_video_history SET mobile=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE email=? `
  44. _, err = o.Raw(sql, wxUser.Mobile, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Email).Exec()
  45. }
  46. return
  47. }
  48. func GetLastCygxActivityVideoHistory(activityId, userId int) (item *CygxActivityVoiceHistory, err error) {
  49. o := orm.NewOrm()
  50. sql := ` SELECT * FROM cygx_activity_video_history WHERE activity_id=? AND user_id=? AND register_platform = 1 ORDER BY create_time DESC limit 1 `
  51. err = o.Raw(sql, activityId, userId).QueryRow(&item)
  52. return
  53. }
  54. //func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) {
  55. // o := orm.NewOrm()
  56. // sql := ` UPDATE cygx_micro_roadshow_video_history SET play_seconds =? WHERE id=? `
  57. // _, err = o.Raw(sql, playSeconds, lastId).Exec()
  58. // return
  59. //}
  60. func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) {
  61. o := orm.NewOrm()
  62. sql := ` UPDATE cygx_activity_video_history SET play_seconds = play_seconds +? WHERE id=? `
  63. _, err = o.Raw(sql, playSeconds, lastId).Exec()
  64. return
  65. }