商队功能补充

This commit is contained in:
meixiongfeng 2023-05-23 17:02:08 +08:00
parent d997a995c2
commit 140550b781
11 changed files with 252 additions and 65 deletions

View File

@ -235,5 +235,47 @@
} }
], ],
"duration": 720 "duration": 720
},
{
"id": "CaravanRank",
"title": {
"key": "mail_mail_title_12",
"text": "排名奖励"
},
"recipient": {
"key": "mail_mail_recipient_12",
"text": "亲爱的{0}"
},
"content": {
"key": "mail_mail_content_12",
"text": "这是商队的排名奖励,恭喜你啦!"
},
"sender": {
"key": "mail_mail_sender_12",
"text": "商队"
},
"reword": [],
"duration": 720
},
{
"id": "CaravanRewards",
"title": {
"key": "mail_mail_title_13",
"text": "结算奖励"
},
"recipient": {
"key": "mail_mail_recipient_13",
"text": "亲爱的{0}"
},
"content": {
"key": "mail_mail_content_13",
"text": "这是商队的赛季结算奖励,恭喜你啦!"
},
"sender": {
"key": "mail_mail_sender_13",
"text": "商队"
},
"reword": [],
"duration": 720
} }
] ]

View File

@ -3641,7 +3641,7 @@
"key": 30100, "key": 30100,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30110, "id_after": 30110,
"group": 370, "group": 370,
"des": 3, "des": 3,
@ -3755,7 +3755,7 @@
"key": 30130, "key": 30130,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30140, "id_after": 30140,
"group": 380, "group": 380,
"des": 3, "des": 3,
@ -3983,7 +3983,7 @@
"key": 30190, "key": 30190,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30200, "id_after": 30200,
"group": 390, "group": 390,
"des": 3, "des": 3,
@ -4097,7 +4097,7 @@
"key": 30220, "key": 30220,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 0, "id_after": 0,
"group": 400, "group": 400,
"des": 3, "des": 3,
@ -4135,7 +4135,7 @@
"key": 30230, "key": 30230,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 0, "id_after": 0,
"group": 410, "group": 410,
"des": 3, "des": 3,
@ -4173,7 +4173,7 @@
"key": 30240, "key": 30240,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 0, "id_after": 0,
"group": 420, "group": 420,
"des": 3, "des": 3,
@ -4211,7 +4211,7 @@
"key": 30250, "key": 30250,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 0, "id_after": 0,
"group": 430, "group": 430,
"des": 3, "des": 3,
@ -4249,7 +4249,7 @@
"key": 30260, "key": 30260,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30270, "id_after": 30270,
"group": 440, "group": 440,
"des": 3, "des": 3,
@ -4363,7 +4363,7 @@
"key": 30290, "key": 30290,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 0, "id_after": 0,
"group": 450, "group": 450,
"des": 3, "des": 3,
@ -4401,7 +4401,7 @@
"key": 30300, "key": 30300,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 0, "id_after": 0,
"group": 460, "group": 460,
"des": 3, "des": 3,
@ -4439,7 +4439,7 @@
"key": 30310, "key": 30310,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30320, "id_after": 30320,
"group": 470, "group": 470,
"des": 3, "des": 3,
@ -4553,7 +4553,7 @@
"key": 30340, "key": 30340,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 0, "id_after": 0,
"group": 480, "group": 480,
"des": 3, "des": 3,
@ -4591,7 +4591,7 @@
"key": 30350, "key": 30350,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30360, "id_after": 30360,
"group": 490, "group": 490,
"des": 3, "des": 3,
@ -4705,7 +4705,7 @@
"key": 30380, "key": 30380,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30390, "id_after": 30390,
"group": 500, "group": 500,
"des": 3, "des": 3,
@ -4819,7 +4819,7 @@
"key": 30410, "key": 30410,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30420, "id_after": 30420,
"group": 510, "group": 510,
"des": 3, "des": 3,
@ -4933,7 +4933,7 @@
"key": 30440, "key": 30440,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30450, "id_after": 30450,
"group": 520, "group": 520,
"des": 3, "des": 3,
@ -5047,7 +5047,7 @@
"key": 30470, "key": 30470,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30480, "id_after": 30480,
"group": 530, "group": 530,
"des": 3, "des": 3,
@ -5161,7 +5161,7 @@
"key": 30500, "key": 30500,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30510, "id_after": 30510,
"group": 540, "group": 540,
"des": 3, "des": 3,
@ -5237,7 +5237,7 @@
"key": 30520, "key": 30520,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30530, "id_after": 30530,
"group": 550, "group": 550,
"des": 3, "des": 3,
@ -5313,7 +5313,7 @@
"key": 30540, "key": 30540,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30550, "id_after": 30550,
"group": 560, "group": 560,
"des": 3, "des": 3,
@ -5541,7 +5541,7 @@
"key": 30600, "key": 30600,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30610, "id_after": 30610,
"group": 570, "group": 570,
"des": 3, "des": 3,
@ -5693,7 +5693,7 @@
"key": 30640, "key": 30640,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30650, "id_after": 30650,
"group": 580, "group": 580,
"des": 3, "des": 3,
@ -5845,7 +5845,7 @@
"key": 30680, "key": 30680,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30690, "id_after": 30690,
"group": 590, "group": 590,
"des": 3, "des": 3,
@ -5921,7 +5921,7 @@
"key": 30700, "key": 30700,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30710, "id_after": 30710,
"group": 600, "group": 600,
"des": 3, "des": 3,
@ -6035,7 +6035,7 @@
"key": 30730, "key": 30730,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30740, "id_after": 30740,
"group": 610, "group": 610,
"des": 3, "des": 3,
@ -6149,7 +6149,7 @@
"key": 30760, "key": 30760,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30770, "id_after": 30770,
"group": 620, "group": 620,
"des": 3, "des": 3,
@ -6225,7 +6225,7 @@
"key": 30780, "key": 30780,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30790, "id_after": 30790,
"group": 630, "group": 630,
"des": 3, "des": 3,
@ -6339,7 +6339,7 @@
"key": 30810, "key": 30810,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30820, "id_after": 30820,
"group": 640, "group": 640,
"des": 3, "des": 3,
@ -6681,7 +6681,7 @@
"key": 30900, "key": 30900,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30910, "id_after": 30910,
"group": 650, "group": 650,
"des": 3, "des": 3,
@ -6833,7 +6833,7 @@
"key": 30940, "key": 30940,
"lock": 1, "lock": 1,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 30950, "id_after": 30950,
"group": 660, "group": 660,
"des": 3, "des": 3,
@ -7035,7 +7035,7 @@
"key": 900010, "key": 900010,
"lock": 0, "lock": 0,
"lockend": 0, "lockend": 0,
"ontxe": 0, "ontxe": 20010,
"id_after": 0, "id_after": 0,
"group": 90010, "group": 90010,
"des": 5, "des": 5,

