任务数据状态更新
This commit is contained in:
parent
58721927ba
commit
c9e30f24a0
@ -82,22 +82,39 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) *pb.DB
|
||||
return nil
|
||||
}
|
||||
|
||||
// 筛选出指定tag的任务
|
||||
var dataList []*pb.TaskData
|
||||
if taskTag == comm.TASK_DAILY {
|
||||
for _, v := range task.DayList {
|
||||
if p, ok := dr.Vals[v.TypeId]; ok {
|
||||
if len(p.Data) > 0 {
|
||||
v.Progress = p.Data[0]
|
||||
}
|
||||
dataList = task.DayList
|
||||
} else if taskTag == comm.TASK_WEEKLY {
|
||||
dataList = task.WeekList
|
||||
}
|
||||
|
||||
// 筛选出指定tag的任务
|
||||
update := map[string]interface{}{}
|
||||
var flag bool
|
||||
for _, v := range dataList {
|
||||
oldVal := v.Progress
|
||||
var newVal int32
|
||||
if p, ok := dr.Vals[v.TypeId]; ok {
|
||||
if len(p.Data) == 0 {
|
||||
continue
|
||||
}
|
||||
newVal = p.Data[0]
|
||||
if code := this.moduleTask.ModuleRtask.CheckCondi(uid, v.TypeId); code == pb.ErrorCode_Success {
|
||||
v.Progress = p.Data[0]
|
||||
v.Status = 1
|
||||
} else {
|
||||
v.Progress = p.Data[0]
|
||||
}
|
||||
}
|
||||
} else if taskTag == comm.TASK_WEEKLY {
|
||||
for _, v := range task.WeekList {
|
||||
if p, ok := dr.Vals[v.TypeId]; ok {
|
||||
if len(p.Data) > 0 {
|
||||
v.Progress = p.Data[0]
|
||||
}
|
||||
}
|
||||
if oldVal != newVal {
|
||||
flag = true
|
||||
}
|
||||
}
|
||||
if flag {
|
||||
update["dayList"] = task.DayList
|
||||
if err := this.moduleTask.modelTask.Change("uid", update); err != nil {
|
||||
log.Error("更新每日任务", log.Fields{"uid": uid})
|
||||
}
|
||||
}
|
||||
|
||||
@ -446,7 +463,7 @@ func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface
|
||||
progress int32
|
||||
update map[string]interface{}
|
||||
)
|
||||
|
||||
|
||||
if code := this.moduleTask.ModuleRtask.CheckCondi(tl.Uid, conf.TypeId); code == pb.ErrorCode_Success {
|
||||
// update data
|
||||
if ret != nil && len(ret.Data) > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user