synthesis.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. // FindUserLogTotal 查询总提现数量,总注册人数,
  41. func (s *Synthesis) FindUserLogTotal(ctx *gin.Context) {
  42. resp, err := s.sev.FindMDBUserLogTotal()
  43. if err != nil {
  44. ctx.JSON(200, gin.H{
  45. "code": 400,
  46. "msg": err.Error(),
  47. })
  48. return
  49. }
  50. ctx.JSON(200, gin.H{
  51. "code": 200,
  52. "msg": "success",
  53. "data": resp,
  54. })
  55. }
  56. // FindUserRetention 查询用户留存
  57. func (s *Synthesis) FindUserRetention(ctx *gin.Context) {
  58. req := &entity.UserRetentionReq{}
  59. if err := ctx.ShouldBindJSON(req); err != nil {
  60. ctx.JSON(200, gin.H{
  61. "code": 400,
  62. "msg": err.Error(),
  63. })
  64. return
  65. }
  66. resp, err := s.sev.FindUserRetention(req)
  67. if err != nil {
  68. ctx.JSON(200, gin.H{
  69. "code": 400,
  70. "msg": err.Error(),
  71. })
  72. return
  73. } else {
  74. ctx.JSON(200, gin.H{
  75. "code": 200,
  76. "msg": "success",
  77. "data": resp,
  78. "total": req.Total,
  79. })
  80. }
  81. }
  82. // FindUserCountryCount 查询用户国家分布
  83. func (s *Synthesis) FindUserCountryCount(ctx *gin.Context) {
  84. resp, err := s.sev.FindUserCountryCount()
  85. if err != nil {
  86. ctx.JSON(200, gin.H{
  87. "code": 400,
  88. "msg": err.Error(),
  89. })
  90. return
  91. } else {
  92. ctx.JSON(200, gin.H{
  93. "code": 200,
  94. "msg": "success",
  95. "data": resp,
  96. })
  97. }
  98. }
  99. // FindWithdrawal 查询提现记录
  100. func (s *Synthesis) FindWithdrawal(ctx *gin.Context) {
  101. req := &entity.UserWithdrawalReq{}
  102. if err := ctx.ShouldBindJSON(req); err != nil {
  103. ctx.JSON(200, gin.H{
  104. "code": 400,
  105. "msg": err.Error(),
  106. })
  107. return
  108. }
  109. var total int64
  110. resp, total, err := s.sev.FindWithdrawal(req)
  111. if err != nil {
  112. ctx.JSON(200, gin.H{
  113. "code": 400,
  114. "msg": err.Error(),
  115. })
  116. return
  117. } else {
  118. ctx.JSON(200, gin.H{
  119. "code": 200,
  120. "msg": "success",
  121. "data": resp,
  122. "total": total,
  123. })
  124. }
  125. }
  126. // WithdrawalStatus 修改提现状态
  127. func (s *Synthesis) WithdrawalStatus(ctx *gin.Context) {
  128. req := &entity.UserWithdrawalStatus{}
  129. if err := ctx.ShouldBindJSON(req); err != nil {
  130. ctx.JSON(200, gin.H{
  131. "code": 400,
  132. "msg": err.Error(),
  133. })
  134. return
  135. }
  136. err := s.sev.WithdrawalStatus(req)
  137. if err != nil {
  138. ctx.JSON(200, gin.H{
  139. "code": 400,
  140. "msg": err.Error(),
  141. })
  142. return
  143. } else {
  144. ctx.JSON(200, gin.H{
  145. "code": 200,
  146. "msg": "success",
  147. })
  148. }
  149. }
  150. // WithdrawalStatusBatch 修改提现状态批量
  151. func (s *Synthesis) WithdrawalStatusBatch(ctx *gin.Context) {
  152. req := &entity.UserWithdrawalStatusBatch{}
  153. if err := ctx.ShouldBindJSON(req); err != nil {
  154. ctx.JSON(200, gin.H{
  155. "code": 400,
  156. "msg": err.Error(),
  157. })
  158. return
  159. }
  160. err := s.sev.WithdrawalStatusBatch(req)
  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. })
  172. }
  173. }
  174. // FindUserLevel 查询用户等级
  175. func (s *Synthesis) FindUserLevel(ctx *gin.Context) {
  176. resp, err := s.sev.FindUserLevel()
  177. if err != nil {
  178. ctx.JSON(200, gin.H{
  179. "code": 400,
  180. "msg": err.Error(),
  181. })
  182. return
  183. } else {
  184. ctx.JSON(200, gin.H{
  185. "code": 200,
  186. "msg": "success",
  187. "data": resp,
  188. })
  189. }
  190. }