View File

@ -37,7 +37,7 @@ type (
Imail interface { Imail interface {
SendMailByCid(session IUserSession, cid string, res []*pb.UserAssets) bool SendMailByCid(session IUserSession, cid string, res []*pb.UserAssets) bool
SendNewMail(mail *pb.DBMailData, uid ...string) bool // 批量发送邮件 支持跨服 SendNewMail(mail *pb.DBMailData, uid ...string) bool // 批量发送邮件 支持跨服
SendMailByUID(uid string, cid string, res []*cfg.Gameatn) bool SendMailByUID(uid string, cid string, res []*cfg.Gameatn, Param []string) bool
IReddot IReddot
} }
//道具背包接口 //道具背包接口
@ -58,6 +58,8 @@ type (
RecoverTicket(session IUserSession) (code pb.ErrorCode) RecoverTicket(session IUserSession) (code pb.ErrorCode)
//出售道具 //出售道具
SellItem(session IUserSession, items map[string]int32, bPush bool) (code pb.ErrorCode, atno []*pb.UserAtno) SellItem(session IUserSession, items map[string]int32, bPush bool) (code pb.ErrorCode, atno []*pb.UserAtno)
CleanItemById(session IUserSession, t string) (code pb.ErrorCode)
} }
//英雄 //英雄

View File

@ -4,6 +4,7 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/sys/mgo" "go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
) )
//参数校验 //参数校验
@ -22,8 +23,11 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.CaravanGetListRe
} }
list, err := this.module.modelCaravan.getCaravanList(session.GetUserId()) list, err := this.module.modelCaravan.getCaravanList(session.GetUserId())
if mgo.MongodbNil == err { // 初始化门票和虚拟币 if configure.Now().Unix() >= list.Resettime || err == mgo.MongodbNil { // 初始化门票和虚拟币
if code = this.module.InitCaravanTicket(session, 1); code != pb.ErrorCode_Success { if conf := this.module.configure.GetCaravanLv(list.Lv); conf != nil {
this.module.ModuleItems.CleanItemById(session, conf.Tickettop.T) // 清理之前的门票数据
}
if code = this.module.InitCaravanTicket(session, list.Lv); code != pb.ErrorCode_Success {
return return
} }
} }

