修改check

This commit is contained in:
zhaocy 2022-07-07 17:01:58 +08:00
parent 447800b886
commit e0522afbe8
5 changed files with 15 additions and 42 deletions

View File

@ -23,8 +23,11 @@ var user_builders = []*TestCase{
mainType: string(comm.ModuleUser),
subType: user.UserSubTypeAddRes,
req: &pb.UserAddResReq{ //设置请求参数
ResType: comm.ResGold,
Count: 100,
Res: &pb.UserAssets{
A: comm.ResGold,
T:"",
N: 100,
},
},
rsp: &pb.UserAddResResp{},
// enabled: true,

View File

@ -18,6 +18,9 @@ func (this *apiComp) ActiveListCheck(session comm.IUserSession, req *pb.TaskActi
func (this *apiComp) ActiveList(session comm.IUserSession, req *pb.TaskActiveListReq) (code pb.ErrorCode, data proto.Message) {
// this.moduleTask.ModuleTask.SendToTask(session.GetUserId(), comm.TaskTypeGetHero, &pb.TaskParam{First: 5})
if code = this.ActiveListCheck(session, req); code != pb.ErrorCode_Success {
return
}
resp := &pb.TaskActiveListResp{}
defer func() {

View File

@ -17,6 +17,9 @@ func (this *apiComp) ActiveReceiveCheck(session comm.IUserSession, req *pb.TaskA
}
func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActiveReceiveReq) (code pb.ErrorCode, data proto.Message) {
if code = this.ActiveReceiveCheck(session, req); code != pb.ErrorCode_Success {
return
}
resp := &pb.TaskActiveReceiveResp{
TaskTag: req.TaskTag,
Id: req.Id,

View File

@ -18,6 +18,10 @@ func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.TaskReceive
}
func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq) (code pb.ErrorCode, data proto.Message) {
if code = this.ReceiveCheck(session, req); code != pb.ErrorCode_Success {
return
}
resp := &pb.TaskReceiveResp{}
defer func() {
err := session.SendMsg(string(this.moduleTask.GetType()), TaskSubTypeList, resp)

View File

@ -6,7 +6,6 @@ import (
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"time"
)
type ModuleTask struct {
@ -15,8 +14,6 @@ type ModuleTask struct {
modelTaskActive *ModelTaskActive
api *apiComp
configure *configureComp
lastDayTime int64 //上次日任务执行时间戳
lastWeekTime int64 //上次周任务执行时间戳
}
func NewModule() core.IModule {
@ -29,16 +26,6 @@ func (this *ModuleTask) GetType() core.M_Modules {
func (this *ModuleTask) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options)
go func() {
tickC := time.NewTicker(time.Second * 1)
for {
select {
case tc := <-tickC.C:
this.update(tc)
}
}
}()
return
}
@ -56,33 +43,6 @@ func (this *ModuleTask) Start() (err error) {
return
}
func (this *ModuleTask) update(t time.Time) {
this.taskEveryDay(t)
this.taskWeekDay(t)
}
//日任务
func (this *ModuleTask) taskEveryDay(t time.Time) {
n := time.Now().Unix()
if t.Hour() == 4 && t.Minute() == 0 {
this.lastDayTime = n
} else {
this.lastDayTime = 0
}
}
//周任务
func (this *ModuleTask) taskWeekDay(t time.Time) {
n := time.Now().Unix()
if int(t.Weekday()) == 1 { //周一
if t.Hour() == 0 && t.Minute() == 0 {
this.lastWeekTime = n
} else {
this.lastWeekTime = 0
}
}
}
//初始化任务
func (this *ModuleTask) InitTask(uid string, taskTag comm.TaskTag) {
if err := this.modelTask.initTaskByTag(uid, taskTag); err != nil {