上传工会任务进度问题
This commit is contained in:
parent
eeadeb379b
commit
01efe7f3f4
@ -108,3 +108,7 @@ func (this *buriedModel) updateUserBurieds(uid string, data *pb.DBBuried) (err e
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *buriedModel) userlock(uid string) (result *redis.RedisMutex, err error) {
|
||||||
|
return this.model.Redis.NewRedisMutex(fmt.Sprintf("ulockburied:%s", uid))
|
||||||
|
}
|
||||||
|
@ -81,7 +81,7 @@ func (this *Buried) ActiveCondition(uid string, condiIds ...int32) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.Debug("激活埋点!", log.Field{Key: "condiIds", Value: condiIds})
|
this.Debug("激活埋点!", log.Field{Key: "condiIds", Value: condiIds})
|
||||||
lock, _ := this.modelBuried.userlock(uid)
|
lock, _ := model.userlock(uid)
|
||||||
err = lock.Lock()
|
err = lock.Lock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.Error("埋点分布式锁失效 err!", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()})
|
this.Error("埋点分布式锁失效 err!", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()})
|
||||||
@ -228,7 +228,7 @@ func (this *Buried) FinishConditionAndCheck(uid string, finishcondiIds []int32,
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.Debug("完成埋点!", log.Field{Key: "finishcondiIds", Value: finishcondiIds})
|
this.Debug("完成埋点!", log.Field{Key: "finishcondiIds", Value: finishcondiIds})
|
||||||
lock, _ := this.modelBuried.userlock(uid)
|
lock, _ := model.userlock(uid)
|
||||||
err = lock.Lock()
|
err = lock.Lock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.Error("埋点分布式锁失效 err!", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()})
|
this.Error("埋点分布式锁失效 err!", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()})
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package sociaty
|
package sociaty
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
@ -13,61 +14,74 @@ 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: session.GetUserId()})
|
||||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_SociatyNoFound,
|
||||||
|
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||||
|
Message: fmt.Sprintf("no found Sociaty!"),
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rsp := &pb.SociatyTaskListResp{}
|
|
||||||
|
|
||||||
sociatyTask := this.module.modelSociatyTask.getUserTask(uid, sociaty.Id)
|
if sociatyTask = this.module.modelSociatyTask.getUserTask(session.GetUserId(), sociaty.Id); sociatyTask.SociatyId == "" {
|
||||||
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: "no found task!",
|
||||||
// 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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user