View File

@ -8,7 +8,6 @@ import (
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure" "go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
@ -46,7 +45,8 @@ func (this *modelCaravan) getCaravanList(uid string) (result *pb.DBCaravan, err
if err = this.Get(uid, result); err != nil && mgo.MongodbNil == err { if err = this.Get(uid, result); err != nil && mgo.MongodbNil == err {
// 创建一条数据 // 创建一条数据
result.Id = primitive.NewObjectID().Hex() result.Id = primitive.NewObjectID().Hex()
result.Resettime = utils.GetZeroTime(configure.Now().Unix()) // 设置起始刷新时间
result.Resettime = this.module.service.GetOpentime().Unix() + int64(this.module.ModuleTools.GetGlobalConf().BusinessRewardday*24*3600)
result.Citystime = configure.Now().Unix() result.Citystime = configure.Now().Unix()
result.Lv = 1 result.Lv = 1
result.Curcity = this.module.configure.GetCaravanInitCity() // 获取默认城市 result.Curcity = this.module.configure.GetCaravanInitCity() // 获取默认城市

View File

@ -12,6 +12,7 @@ import (
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils" "go_dreamfactory/utils"
"math" "math"
"strconv"
"time" "time"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
@ -201,7 +202,10 @@ func (this *Caravan) refreshCaravanCityInfo(uid string, caravan *pb.DBCaravan) {
} }
} }
} }
if configure.Now().Unix() >= caravan.Resettime {
caravan.Resettime = this.service.GetOpentime().Unix() + int64(this.ModuleTools.GetGlobalConf().BusinessRewardday*24*3600)
update["resettime"] = caravan.Resettime
}
if bChange { if bChange {
update["city"] = caravan.City update["city"] = caravan.City
update["goods"] = caravan.Goods update["goods"] = caravan.Goods
@ -317,7 +321,7 @@ func (this *Caravan) ArrayBag(data *pb.DBCaravan, limit int32) (bFull bool) {
return false return false
} }
// 校验商队等级 // 获得利润判断是否能提升商队等级
func (this *Caravan) CheckCaravavLvUp(data *pb.DBCaravan) (curLv int32) { func (this *Caravan) CheckCaravavLvUp(data *pb.DBCaravan) (curLv int32) {
curLv = data.Lv curLv = data.Lv
for { for {
@ -347,6 +351,7 @@ 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) {
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{}, options.Find().SetSort(bson.M{"merchantmoney": -1}).SetLimit(comm.MaxRankList)); err == nil {
@ -356,12 +361,48 @@ func (this *Caravan) Rpc_ModuleCaravanSettlement(ctx context.Context, args *pb.E
if err = _data.Decode(temp); err == nil { if err = _data.Decode(temp); err == nil {
c := this.configure.GetCaravanRank(rankIndex) c := this.configure.GetCaravanRank(rankIndex)
if c != nil { if c != nil {
this.mail.SendMailByUID(temp.Uid, "xxx", c.Reward) // 等配置 this.mail.SendMailByUID(temp.Uid, "CaravanRank", c.Reward, []string{strconv.Itoa(int(rankIndex))})
} }
} }
} }
} }
// 发送虚拟币奖励
if _data, err := this.modelCaravan.DB.Find(comm.TableUser, bson.M{"merchantmoney": bson.M{"$gt": 0}}); err == nil {
for _data.Next(context.TODO()) {
temp := &pb.DBUser{}
if err = _data.Decode(temp); err == nil {
for _, v := range this.configure.GetCaravanReward() {
s := v.Moneystart
e := v.Moneyend
more := false
if e == -1 {
e = math.MaxInt32
more = true
}
if s < temp.Merchantmoney && e <= temp.Merchantmoney {
var res []*cfg.Gameatn
if more { // 超过的部分
r := this.ModuleTools.GetGlobalConf().BusinessMaxintReward
m := this.ModuleTools.GetGlobalConf().BusinessMaxint
n := (temp.Merchantmoney - s) / m
atn := &cfg.Gameatn{
A: r.A,
T: r.T,
N: r.N * n,
}
res = append(res, atn)
}
res = append(res, v.Reward...)
this.mail.SendMailByUID(temp.Uid, "CaravanRewards", v.Reward, []string{})
}
}
}
}
}
Query := bson.M{} Query := bson.M{}
Query["merchantmoney"] = 0 Query["merchantmoney"] = 0
_, err := this.modelCaravan.DB.UpdateMany(core.SqlTable(comm.TableUser), bson.M{}, bson.M{"$set": Query}, options.MergeUpdateOptions().SetUpsert(true)) //, new(options.UpdateOptions).SetUpsert(true) _, err := this.modelCaravan.DB.UpdateMany(core.SqlTable(comm.TableUser), bson.M{}, bson.M{"$set": Query}, options.MergeUpdateOptions().SetUpsert(true)) //, new(options.UpdateOptions).SetUpsert(true)
@ -370,5 +411,7 @@ func (this *Caravan) Rpc_ModuleCaravanSettlement(ctx context.Context, args *pb.E
} }
this.Debugf("sub time:%d", time.Now().Local().Sub(sTime).Milliseconds()) this.Debugf("sub time:%d", time.Now().Local().Sub(sTime).Milliseconds())
}()
return return
} }

