package dispatch import ( "go_dreamfactory/comm" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" "go_dreamfactory/utils" "google.golang.org/protobuf/proto" ) // 公告板信息 func (a *apiComp) NoticeCheck(session comm.IUserSession, req *pb.DispatchNoticeReq) (code pb.ErrorCode) { return } func (a *apiComp) Notice(session comm.IUserSession, req *pb.DispatchNoticeReq) (code pb.ErrorCode, data proto.Message) { d := a.module.modelDispatch.getDBDispatch(session.GetUserId()) if d == nil { code = pb.ErrorCode_DataNotFound return } uid := session.GetUserId() rsp := &pb.DispatchNoticeResp{} if len(d.Nb.Tasks) == 0 { tasks, err := a.module.modelDispatch.taskRandom(uid, d) if err != nil { return } if len(tasks) == 0 { return } freeCount := a.module.configure.GetGlobalConf().DispatchFreecheck ticketCount := a.module.configure.GetGlobalConf().DispatchNumoftimes nb := &pb.Noticeboard{ Lv: 1, //公告初始升级 FreeCount: freeCount, Tasks: tasks, CreateTime: configure.Now().Unix(), } update := map[string]interface{}{ "nb": nb, "ticket": ticketCount, } if err := a.module.modelDispatch.Change(uid, update); err != nil { code = pb.ErrorCode_DBError return } d.Nb = nb } else { //周任务重置 n := utils.DiffDays(d.Nb.CreateTime, configure.Now().Unix()) day := a.module.configure.GetGlobalConf().DispatchWeektaskcheck if int32(n) >= day { d.Nb.WeekCount = 0 d.Nb.WeekReceived = []int32{} } a.module.modelDispatch.updateNotice(session.GetUserId(), d) } rsp.Dispatch = d.Nb session.SendMsg(string(a.module.GetType()), "notice", rsp) return }