Browse Source

新增数据管理员数据

userxzz 8 months ago
parent
commit
07e02892b1

+ 1 - 1
game/game_cluster/internal/mdb/models/cashoutrecord.go

@@ -8,7 +8,7 @@ type CashOutRecord struct {
 	AfterAmount int    `json:"afterAmount" bson:"after_amount"` //
 	Type        int    `json:"type" bson:"type"`                // 货币内型
 	Address     string `json:"address" bson:"address"`          // 地址
-	Withdrawal  int    `json:"withdrawal" bson:"withdrawal"`    // 提现 1:提现成功 2:提现中 3:提现失败 4:拒绝提现
+	Withdrawal  int    `json:"withdrawal" bson:"withdrawal"`    // 提现 0 :未体现 1:提现成功 2:提现中 3:提现失败 4:拒绝提现
 	CreateAt    int64  `json:"createAt" bson:"createAt"`
 	UpdateAt    int64  `json:"updateAt" bson:"updateAt"`
 }

+ 18 - 3
game/game_cluster/nodes/webadmin/service/synthesis.go

@@ -3,6 +3,7 @@ package service
 import (
 	"context"
 	"errors"
+	"log"
 	"math"
 	"time"
 
@@ -185,7 +186,7 @@ func (s *Synthesis) WithdrawalStatus(req *entity.UserWithdrawalStatus) error {
 	// 更新内容
 	updateContent := bson.M{"$set": bson.M{"status": req.Status}}
 	// 设置更新选项
-	updateOptions := options.Update().SetUpsert(true) // 设置 upsert 选项
+	updateOptions := options.Update() // 设置 upsert 选项
 	// 执行更新操作
 	_, err := collection.UpdateOne(context.TODO(), updateCondition, updateContent, updateOptions)
 	if err != nil {
@@ -201,18 +202,32 @@ func (s *Synthesis) WithdrawalStatusBatch(req *entity.UserWithdrawalStatusBatch)
 		return errors.New("id 不能为空")
 	}
 	for _, id := range req.ID {
+
 		objID := primitive.ObjectID{}
 		objID, _ = primitive.ObjectIDFromHex(id)
 		updateCondition := bson.M{"_id": objID}
 		updateContent := bson.M{}
+		withdrawal := models.CashOutRecord{}
+		err := collection.FindOne(context.TODO(), updateCondition).Decode(&withdrawal)
+		if err != nil {
+			log.Printf("查询提现记录失败: %v", err)
+			continue
+		}
 		if req.Withdrawal != 0 {
-			updateContent = bson.M{"$set": bson.M{"withdrawal": req.Withdrawal}}
+			if withdrawal.Status == 1 {
+				updateContent = bson.M{"$set": bson.M{"withdrawal": req.Withdrawal}}
+			} else {
+				continue
+			}
 		}
 		if req.Status > 0 {
+			if withdrawal.Status != 0 {
+				continue
+			}
 			updateContent = bson.M{"$set": bson.M{"status": req.Status}}
 		}
 		updateOptions := options.Update().SetUpsert(true)
-		_, err := collection.UpdateOne(context.TODO(), updateCondition, updateContent, updateOptions)
+		_, err = collection.UpdateOne(context.TODO(), updateCondition, updateContent, updateOptions)
 		if err != nil {
 			continue
 		}