View File

@ -261,3 +261,21 @@ func (this *Items) itemsChangePush(session comm.IUserSession, items []*pb.DB_Use
session.SendMsg(string(this.GetType()), "change", &pb.ItemsChangePush{Grids: items}) session.SendMsg(string(this.GetType()), "change", &pb.ItemsChangePush{Grids: items})
return return
} }
func (this *Items) CleanItemById(session comm.IUserSession, t string) (code pb.ErrorCode) {
var itmes []*pb.DB_UserItemData
if v, err := this.modelItems.QueryUserPack(session.GetUserId()); err == nil {
for _, v := range v {
if v.ItemId == t {
itmes = append(itmes, v)
break
}
}
this.modelItems.DeleteUserPack(session.GetUserId(), itmes...)
code = pb.ErrorCode_Success
return
}
code = pb.ErrorCode_DataNotFound
return
}

View File

@ -219,7 +219,6 @@ func (this *Mail) CheckMaxMail(session comm.IUserSession) bool {
} }
func (this *Mail) SendMailByUID(uid string, cid string, res []*cfg.Gameatn) bool { func (this *Mail) SendMailByUID(uid string, cid string, res []*cfg.Gameatn) bool {
// 获取额外配置
var reward []*pb.UserAssets var reward []*pb.UserAssets
for _, v := range res { for _, v := range res {
if v.N > 0 { if v.N > 0 {
@ -230,11 +229,21 @@ func (this *Mail) SendMailByUID(uid string, cid string, res []*cfg.Gameatn) bool
}) })
} }
} }
conf := this.configure.GetMailConf(cid) conf := this.configure.GetMailConf(cid)
if conf == nil { if conf == nil {
this.Errorf("can't found mail by cid: %s", cid) this.Errorf("can't found mail by cid: %s", cid)
return false return false
} }
if len(conf.Reword) > 0 {
for _, v := range conf.Reword {
reward = append(reward, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N,
})
}
}
// 构建一个每日奖励邮件对象 // 构建一个每日奖励邮件对象
mail := &pb.DBMailData{ mail := &pb.DBMailData{

View File

@ -60,6 +60,9 @@ func (this *apiComp) Rise(session comm.IUserSession, req *pb.SmithyRiseReq) (cod
update["temperature"] = stove.Temperature update["temperature"] = stove.Temperature
this.module.modelStove.updateSmithyStove(session.GetUserId(), update) this.module.modelStove.updateSmithyStove(session.GetUserId(), update)
session.SendMsg(string(this.module.GetType()), "rise", &pb.SmithyRiseResp{Data: stove}) session.SendMsg(string(this.module.GetType()), "rise", &pb.SmithyRiseResp{Data: stove})
tasks := make([]*comm.TaskParam, 0)
tasks = append(tasks, comm.GettaskParam(comm.Rtype171, stove.Temperature))
this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...)
} }
return return

View File

