Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev

This commit is contained in:
meixiongfeng 2022-10-19 16:09:55 +08:00
commit 11f1a08bc3
2 changed files with 15 additions and 15 deletions

View File

@ -5,9 +5,7 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/db"
"go_dreamfactory/utils" "go_dreamfactory/utils"
"time"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
@ -61,23 +59,25 @@ func (this *apiComp) GetRandUser(session comm.IUserSession, req *pb.GourmetGetRa
randOnlineUsers = append(randOnlineUsers, v) randOnlineUsers = append(randOnlineUsers, v)
} }
if len(randOnlineUsers) == 0 { // 一个人也没有 那就从db 中随机取 if len(randOnlineUsers) == 0 { // 一个人也没有 那就从db 中随机取
tag := session.GetServiecTag() //tag := session.GetServiecTag()
if conn, err := db.ServerDBConn(tag); err == nil { //if conn, err := db.ServerDBConn(tag); err == nil {
dbModel := db.NewDBModel(comm.TableUser, time.Hour, conn) //dbModel := db.NewDBModel(comm.TableUser, time.Hour, conn)
if _data, err1 := dbModel.DB.Find(core.SqlTable(comm.TableUser), bson.M{}, options.Find().SetSort(bson.M{"lv": -1}).SetLimit(int64(req.People))); err1 == nil {
for _data.Next(context.TODO()) { if _data, err1 := this.module.modelGourmet.DB.Find(core.SqlTable(comm.TableUser), bson.M{}, options.Find().SetSort(bson.M{"lv": -1}).SetLimit(int64(req.People))); err1 == nil {
temp := &pb.DBUser{} for _data.Next(context.TODO()) {
if err = _data.Decode(temp); err == nil { temp := &pb.DBUser{}
randOnlineUsers = append(randOnlineUsers, temp.Uid) if err = _data.Decode(temp); err == nil {
randOnlineUsers = append(randOnlineUsers, temp.Uid)
}
} }
} }
} }
//}
} }
} }
for _, v := range randOnlineUsers { for _, v := range randOnlineUsers {
szDbUser = append(szDbUser, this.module.ModuleUser.GetUser(v)) // 转成user对象 user, _ := this.module.ModuleUser.GetCrossUser(v)
szDbUser = append(szDbUser, user) // 转成user对象
} }
session.SendMsg(string(this.module.GetType()), GourmetGetRandUserResp, &pb.GourmetGetRandUserResp{User: szDbUser}) session.SendMsg(string(this.module.GetType()), GourmetGetRandUserResp, &pb.GourmetGetRandUserResp{User: szDbUser})
return return

View File

@ -58,7 +58,7 @@ func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftRe
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return return
} }
totalExp += expConf.FavorNum totalExp += expConf.FavorNum * v
} }
if code = this.module.CheckRes(session, res); code != pb.ErrorCode_Success { // 道具不够直接返回 if code = this.module.CheckRes(session, res); code != pb.ErrorCode_Success { // 道具不够直接返回
return return
@ -71,8 +71,8 @@ func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftRe
code = pb.ErrorCode_LibraryMaxLv code = pb.ErrorCode_LibraryMaxLv
break break
} }
if favorConf[_heroObj.Favorlv+1] <= _heroObj.Favorexp { if favorConf[_heroObj.Favorlv] <= _heroObj.Favorexp {
_heroObj.Favorexp -= favorConf[_heroObj.Favorlv+1] _heroObj.Favorexp -= favorConf[_heroObj.Favorlv]
_heroObj.Favorlv += 1 _heroObj.Favorlv += 1
} else { } else {
break break