2 Commits f66e88ae70 ... 99bf640a9a

Author SHA1 Message Date
  Alvin 99bf640a9a update 完善提现记录接口 8 months ago
  Alvin 94ed3cacab update 新增对货币类型的校验 8 months ago

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

@@ -58,11 +58,3 @@ const (
 	IncreaseOp OperationTypeStr = "increase"
 	DecreaseOp OperationTypeStr = "decrease"
 )
-
-type CurrencyTypeStr string
-
-const (
-	PointsCurrency CurrencyTypeStr = "POINTS" // 积分
-	TonCurrency    CurrencyTypeStr = "TON"
-	UsdtCurrency   CurrencyTypeStr = "USDT"
-)

+ 25 - 0
game/game_cluster/internal/constant/currency.go

@@ -0,0 +1,25 @@
+package constant
+
+type CurrencyTypeStr string
+
+const (
+	PointsCurrency CurrencyTypeStr = "POINTS" // 积分
+	TonCurrency    CurrencyTypeStr = "TON"
+	UsdtCurrency   CurrencyTypeStr = "USDT"
+)
+
+var (
+	currencyMap map[string]CurrencyTypeStr
+)
+
+func init() {
+	currencyMap = make(map[string]CurrencyTypeStr, 8)
+	currencyMap["POINTS"] = PointsCurrency
+	currencyMap["TON"] = TonCurrency
+	currencyMap["USDT"] = UsdtCurrency
+}
+
+func CurrencyValid(currency string) bool {
+	_, exist := currencyMap[currency]
+	return exist
+}

+ 1 - 0
game/game_cluster/internal/mdb/eventmodels/userWithdrawEvent.go

@@ -15,6 +15,7 @@ type UserWithdrawEventContent struct {
 	BeforeBalance   int64                    `json:"before_balance"`   // 提现前余额
 	Amount          int64                    `json:"amount"`           // 提现金额
 	AfterBalance    int64                    `json:"after_balance"`    // 提现后余额
+	Reason          string                   `json:"reason"`           // 提现原因
 	State           int                      `json:"state"`            // 服务器是否已经处理 0 未处理 1已处理
 	WithdrawalState int                      `json:"withdrawal_state"` // 提现 0 :未体现 1:提现成功 2:提现中 3:提现失败 4:拒绝提现
 }

+ 2 - 1
game/game_cluster/nodes/webadmin/entity/user_withdrawal.go

@@ -26,11 +26,12 @@ type UserWithdrawalReq struct {
 	UserName       string `json:"user_name" bson:"user_name"` // 用户ID
 	NickName       string `json:"nick_name" bson:"nick_name"` // 昵称
 	ID             string `json:"id" bson:"id"`               // ID
+	Address        string `json:"address"`                    // 地址
+	Currency       string `json:"currency"`                   // 货币类型
 	StartTime      int64  `json:"start_time"`                 // 开始时间
 	EndTime        int64  `json:"end_time"`                   // 结束时间
 	Page           int    `json:"page"`                       // 页码
 	Size           int    `json:"size"`                       // 每页数量
-	Address        string `json:"address"`                    // 地址
 	State          int    `json:"state"`                      // 服务器是否已经处理 0 未处理 1已处理
 	Withdrawal     int    `json:"withdrawal"`                 // 提现 0 :未体现 1:提现成功 2:提现中 3:提现失败 4:拒绝提现
 	AmountMin      int    `json:"amount_min"`                 // 提现金额最小值

+ 19 - 15
game/game_cluster/nodes/webadmin/service/synthesis.go

@@ -255,6 +255,11 @@ func (s *Synthesis) FindMDBUserLogDaily(req entity.UserLogDailyReq) (*entity.Use
 func (s *Synthesis) FindWithdrawal(req entity.UserWithdrawalReq) (*entity.UserWithdrawalResp, *code.Result) {
 	page, pageSize := checkPageParam(req.Page, req.Size)
 
+	if !constant.CurrencyValid(req.Currency) {
+		mhayaLogger.Warnf("FindWithdrawal unknow currency:%v", req.Currency)
+		return nil, common.NewResult(code.ParamError)
+	}
+
 	var records []*eventmodels.UserWithdrawEventContent
 
 	where := &eventmodels.UserWithdrawEventContent{
@@ -266,7 +271,7 @@ func (s *Synthesis) FindWithdrawal(req entity.UserWithdrawalReq) (*entity.UserWi
 			ServerId: s.nodeId,
 		},
 		WithdrawId:      req.ID,
-		Currency:        constant.UsdtCurrency,
+		Currency:        constant.CurrencyTypeStr(req.Currency),
 		Address:         req.Address,
 		State:           req.State,
 		WithdrawalState: req.Withdrawal,
@@ -293,20 +298,19 @@ func (s *Synthesis) FindWithdrawal(req entity.UserWithdrawalReq) (*entity.UserWi
 	var results []*entity.UserWithdrawalDetail
 	for _, v := range records {
 		results = append(results, &entity.UserWithdrawalDetail{
-			// TODO
-			// Id:          v.WithdrawId,
-			// UserName:    v.UserId,
-			// NickName:    v.UserName,
-			// OpenId:      v.TgId,
-			// Status:      v.State,
-			// Reason:      "",
-			// Withdrawal:  0,
-			// Amount:      0,
-			// AfterAmount: 0,
-			// Type:        nil,
-			// Address:     "",
-			// CreateAt:    nil,
-			// UpdateAt:    nil,
+			Id:          v.WithdrawId,
+			UserName:    v.UserId,
+			NickName:    v.UserName,
+			OpenId:      v.TgId,
+			Status:      v.State,
+			Reason:      v.Reason,
+			Withdrawal:  v.WithdrawalState,
+			Amount:      int(v.Amount),
+			AfterAmount: int(v.AfterBalance),
+			Type:        v.Currency,
+			Address:     v.Address,
+			CreateAt:    v.CreateAt,
+			UpdateAt:    v.CreateAt,
 		})
 	}