清空缓存
This commit is contained in:
parent
9706fc4847
commit
d17ad438d4
@ -226,7 +226,6 @@ func (r *Robot) handleRsp(id string) {
|
||||
if v.enabled &&
|
||||
(msg.MainType == v.mainType &&
|
||||
msg.SubType == v.subType) {
|
||||
zlog.Debugf("2 %v.%v", msg.MainType, msg.SubType)
|
||||
v.hs = time.Since(v.start)
|
||||
if !comm.ProtoUnmarshal(msg, v.rsp) {
|
||||
return
|
||||
|
@ -17,9 +17,9 @@ var (
|
||||
subType: task.TaskSubTypeList,
|
||||
req: &pb.TaskListReq{
|
||||
//设置任务类型
|
||||
TaskTag: int32(comm.TASK_DAILY), //每天任务
|
||||
// TaskTag: int32(comm.TASK_DAILY), //每天任务
|
||||
// TaskTag: int32(comm.TASK_WEEKLY), //周任务
|
||||
// TaskTag: int32(comm.TASK_ACHIEVE),
|
||||
TaskTag: int32(comm.TASK_ACHIEVE),
|
||||
// TaskTag: int32(comm.TASK_STRATEGY),
|
||||
},
|
||||
rsp: &pb.TaskListResp{},
|
||||
|
@ -65,6 +65,18 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) (newli
|
||||
return nil
|
||||
}
|
||||
|
||||
// 判断上个任务领取了才显示最后一个任务
|
||||
isReceived := func(taskId int32) bool {
|
||||
if preCnf := this.moduleTask.configure.getPreTask(taskId); preCnf != nil {
|
||||
if preTask := getCurTask(preCnf.Key); preTask != nil {
|
||||
if preTask.Received == 1 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if taskTag == comm.TASK_ACHIEVE {
|
||||
for _, v := range taskList {
|
||||
if curTask := this.moduleTask.configure.getTaskById(v.TaskId); curTask != nil {
|
||||
@ -75,24 +87,11 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) (newli
|
||||
if next != nil && v.Received == 0 {
|
||||
newlist = append(newlist, v)
|
||||
}
|
||||
} else if !this.moduleTask.configure.isFirstTask(curTask.Key) && curTask.IdAfter == 0 { //连续任务的最后一个任务
|
||||
// 上个任务
|
||||
if preCnf := this.moduleTask.configure.getPreTask(curTask.Key); preCnf != nil {
|
||||
if preTask := getCurTask(preCnf.Key); preTask != nil {
|
||||
if preTask.Received == 1 { //判断上个任务领取了才显示最后一个任务
|
||||
newlist = append(newlist, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if preCnf := this.moduleTask.configure.getPreTask(curTask.Key); preCnf != nil {
|
||||
if preTask := getCurTask(preCnf.Key); preTask != nil {
|
||||
if preTask.Received == 1 { //判断上个任务领取了才显示最后一个任务
|
||||
if isReceived(curTask.Key) {
|
||||
newlist = append(newlist, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
@ -46,6 +47,7 @@ func (this *ModuleTask) OnInstallComp() {
|
||||
//模块启动接口
|
||||
func (this *ModuleTask) Start() (err error) {
|
||||
err = this.ModuleBase.Start()
|
||||
event.RegisterGO(comm.EventUserOffline, this.CleanTask)
|
||||
return
|
||||
}
|
||||
|
||||
@ -55,6 +57,12 @@ func (this *ModuleTask) InitTaskAll(uid string) {
|
||||
this.modelTaskActive.initActiveReward(uid)
|
||||
}
|
||||
|
||||
// 清除缓存
|
||||
func (this *ModuleTask) CleanTask(session comm.IUserSession) {
|
||||
this.modelTask.BatchDelLists(session.GetUserId())
|
||||
this.modelTaskActive.BatchDelLists(session.GetUserId())
|
||||
}
|
||||
|
||||
//重置任务
|
||||
func (this *ModuleTask) ResetTask(uid string, taskTag comm.TaskTag) {
|
||||
this.modelTask.clearTask(uid, taskTag)
|
||||
|
@ -26,10 +26,3 @@ func (this *ModelSession) getUserSession(uid string) (cuser *pb.CacheUser) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//清除session缓存
|
||||
func (this *ModelSession) cleanSession(uid string) {
|
||||
if err := this.Del(uid); err != nil {
|
||||
log.Errorf("clean session err: %v", err)
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,8 @@ func (this *User) GetUserSession(uid string) *pb.CacheUser {
|
||||
|
||||
// 清除session
|
||||
func (this *User) CleanSession(session comm.IUserSession) {
|
||||
this.modelSession.cleanSession(session.GetUserId())
|
||||
this.modelSession.Del(session.GetUserId(), modules.SetDBMgoLog(false))
|
||||
this.modelUser.Del(session.GetUserId(), modules.SetDBMgoLog(false))
|
||||
}
|
||||
|
||||
//查询用户属性值 例如 金币 经验
|
||||
|
Loading…
Reference in New Issue
Block a user