@ -3,13 +3,16 @@ package timer
import ( import (
"context" "context"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/lego/base" "go_dreamfactory/lego/base"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/cron" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/sys/timewheel"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
) )
// 此组件废弃 // 此组件废弃
@ -20,6 +23,10 @@ type CaravanRank struct {
module *Timer module *Timer
} }
const (
game_global = "game_global.json" //全局配置表
)
//组件初始化接口 //组件初始化接口
func (this *CaravanRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *CaravanRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
@ -27,18 +34,60 @@ func (this *CaravanRank) Init(service core.IService, module core.IModule, comp c
this.MCompModel.Init(service, module, comp, options) this.MCompModel.Init(service, module, comp, options)
this.module = module.(*Timer) this.module = module.(*Timer)
this.service = service.(base.IRPCXService) this.service = service.(base.IRPCXService)
err = this.LoadConfigure(game_global, cfg.NewGameGlobal)
return return
} }
func (this *CaravanRank) LoadConfigure(name string, fn interface{}) (err error) {
return configure.RegisterConfigure(name, fn, nil)
}
//读取配置数据
func (this *CaravanRank) GetConfigure(name string) (v interface{}, err error) {
return configure.GetConfigure(name)
}
//全局配置
func (this *CaravanRank) GetGlobalConf() *cfg.GameGlobalData {
var (
configure *cfg.GameGlobal
ok bool
)
if v, err := this.GetConfigure(game_global); err != nil {
log.Errorf("get global conf err:%v", err)
return nil
} else {
if configure, ok = v.(*cfg.GameGlobal); !ok {
log.Errorf("%T no is *cfg.Game_global", v)
return nil
}
}
return configure.GetDataList()[0] // 返回对象信息
}
func (this *CaravanRank) Start() (err error) { func (this *CaravanRank) Start() (err error) {
err = this.MCompModel.Start() err = this.MCompModel.Start()
cron.AddFunc("30 10 1 * * ?", this.TimerSeason) opentime := this.service.GetOpentime().Unix()
this.module.Debugf("%d", opentime)
//cron.AddFunc("30 10 1 * * ?", this.TimerSeason)
this.module.Debugf("--%d", time.Now().Unix())
seasonTime := this.GetGlobalConf().BusinessRewardday
if configure.Now().Unix() < opentime { // 开服时间是未来可能存在问题
return
}
subTime := int32(configure.Now().Unix() - opentime)
if subTime < seasonTime {
timewheel.Add(time.Second*time.Duration(subTime), this.TimerSeason, nil)
} else {
s := configure.Now().Unix() - (configure.Now().Unix()-opentime)%int64(subTime) + int64(seasonTime)
timewheel.Add(time.Second*time.Duration(s), this.TimerSeason, nil)
}
return return
} }
func (this *CaravanRank) TimerSeason() { func (this *CaravanRank) TimerSeason(task *timewheel.Task, args ...interface{}) {
this.module.Debugf("==%d", time.Now().Unix())
if _, err := this.service.RpcGo(context.Background(), if _, err := this.service.RpcGo(context.Background(),
comm.Service_Worker, comm.Service_Worker,
string(comm.Rpc_ModuleCaravanSettlement), string(comm.Rpc_ModuleCaravanSettlement),
@ -48,6 +97,16 @@ func (this *CaravanRank) TimerSeason() {
this.module.Errorln(err) this.module.Errorln(err)
} }
// if _data, err := this.DB.Find(comm.TableUser, bson.M{"merchantmoney": bson.M{"$gt": 0}}); err == nil {
// for _data.Next(context.TODO()) {
// temp := &pb.DBUser{}
// if err = _data.Decode(temp); err == nil {
// }
// }
// }
// sTime := time.Now() // sTime := time.Now()
// Query := bson.M{} // Query := bson.M{}
// Query["merchantmoney"] = 0 // Query["merchantmoney"] = 0

View File

@ -8,12 +8,14 @@ import (
"go_dreamfactory/modules/web" "go_dreamfactory/modules/web"
"go_dreamfactory/services" "go_dreamfactory/services"
"go_dreamfactory/sys/db" "go_dreamfactory/sys/db"
"time"
"go_dreamfactory/lego" "go_dreamfactory/lego"
"go_dreamfactory/lego/base/rpcx" "go_dreamfactory/lego/base/rpcx"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/cron" "go_dreamfactory/lego/sys/cron"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/sys/timewheel"
) )
/* /*
@ -62,7 +64,12 @@ func (this *Service) InitSys() {
} else { } else {
log.Infof("init sys.cron success!") log.Infof("init sys.cron success!")
} }
//定时系统 秒级时间轮
if err := timewheel.OnInit(nil, timewheel.SetTick(time.Second)); err != nil {
panic(fmt.Sprintf("init sys.timewheel err: %s", err.Error()))
} else {
log.Infof("init sys.timewheel success!")
}
//存储系统 //存储系统
if err := db.OnInit(this.GetSettings().Sys["db"]); err != nil { if err := db.OnInit(this.GetSettings().Sys["db"]); err != nil {
panic(fmt.Sprintf("init sys.db err: %s", err.Error())) panic(fmt.Sprintf("init sys.db err: %s", err.Error()))