|
@@ -9,6 +9,7 @@ import (
|
|
|
"strconv"
|
|
|
"time"
|
|
|
|
|
|
+ mhayaTime "github.com/mhaya/extend/time"
|
|
|
"github.com/mhaya/game/game_cluster/internal/constant"
|
|
|
"github.com/mhaya/game/game_cluster/internal/mdb"
|
|
|
"github.com/mhaya/game/game_cluster/internal/mdb/models"
|
|
@@ -166,6 +167,65 @@ func (s *Synthesis) FindMDBUserLogTotal() (*entity.UserLogTotalResp, error) {
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
+// FindUserLogHistory 近30天每天的U提现 新注册用户数
|
|
|
+func (s *Synthesis) FindUserLogHistory() ([]*entity.UserLogHistoryResp, 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": mhayaTime.Now().StartOfDay().Add(-30 * 24 * time.Hour).Unix(),
|
|
|
+ "$lte": mhayaTime.Now().Unix(),
|
|
|
+ }
|
|
|
+
|
|
|
+ cursor, err := collection.Find(ctx, filter, nil)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ defer cursor.Close(ctx)
|
|
|
+
|
|
|
+ // 解析查询结果
|
|
|
+ var results []*entity.UserLogHistoryResp
|
|
|
+
|
|
|
+ for cursor.Next(ctx) {
|
|
|
+ var result *entity.UserLogHistoryResp
|
|
|
+ err := cursor.Decode(&result)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ results = append(results, result)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 合并每日的数据
|
|
|
+ allPlatformRecordMap := make(map[int64]*entity.UserLogHistoryResp)
|
|
|
+ for _, result := range results {
|
|
|
+ item, exist := allPlatformRecordMap[result.Timestamp]
|
|
|
+ if !exist {
|
|
|
+ allPlatformRecordMap[result.Timestamp] = &entity.UserLogHistoryResp{
|
|
|
+ Timestamp: result.Timestamp,
|
|
|
+ Registered: result.Registered,
|
|
|
+ UCashout: result.UCashout,
|
|
|
+ }
|
|
|
+
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ item.Registered += result.Registered
|
|
|
+ item.UCashout += result.UCashout
|
|
|
+ allPlatformRecordMap[result.Timestamp] = item
|
|
|
+ }
|
|
|
+
|
|
|
+ results = make([]*entity.UserLogHistoryResp, 0, len(allPlatformRecordMap))
|
|
|
+
|
|
|
+ for _, v := range allPlatformRecordMap {
|
|
|
+ results = append(results, v)
|
|
|
+ }
|
|
|
+
|
|
|
+ return results, nil
|
|
|
+}
|
|
|
+
|
|
|
// FindWithdrawal 根据请求查询提现记录
|
|
|
func (s *Synthesis) FindWithdrawal(req *entity.UserWithdrawalReq) ([]*entity.UserWithdrawalResp, int64, error) {
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
|
|
@@ -178,7 +238,7 @@ func (s *Synthesis) FindWithdrawal(req *entity.UserWithdrawalReq) ([]*entity.Use
|
|
|
filter["userName"] = req.UserName
|
|
|
}
|
|
|
if req.NickName != "" {
|
|
|
- filter["nickName"] = req.NickName
|
|
|
+ filter["nickName"] = bson.M{"$regex": escapeRegex(req.NickName), "$options": "i"}
|
|
|
}
|
|
|
if req.ID != "" {
|
|
|
filter["_id"], _ = primitive.ObjectIDFromHex(req.ID)
|