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