This commit is contained in:
wh_zcy 2023-03-03 09:45:18 +08:00
parent 82ccec5660
commit db587b9198
2 changed files with 21 additions and 11 deletions

View File

@ -23,8 +23,8 @@ func (a *apiComp) Refresh(session comm.IUserSession, req *pb.DispatchRefreshReq)
return
}
if d.GetNb() != nil {
if d.GetNb().FreeCount > 0 {
if d.Nb != nil {
if d.Nb.FreeCount > 0 {
//更新刷新次数
if err := a.module.modelDispatch.updateFreeCount(session.GetUserId(), d.Nb); err != nil {
var customer = new(comm.CustomError)
@ -59,7 +59,7 @@ func (a *apiComp) Refresh(session comm.IUserSession, req *pb.DispatchRefreshReq)
//更新公告任务
if err := a.module.modelDispatch.updateTasks(session.GetUserId(), d.Nb, taskIds); err != nil {
a.module.Debug("更新公告失败", log.Field{Key: ""})
a.module.Debug("更新公告失败", log.Field{Key: "uid", Value: session.GetUserId()})
return
}

View File

@ -42,13 +42,15 @@ func (this *modelDispatch) initDispatch(uid string, dispatch *pb.DBDispatch) *pb
freeCount := this.module.configure.GetGlobalConf().DispatchFreecheck
ticketCount := this.module.configure.GetGlobalConf().DispatchNumoftimes
refreshCount := this.module.configure.GetGlobalConf().DispatchRefreshtimes
dis := &pb.DBDispatch{
Uid: uid,
Ticket: ticketCount,
Nb: &pb.Noticeboard{
Lv: 1, //公告初始升级
FreeCount: freeCount,
Tasks: tasks,
Lv: 1, //公告初始升级
FreeCount: freeCount,
Tasks: tasks,
RefreshCount: refreshCount,
},
}
@ -369,8 +371,12 @@ func (this *modelDispatch) dispatch(uid string, taskId int32, heroIds []string,
v.Status = 2 //任务结束
v.Exaward = flag
} else {
taskConf, err := this.module.configure.getDispatchTaskConf(v.TaskId)
if err != nil {
continue
}
v.Status = 1 //任务进行中
leftTime := configure.Now().Unix()
leftTime := configure.Now().Unix() + int64(taskConf.Tasktime)
v.LeftTime = leftTime
}
}
@ -396,8 +402,9 @@ func (this *modelDispatch) updateFreeCount(uid string, noticeboard *pb.Noticeboa
if noticeboard.FreeCount <= 0 {
return comm.NewCustomError(pb.ErrorCode_DispatchNoFree)
}
noticeboard.FreeCount--
update := map[string]interface{}{
"freeCount": noticeboard.FreeCount - 1,
"nb": noticeboard,
}
return this.Change(uid, update)
}
@ -406,7 +413,7 @@ func (this *modelDispatch) updateFreeCount(uid string, noticeboard *pb.Noticeboa
func (this *modelDispatch) updateRefreshCount(uid string, noticeboard *pb.Noticeboard) error {
noticeboard.RefreshCount++
update := map[string]interface{}{
"refreshCount": noticeboard.RefreshCount,
"nb": noticeboard,
}
return this.Change(uid, update)
}
@ -425,7 +432,7 @@ func (this *modelDispatch) updateNotice(uid string, dispatch *pb.DBDispatch) err
for i, v := range dispatch.Nb.Tasks {
if v.Status == 0 {
//判断到期时间
if v.Duration <= configure.Now().Unix() {
if v.Duration != 0 && v.Duration <= configure.Now().Unix() {
//替换到期任务
// dispatch.Nb.Tasks = this.replaceTask(uid, v.TaskId, dispatch)
dispatch.Nb.Tasks = append(dispatch.Nb.Tasks[:i], dispatch.Nb.Tasks[i+1:]...)
@ -436,7 +443,7 @@ func (this *modelDispatch) updateNotice(uid string, dispatch *pb.DBDispatch) err
}
if v.Status == 1 {
if v.LeftTime <= configure.Now().Unix() {
if v.LeftTime != 0 && v.LeftTime <= configure.Now().Unix() {
//更改次任务状态为
v.Status = 2 //任务结束
v.LeftTime = 0
@ -448,6 +455,9 @@ func (this *modelDispatch) updateNotice(uid string, dispatch *pb.DBDispatch) err
if dispatch.Nb.WeekCount >= conf.Upgrade {
dispatch.Nb.Lv++
}
//累计任务数
dispatch.Nb.TaskCount++
dispatch.Nb.WeekCount++
}
}
}