activity_points_set.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type YanXuanActivityPointsRedis struct {
  7. UserId int `description:"用户ID"`
  8. ComapnyId int `description:"公司ID"`
  9. ActivityId int `description:"活动ID"`
  10. PublishStatus int `description:"发布状态 1已发布,0未发布"`
  11. SourceType int `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
  12. AdminId int `description:"管理员、销售ID"`
  13. Source int `description:" 来源,1客户端,2后台添加, 3开发人员手动添加、4定时任务"`
  14. RegisterPlatform int `description:"来源 1小程序,2:网页"`
  15. CreateTime time.Time `description:"创建时间"`
  16. }
  17. type CygxActivityPointsSet struct {
  18. Id int `gorm:"column:id;primary_key;AUTO_INCREMENT" json:"id"`
  19. ActivityId int `gorm:"column:activity_id;NOT NULL" json:"activity_id"` // 活动ID
  20. PointsObject int `gorm:"column:points_object;default:1;NOT NULL" json:"points_object"` // 扣点对象,1:参会人、2:办会人、3:办会人和参会人
  21. CompanyId int `gorm:"column:company_id;default:0;NOT NULL" json:"company_id"` // 公司ID
  22. CompanyName float64 `gorm:"column:company_name;NOT NULL" json:"company_name"` // 公司名称
  23. UserPointsNum float64 `gorm:"column:user_points_num;default:0;NOT NULL" json:"user_points_num"` // 参会人扣点数量
  24. PointsType int `gorm:"column:points_type;default:0;NOT NULL" json:"points_type"` // 扣点形式,1:报名即扣点,2:到会即扣点
  25. CompanyPointsNum float64 `gorm:"column:company_points_num;default:0;NOT NULL" json:"company_points_num"` // 办会人扣点数量
  26. CancelDeadlineType int `description:"取消报名截止时间类型,0:不设置,1:同报名截止时间, 2:24小时之前、3:48小时之前"`
  27. CreateTime time.Time `gorm:"column:create_time;NOT NULL" json:"create_time"` // 创建时间
  28. ModifyTime time.Time `gorm:"column:modify_time;NOT NULL" json:"modify_time"` // 更新时间
  29. }
  30. // 通过活动ID获取详情
  31. func GetCygxActivityPointsSetDetail(activityId int) (item *CygxActivityPointsSet, err error) {
  32. o := orm.NewOrm()
  33. sql := `SELECT * FROM cygx_activity_points_set WHERE activity_id=? `
  34. err = o.Raw(sql, activityId).QueryRow(&item)
  35. return
  36. }
  37. // 通过活动ID获取详情
  38. func GetCygxActivityPointsSetUserNum(activityId int) (userPointsNum float64, err error) {
  39. o := orm.NewOrm()
  40. sql := `SELECT user_points_num FROM cygx_activity_points_set WHERE activity_id=? `
  41. err = o.Raw(sql, activityId).QueryRow(&userPointsNum)
  42. return
  43. }
  44. // 通过互动ID获取数量
  45. func GetCygxActivityPointsSetCountByActivityId(ActivityId int) (count int, err error) {
  46. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_activity_points_set WHERE activity_id=? `
  47. o := orm.NewOrm()
  48. err = o.Raw(sqlCount, ActivityId).QueryRow(&count)
  49. return
  50. }
  51. // 列表
  52. func GetCygxActivityPointsSetList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityPointsSet, err error) {
  53. o := orm.NewOrm()
  54. sql := `SELECT * FROM cygx_activity_points_set as art WHERE 1= 1 `
  55. if condition != "" {
  56. sql += condition
  57. }
  58. if startSize+pageSize == 0 {
  59. _, err = o.Raw(sql, pars).QueryRows(&items)
  60. } else {
  61. sql += ` LIMIT ?,? `
  62. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  63. }
  64. return
  65. }