上传代码
This commit is contained in:
parent
abd877dddd
commit
86a782c35b
@ -155,6 +155,9 @@ func (this *modelArena) updateArenaUserInfo(info *pb.DBArenaUser) (err error) {
|
||||
var (
|
||||
dan int32
|
||||
)
|
||||
if info.Integral < 0 {
|
||||
info.Integral = 0
|
||||
}
|
||||
if dan, err = this.computedan(info.Integral); err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PlunderGetListRe
|
||||
}
|
||||
|
||||
if list.Landid == "" {
|
||||
if land, err = this.module.modelLand.createPlunderLandData(session.GetUserId()); err != nil {
|
||||
if land, err = this.module.modelLand.createPlunderLandData(session.GetUserId(), list.Score); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Message: err.Error(),
|
||||
|
@ -46,10 +46,8 @@ func (this *modelLand) changePlunderLandData(id string, update map[string]interf
|
||||
return
|
||||
}
|
||||
|
||||
func (this *modelLand) createPlunderLandData(uid string) (land *pb.DBPlunderLand, err error) {
|
||||
func (this *modelLand) createPlunderLandData(uid string, socre int32) (land *pb.DBPlunderLand, err error) {
|
||||
var (
|
||||
user *pb.DBUser
|
||||
limtSocre int32
|
||||
uids []string
|
||||
users []*pb.DBUser
|
||||
uInfos []*pb.BaseUserInfo
|
||||
@ -61,24 +59,18 @@ func (this *modelLand) createPlunderLandData(uid string) (land *pb.DBPlunderLand
|
||||
Score: make(map[string]int32, 0),
|
||||
Etime: utils.GetTodayZeroTime(configure.Now().Unix()) + 48*3600, // 临时处理 后面走配置
|
||||
}
|
||||
if user, err = this.module.ModuleUser.GetUser(uid); err != nil {
|
||||
return
|
||||
}
|
||||
limtSocre = user.Plunder - 100
|
||||
if limtSocre < 0 {
|
||||
limtSocre = 0
|
||||
socre = socre - 100
|
||||
if socre < 0 {
|
||||
socre = 0
|
||||
}
|
||||
uids = append(uids, uid) // 优先加入自己
|
||||
uInfos = append(uInfos, comm.GetUserBaseInfo(user))
|
||||
cur, err := this.DB.Find(core.SqlTable(comm.TablePlunder), bson.M{"score": bson.M{"$gte": limtSocre}, "landid": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(0)).SetLimit(int64(20)))
|
||||
cur, err := this.DB.Find(core.SqlTable(comm.TablePlunder), bson.M{"score": bson.M{"$gte": socre}, "uid": bson.M{"$ne": uid}, "landid": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(0)).SetLimit(int64(20)))
|
||||
for cur.Next(context.TODO()) {
|
||||
tmp := &pb.DBPlunder{}
|
||||
if err = cur.Decode(tmp); err == nil {
|
||||
if uid != tmp.Uid {
|
||||
uids = append(uids, tmp.Uid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if users, err = this.module.ModuleUser.GetUsers(uids); err == nil {
|
||||
for _, v := range users {
|
||||
@ -96,9 +88,7 @@ func (this *modelLand) createPlunderLandData(uid string) (land *pb.DBPlunderLand
|
||||
if _, err = this.module.modelRecord.getPlunderRecordData(land.Id); err != nil {
|
||||
return
|
||||
}
|
||||
if _, err = this.DB.UpdateMany(core.SqlTable(comm.TablePlunder), bson.M{"uid": bson.M{"$in": uids}}, bson.M{"$set": bson.M{"landid": land.Id}}); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
func NewModule() core.IModule {
|
||||
@ -67,10 +66,6 @@ func (this *Plunder) OnInstallComp() {
|
||||
this.modelRecord = this.RegisterComp(new(modelRecord)).(*modelRecord)
|
||||
}
|
||||
|
||||
func (this *Plunder) CreatePlunderLand(uid string) (land *pb.DBPlunderLand, err error) {
|
||||
return this.modelLand.createPlunderLandData(uid)
|
||||
}
|
||||
|
||||
//初始化用户掠夺信息
|
||||
func (this *Plunder) InitPlunderByUser(session comm.IUserSession) {
|
||||
var (
|
||||
|
Loading…
Reference in New Issue
Block a user