synthesis.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. // FindUserLogHistory 近30天每天的U提现 新注册用户数
  41. func (s *Synthesis) FindUserLogHistory(ctx *gin.Context) {
  42. req := &entity.UserLogDailyReq{}
  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.FindUserLogHistory()
  51. if err != nil {
  52. ctx.JSON(200, gin.H{
  53. "code": 400,
  54. "msg": err.Error(),
  55. })
  56. return
  57. }
  58. ctx.JSON(200, gin.H{
  59. "code": 200,
  60. "msg": "success",
  61. "data": resp,
  62. })
  63. }
  64. // FindUserLogTotal 查询总提现数量,总注册人数,
  65. func (s *Synthesis) FindUserLogTotal(ctx *gin.Context) {
  66. resp, err := s.sev.FindMDBUserLogTotal()
  67. if err != nil {
  68. ctx.JSON(200, gin.H{
  69. "code": 400,
  70. "msg": err.Error(),
  71. })
  72. return
  73. }
  74. ctx.JSON(200, gin.H{
  75. "code": 200,
  76. "msg": "success",
  77. "data": resp,
  78. })
  79. }
  80. // FindUserRetention 查询用户留存
  81. func (s *Synthesis) FindUserRetention(ctx *gin.Context) {
  82. req := &entity.UserRetentionReq{}
  83. if err := ctx.ShouldBindJSON(req); err != nil {
  84. ctx.JSON(200, gin.H{
  85. "code": 400,
  86. "msg": err.Error(),
  87. })
  88. return
  89. }
  90. resp, err := s.sev.FindUserRetention(req)
  91. if err != nil {
  92. ctx.JSON(200, gin.H{
  93. "code": 400,
  94. "msg": err.Error(),
  95. })
  96. return
  97. } else {
  98. ctx.JSON(200, gin.H{
  99. "code": 200,
  100. "msg": "success",
  101. "data": resp,
  102. "total": req.Total,
  103. })
  104. }
  105. }
  106. // FindUserCountryCount 查询用户国家分布
  107. func (s *Synthesis) FindUserCountryCount(ctx *gin.Context) {
  108. resp, err := s.sev.FindUserCountryCount()
  109. if err != nil {
  110. ctx.JSON(200, gin.H{
  111. "code": 400,
  112. "msg": err.Error(),
  113. })
  114. return
  115. } else {
  116. ctx.JSON(200, gin.H{
  117. "code": 200,
  118. "msg": "success",
  119. "data": resp,
  120. })
  121. }
  122. }
  123. // FindWithdrawal 查询提现记录
  124. func (s *Synthesis) FindWithdrawal(ctx *gin.Context) {
  125. req := &entity.UserWithdrawalReq{}
  126. if err := ctx.ShouldBindJSON(req); err != nil {
  127. ctx.JSON(200, gin.H{
  128. "code": 400,
  129. "msg": err.Error(),
  130. })
  131. return
  132. }
  133. var total int64
  134. resp, total, err := s.sev.FindWithdrawal(req)
  135. if err != nil {
  136. ctx.JSON(200, gin.H{
  137. "code": 400,
  138. "msg": err.Error(),
  139. })
  140. return
  141. } else {
  142. ctx.JSON(200, gin.H{
  143. "code": 200,
  144. "msg": "success",
  145. "data": resp,
  146. "total": total,
  147. })
  148. }
  149. }
  150. // WithdrawalStatus 修改提现状态
  151. func (s *Synthesis) WithdrawalStatus(ctx *gin.Context) {
  152. req := &entity.UserWithdrawalStatus{}
  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.WithdrawalStatus(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. // WithdrawalStatusBatch 修改提现状态批量
  175. func (s *Synthesis) WithdrawalStatusBatch(ctx *gin.Context) {
  176. req := &entity.UserWithdrawalStatusBatch{}
  177. if err := ctx.ShouldBindJSON(req); err != nil {
  178. ctx.JSON(200, gin.H{
  179. "code": 400,
  180. "msg": err.Error(),
  181. })
  182. return
  183. }
  184. err := s.sev.WithdrawalStatusBatch(req)
  185. if err != nil {
  186. ctx.JSON(200, gin.H{
  187. "code": 400,
  188. "msg": err.Error(),
  189. })
  190. return
  191. } else {
  192. ctx.JSON(200, gin.H{
  193. "code": 200,
  194. "msg": "success",
  195. })
  196. }
  197. }
  198. // FindUserLevel 查询用户等级
  199. func (s *Synthesis) FindUserLevel(ctx *gin.Context) {
  200. resp, err := s.sev.FindUserLevel()
  201. if err != nil {
  202. ctx.JSON(200, gin.H{
  203. "code": 400,
  204. "msg": err.Error(),
  205. })
  206. return
  207. } else {
  208. ctx.JSON(200, gin.H{
  209. "code": 200,
  210. "msg": "success",
  211. "data": resp,
  212. })
  213. }
  214. }