Ver código fonte

update 新增查询总提现数量,总注册人数接口;完善提现记录过滤条件

Alvin 8 meses atrás
pai
commit
33c41d84ac

+ 17 - 0
game/game_cluster/nodes/webadmin/controller/synthesis.go

@@ -42,6 +42,23 @@ func (s *Synthesis) FindUserLogDaily(ctx *gin.Context) {
 	})
 }
 
+// FindUserLogTotal 查询总提现数量,总注册人数,
+func (s *Synthesis) FindUserLogTotal(ctx *gin.Context) {
+	resp, err := s.sev.FindMDBUserLogTotal()
+	if err != nil {
+		ctx.JSON(200, gin.H{
+			"code": 400,
+			"msg":  err.Error(),
+		})
+		return
+	}
+	ctx.JSON(200, gin.H{
+		"code": 200,
+		"msg":  "success",
+		"data": resp,
+	})
+}
+
 // FindUserRetention 查询用户留存
 func (s *Synthesis) FindUserRetention(ctx *gin.Context) {
 	req := &entity.UserRetentionReq{}

+ 5 - 0
game/game_cluster/nodes/webadmin/entity/user_log_daily.go

@@ -26,3 +26,8 @@ type UserLogDailyReq struct {
 	Size      int    `json:"size"`
 	Total     int64  `json:"total"`
 }
+
+type UserLogTotalResp struct {
+	Registered int     `bson:"registered" json:"registered"` // registered: 总注册人数
+	UCashout   float64 `bson:"u_cashout" json:"u_cashout"`   // u_cashout: 全服U的提现总值
+}

+ 2 - 2
game/game_cluster/nodes/webadmin/entity/user_withdrawal.go

@@ -24,8 +24,8 @@ type UserWithdrawalReq struct {
 	EndTime    int64  `json:"end_time"`                     // 结束时间
 	Page       int    `json:"page"`                         // 页码
 	Size       int    `json:"size"`                         // 每页数量
-	Withdrawal int    `json:"withdrawal" bson:"withdrawal"` // 提现 1:提现成功 2:提现中 3:提现失败 4:拒绝提现
-	Status     int    `json:"status" bson:"status"`         // 0:未审核 1:审核通过 2:审核失败
+	Withdrawal string `json:"withdrawal" bson:"withdrawal"` // 提现 1:提现成功 2:提现中 3:提现失败 4:拒绝提现
+	Status     string `json:"status" bson:"status"`         // 0:未审核 1:审核通过 2:审核失败
 	Address    string `json:"address" bson:"address"`       // 地址
 }
 

+ 1 - 0
game/game_cluster/nodes/webadmin/router/router.go

@@ -38,6 +38,7 @@ func (c *Controller) SetRouter() {
 
 func (c *Controller) InitApiRouter(u *gin.RouterGroup) {
 	u.Use(Auth())
+	u.POST("/user/log/total", controller.NewSynthesis().FindUserLogTotal)
 	u.POST("/user/log/daily", controller.NewSynthesis().FindUserLogDaily)
 	u.POST("/user/retention", controller.NewSynthesis().FindUserRetention)
 	u.POST("/user/country", controller.NewSynthesis().FindUserCountryCount)

+ 57 - 4
game/game_cluster/nodes/webadmin/service/synthesis.go

@@ -6,6 +6,7 @@ import (
 	"log"
 	"math"
 	"sort"
+	"strconv"
 	"time"
 
 	"github.com/mhaya/game/game_cluster/internal/constant"
@@ -121,6 +122,50 @@ func (s *Synthesis) FindMDBUserLogDaily(req *entity.UserLogDailyReq) ([]entity.U
 	return results, nil
 }
 
+// FindUserLogTotal 查询总提现数量,总注册人数,
+func (s *Synthesis) FindMDBUserLogTotal() (*entity.UserLogTotalResp, error) {
+	collection := mdb.MDB.Collection("playerDailyRecord")
+
+	ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
+	defer cancel()
+
+	filter := bson.M{}
+	filter["daily"] = bson.M{
+		"$gte": 0,
+	}
+
+	cursor, err := collection.Find(ctx, filter, nil)
+	if err != nil {
+		return nil, err
+	}
+	defer cursor.Close(ctx)
+
+	// 解析查询结果
+	var results []entity.UserLogDailyResp
+
+	for cursor.Next(ctx) {
+		var result entity.UserLogDailyResp
+		err := cursor.Decode(&result)
+		if err != nil {
+			return nil, err
+		}
+		results = append(results, result)
+	}
+
+	registerCount := 0
+	var uCashoutCount float64
+
+	for _, v := range results {
+		registerCount += v.Registered
+		uCashoutCount += v.UCashout
+	}
+
+	return &entity.UserLogTotalResp{
+		Registered: registerCount,
+		UCashout:   uCashoutCount,
+	}, nil
+}
+
 // FindWithdrawal 根据请求查询提现记录
 func (s *Synthesis) FindWithdrawal(req *entity.UserWithdrawalReq) ([]*entity.UserWithdrawalResp, int64, error) {
 	ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
@@ -146,16 +191,24 @@ func (s *Synthesis) FindWithdrawal(req *entity.UserWithdrawalReq) ([]*entity.Use
 		}
 	}
 
-	if req.Withdrawal >= 0 {
-		filter["withdrawal"] = req.Withdrawal
+	if req.Withdrawal != "" {
+		withdrawal, err := strconv.Atoi(req.Withdrawal)
+		if err != nil {
+			return nil, 0, err
+		}
+		filter["withdrawal"] = withdrawal
 	}
 
 	if req.Address != "" {
 		filter["address"] = req.Address
 	}
 
-	if req.Status >= 0 {
-		filter["status"] = req.Status
+	if req.Status != "" {
+		status, err := strconv.Atoi(req.Status)
+		if err != nil {
+			return nil, 0, err
+		}
+		filter["status"] = status
 	}
 
 	// 设置分页选项