synthesis.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. package controller
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/mhaya/game/game_cluster/nodes/webadmin/entity"
  5. "github.com/mhaya/game/game_cluster/nodes/webadmin/service"
  6. )
  7. type Synthesis struct {
  8. sev *service.Synthesis
  9. }
  10. func NewSynthesis() *Synthesis {
  11. return &Synthesis{
  12. sev: service.NewSynthesis(),
  13. }
  14. }
  15. // FindUserLogDaily 查询用户日活跃
  16. func (s *Synthesis) FindUserLogDaily(ctx *gin.Context) {
  17. req := &entity.UserLogDailyReq{}
  18. if err := ctx.ShouldBindJSON(req); err != nil {
  19. ctx.JSON(200, gin.H{
  20. "code": 400,
  21. "msg": err.Error(),
  22. })
  23. return
  24. }
  25. resp, err := s.sev.FindMDBUserLogDaily(req)
  26. if err != nil {
  27. ctx.JSON(200, gin.H{
  28. "code": 400,
  29. "msg": err.Error(),
  30. })
  31. return
  32. }
  33. ctx.JSON(200, gin.H{
  34. "code": 200,
  35. "msg": "success",
  36. "data": resp,
  37. "total": req.Total,
  38. })
  39. }
  40. // FindUserRetention 查询用户留存
  41. func (s *Synthesis) FindUserRetention(ctx *gin.Context) {
  42. req := &entity.UserRetentionReq{}
  43. if err := ctx.ShouldBindJSON(req); err != nil {
  44. ctx.JSON(200, gin.H{
  45. "code": 400,
  46. "msg": err.Error(),
  47. })
  48. return
  49. }
  50. resp, err := s.sev.FindUserRetention(req)
  51. if err != nil {
  52. ctx.JSON(200, gin.H{
  53. "code": 400,
  54. "msg": err.Error(),
  55. })
  56. return
  57. } else {
  58. ctx.JSON(200, gin.H{
  59. "code": 200,
  60. "msg": "success",
  61. "data": resp,
  62. "total": req.Total,
  63. })
  64. }
  65. }
  66. // FindUserCountryCount 查询用户国家分布
  67. func (s *Synthesis) FindUserCountryCount(ctx *gin.Context) {
  68. resp, err := s.sev.FindUserCountryCount()
  69. if err != nil {
  70. ctx.JSON(200, gin.H{
  71. "code": 400,
  72. "msg": err.Error(),
  73. })
  74. return
  75. } else {
  76. ctx.JSON(200, gin.H{
  77. "code": 200,
  78. "msg": "success",
  79. "data": resp,
  80. })
  81. }
  82. }
  83. // FindWithdrawal 查询提现记录
  84. func (s *Synthesis) FindWithdrawal(ctx *gin.Context) {
  85. req := &entity.UserWithdrawalReq{}
  86. if err := ctx.ShouldBindJSON(req); err != nil {
  87. ctx.JSON(200, gin.H{
  88. "code": 400,
  89. "msg": err.Error(),
  90. })
  91. return
  92. }
  93. var total int64
  94. resp, total, err := s.sev.FindWithdrawal(req)
  95. if err != nil {
  96. ctx.JSON(200, gin.H{
  97. "code": 400,
  98. "msg": err.Error(),
  99. })
  100. return
  101. } else {
  102. ctx.JSON(200, gin.H{
  103. "code": 200,
  104. "msg": "success",
  105. "data": resp,
  106. "total": total,
  107. })
  108. }
  109. }
  110. // WithdrawalStatus 修改提现状态
  111. func (s *Synthesis) WithdrawalStatus(ctx *gin.Context) {
  112. req := &entity.UserWithdrawalStatus{}
  113. if err := ctx.ShouldBindJSON(req); err != nil {
  114. ctx.JSON(200, gin.H{
  115. "code": 400,
  116. "msg": err.Error(),
  117. })
  118. return
  119. }
  120. err := s.sev.WithdrawalStatus(req)
  121. if err != nil {
  122. ctx.JSON(200, gin.H{
  123. "code": 400,
  124. "msg": err.Error(),
  125. })
  126. return
  127. } else {
  128. ctx.JSON(200, gin.H{
  129. "code": 200,
  130. "msg": "success",
  131. })
  132. }
  133. }
  134. // WithdrawalStatusBatch 修改提现状态批量
  135. func (s *Synthesis) WithdrawalStatusBatch(ctx *gin.Context) {
  136. req := &entity.UserWithdrawalStatusBatch{}
  137. if err := ctx.ShouldBindJSON(req); err != nil {
  138. ctx.JSON(200, gin.H{
  139. "code": 400,
  140. "msg": err.Error(),
  141. })
  142. return
  143. }
  144. err := s.sev.WithdrawalStatusBatch(req)
  145. if err != nil {
  146. ctx.JSON(200, gin.H{
  147. "code": 400,
  148. "msg": err.Error(),
  149. })
  150. return
  151. } else {
  152. ctx.JSON(200, gin.H{
  153. "code": 200,
  154. "msg": "success",
  155. })
  156. }
  157. }
  158. // FindUserLevel 查询用户等级
  159. func (s *Synthesis) FindUserLevel(ctx *gin.Context) {
  160. resp, err := s.sev.FindUserLevel()
  161. if err != nil {
  162. ctx.JSON(200, gin.H{
  163. "code": 400,
  164. "msg": err.Error(),
  165. })
  166. return
  167. } else {
  168. ctx.JSON(200, gin.H{
  169. "code": 200,
  170. "msg": "success",
  171. "data": resp,
  172. })
  173. }
  174. }