上传工会任务代码优化
This commit is contained in:
parent
7dbb1e2424
commit
82f1562291
@ -30,8 +30,8 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (er
|
|||||||
// 未加入公会
|
// 未加入公会
|
||||||
if userEx.SociatyId == "" {
|
if userEx.SociatyId == "" {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_SociatyNoAdded,
|
Code: pb.ErrorCode_SociatyNoAdded,
|
||||||
Title: pb.ErrorCode_SociatyNoAdded.ToString(),
|
Title: pb.ErrorCode_SociatyNoAdded.ToString(),
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 初始玩家公会任务
|
// 初始玩家公会任务
|
||||||
sociatyTask := this.module.modelSociatyTask.getUserTask(uid, sociaty.Id)
|
sociatyTask, _ := this.module.modelSociatyTask.getUserTask(uid, sociaty.Id)
|
||||||
if sociatyTask.SociatyId != "" {
|
if sociatyTask.SociatyId != "" {
|
||||||
// 今日首次进入公会
|
// 今日首次进入公会
|
||||||
if utils.IsFirstTody(sociatyTask.LastUpdateTime) {
|
if utils.IsFirstTody(sociatyTask.LastUpdateTime) {
|
||||||
|
@ -31,7 +31,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sociatyTask := this.module.modelSociatyTask.getUserTask(uid, sociaty.Id)
|
sociatyTask, _ := this.module.modelSociatyTask.getUserTask(uid, sociaty.Id)
|
||||||
for _, v := range sociatyTask.TaskList {
|
for _, v := range sociatyTask.TaskList {
|
||||||
if v.TaskId == req.TaskId {
|
if v.TaskId == req.TaskId {
|
||||||
if v.Status != 1 {
|
if v.Status != 1 {
|
||||||
|
@ -13,61 +13,72 @@ func (this *apiComp) TaskListCheck(session comm.IUserSession, req *pb.SociatyTas
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) TaskList(session comm.IUserSession, req *pb.SociatyTaskListReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) TaskList(session comm.IUserSession, req *pb.SociatyTaskListReq) (errdata *pb.ErrorData) {
|
||||||
uid := session.GetUserId()
|
var (
|
||||||
|
sociatyTask *pb.DBSociatyTask
|
||||||
|
condis []*pb.ConIProgress
|
||||||
|
condisMap map[int32]*pb.ConIProgress = make(map[int32]*pb.ConIProgress)
|
||||||
|
comid *pb.ConIProgress
|
||||||
|
ok bool
|
||||||
|
tasklist []int32
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
sociaty := this.module.modelSociaty.getUserSociaty(session.GetUserId())
|
||||||
if sociaty == nil {
|
if sociaty == nil {
|
||||||
|
|
||||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: session.GetUserId()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rsp := &pb.SociatyTaskListResp{}
|
|
||||||
|
|
||||||
sociatyTask := this.module.modelSociatyTask.getUserTask(uid, sociaty.Id)
|
if sociatyTask, err = this.module.modelSociatyTask.getUserTask(session.GetUserId(), sociaty.Id); err != nil {
|
||||||
if sociatyTask.SociatyId != "" {
|
errdata = &pb.ErrorData{
|
||||||
var taskList []*pb.SociatyTask
|
Code: pb.ErrorCode_DBError,
|
||||||
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
for _, v := range sociatyTask.TaskList {
|
Message: err.Error(),
|
||||||
// if _, ok := this.module.modelSociaty.validTask(uid, v.TaskId); ok {
|
|
||||||
// status = 1 //完成
|
|
||||||
// }
|
|
||||||
|
|
||||||
conds, err := this.module.ModuleBuried.CheckCondition(uid, v.TaskId)
|
|
||||||
if err != nil {
|
|
||||||
this.module.Error(err.Error())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, cond := range conds {
|
|
||||||
v.Cond = cond
|
|
||||||
if cond.State == pb.BuriedItemFinishState_buried_finish {
|
|
||||||
v.Status = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
taskList = append(taskList, &pb.SociatyTask{
|
|
||||||
TaskId: v.TaskId,
|
|
||||||
Status: v.Status,
|
|
||||||
Received: v.Received,
|
|
||||||
Cond: v.Cond,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
rsp.List = taskList
|
return
|
||||||
|
}
|
||||||
|
for _, v := range sociatyTask.TaskList {
|
||||||
|
if v.Status == 0 {
|
||||||
|
tasklist = append(tasklist, v.TaskId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
condis, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), tasklist...)
|
||||||
|
if err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ExternalModule,
|
||||||
|
Title: pb.ErrorCode_ExternalModule.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, v := range condis {
|
||||||
|
condisMap[v.Conid] = v
|
||||||
|
}
|
||||||
|
|
||||||
if err := this.module.modelSociatyTask.updateTaskList(sociaty.Id, uid, taskList); err != nil {
|
for _, v := range sociatyTask.TaskList {
|
||||||
errdata = &pb.ErrorData{
|
if comid, ok = condisMap[v.TaskId]; ok {
|
||||||
Code: pb.ErrorCode_DBError,
|
v.Cond = comid
|
||||||
Title: pb.ErrorCode_DBError.ToString(),
|
if comid.State == pb.BuriedItemFinishState_buried_finish {
|
||||||
Message: err.Error(),
|
v.Status = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
this.module.Error("更新公会任务列表失败",
|
|
||||||
log.Field{Key: "uid", Value: uid},
|
|
||||||
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
|
||||||
log.Field{Key: "err", Value: err.Error()})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeTasklist, rsp)
|
if err := this.module.modelSociatyTask.updateTaskList(sociaty.Id, session.GetUserId(), sociatyTask.TaskList); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_DBError,
|
||||||
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
|
||||||
|
this.module.Error("更新公会任务列表失败",
|
||||||
|
log.Field{Key: "uid", Value: session.GetUserId()},
|
||||||
|
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
||||||
|
log.Field{Key: "err", Value: err.Error()})
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
|
||||||
|
session.SendMsg(string(this.module.GetType()), SociatySubTypeTasklist, &pb.SociatyTaskListResp{List: sociatyTask.TaskList})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -65,9 +65,9 @@ func (this *ModelSociatyTask) initSociatyTask(uid, sociatyId string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 公会任务列表
|
// 公会任务列表
|
||||||
func (this *ModelSociatyTask) getUserTask(uid, sociatyId string) (task *pb.DBSociatyTask) {
|
func (this *ModelSociatyTask) getUserTask(uid, sociatyId string) (task *pb.DBSociatyTask, err error) {
|
||||||
task = &pb.DBSociatyTask{}
|
task = &pb.DBSociatyTask{}
|
||||||
this.GetListObj(sociatyId, uid, task)
|
err = this.GetListObj(sociatyId, uid, task)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,8 +339,8 @@ func (this *Sociaty) RpcUpdateUserTask(ctx context.Context, p *TaskParams, reply
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Sociaty) RpcGetUserTask(ctx context.Context, p *pb.RPCGeneralReqA2, reply *pb.DBSociatyTask) error {
|
func (this *Sociaty) RpcGetUserTask(ctx context.Context, p *pb.RPCGeneralReqA2, reply *pb.DBSociatyTask) error {
|
||||||
dt := this.modelSociatyTask.getUserTask(p.Param2, p.Param1)
|
dt, err := this.modelSociatyTask.getUserTask(p.Param2, p.Param1)
|
||||||
if dt == nil {
|
if err != nil {
|
||||||
return errors.New("not found")
|
return errors.New("not found")
|
||||||
}
|
}
|
||||||
reply.Uid = dt.Uid
|
reply.Uid = dt.Uid
|
||||||
|
Loading…
Reference in New Issue
Block a user