|
@@ -2,9 +2,11 @@ package service
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
+ "fmt"
|
|
|
"math"
|
|
|
"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"
|
|
|
"github.com/mhaya/game/game_cluster/nodes/webadmin/entity"
|
|
@@ -36,7 +38,7 @@ func (s *Synthesis) FindMDBUserLogDaily(req *entity.UserLogDailyReq) ([]entity.U
|
|
|
filter := bson.M{}
|
|
|
|
|
|
if req.StartTime != 0 {
|
|
|
- filter["timestamp"] = bson.M{
|
|
|
+ filter["daily"] = bson.M{
|
|
|
"$gte": req.StartTime,
|
|
|
"$lte": req.EndTime,
|
|
|
}
|
|
@@ -112,7 +114,7 @@ func (s *Synthesis) FindMDBUserLogDaily(req *entity.UserLogDailyReq) ([]entity.U
|
|
|
func (s *Synthesis) FindWithdrawal(req *entity.UserWithdrawalReq) ([]*entity.UserWithdrawalResp, error) {
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
|
|
|
defer cancel()
|
|
|
- collection := mdb.MDB.Collection("CashOutRecord")
|
|
|
+ collection := mdb.MDB.Collection("cashOutRecord ")
|
|
|
|
|
|
// 构建过滤器
|
|
|
filter := bson.M{}
|
|
@@ -122,13 +124,14 @@ func (s *Synthesis) FindWithdrawal(req *entity.UserWithdrawalReq) ([]*entity.Use
|
|
|
if req.NickName != "" {
|
|
|
filter["nickName"] = req.NickName
|
|
|
}
|
|
|
- if req.StartTime > 0 && req.EndTime > 0 {
|
|
|
- filter["createdAt"] = bson.M{"$gte": time.Unix(req.StartTime, 0), "$lte": time.Unix(req.EndTime, 0)}
|
|
|
- } else if req.StartTime > 0 {
|
|
|
- filter["createdAt"] = bson.M{"$gte": time.Unix(req.StartTime, 0)}
|
|
|
- } else if req.EndTime > 0 {
|
|
|
- filter["createdAt"] = bson.M{"$lte": time.Unix(req.EndTime, 0)}
|
|
|
+
|
|
|
+ if req.StartTime != 0 {
|
|
|
+ filter["createAt"] = bson.M{
|
|
|
+ "$gte": req.StartTime,
|
|
|
+ "$lte": req.EndTime,
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
// 设置分页选项
|
|
|
findOptions := options.Find()
|
|
|
findOptions.SetSkip(int64((req.Page - 1) * req.Size))
|
|
@@ -160,11 +163,21 @@ func (s *Synthesis) FindWithdrawal(req *entity.UserWithdrawalReq) ([]*entity.Use
|
|
|
|
|
|
// WithdrawalStatus 更新提现状态
|
|
|
func (s *Synthesis) WithdrawalStatus(req *entity.UserWithdrawalStatus) error {
|
|
|
- ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
|
|
|
- defer cancel()
|
|
|
- collection := mdb.MDB.Collection("CashOutRecord")
|
|
|
- _, err := collection.UpdateOne(ctx, bson.M{"userName": req.UserName}, bson.M{"$set": bson.M{"status": req.Status}})
|
|
|
+ // ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
|
|
|
+ // defer cancel()
|
|
|
+ collection := mdb.MDB.Collection(constant.CNameCashOutRecord)
|
|
|
+
|
|
|
+ // 更新条件
|
|
|
+ updateCondition := bson.M{"userName": req.UserName}
|
|
|
+ // 更新内容
|
|
|
+ updateContent := bson.M{"$set": bson.M{"status": req.Status}}
|
|
|
+ // 设置更新选项
|
|
|
+ updateOptions := options.Update().SetUpsert(true) // 设置 upsert 选项
|
|
|
+ // 执行更新操作
|
|
|
+ result, err := collection.UpdateOne(context.TODO(), updateCondition, updateContent, updateOptions)
|
|
|
if err != nil {
|
|
|
+ fmt.Println(result)
|
|
|
+ fmt.Println(err)
|
|
|
return err
|
|
|
}
|
|
|
return nil
|