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