yb_research_signup_statistics.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. }
  69. type YbResearchSignupStatisticsItemsResp struct {
  70. List []*YbResearchSignupStatisticsItem
  71. Total int
  72. HasPayed PayItem
  73. NoPay PayItem
  74. }
  75. type PayItem struct {
  76. Count int
  77. Amount float64
  78. Percentage int
  79. }
  80. func GetYbResearchSignupStatisticsItemsById(bannerId int) (items []*YbResearchSignupStatisticsItem, err error) {
  81. sql := ` SELECT
  82. *,count(1) as count
  83. FROM
  84. yb_research_signup_statistics
  85. WHERE
  86. 1 = 1 and banner_id = ?
  87. GROUP BY
  88. mobile
  89. ORDER BY
  90. count DESC `
  91. o := orm.NewOrm()
  92. _, err = o.Raw(sql, bannerId).QueryRows(&items)
  93. return
  94. }
  95. func GetYbResearchSignupStatisticsItemsByMobile(mobile string) (items []*YbResearchSignupStatisticsItem, err error) {
  96. sql := ` SELECT
  97. *
  98. FROM
  99. yb_research_signup_statistics
  100. WHERE
  101. 1 = 1 and mobile = ?
  102. ORDER BY
  103. create_time DESC `
  104. o := orm.NewOrm()
  105. _, err = o.Raw(sql, mobile).QueryRows(&items)
  106. return
  107. }
  108. // UpdateYbResearchSignupStatistics 更新付款金额
  109. func UpdateYbResearchSignupStatisticsAmountById(amount float64, id int) (err error) {
  110. o := orm.NewOrm()
  111. sql := `UPDATE yb_research_signup_statistics SET amount=? WHERE yb_research_signup_statistics_id=?`
  112. _, err = o.Raw(sql, amount, id).Exec()
  113. return
  114. }
  115. func GetYbResearchSignupStatisticsAmount(bannerId int) (items []*YbResearchSignupStatisticsListItem, err error) {
  116. sql := ` SELECT
  117. a.*
  118. FROM
  119. yb_research_signup_statistics AS a
  120. INNER JOIN banner AS b ON a.banner_id = b.id
  121. WHERE
  122. 1 = 1 AND a.banner_id = ? `
  123. o := orm.NewOrm()
  124. _, err = o.Raw(sql, bannerId).QueryRows(&items)
  125. return
  126. }