yb_research_signup_statistics.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // YbResearchSignupStatistics 调研报名统计结构体
  7. type YbResearchSignupStatistics struct {
  8. YbResearchSignupStatisticsId int // 主键ID
  9. UserId int // 分享人ID
  10. RealName string // 分享人姓名
  11. Mobile string // 分享人手机号
  12. CompanyName string // 公司名称
  13. BannerId int // 活动ID
  14. CreateTime time.Time // 创建时间
  15. Amount float64 // 付款金额
  16. CustomName string // 报名人姓名
  17. CustomMobile string // 报名人手机号
  18. CustomCompanyName string // 报名人公司名称
  19. }
  20. type YbResearchSignupStatisticsListItem struct {
  21. YbResearchSignupStatisticsId int // 主键ID
  22. BannerId int // 活动ID
  23. Amount float64 // 付款金额
  24. Count int // 报名人数
  25. Remark string // 备注-活动名称
  26. StartDate string // 活动开始时间
  27. EndDate string // 活动结束时间
  28. Enable int // 1:有效,0:禁用
  29. }
  30. func GetYbResearchSignupStatisticsItems() (items []*YbResearchSignupStatisticsListItem, err error) {
  31. sql := ` SELECT
  32. a.*,
  33. b.start_date,
  34. b.end_date,
  35. b.remark,
  36. b.enable,
  37. COUNT( 1 ) AS count
  38. FROM
  39. yb_research_signup_statistics AS a
  40. INNER JOIN banner AS b ON a.banner_id = b.id
  41. WHERE
  42. 1 = 1
  43. GROUP BY
  44. a.banner_id
  45. ORDER BY
  46. start_date DESC `
  47. o := orm.NewOrm()
  48. _, err = o.Raw(sql).QueryRows(&items)
  49. return
  50. }
  51. type YbResearchSignupStatisticsResp struct {
  52. OngoingList []*YbResearchSignupStatisticsListItem
  53. OverList []*YbResearchSignupStatisticsListItem
  54. }
  55. type YbResearchSignupStatisticsItem struct {
  56. YbResearchSignupStatisticsId int // 主键ID
  57. UserId int // 分享人ID
  58. RealName string // 分享人姓名
  59. Mobile string // 分享人手机号
  60. CompanyName string // 公司名称
  61. BannerId int // 活动ID
  62. CreateTime string // 创建时间
  63. Amount float64 // 付款金额
  64. CustomName string // 报名人姓名
  65. CustomMobile string // 报名人手机号
  66. CustomCompanyName string // 报名人公司名称
  67. Count int // 报名人数
  68. Enable int // 1:有效,0:禁用
  69. }
  70. type YbResearchSignupStatisticsItemsResp struct {
  71. List []*YbResearchSignupStatisticsItem
  72. Total int
  73. HasPayed PayItem
  74. NoPay PayItem
  75. }
  76. type PayItem struct {
  77. Name string
  78. Count int
  79. Amount float64
  80. Percentage int
  81. }
  82. func GetYbResearchSignupStatisticsItemsById(bannerId int) (items []*YbResearchSignupStatisticsItem, err error) {
  83. sql := ` SELECT
  84. *,count(1) as count
  85. FROM
  86. yb_research_signup_statistics
  87. WHERE
  88. 1 = 1 and banner_id = ?
  89. GROUP BY
  90. mobile
  91. ORDER BY
  92. count DESC `
  93. o := orm.NewOrm()
  94. _, err = o.Raw(sql, bannerId).QueryRows(&items)
  95. return
  96. }
  97. func GetYbResearchSignupStatisticsItemsByMobile(mobile string, bannerId int) (items []*YbResearchSignupStatisticsItem, err error) {
  98. sql := `SELECT
  99. a.*,b.enable
  100. FROM
  101. yb_research_signup_statistics AS a
  102. INNER JOIN banner AS b ON a.banner_id = b.id
  103. WHERE
  104. 1 = 1 AND mobile = ? and banner_id = ?
  105. ORDER BY
  106. create_time DESC `
  107. o := orm.NewOrm()
  108. _, err = o.Raw(sql, mobile, bannerId).QueryRows(&items)
  109. return
  110. }
  111. // UpdateYbResearchSignupStatistics 更新付款金额
  112. func UpdateYbResearchSignupStatisticsAmountById(amount float64, id int) (err error) {
  113. o := orm.NewOrm()
  114. sql := `UPDATE yb_research_signup_statistics SET amount=? WHERE yb_research_signup_statistics_id=?`
  115. _, err = o.Raw(sql, amount, id).Exec()
  116. return
  117. }
  118. func GetYbResearchSignupStatisticsAmount(bannerId int) (items []*YbResearchSignupStatisticsListItem, err error) {
  119. sql := ` SELECT
  120. a.*
  121. FROM
  122. yb_research_signup_statistics AS a
  123. INNER JOIN banner AS b ON a.banner_id = b.id
  124. WHERE
  125. 1 = 1 AND a.banner_id = ? `
  126. o := orm.NewOrm()
  127. _, err = o.Raw(sql, bannerId).QueryRows(&items)
  128. return
  129. }