修复代码

This commit is contained in:
liwei1dao 2023-09-25 15:35:59 +08:00
parent abaf242108
commit 019455923d
4 changed files with 57 additions and 57 deletions

View File

@ -293,7 +293,7 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade
if len(tasks) > 0 { if len(tasks) > 0 {
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype95, 1)) this.module.ModuleBuried.TriggerBuried(session, tasks...)
}) })
} }
return return

View File

@ -8,7 +8,6 @@ import (
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure" "go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
) )
@ -36,27 +35,27 @@ func (this *ModelSociatyTask) initSociatyTask(uid, sociatyId string) error {
var taskList []*pb.SociatyTask var taskList []*pb.SociatyTask
taskListConf := this.moduleSociaty.sociatyTaskConf.GetDataList() taskListConf := this.moduleSociaty.sociatyTaskConf.GetDataList()
globalConf := this.moduleSociaty.globalConf // globalConf := this.moduleSociaty.globalConf
var condIds []int32 var condIds []int32
// 大于4条配置 // 大于4条配置
if len(taskListConf) > int(globalConf.GuildTaskNum) { // if len(taskListConf) > int(globalConf.GuildTaskNum) {
// 按照权重 // // 按照权重
//随机4条任务 // //随机4条任务
randInts := utils.RandomNumbers(0, len(taskListConf)-1, int(globalConf.GuildTaskNum)) // randInts := utils.RandomNumbers(0, len(taskListConf)-1, int(globalConf.GuildTaskNum))
for _, v := range randInts { // for _, v := range randInts {
taskList = append(taskList, &pb.SociatyTask{ // taskList = append(taskList, &pb.SociatyTask{
TaskId: taskListConf[v].TypeId, // TaskId: taskListConf[v].TypeId,
}) // })
condIds = append(condIds, taskListConf[v].TypeId) // condIds = append(condIds, taskListConf[v].TypeId)
} // }
} else { // } else {
for _, v := range taskListConf { for _, v := range taskListConf {
taskList = append(taskList, &pb.SociatyTask{ taskList = append(taskList, &pb.SociatyTask{
TaskId: v.TypeId, TaskId: v.TypeId,
}) })
condIds = append(condIds, v.TypeId) condIds = append(condIds, v.TypeId)
}
} }
// }
sociatyTask.TaskList = taskList sociatyTask.TaskList = taskList
sociatyTask.LastUpdateTime = configure.Now().Unix() sociatyTask.LastUpdateTime = configure.Now().Unix()
// 激活所有任务 // 激活所有任务

View File

@ -323,48 +323,49 @@ type TaskParams struct {
} }
// 任务条件达成通知 // 任务条件达成通知
// 废弃 不需要主动推送任务变化 前端主动刷新页面即可
func (this *Sociaty) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) { func (this *Sociaty) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) {
log.Debug("公会任务通知", // log.Debug("公会任务通知",
log.Field{Key: "uid", Value: session.GetUserId()}, // log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "condIds", Value: conds}) // log.Field{Key: "condIds", Value: conds})
sociaty := this.modelSociaty.getUserSociaty(session.GetUserId()) // sociaty := this.modelSociaty.getUserSociaty(session.GetUserId())
if sociaty == nil { // if sociaty == nil {
return // return
} // }
sociatyId := sociaty.Id // sociatyId := sociaty.Id
dt := &pb.DBSociatyTask{} // dt := &pb.DBSociatyTask{}
err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), // err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
comm.Service_Worker, string(comm.Rpc_ModuleSociatyGetTask), // comm.Service_Worker, string(comm.Rpc_ModuleSociatyGetTask),
&pb.RPCGeneralReqA2{Param1: sociatyId, Param2: session.GetUserId()}, dt) // &pb.RPCGeneralReqA2{Param1: sociatyId, Param2: session.GetUserId()}, dt)
var flag bool // var flag bool
for _, v := range dt.TaskList { // for _, v := range dt.TaskList {
for _, cond := range conds { // for _, cond := range conds {
if v.TaskId == cond.Conid && cond.State == pb.BuriedItemFinishState_buried_finish { // if v.TaskId == cond.Conid && cond.State == pb.BuriedItemFinishState_buried_finish {
v.Status = 1 // v.Status = 1
flag = true // flag = true
} // }
} // }
} // }
if !flag { // if !flag {
return // return
} // }
update := map[string]interface{}{ // update := map[string]interface{}{
"taskList": dt.TaskList, // "taskList": dt.TaskList,
"lastUpdateTime": configure.Now().Unix(), // "lastUpdateTime": configure.Now().Unix(),
} // }
err = this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), // err = this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
comm.Service_Worker, string(comm.Rpc_ModuleSociatyTask), // comm.Service_Worker, string(comm.Rpc_ModuleSociatyTask),
&TaskParams{SociatyId: sociatyId, Uid: session.GetUserId(), Data: update}, &pb.EmptyResp{}) // &TaskParams{SociatyId: sociatyId, Uid: session.GetUserId(), Data: update}, &pb.EmptyResp{})
if err != nil { // if err != nil {
return // return
} // }
return // return
} }
func (this *Sociaty) RpcUpdateUserTask(ctx context.Context, p *TaskParams, reply *pb.EmptyResp) error { func (this *Sociaty) RpcUpdateUserTask(ctx context.Context, p *TaskParams, reply *pb.EmptyResp) error {

View File

@ -102,12 +102,12 @@ func (this *ModelUser) GetUser(uid string) (user *pb.DBUser, err error) {
this.module.Errorln(err) this.module.Errorln(err)
} else { } else {
if err = model.Get(uid, user); err != nil { if err = model.Get(uid, user); err != nil {
this.module.Errorf("err:%v", err) this.module.Errorf("uid:%s err:%v", uid, err)
} }
} }
} else { } else {
if err = this.Get(uid, user); err != nil { if err = this.Get(uid, user); err != nil {
this.module.Errorf("err:%v", err) this.module.Errorf("uid:%s err:%v", uid, err)
} }
} }
return return