yb_research_signup_statistics.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. package controllers
  2. import (
  3. "hongze/hz_crm_api/models"
  4. )
  5. // @Title 调研报名统计列表
  6. // @Description 获取分类
  7. // @Success 200 {object} models.BannerListResp
  8. // @router /research_statistics/list [get]
  9. func (this *BannerController) StatisticsList() {
  10. br := new(models.BaseResponse).Init()
  11. defer func() {
  12. this.Data["json"] = br
  13. this.ServeJSON()
  14. }()
  15. list, err := models.GetYbResearchSignupStatisticsItems()
  16. if err != nil {
  17. br.Msg = "获取失败"
  18. br.ErrMsg = "获取失败,Err:" + err.Error()
  19. return
  20. }
  21. resp := new(models.YbResearchSignupStatisticsResp)
  22. for _, v := range list {
  23. if v.Enable == 1 {
  24. resp.OngoingList = append(resp.OngoingList, v)
  25. } else {
  26. resp.OverList = append(resp.OverList, v)
  27. }
  28. }
  29. br.Ret = 200
  30. br.Success = true
  31. br.Msg = "获取成功"
  32. br.Data = resp
  33. }
  34. // @Title 调研报名统计列表
  35. // @Description 获取分类
  36. // @Param BannerId query int true "图片id"
  37. // @Success 200 {object} models.BannerListResp
  38. // @router /research_statistics/item [get]
  39. func (this *BannerController) StatisticsItem() {
  40. br := new(models.BaseResponse).Init()
  41. defer func() {
  42. this.Data["json"] = br
  43. this.ServeJSON()
  44. }()
  45. bannerId, _ := this.GetInt("BannerId")
  46. if bannerId <= 0 {
  47. br.Msg = "参数错误"
  48. br.ErrMsg = "参数错误"
  49. return
  50. }
  51. var resp models.YbResearchSignupStatisticsItemsResp
  52. list, err := models.GetYbResearchSignupStatisticsItemsById(bannerId)
  53. if err != nil {
  54. br.Msg = "获取失败"
  55. br.ErrMsg = "GetYbResearchSignupStatisticsItemsById,Err:" + err.Error()
  56. return
  57. }
  58. resp.List = list
  59. for _, v := range list {
  60. resp.Total += v.Count
  61. }
  62. amountList, err := models.GetYbResearchSignupStatisticsAmount(bannerId)
  63. if err != nil {
  64. br.Msg = "获取失败"
  65. br.ErrMsg = "GetYbResearchSignupStatisticsAmount,Err:" + err.Error()
  66. return
  67. }
  68. for _, v := range amountList {
  69. if v.Amount > 0 {
  70. resp.HasPayed.Amount += v.Amount
  71. resp.HasPayed.Count += 1
  72. } else {
  73. resp.NoPay.Count += 1
  74. }
  75. }
  76. resp.HasPayed.Name = "已付款"
  77. resp.NoPay.Name = "未付款"
  78. resp.NoPay.Percentage = resp.NoPay.Count * 100 / resp.Total
  79. resp.HasPayed.Percentage = resp.HasPayed.Count * 100 / resp.Total
  80. br.Ret = 200
  81. br.Success = true
  82. br.Msg = "获取成功"
  83. br.Data = resp
  84. }
  85. // @Title 调研报名统计列表
  86. // @Description 获取分类
  87. // @Param Mobile query int true "分享人手机号"
  88. // @Success 200 {object} models.BannerListResp
  89. // @router /research_statistics/detail [get]
  90. func (this *BannerController) StatisticsDetail() {
  91. br := new(models.BaseResponse).Init()
  92. defer func() {
  93. this.Data["json"] = br
  94. this.ServeJSON()
  95. }()
  96. mobile := this.GetString("Mobile")
  97. bannerId, _ := this.GetInt("BannerId")
  98. if mobile == "" {
  99. br.Msg = "参数错误"
  100. br.ErrMsg = "参数错误"
  101. return
  102. }
  103. list, err := models.GetYbResearchSignupStatisticsItemsByMobile(mobile, bannerId)
  104. if err != nil {
  105. br.Msg = "获取失败"
  106. br.ErrMsg = "获取失败,Err:" + err.Error()
  107. return
  108. }
  109. br.Ret = 200
  110. br.Success = true
  111. br.Msg = "获取成功"
  112. br.Data = list
  113. }
  114. // @Title 调研报名统计列表
  115. // @Description 获取分类
  116. // @Param Amount query float64 true "付款金额"
  117. // @Param YbResearchSignupStatisticsId query int true "报名id"
  118. // @Success 200 {object} models.BannerListResp
  119. // @router /research_statistics/amount [get]
  120. func (this *BannerController) Amount() {
  121. br := new(models.BaseResponse).Init()
  122. defer func() {
  123. this.Data["json"] = br
  124. this.ServeJSON()
  125. }()
  126. ybResearchSignupStatisticsId, _ := this.GetInt("YbResearchSignupStatisticsId")
  127. amount, _ := this.GetFloat("Amount")
  128. if ybResearchSignupStatisticsId <= 0 {
  129. br.Msg = "参数错误"
  130. br.ErrMsg = "参数错误"
  131. return
  132. }
  133. err := models.UpdateYbResearchSignupStatisticsAmountById(amount, ybResearchSignupStatisticsId)
  134. if err != nil {
  135. br.Msg = "更新付款金额失败"
  136. br.ErrMsg = "UpdateYbResearchSignupStatisticsAmountById,Err:" + err.Error()
  137. return
  138. }
  139. br.Ret = 200
  140. br.Success = true
  141. br.Msg = "修改成功"
  142. }