yb_research_signup_statistics.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. list, err := models.GetYbResearchSignupStatisticsItemsById(bannerId)
  52. if err != nil {
  53. br.Msg = "获取失败"
  54. br.ErrMsg = "获取失败,Err:" + err.Error()
  55. return
  56. }
  57. var resp models.YbResearchSignupStatisticsItemsResp
  58. resp.List = list
  59. for _, v := range list {
  60. resp.Total += v.Count
  61. }
  62. br.Ret = 200
  63. br.Success = true
  64. br.Msg = "获取成功"
  65. br.Data = resp
  66. }
  67. // @Title 调研报名统计列表
  68. // @Description 获取分类
  69. // @Param Mobile query int true "分享人手机号"
  70. // @Success 200 {object} models.BannerListResp
  71. // @router /research_statistics/detail [get]
  72. func (this *BannerController) StatisticsDetail() {
  73. br := new(models.BaseResponse).Init()
  74. defer func() {
  75. this.Data["json"] = br
  76. this.ServeJSON()
  77. }()
  78. mobile := this.GetString("Mobile")
  79. if mobile == "" {
  80. br.Msg = "参数错误"
  81. br.ErrMsg = "参数错误"
  82. return
  83. }
  84. list, err := models.GetYbResearchSignupStatisticsItemsByMobile(mobile)
  85. if err != nil {
  86. br.Msg = "获取失败"
  87. br.ErrMsg = "获取失败,Err:" + err.Error()
  88. return
  89. }
  90. br.Ret = 200
  91. br.Success = true
  92. br.Msg = "获取成功"
  93. br.Data = list
  94. }
  95. // @Title 调研报名统计列表
  96. // @Description 获取分类
  97. // @Param Amount query float64 true "付款金额"
  98. // @Param YbResearchSignupStatisticsId query int true "报名id"
  99. // @Success 200 {object} models.BannerListResp
  100. // @router /research_statistics/amount [get]
  101. func (this *BannerController) Amount() {
  102. br := new(models.BaseResponse).Init()
  103. defer func() {
  104. this.Data["json"] = br
  105. this.ServeJSON()
  106. }()
  107. ybResearchSignupStatisticsId, _ := this.GetInt("YbResearchSignupStatisticsId")
  108. amount, _ := this.GetFloat("Amount")
  109. if ybResearchSignupStatisticsId <= 0 {
  110. br.Msg = "参数错误"
  111. br.ErrMsg = "参数错误"
  112. return
  113. }
  114. err := models.UpdateYbResearchSignupStatisticsAmountById(amount, ybResearchSignupStatisticsId)
  115. if err != nil {
  116. br.Msg = "更新付款金额失败"
  117. br.ErrMsg = "UpdateYbResearchSignupStatisticsAmountById,Err:" + err.Error()
  118. return
  119. }
  120. br.Ret = 200
  121. br.Success = true
  122. br.Msg = "修改成功"
  123. }