Browse Source

修改邀请的bug

xh 10 months ago
parent
commit
5a76d6916f

+ 6 - 3
game/game_cluster/internal/mdb/models/player.go

@@ -506,8 +506,10 @@ func (p *Player) SetPassiveInviteReward() {
 	if !ok || !tok || c != p.Level {
 		return
 	}
-	//获取邀请人
+	//邀请人
 	key := fmt.Sprintf("%v:1:%v", constant.InviteKey, p.UserName)
+
+	//获取邀请人
 	pUid := mdb.RDB.Get(context.Background(), key).Val()
 
 	pbase, err := mdb.RDB.Get(context.Background(), GetPlayBaseKey(pUid)).Bytes()
@@ -581,6 +583,7 @@ func (p *Player) SetInviteReward() {
 	key1 := fmt.Sprintf("%v:%v:%v", constant.InviteKey, InvitePlayer, p.UserName)
 	key2 := fmt.Sprintf("%v:%v:%v", constant.InviteKey, InviteVipPlayer, p.UserName)
 
+	//自己作为邀请人判断奖励
 	freeNum, _ := mdb.RDB.Get(context.Background(), key1).Int()
 
 	VipNum, _ := mdb.RDB.Get(context.Background(), key2).Int()
@@ -643,13 +646,13 @@ func (p *Player) SetInvite(uid string) bool {
 	//}
 	//return true
 
-	key := fmt.Sprintf("%v:1:%v", constant.InviteKey, uid)
+	key := fmt.Sprintf("%v:1:%v", constant.InviteKey, p.UserName)
 	ret, ok := data.DiscreteRuleConfig.Get(InviteMaxExpireTime)
 	if !ok {
 		return false
 	}
 	t, _ := mhayaString.ToInt64(ret.Condition)
-	err := mdb.RDB.Set(context.Background(), key, p.UserName, time.Duration(t)*24*time.Hour).Err()
+	err := mdb.RDB.Set(context.Background(), key, uid, time.Duration(t)*24*time.Hour).Err()
 	if err != nil {
 		return false
 	}

+ 2 - 1
game/game_cluster/nodes/game/module/player/invite.go

@@ -20,11 +20,12 @@ func (p *actorPlayer) invite(req *param.InviteReq) int32 {
 		return code.InviteEmpoweringOthersError
 	}
 
-	exists := mdb.RDB.Exists(context.Background(), fmt.Sprintf("%v:1:%v", constant.InviteKey, req.ParentName)).Val()
+	exists := mdb.RDB.Exists(context.Background(), fmt.Sprintf("%v:1:%v", constant.InviteKey, p.Player.UserName)).Val()
 	if exists > 0 {
 		return code.Error
 	}
 
+	//req.ParentName 是邀请玩家id
 	p.dirty = true
 	p.Player.Pid = req.ParentName