yb_research_signup_statistics.go 3.6 KB

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