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