userxzz 9 месяцев назад
Родитель
Сommit
c614df80c8

+ 8 - 8
game/game_cluster/internal/constant/constant.go

@@ -27,7 +27,7 @@ const (
 	CNamePlayer                = "player"
 	CNamePlayerReward          = "playerReward"
 	CNamePlayerDailyRecord     = "playerDailyRecord"
-	CNameCashOutRecord         = "cashOutRecord "
+	CNameCashOutRecord         = "cashOutRecord"
 	CNamePlayerLevelStat       = "playerLevelStat"
 	CNameServerLoadStat        = "serverLoadStat "
 	CNamePlayerCountryByIPStat = "playerCountryStat"
@@ -36,16 +36,16 @@ const (
 // 榜单数据来源类型
 
 const (
-	RankSourceScore  = 1 //积分
-	RankSourceInvite = 2 //邀请
+	RankSourceScore  = 1 // 积分
+	RankSourceInvite = 2 // 邀请
 	RankSourceRoll   = 3 // 抽奖次数
 )
 
 // roll 结果类型
 const (
-	RollSmallBet         = 0 //<9
-	RollBigBet           = 1 //>=9
-	RollDoubleBet        = 2 //对子
-	RollTripleBet        = 3 //豹子2345
-	RollSpecialTripleBet = 4 //豹子16
+	RollSmallBet         = 0 // <9
+	RollBigBet           = 1 // >=9
+	RollDoubleBet        = 2 // 对子
+	RollTripleBet        = 3 // 豹子2345
+	RollSpecialTripleBet = 4 // 豹子16
 )

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

@@ -2,8 +2,8 @@ package entity
 
 // UserWithdrawalResp \game\game_cluster\nodes\webadmin\entity\user_withdrawal.go
 type UserWithdrawalResp struct {
-	UserName    string `json:"user_name" bson:"user_name"`       // 用户ID
-	NickName    string `json:"nick_name" bson:"nick_name"`       // 昵称
+	UserName    string `json:"user_name" bson:"userName"`        // 用户ID
+	NickName    string `json:"nick_name" bson:"nickName"`        // 昵称
 	Status      int    `json:"status" bson:"status"`             // 0:未审核 1:审核通过 2:审核失败
 	Amount      int    `json:"amount" bson:"amount"`             // 提现金额
 	AfterAmount int    `json:"after_amount" bson:"after_amount"` // 提现后金额
@@ -24,5 +24,5 @@ type UserWithdrawalReq struct {
 
 type UserWithdrawalStatus struct {
 	UserName string `json:"user_name" bson:"user_name"` // 用户ID
-	Status   int    `json:"status" bson:"status"`       // 0:未审核 1:审核通过 2:审核失败
+	Status   int32  `json:"status" bson:"status"`       // 0:未审核 1:审核通过 2:审核失败
 }

+ 25 - 12
game/game_cluster/nodes/webadmin/service/synthesis.go

@@ -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