activity_points_set.go 4.8 KB

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