update
This commit is contained in:
parent
82ccec5660
commit
db587b9198
@ -23,8 +23,8 @@ func (a *apiComp) Refresh(session comm.IUserSession, req *pb.DispatchRefreshReq)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.GetNb() != nil {
|
if d.Nb != nil {
|
||||||
if d.GetNb().FreeCount > 0 {
|
if d.Nb.FreeCount > 0 {
|
||||||
//更新刷新次数
|
//更新刷新次数
|
||||||
if err := a.module.modelDispatch.updateFreeCount(session.GetUserId(), d.Nb); err != nil {
|
if err := a.module.modelDispatch.updateFreeCount(session.GetUserId(), d.Nb); err != nil {
|
||||||
var customer = new(comm.CustomError)
|
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 {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ func (this *modelDispatch) initDispatch(uid string, dispatch *pb.DBDispatch) *pb
|
|||||||
|
|
||||||
freeCount := this.module.configure.GetGlobalConf().DispatchFreecheck
|
freeCount := this.module.configure.GetGlobalConf().DispatchFreecheck
|
||||||
ticketCount := this.module.configure.GetGlobalConf().DispatchNumoftimes
|
ticketCount := this.module.configure.GetGlobalConf().DispatchNumoftimes
|
||||||
|
refreshCount := this.module.configure.GetGlobalConf().DispatchRefreshtimes
|
||||||
dis := &pb.DBDispatch{
|
dis := &pb.DBDispatch{
|
||||||
Uid: uid,
|
Uid: uid,
|
||||||
Ticket: ticketCount,
|
Ticket: ticketCount,
|
||||||
@ -49,6 +50,7 @@ func (this *modelDispatch) initDispatch(uid string, dispatch *pb.DBDispatch) *pb
|
|||||||
Lv: 1, //公告初始升级
|
Lv: 1, //公告初始升级
|
||||||
FreeCount: freeCount,
|
FreeCount: freeCount,
|
||||||
Tasks: tasks,
|
Tasks: tasks,
|
||||||
|
RefreshCount: refreshCount,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,8 +371,12 @@ func (this *modelDispatch) dispatch(uid string, taskId int32, heroIds []string,
|
|||||||
v.Status = 2 //任务结束
|
v.Status = 2 //任务结束
|
||||||
v.Exaward = flag
|
v.Exaward = flag
|
||||||
} else {
|
} else {
|
||||||
|
taskConf, err := this.module.configure.getDispatchTaskConf(v.TaskId)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
v.Status = 1 //任务进行中
|
v.Status = 1 //任务进行中
|
||||||
leftTime := configure.Now().Unix()
|
leftTime := configure.Now().Unix() + int64(taskConf.Tasktime)
|
||||||
v.LeftTime = leftTime
|
v.LeftTime = leftTime
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -396,8 +402,9 @@ func (this *modelDispatch) updateFreeCount(uid string, noticeboard *pb.Noticeboa
|
|||||||
if noticeboard.FreeCount <= 0 {
|
if noticeboard.FreeCount <= 0 {
|
||||||
return comm.NewCustomError(pb.ErrorCode_DispatchNoFree)
|
return comm.NewCustomError(pb.ErrorCode_DispatchNoFree)
|
||||||
}
|
}
|
||||||
|
noticeboard.FreeCount--
|
||||||
update := map[string]interface{}{
|
update := map[string]interface{}{
|
||||||
"freeCount": noticeboard.FreeCount - 1,
|
"nb": noticeboard,
|
||||||
}
|
}
|
||||||
return this.Change(uid, update)
|
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 {
|
func (this *modelDispatch) updateRefreshCount(uid string, noticeboard *pb.Noticeboard) error {
|
||||||
noticeboard.RefreshCount++
|
noticeboard.RefreshCount++
|
||||||
update := map[string]interface{}{
|
update := map[string]interface{}{
|
||||||
"refreshCount": noticeboard.RefreshCount,
|
"nb": noticeboard,
|
||||||
}
|
}
|
||||||
return this.Change(uid, update)
|
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 {
|
for i, v := range dispatch.Nb.Tasks {
|
||||||
if v.Status == 0 {
|
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 = this.replaceTask(uid, v.TaskId, dispatch)
|
||||||
dispatch.Nb.Tasks = append(dispatch.Nb.Tasks[:i], dispatch.Nb.Tasks[i+1:]...)
|
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.Status == 1 {
|
||||||
if v.LeftTime <= configure.Now().Unix() {
|
if v.LeftTime != 0 && v.LeftTime <= configure.Now().Unix() {
|
||||||
//更改次任务状态为
|
//更改次任务状态为
|
||||||
v.Status = 2 //任务结束
|
v.Status = 2 //任务结束
|
||||||
v.LeftTime = 0
|
v.LeftTime = 0
|
||||||
@ -448,6 +455,9 @@ func (this *modelDispatch) updateNotice(uid string, dispatch *pb.DBDispatch) err
|
|||||||
if dispatch.Nb.WeekCount >= conf.Upgrade {
|
if dispatch.Nb.WeekCount >= conf.Upgrade {
|
||||||
dispatch.Nb.Lv++
|
dispatch.Nb.Lv++
|
||||||
}
|
}
|
||||||
|
//累计任务数
|
||||||
|
dispatch.Nb.TaskCount++
|
||||||
|
dispatch.Nb.WeekCount++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user