商队结算
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) {
|
||||
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 reward = configure.Get(index); reward == nil {
|
||||
err = comm.NewNotFoundConfErr(moduleName, game_caravan_rank, index)
|
||||
this.module.Errorln(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
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() {
|
||||
sTime := time.Now()
|
||||
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()) {
|
||||
rankIndex++
|
||||
temp := &pb.DBUser{}
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/sys/db"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -68,6 +69,9 @@ func (this *CaravanRank) GetGlobalConf() *cfg.GameGlobalData {
|
||||
return configure.GetDataList()[0] // 返回对象信息
|
||||
}
|
||||
func (this *CaravanRank) Start() (err error) {
|
||||
if db.IsCross() {
|
||||
return
|
||||
}
|
||||
err = this.MCompModel.Start()
|
||||
opentime := this.service.GetOpentime().Unix()
|
||||
if configure.Now().Unix() < opentime { // 开服时间是未来可能存在问题
|
||||
@ -77,16 +81,19 @@ func (this *CaravanRank) Start() (err error) {
|
||||
currentTime := time.Unix(opentime, 0)
|
||||
m := currentTime.Minute()
|
||||
s := currentTime.Second()
|
||||
h := currentTime.Hour()
|
||||
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)
|
||||
|
||||
//this.TimerSeason()
|
||||
return
|
||||
}
|
||||
|
||||
func (this *CaravanRank) TimerSeason() {
|
||||
|
||||
if _, err := this.service.RpcGo(context.Background(),
|
||||
this.module.Debugf("TimerSeason start: %d", configure.Now().Unix())
|
||||
if err := this.service.RpcCall(
|
||||
context.Background(),
|
||||
comm.Service_Worker,
|
||||
string(comm.Rpc_ModuleCaravanSettlement),
|
||||
pb.EmptyReq{},
|
||||
@ -94,5 +101,4 @@ func (this *CaravanRank) TimerSeason() {
|
||||
); err != nil {
|
||||
this.module.Errorln(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user