activity_voice_history.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxActivityVoiceHistory struct {
  7. Id int `orm:"column(id);pk"`
  8. ActivityId int `description:"活动ID"`
  9. UserId int `description:"用户ID"`
  10. CreateTime time.Time `description:"创建时间"`
  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. ModifyTime time.Time `description:"视频修改时间"`
  19. }
  20. //添加
  21. func AddCygxActivityVoiceHistory(item *CygxActivityVoiceHistory) (err error) {
  22. o := orm.NewOrm()
  23. _, err = o.Insert(item)
  24. return
  25. }
  26. func GetLastCygxActivityVoiceHistory(activityId, userId int) (item *CygxActivityVoiceHistory, err error) {
  27. o := orm.NewOrm()
  28. sql := ` SELECT * FROM cygx_activity_voice_history WHERE activity_id=? AND user_id=? ORDER BY create_time DESC limit 1 `
  29. err = o.Raw(sql, activityId, userId).QueryRow(&item)
  30. return
  31. }
  32. func UpdateLastCygxActivityVoiceHistory(playSeconds string, lastId int) (err error) {
  33. o := orm.NewOrm()
  34. sql := ` UPDATE cygx_activity_voice_history SET play_seconds =? WHERE id=? `
  35. _, err = o.Raw(sql, playSeconds, lastId).Exec()
  36. return
  37. }
  38. //获取列表信息根据手机号分组
  39. func GetActivityVoiceHistoryByMobileList(condition string) (items []*CygxActivityVoiceHistory, err error) {
  40. o := orm.NewOrm()
  41. sql := `SELECT * FROM cygx_activity_voice_history WHERE 1 =1 ` + condition + ` GROUP BY user_id `
  42. _, err = o.Raw(sql).QueryRows(&items)
  43. return
  44. }
  45. //修改用户浏览活动音频的相关信息
  46. func UpdateCygxActivityVoiceHistory(wxUser *WxUserItem) (err error) {
  47. o := orm.NewOrm()
  48. var sql string
  49. if wxUser.Mobile != "" {
  50. sql = `UPDATE cygx_activity_voice_history SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
  51. _, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec()
  52. } else if wxUser.Email != "" {
  53. sql = `UPDATE cygx_activity_voice_history SET mobile=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE email=? `
  54. _, err = o.Raw(sql, wxUser.Mobile, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Email).Exec()
  55. }
  56. return
  57. }