activity_special_trip.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package models
  2. import (
  3. //"hongze/hongze_admin/models"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. type CygxActivitySpecialTrip struct {
  8. Id int `orm:"column(id);pk"`
  9. UserId int `description:"用户id,多个用,隔开"`
  10. ActivityId int `description:"活动ID"`
  11. CreateTime time.Time `description:"创建时间"`
  12. Mobile string `description:"手机号"`
  13. Email string `description:"邮箱号"`
  14. CompanyId int `description:"公司ID"`
  15. CompanyName string `description:"公司名称"`
  16. RealName string `description:"用户实际名称"`
  17. SellerName string `description:"所属销售"`
  18. AdminId int `description:"销售/管理员ID"`
  19. Source int `description:"来源,1小程序,2后台添加"`
  20. OutboundMobile string `description:"外呼手机号"`
  21. CountryCode string `description:"手机国家区号"`
  22. }
  23. type CygxActivitySpecialTripResp struct {
  24. Id int `description:"ID"`
  25. UserId int `description:"用户id"`
  26. ActivityId int `description:"活动ID"`
  27. CreateTime string `description:"创建时间"`
  28. Mobile string `description:"手机号"`
  29. Email string `description:"邮箱号"`
  30. CompanyId int `description:"公司ID"`
  31. CompanyName string `description:"公司名称"`
  32. RealName string `description:"用户实际名称"`
  33. SellerName string `description:"所属销售"`
  34. OutboundMobile string `description:"外呼手机号"`
  35. CountryCode string `description:"手机国家区号"`
  36. }
  37. func GetCygxActivitySpecialTripList(condition string, pars []interface{}) (item []*CygxActivitySpecialTripResp, err error) {
  38. o := orm.NewOrm()
  39. sql := `SELECT *
  40. FROM
  41. cygx_activity_special_trip
  42. WHERE 1 = 1 ` + condition
  43. _, err = o.Raw(sql, pars).QueryRows(&item)
  44. return
  45. }
  46. //获取某一用户的报名的数量
  47. func GetUserActivitySpecialTripCount(uid, activityId int) (count int, err error) {
  48. sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_trip WHERE user_id=? AND activity_id =? `
  49. o := orm.NewOrm()
  50. err = o.Raw(sqlCount, uid, activityId).QueryRow(&count)
  51. return
  52. }
  53. //获取某一活动的报名的数量
  54. func GetActivitySpecialTripCountByActivityId(condition string, pars []interface{}) (count int, err error) {
  55. sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_trip WHERE 1 = 1 ` + condition
  56. o := orm.NewOrm()
  57. err = o.Raw(sqlCount, pars).QueryRow(&count)
  58. return
  59. }
  60. //获取某一活动的报名的数量 (同时关联活动类型进行获取)
  61. func GetActivitySpecialTripCountByActivitySpecial(condition string, pars []interface{}) (count int, err error) {
  62. sqlCount := ` SELECT COUNT(1) AS count
  63. FROM
  64. cygx_activity_special_trip AS t
  65. INNER JOIN cygx_activity_special AS a ON a.activity_id = t.activity_id
  66. WHERE
  67. 1= 1 ` + condition
  68. o := orm.NewOrm()
  69. err = o.Raw(sqlCount, pars).QueryRow(&count)
  70. return
  71. }
  72. //添加
  73. func AddCygxActivitySpecialTrip(item *CygxActivitySpecialTrip) (err error) {
  74. o := orm.NewOrm()
  75. _, err = o.Insert(item)
  76. return
  77. }
  78. //取消
  79. func CancelActivitySpecialTrip(uid int, item *CygxActivitySpecialDetail) (err error) {
  80. o := orm.NewOrm()
  81. sql := `DELETE FROM cygx_activity_special_trip WHERE user_id=? AND activity_id=? `
  82. _, err = o.Raw(sql, uid, item.ActivityId).Exec()
  83. return
  84. }