yb_research_signup_statistics.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. if len(list) == 0 {
  59. br.Ret = 200
  60. br.Success = true
  61. br.Msg = "获取成功"
  62. return
  63. }
  64. resp.List = list
  65. for _, v := range list {
  66. resp.Total += v.Count
  67. }
  68. amountList, err := models.GetYbResearchSignupStatisticsAmount(bannerId)
  69. if err != nil {
  70. br.Msg = "获取失败"
  71. br.ErrMsg = "GetYbResearchSignupStatisticsAmount,Err:" + err.Error()
  72. return
  73. }
  74. for _, v := range amountList {
  75. if v.Amount > 0 {
  76. resp.HasPayed.Amount += v.Amount
  77. resp.HasPayed.Count += 1
  78. } else {
  79. resp.NoPay.Count += 1
  80. }
  81. }
  82. resp.HasPayed.Name = "已付款"
  83. resp.NoPay.Name = "未付款"
  84. resp.NoPay.Percentage = resp.NoPay.Count * 100 / resp.Total
  85. resp.HasPayed.Percentage = resp.HasPayed.Count * 100 / resp.Total
  86. br.Ret = 200
  87. br.Success = true
  88. br.Msg = "获取成功"
  89. br.Data = resp
  90. }
  91. // @Title 调研报名统计列表
  92. // @Description 获取分类
  93. // @Param Mobile query int true "分享人手机号"
  94. // @Success 200 {object} models.BannerListResp
  95. // @router /research_statistics/detail [get]
  96. func (this *BannerController) StatisticsDetail() {
  97. br := new(models.BaseResponse).Init()
  98. defer func() {
  99. this.Data["json"] = br
  100. this.ServeJSON()
  101. }()
  102. mobile := this.GetString("Mobile")
  103. bannerId, _ := this.GetInt("BannerId")
  104. if mobile == "" {
  105. br.Msg = "参数错误"
  106. br.ErrMsg = "参数错误"
  107. return
  108. }
  109. list, err := models.GetYbResearchSignupStatisticsItemsByMobile(mobile, bannerId)
  110. if err != nil {
  111. br.Msg = "获取失败"
  112. br.ErrMsg = "获取失败,Err:" + err.Error()
  113. return
  114. }
  115. br.Ret = 200
  116. br.Success = true
  117. br.Msg = "获取成功"
  118. br.Data = list
  119. }
  120. // @Title 调研报名统计列表
  121. // @Description 获取分类
  122. // @Param Amount query float64 true "付款金额"
  123. // @Param YbResearchSignupStatisticsId query int true "报名id"
  124. // @Success 200 {object} models.BannerListResp
  125. // @router /research_statistics/amount [get]
  126. func (this *BannerController) Amount() {
  127. br := new(models.BaseResponse).Init()
  128. defer func() {
  129. this.Data["json"] = br
  130. this.ServeJSON()
  131. }()
  132. ybResearchSignupStatisticsId, _ := this.GetInt("YbResearchSignupStatisticsId")
  133. amount, _ := this.GetFloat("Amount")
  134. if ybResearchSignupStatisticsId <= 0 {
  135. br.Msg = "参数错误"
  136. br.ErrMsg = "参数错误"
  137. return
  138. }
  139. err := models.UpdateYbResearchSignupStatisticsAmountById(amount, ybResearchSignupStatisticsId)
  140. if err != nil {
  141. br.Msg = "更新付款金额失败"
  142. br.ErrMsg = "UpdateYbResearchSignupStatisticsAmountById,Err:" + err.Error()
  143. return
  144. }
  145. br.Ret = 200
  146. br.Success = true
  147. br.Msg = "修改成功"
  148. }