商队结算
This commit is contained in:
parent
8d3acd80bd
commit
356a22a4c8
@ -199,12 +199,16 @@ func (this *configureComp) GetCaravanReward() (reward []*cfg.GameCaravanRewardDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *configureComp) GetCaravanRank(index int32) (reward *cfg.GameCaravanRankData, err error) {
|
func (this *configureComp) GetCaravanRank(index int32) (reward *cfg.GameCaravanRankData, err error) {
|
||||||
if v, err := this.GetConfigure(game_caravan_rank); err == nil {
|
var (
|
||||||
|
v interface{}
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(game_caravan_rank); err == nil {
|
||||||
if configure, ok := v.(*cfg.GameCaravanRank); ok {
|
if configure, ok := v.(*cfg.GameCaravanRank); ok {
|
||||||
if reward = configure.Get(index); reward == nil {
|
if reward = configure.Get(index); reward == nil {
|
||||||
err = comm.NewNotFoundConfErr(moduleName, game_caravan_rank, index)
|
err = comm.NewNotFoundConfErr(moduleName, game_caravan_rank, index)
|
||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = comm.NewNotFoundConfErr(moduleName, game_caravan_rank, index)
|
err = comm.NewNotFoundConfErr(moduleName, game_caravan_rank, index)
|
||||||
|
@ -354,11 +354,14 @@ func (this *Caravan) TestFunc(session comm.IUserSession) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 赛季结算
|
// 赛季结算
|
||||||
func (this *Caravan) Rpc_ModuleCaravanSettlement(ctx context.Context, args *pb.EmptyReq, reply *pb.EmptyResp) {
|
func (this *Caravan) Rpc_ModuleCaravanSettlement(ctx context.Context, args *pb.EmptyReq, reply *pb.EmptyResp) (err error) {
|
||||||
|
this.Debug("Rpc_ModuleCaravanSettlement",
|
||||||
|
log.Field{Key: "args", Value: args.String()},
|
||||||
|
)
|
||||||
go func() {
|
go func() {
|
||||||
sTime := time.Now()
|
sTime := time.Now()
|
||||||
var rankIndex int32
|
var rankIndex int32
|
||||||
if _data, err := this.modelCaravan.DB.Find(comm.TableUser, bson.M{}, options.Find().SetSort(bson.M{"merchantmoney": -1}).SetLimit(comm.MaxRankList)); err == nil {
|
if _data, err := this.modelCaravan.DB.Find(comm.TableUser, bson.M{"merchantmoney": bson.M{"$gt": 0}}, options.Find().SetSort(bson.M{"merchantmoney": -1}).SetLimit(comm.MaxRankList)); err == nil {
|
||||||
for _data.Next(context.TODO()) {
|
for _data.Next(context.TODO()) {
|
||||||
rankIndex++
|
rankIndex++
|
||||||
temp := &pb.DBUser{}
|
temp := &pb.DBUser{}
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"go_dreamfactory/sys/db"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -68,6 +69,9 @@ func (this *CaravanRank) GetGlobalConf() *cfg.GameGlobalData {
|
|||||||
return configure.GetDataList()[0] // 返回对象信息
|
return configure.GetDataList()[0] // 返回对象信息
|
||||||
}
|
}
|
||||||
func (this *CaravanRank) Start() (err error) {
|
func (this *CaravanRank) Start() (err error) {
|
||||||
|
if db.IsCross() {
|
||||||
|
return
|
||||||
|
}
|
||||||
err = this.MCompModel.Start()
|
err = this.MCompModel.Start()
|
||||||
opentime := this.service.GetOpentime().Unix()
|
opentime := this.service.GetOpentime().Unix()
|
||||||
if configure.Now().Unix() < opentime { // 开服时间是未来可能存在问题
|
if configure.Now().Unix() < opentime { // 开服时间是未来可能存在问题
|
||||||
@ -77,16 +81,19 @@ func (this *CaravanRank) Start() (err error) {
|
|||||||
currentTime := time.Unix(opentime, 0)
|
currentTime := time.Unix(opentime, 0)
|
||||||
m := currentTime.Minute()
|
m := currentTime.Minute()
|
||||||
s := currentTime.Second()
|
s := currentTime.Second()
|
||||||
|
h := currentTime.Hour()
|
||||||
day := this.GetGlobalConf().BusinessRewardday
|
day := this.GetGlobalConf().BusinessRewardday
|
||||||
cronStr := fmt.Sprintf("%d %d */%d * * ?", m, s, day) // 每天的
|
cronStr := fmt.Sprintf("%d %d %d */%d * ?", m, s, h, day) //
|
||||||
|
this.module.Debugf("cron start: %s", cronStr)
|
||||||
cron.AddFunc(cronStr, this.TimerSeason)
|
cron.AddFunc(cronStr, this.TimerSeason)
|
||||||
|
//this.TimerSeason()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CaravanRank) TimerSeason() {
|
func (this *CaravanRank) TimerSeason() {
|
||||||
|
this.module.Debugf("TimerSeason start: %d", configure.Now().Unix())
|
||||||
if _, err := this.service.RpcGo(context.Background(),
|
if err := this.service.RpcCall(
|
||||||
|
context.Background(),
|
||||||
comm.Service_Worker,
|
comm.Service_Worker,
|
||||||
string(comm.Rpc_ModuleCaravanSettlement),
|
string(comm.Rpc_ModuleCaravanSettlement),
|
||||||
pb.EmptyReq{},
|
pb.EmptyReq{},
|
||||||
@ -94,5 +101,4 @@ func (this *CaravanRank) TimerSeason() {
|
|||||||
); err != nil {
|
); err != nil {
|
||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user