|
@@ -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
|
|
|
}
|
|
|
|
|
|
// 设置分页选项
|