From a686976b28fa51a54e098569c91bc24e996dd3d8 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Thu, 5 Jan 2023 13:46:44 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E5=85=AC=E4=BC=9A=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 3 ++ comm/imodule.go | 2 ++ modules/rtask/module.go | 75 +++++++++++++++++++++++++++------------ modules/sociaty/module.go | 74 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 23 deletions(-) diff --git a/comm/const.go b/comm/const.go index 3f52107d6..60771655b 100644 --- a/comm/const.go +++ b/comm/const.go @@ -259,6 +259,9 @@ const ( //Rpc // 公会更新 Rpc_ModuleSociatyUpdate core.Rpc_Key = "Rpc_ModuleSociatyUpdate" + //公会任务列表 + Rpc_ModuleSociatyTask core.Rpc_Key = "Rpc_ModuleSociatyTask" + // RPC 通知来了邮件 Rpc_Mail core.Rpc_Key = "Rpc_Mail" ) diff --git a/comm/imodule.go b/comm/imodule.go index f66976a3e..73579d481 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -282,6 +282,8 @@ type ( BingoSetExp(session IUserSession, exp int32) error // 设置工会活跃度 BingoSetActivity(session IUserSession, activity int32) error + // 任务条件达成通知 + TaskcondNotify(uid, sociatyId string, condId int32) error ///红点 IReddot } diff --git a/modules/rtask/module.go b/modules/rtask/module.go index 092c312ce..2b944e4f0 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -184,7 +184,9 @@ func (this *ModuleRtask) initRtaskVerifyHandle() { }) case comm.Rtype63: this.registerVerifyHandle(v.Id, &rtaskCondi{ + find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verifyRtype63, + update: this.modelRtaskRecord.addUpdate, }) case comm.Rtype16, comm.Rtype17, comm.Rtype35, comm.Rtype44, @@ -291,33 +293,60 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T if code := this.CheckCondi(uid, conf.Id); code == pb.ErrorCode_Success { module, err := this.service.GetModule(comm.ModuleWorldtask) if err == nil { - // 世界任务 - if worldtask, ok := module.(comm.IWorldtask); ok { - if err := worldtask.TaskcondNotify(session, conf.Id); err != nil { - var customErr = new(comm.CustomError) - if errors.As(err, &customErr) { - notifyErr := &pb.NotifyErrorNotifyPush{ - ReqMainType: string(comm.ModuleWorldtask), - ReqSubType: "finish", - Message: "", - } + go func() { + // 世界任务 + if worldtask, ok := module.(comm.IWorldtask); ok { + if err := worldtask.TaskcondNotify(session, conf.Id); err != nil { + var customErr = new(comm.CustomError) + if errors.As(err, &customErr) { + notifyErr := &pb.NotifyErrorNotifyPush{ + ReqMainType: string(comm.ModuleWorldtask), + ReqSubType: "finish", + Message: "", + } - if customErr.Code == pb.ErrorCode_WorldtaskLvNotEnough { - notifyErr.Code = pb.ErrorCode_WorldtaskLvNotEnough - session.SendMsg(string(comm.ModuleWorldtask), "finish", notifyErr) - } else if customErr.Code == pb.ErrorCode_UserSessionNobeing { - notifyErr.Code = pb.ErrorCode_UserSessionNobeing - session.SendMsg(string(comm.ModuleWorldtask), "finish", notifyErr) - } else { - log.Error("任务条件达成通知", - log.Field{Key: "uid", Value: uid}, - log.Field{Key: "condId", Value: conf.Id}, - log.Field{Key: "err", Value: err.Error()}, - ) + if customErr.Code == pb.ErrorCode_WorldtaskLvNotEnough { + notifyErr.Code = pb.ErrorCode_WorldtaskLvNotEnough + session.SendMsg(string(comm.ModuleWorldtask), "finish", notifyErr) + } else if customErr.Code == pb.ErrorCode_UserSessionNobeing { + notifyErr.Code = pb.ErrorCode_UserSessionNobeing + session.SendMsg(string(comm.ModuleWorldtask), "finish", notifyErr) + } else { + log.Error("任务条件达成通知", + log.Field{Key: "uid", Value: uid}, + log.Field{Key: "condId", Value: conf.Id}, + log.Field{Key: "err", Value: err.Error()}, + ) + } } } } - } + }() + } + userModule, err := this.service.GetModule(comm.ModuleUser) + if err == nil { + go func() { + // 公会 + if user, ok := userModule.(comm.IUser); ok { + ex, err := user.GetUserExpand(session.GetUserId()) + if err == nil && ex.SociatyId != "" { + sociatyModule, err := this.service.GetModule(comm.ModuleSociaty) + if err != nil { + return + } + if sociaty, ok := sociatyModule.(comm.ISociaty); ok { + if err2 := sociaty.TaskcondNotify(uid, ex.SociatyId, conf.Id); err2 != nil { + log.Error("公会任务条件达成通知", + log.Field{Key: "uid", Value: uid}, + log.Field{Key: "sociatyId", Value: ex.SociatyId}, + log.Field{Key: "condId", Value: conf.Id}, + log.Field{Key: "err", Value: err2.Error()}, + ) + } + } + } + } + }() } } } diff --git a/modules/sociaty/module.go b/modules/sociaty/module.go index b27142e8f..9f28b4701 100644 --- a/modules/sociaty/module.go +++ b/modules/sociaty/module.go @@ -6,6 +6,7 @@ package sociaty import ( "context" "errors" + "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" @@ -14,6 +15,9 @@ import ( "go_dreamfactory/pb" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" + "go_dreamfactory/sys/db" + + "go.mongodb.org/mongo-driver/bson" ) var _ comm.ISociaty = (*Sociaty)(nil) @@ -60,6 +64,7 @@ func (this *Sociaty) Start() (err error) { err = this.ModuleBase.Start() this.service.RegisterFunctionName(string(comm.Rpc_ModuleSociaty), this.RpcGetSociaty) this.service.RegisterFunctionName(string(comm.Rpc_ModuleSociatyUpdate), this.RpcUpdateSociaty) + this.service.RegisterFunctionName(string(comm.Rpc_ModuleSociatyTask), this.RpcUpdateUserTask) this.globalConf = this.configure.GetGlobalConf() if this.globalConf == nil { err = errors.New("global config not found") @@ -220,3 +225,72 @@ func (this *Sociaty) BingoSetActivity(session comm.IUserSession, activity int32) } return this.modelSociaty.updateSociaty(sociaty.Id, update) } + +type TaskParams struct { + SociatyId string + Uid string + Data interface{} +} + +// 任务条件达成通知 +func (this *Sociaty) TaskcondNotify(uid, sociatyId string, condId int32) error { + log.Debug("公会任务", + log.Field{Key: "uid", Value: uid}, + log.Field{Key: "sociatyId", Value: sociatyId}, + log.Field{Key: "condId", Value: condId}) + dt := this.modelSociatyTask.getUserTask(uid, sociatyId) + + var flag bool + for _, v := range dt.TaskList { + if v.TaskId == condId { + v.Status = 1 + flag = true + break + } + } + if !flag { + return nil + } + + update := map[string]interface{}{ + "taskList": dt.TaskList, + "lastUpdateTime": configure.Now().Unix(), + } + + err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), + comm.Service_Worker, string(comm.Rpc_ModuleSociatyTask), + &TaskParams{SociatyId: sociatyId, Uid: uid, Data: update}, &pb.EmptyResp{}) + if err != nil { + return err + } + return nil +} + +func (this *Sociaty) RpcUpdateUserTask(ctx context.Context, p *TaskParams, reply *pb.EmptyResp) error { + conn, err := db.Local() + if err != nil { + return err + } + model := db.NewDBModel(comm.TableSociatyTask, 0, conn) + + if err := model.Redis.HMSet(fmt.Sprintf("%s:%s-%s", this.modelSociatyTask.TableName, + p.SociatyId, p.Uid), p.Data); err != nil { + log.Error("DBModel ChangeList", log.Field{Key: "err", Value: err.Error()}) + return err + } + + if err := model.UpdateModelLogs(this.modelSociatyTask.TableName, + p.Uid, bson.M{"sociatyid": p.SociatyId, "uid": p.Uid}, p.Data); err != nil { + return err + } + // task := &pb.DBSociatyTask{} + // if err := model.GetListObj(p.Param1, p.Param2, task); err != nil { + // return err + // } + // reply.TaskList = task.TaskList + // reply.Uid = task.Uid + // reply.ActivityList = task.ActivityList + // reply.SociatyId = task.SociatyId + // reply.LastUpdateTime = task.LastUpdateTime + return nil +} From 0eb842110e635cb98da75b1092a0daa8cf202725 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Thu, 5 Jan 2023 14:39:27 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E5=85=AC=E4=BC=9A=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 3 +- modules/sociaty/api_cross_receive.go | 21 ++++------- modules/sociaty/model_sociatytask.go | 19 ++++++++-- modules/sociaty/module.go | 31 ++++++++++------ pb/sociaty_db.pb.go | 54 ++++++++++++++++------------ 5 files changed, 77 insertions(+), 51 deletions(-) diff --git a/comm/const.go b/comm/const.go index 73d9b8235..93cbf486c 100644 --- a/comm/const.go +++ b/comm/const.go @@ -261,7 +261,8 @@ const ( //Rpc //公会任务列表 Rpc_ModuleSociatyTask core.Rpc_Key = "Rpc_ModuleSociatyTask" - + Rpc_ModuleSociatyGetTask core.Rpc_Key = "Rpc_ModuleSociatyGetTask" + // RPC 通知来了邮件 Rpc_Mail core.Rpc_Key = "Rpc_Mail" ) diff --git a/modules/sociaty/api_cross_receive.go b/modules/sociaty/api_cross_receive.go index 87b27586d..722897657 100644 --- a/modules/sociaty/api_cross_receive.go +++ b/modules/sociaty/api_cross_receive.go @@ -30,11 +30,14 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe return } - // 判断奖励是否已领 - sociatyTask := this.module.modelSociaty.getUserTaskList(uid, sociaty.Id) + sociatyTask := this.module.modelSociatyTask.getUserTask(uid, sociaty.Id) for _, v := range sociatyTask.TaskList { if v.TaskId == req.TaskId { - if v.Status == 1 { //已领取 + if v.Status != 1 { + code = pb.ErrorCode_SociatyTaskValidation + return + } + if v.Received == 1 { //已领取 code = pb.ErrorCode_SociatyRewardReceived return } @@ -42,18 +45,6 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe } } - // 验证任务是否完成 - if err, ok := this.module.modelSociaty.validTask(uid, req.TaskId); err != nil || !ok { - code = pb.ErrorCode_SociatyTaskValidation - this.module.Error("公会任务未通过", - log.Field{Key: "uid", Value: uid}, - log.Field{Key: "sociatyId", Value: sociaty.Id}, - log.Field{Key: "taskId", Value: req.TaskId}, - log.Field{Key: "err", Value: err.Error()}, - ) - return - } - // 奖励领取 if err := this.module.modelSociatyTask.receive(req.TaskId, sociaty.Id, uid); err != nil { code = pb.ErrorCode_SociatyRewardReceive diff --git a/modules/sociaty/model_sociatytask.go b/modules/sociaty/model_sociatytask.go index 45b5bce06..98106292b 100644 --- a/modules/sociaty/model_sociatytask.go +++ b/modules/sociaty/model_sociatytask.go @@ -1,12 +1,16 @@ package sociaty import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" "go_dreamfactory/utils" + + "go.mongodb.org/mongo-driver/bson" ) type ModelSociatyTask struct { @@ -72,14 +76,25 @@ func (this *ModelSociatyTask) receive(taskId int32, sociatyId, uid string) error this.GetListObj(sociatyId, uid, sociatyTask) for _, t := range sociatyTask.TaskList { if t.TaskId == taskId { - t.Status = 1 //领取 + t.Received = 1 //领取 break } } update := map[string]interface{}{ "taskList": sociatyTask.TaskList, } - return this.ChangeList(sociatyId, uid, update) + + if err := this.Redis.HMSet(fmt.Sprintf("%s:%s-%s", this.TableName, + sociatyId, uid), update); err != nil { + log.Error("DBModel ChangeList", log.Field{Key: "err", Value: err.Error()}) + return err + } + + if err := this.UpdateModelLogs(this.TableName, + uid, bson.M{"sociatyid": sociatyId, "uid": uid}, update); err != nil { + return err + } + return nil } // 活跃度奖励领取 diff --git a/modules/sociaty/module.go b/modules/sociaty/module.go index 9f28b4701..2a194f2fa 100644 --- a/modules/sociaty/module.go +++ b/modules/sociaty/module.go @@ -65,6 +65,7 @@ func (this *Sociaty) Start() (err error) { this.service.RegisterFunctionName(string(comm.Rpc_ModuleSociaty), this.RpcGetSociaty) this.service.RegisterFunctionName(string(comm.Rpc_ModuleSociatyUpdate), this.RpcUpdateSociaty) this.service.RegisterFunctionName(string(comm.Rpc_ModuleSociatyTask), this.RpcUpdateUserTask) + this.service.RegisterFunctionName(string(comm.Rpc_ModuleSociatyGetTask), this.RpcGetUserTask) this.globalConf = this.configure.GetGlobalConf() if this.globalConf == nil { err = errors.New("global config not found") @@ -238,7 +239,11 @@ func (this *Sociaty) TaskcondNotify(uid, sociatyId string, condId int32) error { log.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: sociatyId}, log.Field{Key: "condId", Value: condId}) - dt := this.modelSociatyTask.getUserTask(uid, sociatyId) + + dt := &pb.DBSociatyTask{} + err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), + comm.Service_Worker, string(comm.Rpc_ModuleSociatyGetTask), + &pb.RPCGeneralReqA2{Param1: sociatyId, Param2: uid}, dt) var flag bool for _, v := range dt.TaskList { @@ -257,7 +262,7 @@ func (this *Sociaty) TaskcondNotify(uid, sociatyId string, condId int32) error { "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), &TaskParams{SociatyId: sociatyId, Uid: uid, Data: update}, &pb.EmptyResp{}) if err != nil { @@ -283,14 +288,18 @@ func (this *Sociaty) RpcUpdateUserTask(ctx context.Context, p *TaskParams, reply p.Uid, bson.M{"sociatyid": p.SociatyId, "uid": p.Uid}, p.Data); err != nil { return err } - // task := &pb.DBSociatyTask{} - // if err := model.GetListObj(p.Param1, p.Param2, task); err != nil { - // return err - // } - // reply.TaskList = task.TaskList - // reply.Uid = task.Uid - // reply.ActivityList = task.ActivityList - // reply.SociatyId = task.SociatyId - // reply.LastUpdateTime = task.LastUpdateTime + return nil +} + +func (this *Sociaty) RpcGetUserTask(ctx context.Context, p *pb.RPCGeneralReqA2, reply *pb.DBSociatyTask) error { + dt := this.modelSociatyTask.getUserTask(p.Param2, p.Param1) + if dt == nil { + return errors.New("not found") + } + reply.Uid = dt.Uid + reply.TaskList = dt.TaskList + reply.ActivityList = dt.ActivityList + reply.SociatyId = dt.SociatyId + reply.LastUpdateTime = dt.LastUpdateTime return nil } diff --git a/pb/sociaty_db.pb.go b/pb/sociaty_db.pb.go index c063a7a51..7af79c145 100644 --- a/pb/sociaty_db.pb.go +++ b/pb/sociaty_db.pb.go @@ -584,8 +584,9 @@ type SociatyTask struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TaskId int32 `protobuf:"varint,1,opt,name=taskId,proto3" json:"taskId" bson:"taskId"` //任务ID - Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status" bson:"status"` //领取状态:0未领取 1已领取 + TaskId int32 `protobuf:"varint,1,opt,name=taskId,proto3" json:"taskId" bson:"taskId"` //任务ID + Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status" bson:"status"` //领取状态:0未完成 1已完成 + Received int32 `protobuf:"varint,3,opt,name=received,proto3" json:"received" bson:"received"` //领取状态: 0未领取 1已领取 } func (x *SociatyTask) Reset() { @@ -634,6 +635,13 @@ func (x *SociatyTask) GetStatus() int32 { return 0 } +func (x *SociatyTask) GetReceived() int32 { + if x != nil { + return x.Received + } + return 0 +} + // 活跃度 type SociatyActivity struct { state protoimpl.MessageState @@ -839,29 +847,31 @@ var file_sociaty_sociaty_db_proto_rawDesc = []byte{ 0x74, 0x79, 0x52, 0x0c, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x3d, 0x0a, 0x0b, 0x53, 0x6f, 0x63, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x59, 0x0a, 0x0b, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x39, 0x0a, 0x0f, 0x53, 0x6f, 0x63, 0x69, 0x61, - 0x74, 0x79, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x22, 0x83, 0x01, 0x0a, 0x0d, 0x44, 0x42, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, - 0x52, 0x61, 0x6e, 0x6b, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, - 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, - 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, - 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x2a, 0x50, 0x0a, 0x0a, 0x53, 0x6f, 0x63, 0x69, - 0x61, 0x74, 0x79, 0x4a, 0x6f, 0x62, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x4f, 0x4a, 0x4f, 0x42, 0x10, - 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x01, 0x12, 0x09, 0x0a, - 0x05, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x56, 0x49, 0x43, 0x45, - 0x50, 0x52, 0x45, 0x53, 0x49, 0x44, 0x45, 0x4e, 0x54, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x50, - 0x52, 0x45, 0x53, 0x49, 0x44, 0x45, 0x4e, 0x54, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, + 0x76, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, + 0x76, 0x65, 0x64, 0x22, 0x39, 0x0a, 0x0f, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x63, + 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x83, + 0x01, 0x0a, 0x0d, 0x44, 0x42, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x61, 0x6e, 0x6b, + 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, + 0x6c, 0x76, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x12, 0x14, + 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, + 0x74, 0x69, 0x6d, 0x65, 0x2a, 0x50, 0x0a, 0x0a, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4a, + 0x6f, 0x62, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x4f, 0x4a, 0x4f, 0x42, 0x10, 0x00, 0x12, 0x0a, 0x0a, + 0x06, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x44, 0x4d, + 0x49, 0x4e, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x56, 0x49, 0x43, 0x45, 0x50, 0x52, 0x45, 0x53, + 0x49, 0x44, 0x45, 0x4e, 0x54, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x50, 0x52, 0x45, 0x53, 0x49, + 0x44, 0x45, 0x4e, 0x54, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( From 755c571cbc493b702e9f73ce689d381f19522ef3 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Thu, 5 Jan 2023 15:49:41 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=AC=E4=BC=9A?= =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=A6=9C=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/sociaty/model_sociaty.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/sociaty/model_sociaty.go b/modules/sociaty/model_sociaty.go index d47fc0c47..9a5f30b30 100644 --- a/modules/sociaty/model_sociaty.go +++ b/modules/sociaty/model_sociaty.go @@ -770,10 +770,10 @@ func (this *ModelSociaty) sort(list []*pb.DBSociatyRank) []*pb.DBSociatyRank { if list[i].Activity == list[j].Activity { return list[i].Ctime > list[j].Ctime } else { - return list[i].Activity < list[j].Activity + return list[i].Activity > list[j].Activity } } - return list[i].Lv < list[j].Lv + return list[i].Lv > list[j].Lv }) return list } @@ -822,7 +822,7 @@ func (this *ModelSociaty) rankDataChanged(event interface{}, next func(event int } } -// 排行榜列表 +// 排行榜列表(活跃度) func (this *ModelSociaty) rank() (rank []*pb.DBSociatyRank) { var list []*pb.DBSociaty if err := this.GetList("", &list); err != nil { From 9c841d2b07a1b243ce4a4ecb7df101fe292ac17c Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Thu, 5 Jan 2023 15:50:12 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E6=89=AB=E6=8F=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/v2/lib/common/lang.go | 1 + cmd/v2/ui/app_interface.go | 1 + cmd/v2/ui/tool_ping.go | 76 ++++++++++++++++++++++++++++++++++++++ cmd/v2/ui/toolwindow.go | 4 ++ 4 files changed, 82 insertions(+) create mode 100644 cmd/v2/ui/tool_ping.go diff --git a/cmd/v2/lib/common/lang.go b/cmd/v2/lib/common/lang.go index 5f325b8d8..865c2b1d6 100644 --- a/cmd/v2/lib/common/lang.go +++ b/cmd/v2/lib/common/lang.go @@ -96,6 +96,7 @@ const ( TOOLBAR_TERM = "同步配置" TOOLBAR_PB = "protobuf" TOOLBAR_AUTO = "自动化" + TOOLBAR_PING = "端口扫描" TOOLBAR_PERF_TIP = "开始" TOOLBAR_PERF_CONF = "配置" diff --git a/cmd/v2/ui/app_interface.go b/cmd/v2/ui/app_interface.go index 19e9f378d..fa3f39373 100644 --- a/cmd/v2/ui/app_interface.go +++ b/cmd/v2/ui/app_interface.go @@ -32,6 +32,7 @@ var ( &appPbGen{}, &appLock{}, &appTerm{}, + &appPing{}, } perfRegister = []appInterface{ diff --git a/cmd/v2/ui/tool_ping.go b/cmd/v2/ui/tool_ping.go new file mode 100644 index 000000000..d863e67f0 --- /dev/null +++ b/cmd/v2/ui/tool_ping.go @@ -0,0 +1,76 @@ +package ui + +import ( + "fmt" + "go_dreamfactory/cmd/v2/lib/common" + "go_dreamfactory/cmd/v2/service" + "go_dreamfactory/cmd/v2/service/observer" + "net" + "strings" + "sync" + "time" + + "fyne.io/fyne/v2" + "fyne.io/fyne/v2/container" + "fyne.io/fyne/v2/theme" + "fyne.io/fyne/v2/widget" + "github.com/spf13/cast" +) + +type appPing struct { + appAdapter + resultCh chan int +} + +func (this *appPing) LazyInit(ptService service.PttService, obs observer.Observer) error { + this.tabItem = container.NewTabItemWithIcon(common.TOOLBAR_PING, theme.DownloadIcon(), nil) + + this.resultCh = make(chan int) + + content := container.NewMax() + content.Objects = []fyne.CanvasObject{} + + targetHost := widget.NewEntry() + targetHost.PlaceHolder = "目标主机Ip" + + portEntry := widget.NewMultiLineEntry() + portEntry.Text = "80,3306,6379" + form := widget.NewForm( + widget.NewFormItem("端口", portEntry), + ) + + form.OnSubmit = func() { + ports := strings.Split(portEntry.Text, ",") + this.ping(targetHost.Text, ports) + for p := range this.resultCh { + fmt.Println(p, "ok") + } + } + form.Items[1].HintText = "多个端口使用英文,号分隔" + content.Objects = append(content.Objects, form) + this.tabItem.Content = content + return nil +} + +func (this *appPing) ping(targetHost string, ports []string) { + var wg sync.WaitGroup + wg.Add(len(ports)) + for _, port := range ports { + go func(p int) { + defer wg.Done() + _, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", targetHost, p), time.Millisecond*500) + if err == nil { + this.resultCh <- p + } + }(cast.ToInt(port)) + } + + go func() { + defer close(this.resultCh) + wg.Wait() + }() +} + +func (a *appPing) GetAppName() string { + return common.TOOLBAR_PING +} diff --git a/cmd/v2/ui/toolwindow.go b/cmd/v2/ui/toolwindow.go index 7089092f8..043e7b783 100644 --- a/cmd/v2/ui/toolwindow.go +++ b/cmd/v2/ui/toolwindow.go @@ -53,6 +53,10 @@ func NewToolWindow(ui *UIImpl, parent fyne.Window) ToolWindow { openApp2(mw.at, common.TOOLBAR_TERM) }), + widget.NewToolbarAction(theme.MailSendIcon(), func() { + openApp2(mw.at, common.TOOLBAR_PING) + }), + widget.NewToolbarSpacer(), widget.NewToolbarAction(theme.HelpIcon(), func() { showAbout() From 645113c08fac36bd02dd4ea48da0840666b87832 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Thu, 5 Jan 2023 15:50:30 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=AC=E4=BC=9A?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E9=A2=86=E5=8F=96=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/sociaty/api_cross_tasklist.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/sociaty/api_cross_tasklist.go b/modules/sociaty/api_cross_tasklist.go index bcf50e97b..73f8a74f3 100644 --- a/modules/sociaty/api_cross_tasklist.go +++ b/modules/sociaty/api_cross_tasklist.go @@ -30,8 +30,9 @@ func (this *apiComp) TaskList(session comm.IUserSession, req *pb.SociatyTaskList for _, v := range sociatyTask.TaskList { taskList = append(taskList, &pb.SociatyTask{ - TaskId: v.TaskId, - Status: v.Status, + TaskId: v.TaskId, + Status: v.Status, + Received: v.Received, }) } rsp.List = taskList From 2807ec89ab719ee667bd8c71773975825e48ae33 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Thu, 5 Jan 2023 15:51:47 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=96=E7=95=8C?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_worldtask.json | 126 ++++++++++++++++++++++++++++++++--- 1 file changed, 118 insertions(+), 8 deletions(-) diff --git a/bin/json/game_worldtask.json b/bin/json/game_worldtask.json index d8cc9981b..1a96ab016 100644 --- a/bin/json/game_worldtask.json +++ b/bin/json/game_worldtask.json @@ -2,8 +2,8 @@ { "key": 10100, "lock": 1, - "ontxe": 0, - "id_after": 10101, + "ontxe": 99999, + "id_after": 0, "group": 1, "des": 2, "icon": "", @@ -30,7 +30,7 @@ { "key": 10101, "lock": 1, - "ontxe": 10101, + "ontxe": 10100, "id_after": 10102, "group": 1, "des": 2, @@ -45,14 +45,14 @@ 1002 ], "completetask": 0, - "auto_accept": 1, + "auto_accept": 0, "overtips": 1, "reword": [] }, { "key": 10102, "lock": 1, - "ontxe": 0, + "ontxe": 10101, "id_after": 10103, "group": 1, "des": 2, @@ -1971,21 +1971,131 @@ "reword": [] }, { - "key": 101, + "key": 20010, "lock": 1, "ontxe": 0, + "id_after": 20020, + "group": 2, + "des": 2, + "icon": "", + "npc": [ + "scenes_boundary_01_recordtask", + "新手引导-杰克第一幕1", + "150" + ], + "getafter_event": [ + 2, + 4001 + ], + "completetask": 0, + "auto_accept": 0, + "overtips": 1, + "reword": [] + }, + { + "key": 20020, + "lock": 1, + "ontxe": 20010, + "id_after": 20030, + "group": 2, + "des": 2, + "icon": "", + "npc": [ + "scenes_boundary_01_recordtask", + "新手引导-杰克第一幕1", + "150" + ], + "getafter_event": [ + 2, + 401 + ], + "completetask": 0, + "auto_accept": 0, + "overtips": 1, + "reword": [] + }, + { + "key": 20030, + "lock": 1, + "ontxe": 20020, + "id_after": 20040, + "group": 2, + "des": 2, + "icon": "", + "npc": [ + "scenes_boundary_01_recordtask", + "新手引导-杰克第一幕1", + "150" + ], + "getafter_event": [ + 2, + 401 + ], + "completetask": 0, + "auto_accept": 0, + "overtips": 1, + "reword": [] + }, + { + "key": 20040, + "lock": 1, + "ontxe": 20030, + "id_after": 20050, + "group": 2, + "des": 2, + "icon": "", + "npc": [ + "scenes_boundary_01_recordtask", + "新手引导-杰克第一幕1", + "150" + ], + "getafter_event": [ + 2, + 401 + ], + "completetask": 0, + "auto_accept": 0, + "overtips": 1, + "reword": [] + }, + { + "key": 20050, + "lock": 1, + "ontxe": 20040, + "id_after": 20060, + "group": 2, + "des": 2, + "icon": "", + "npc": [ + "scenes_boundary_01_recordtask", + "新手引导-杰克第一幕1", + "150" + ], + "getafter_event": [ + 2, + 401 + ], + "completetask": 0, + "auto_accept": 0, + "overtips": 1, + "reword": [] + }, + { + "key": 20060, + "lock": 1, + "ontxe": 20050, "id_after": 0, "group": 2, "des": 2, "icon": "", "npc": [ "scenes_boundary_01_recordtask", - "杰克A", + "新手引导-杰克第一幕1", "150" ], "getafter_event": [ 2, - 1002 + 401 ], "completetask": 0, "auto_accept": 0, From 841bcec958ac471f84abfa1025d79b963314aa10 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 5 Jan 2023 17:56:33 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=9F=8B=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/model_hero.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 00371d87c..9c995f191 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -594,7 +594,7 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex if curLv-preLv > 0 { // 升级了 统计任务 this.ChangeHeroProperty(session, hero) // 重新计算属性值 // 推送 - + this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype147, utils.ToInt32(hero.HeroID), curLv-preLv) this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype113, utils.ToInt32(hero.HeroID), curLv-preLv) this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype4, utils.ToInt32(hero.HeroID), hero.Lv) this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype23, 1, hero.Star, hero.Lv) From da399799ff31b344496102a95c960e5c3e7c2982 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 5 Jan 2023 17:56:48 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=9F=8B=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 9 ++++++++- modules/gourmet/api_createorder.go | 6 ++++++ modules/smithy/api_createorder.go | 5 +++++ modules/troll/api_buyorsell.go | 2 ++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/comm/const.go b/comm/const.go index 93cbf486c..e52b1f4b1 100644 --- a/comm/const.go +++ b/comm/const.go @@ -260,7 +260,7 @@ const ( //Rpc Rpc_ModuleSociatyUpdate core.Rpc_Key = "Rpc_ModuleSociatyUpdate" //公会任务列表 - Rpc_ModuleSociatyTask core.Rpc_Key = "Rpc_ModuleSociatyTask" + Rpc_ModuleSociatyTask core.Rpc_Key = "Rpc_ModuleSociatyTask" Rpc_ModuleSociatyGetTask core.Rpc_Key = "Rpc_ModuleSociatyGetTask" // RPC 通知来了邮件 @@ -545,6 +545,13 @@ const ( Rtype144 TaskType = 144 //日常任务阵营接取抽卡 Rtype145 TaskType = 145 //周长任务接取抽卡 Rtype146 TaskType = 146 //周长任务阵营接取抽卡 + Rtype147 TaskType = 147 // + Rtype148 TaskType = 148 // + Rtype149 TaskType = 149 // + Rtype150 TaskType = 150 // + Rtype151 TaskType = 151 // + Rtype152 TaskType = 152 // + Rtype153 TaskType = 153 // ) const ( diff --git a/modules/gourmet/api_createorder.go b/modules/gourmet/api_createorder.go index 97f126785..cce211b07 100644 --- a/modules/gourmet/api_createorder.go +++ b/modules/gourmet/api_createorder.go @@ -142,5 +142,11 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreat code = this.module.ModifyGourmetData(session.GetUserId(), mapData) session.SendMsg(string(this.module.GetType()), GourmetCreateOrderResp, &pb.GourmetCreateOrderResp{Data: _gourmet}) + + iTotal := 0 + for _, v := range req.Order { + iTotal += int(v.FoodCount) + } + this.module.ModuleRtask.SendToRtask(session, comm.Rtype150, int32(iTotal)) return } diff --git a/modules/smithy/api_createorder.go b/modules/smithy/api_createorder.go index eff21251b..c042a9b9c 100644 --- a/modules/smithy/api_createorder.go +++ b/modules/smithy/api_createorder.go @@ -107,6 +107,11 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreate mapData["clang"] = _smithy.Clang // 正在做的 mapData["ctime"] = _smithy.Ctime code = this.module.ModifySmithyData(session.GetUserId(), mapData) + iTotal := 0 + for _, v := range req.Order { + iTotal += int(v.Count) + } + this.module.ModuleRtask.SendToRtask(session, comm.Rtype148, int32(iTotal)) session.SendMsg(string(this.module.GetType()), SmithyCreateOrderResp, &pb.SmithyCreateOrderResp{Data: _smithy}) return diff --git a/modules/troll/api_buyorsell.go b/modules/troll/api_buyorsell.go index 108fcdc39..0ecdd06b2 100644 --- a/modules/troll/api_buyorsell.go +++ b/modules/troll/api_buyorsell.go @@ -169,5 +169,7 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSell if gold != 0 { this.module.record.AddTrollRecord(session.GetUserId(), gold, trolltrain.TarinPos) } + + this.module.ModuleRtask.SendToRtask(session, comm.Rtype151, 1) return }