activity_meeting_history.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxActivityMeetingHistory struct {
  7. Id int `orm:"column(id);pk"`
  8. ActivityId int `description:"活动ID "`
  9. StopTime int `description:"停留时间 "`
  10. AdminId int `description:"销售/管理员ID"`
  11. RealName string `description:"销售/管理员姓名"`
  12. CreateTime time.Time `description:"创建时间"`
  13. RoleTypeCode string `description:"角色编码"`
  14. }
  15. type CygxActivityMeetingHistoryAddReq struct {
  16. ActivityId int `description:"活动ID "`
  17. StopTime int `description:"停留时间 "`
  18. }
  19. type CygxActivityMeetingHistoryResp struct {
  20. Id int `orm:"column(id);pk"`
  21. ActivityId int `description:"活动ID "`
  22. AdminId int `description:"销售/管理员ID"`
  23. RealName string `description:"销售/管理员姓名"`
  24. StopTime int `description:"停留时间 "`
  25. CreateTime string `description:"创建时间"`
  26. }
  27. type CygxActivityMeetingHistoryListResp struct {
  28. List []*CygxActivityMeetingHistoryResp
  29. }
  30. // 新增
  31. func AddCygxActivityMeetingHistory(item *CygxActivityMeetingHistory) (err error) {
  32. o := orm.NewOrmUsingDB("hz_cygx")
  33. _, err = o.Insert(item)
  34. return
  35. }
  36. // 获取列表
  37. func GetCygxActivityMeetingHistoryLlist(activityId int) (items []*CygxActivityMeetingHistoryResp, err error) {
  38. o := orm.NewOrmUsingDB("hz_cygx")
  39. sql := ` SELECT * FROM cygx_activity_meeting_history WHERE activity_id= ? AND role_type_code IN ('rai_seller','rai_group') ORDER BY id DESC `
  40. _, err = o.Raw(sql, activityId).QueryRows(&items)
  41. return
  42. }
  43. // 获取最新详情
  44. func GetCygxActivityMeetingHistoryNew(activityId, adminId int) (item *CygxActivityMeetingHistory, err error) {
  45. o := orm.NewOrmUsingDB("hz_cygx")
  46. sql := `SELECT * FROM cygx_activity_meeting_history WHERE activity_id=? AND admin_id = ? ORDER BY id DESC LIMIT 1 `
  47. err = o.Raw(sql, activityId, adminId).QueryRow(&item)
  48. return
  49. }
  50. // 更新阅读时间
  51. func UpdateActivityMeetingHistoryTime(stipTime, id int) (err error) {
  52. o := orm.NewOrmUsingDB("hz_cygx")
  53. sql := ` UPDATE cygx_activity_meeting_history SET stop_time=? WHERE id=?`
  54. _, err = o.Raw(sql, stipTime, id).Exec()
  55. return
  56. }