This commit is contained in:
wh_zcy 2023-03-10 15:43:58 +08:00
parent 158ac69b08
commit 5acf0521c4
2 changed files with 80 additions and 5 deletions

View File

@ -214,7 +214,7 @@ type (
//任务触发
SendToRtask(session IUserSession, rtaskType TaskType, params ...int32) (code pb.ErrorCode)
//任务批量触发
TriggerTask(uid string, taskParams ...TaskParam) (code pb.ErrorCode)
TriggerTask(uid string, taskParams ...*TaskParam)
// 获取任务条件记录
GetCondiData(uid string) *pb.DBRtaskRecord
}

View File

@ -218,8 +218,7 @@ func (this *ModuleRtask) initRtaskVerifyHandle() {
}
}
func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) {
uid := session.GetUserId()
func (this *ModuleRtask) processOneTask(uid string, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) {
var condis []*rtaskCondi
for _, codiConf := range this.configure.getRtaskCondis(int32(rtaskType)) {
v, ok := this.handleMap[codiConf.Id]
@ -245,6 +244,7 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
condis = append(condis, v)
}
}
session, _ := this.GetUserSession(uid)
// update
for _, v := range condis {
@ -262,7 +262,82 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
}
}
//
//任务完成则推送
if code := this.CheckCondi(uid, conf.Id); code == pb.ErrorCode_Success {
module, err := this.service.GetModule(comm.ModuleWorldtask)
if err == nil {
go func() {
defer func() {
if r := recover(); r != nil {
log.Errorf("[worldtask ] err:%v ", r)
}
}()
if worldtask, ok := module.(comm.IWorldtask); ok {
if err := worldtask.TaskcondNotify(session, conf.Id); err != nil {
var customErr = new(comm.CustomError)
if errors.As(err, &customErr) {
notifyErr := &pb.NotifyErrorNotifyPush{
ReqMainType: string(comm.ModuleWorldtask),
ReqSubType: "finish",
Message: "",
}
if customErr.Code == pb.ErrorCode_WorldtaskLvNotEnough {
notifyErr.Code = pb.ErrorCode_WorldtaskLvNotEnough
session.SendMsg(string(comm.ModuleWorldtask), "finish", notifyErr)
} else if customErr.Code == pb.ErrorCode_UserSessionNobeing {
notifyErr.Code = pb.ErrorCode_UserSessionNobeing
session.SendMsg(string(comm.ModuleWorldtask), "finish", notifyErr)
} else {
log.Error("任务条件达成通知",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "condId", Value: conf.Id},
log.Field{Key: "err", Value: err.Error()},
)
}
}
}
}
}()
}
userModule, err := this.service.GetModule(comm.ModuleUser)
if err == nil {
go func() {
defer func() { //程序异常 收集异常信息传递给前端显示
if r := recover(); r != nil {
log.Errorf("[sociatytask ] err:%v ", r)
}
}()
// 公会
if user, ok := userModule.(comm.IUser); ok {
ex, err := user.GetUserExpand(session.GetUserId())
if err == nil && ex.SociatyId != "" {
sociatyModule, err := this.service.GetModule(comm.ModuleSociaty)
if err != nil {
return
}
if sociaty, ok := sociatyModule.(comm.ISociaty); ok {
if err2 := sociaty.TaskcondNotify(uid, ex.SociatyId, conf.Id); err2 != nil {
log.Error("公会任务条件达成通知",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: ex.SociatyId},
log.Field{Key: "condId", Value: conf.Id},
log.Field{Key: "err", Value: err2.Error()},
)
}
if module, err := this.service.GetModule(comm.ModuleRtask); err == nil {
if iRtask, ok := module.(comm.IRtask); ok {
iRtask.SendToRtask(session, comm.Rtype156, 1)
}
}
}
}
}
}()
}
}
}
return
@ -414,7 +489,7 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T
return
}
func (this *ModuleRtask) TriggerTask(uid string, taskParams ...comm.TaskParam) (code pb.ErrorCode) {
func (this *ModuleRtask) TriggerTask(uid string, taskParams ...*comm.TaskParam) {
return
}