diff --git a/modules/friend/api_cross_randlist.go b/modules/friend/api_cross_randlist.go index fe0262979..3922a178f 100644 --- a/modules/friend/api_cross_randlist.go +++ b/modules/friend/api_cross_randlist.go @@ -6,6 +6,8 @@ import ( "go_dreamfactory/utils" "google.golang.org/protobuf/proto" + + cfg "go_dreamfactory/sys/configure/structs" ) func (this *apiComp) RandlistCheck(session comm.IUserSession, req *pb.FriendRandlistReq) (code pb.ErrorCode) { @@ -87,6 +89,14 @@ func (this *apiComp) Randlist(session comm.IUserSession, req *pb.FriendRandlistR } + this.moduleFriend.DispenseRes(session, []*cfg.Gameatn{ + { + A: "attr", + T: "gold", + N: 10, + }, + }, true) + rsp := &pb.FriendRandlistResp{ List: userList, } diff --git a/modules/user/module.go b/modules/user/module.go index 375e3519f..106c4d13b 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -183,7 +183,19 @@ func (this *User) SearchRmoteUser(nickname string) ([]*pb.DBUser, error) { //查询用户属性值 例如 金币 经验 func (this *User) QueryAttributeValue(uid string, attr string) (value int64) { - user := this.modelUser.GetUser(uid) + var ( + user *pb.DBUser + err error + ) + if this.IsCross() { + user, err = this.GetRmoteUser(uid) + if err != nil { + return + } + } else { + user = this.modelUser.GetUser(uid) + } + if user == nil { return } @@ -206,15 +218,30 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha return } - user := this.GetUser(session.GetUserId()) - if user == nil { - code = pb.ErrorCode_UserSessionNobeing - return + uid := session.GetUserId() + var ( + user *pb.DBUser + userEx *pb.DBUserExpand + err error + ) + if this.IsCross() { + user, err = this.GetRmoteUser(uid) + if err != nil { + code = pb.ErrorCode_UserSessionNobeing + return + } + + } else { + user = this.GetUser(uid) + userEx, err = this.GetUserExpand(uid) + if err != nil { + code = pb.ErrorCode_UserExpandNull + return + } } - userEx, err := this.GetUserExpand(session.GetUserId()) - if userEx == nil || err != nil { - code = pb.ErrorCode_UserExpandNull + if user == nil { + code = pb.ErrorCode_UserSessionNobeing return } @@ -275,12 +302,12 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha comm.ResFriend: change.Friend, } - if err := this.modelUser.updateUserAttr(session.GetUserId(), update); err != nil { + if err := this.modelUser.updateUserAttr(uid, update); err != nil { this.Errorf("AddAttributeValue err:%v", err) code = pb.ErrorCode_DBError } - if err := this.modelExpand.ChangeUserExpand(session.GetUserId(), updateEx); err != nil { + if err := this.modelExpand.ChangeUserExpand(uid, updateEx); err != nil { this.Errorf("AddAttributeValue ex err:%v", err) code = pb.ErrorCode_DBError }