From f901ae60b915e0a4954567fa80b3c3a9fcf627c9 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 24 Nov 2022 16:01:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=AD=E4=B9=B0=E6=8E=A8=E9=80=81=20?= =?UTF-8?q?=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/robot/options.go | 4 ++-- comm/imodule.go | 4 ++-- modules/modulebase.go | 4 ++-- modules/privilege/api_buyyueka.go | 2 +- modules/privilege/module.go | 25 ++++--------------------- 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/cmd/robot/options.go b/cmd/robot/options.go index c9abbd542..b42161034 100644 --- a/cmd/robot/options.go +++ b/cmd/robot/options.go @@ -12,8 +12,8 @@ type Options struct { func DefaultOpts() *Options { return &Options{ - WsUrl: "ws://localhost:7891/gateway", - RegUrl: "http://localhost:8000/register", + WsUrl: "ws://10.0.5.73:7891/gateway", + RegUrl: "http://10.0.5.73:8000/register", Create: false, ServerId: "1", } diff --git a/comm/imodule.go b/comm/imodule.go index 4ba88f88b..fcc615092 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -169,7 +169,7 @@ type ( // 远程任务条件校验 RemoteCheckCondi(uid string, condiId int32, rsp *pb.DBRtaskRecord) error // 删除任务条件数据 - RemoveCondi(uid string ,condiId int32) error + RemoveCondi(uid string, condiId int32) error //任务触发 SendToRtask(session IUserSession, rtaskType TaskType, params ...int32) (code pb.ErrorCode) // 初始化条件数据 @@ -270,7 +270,7 @@ type ( } IPrivilege interface { // 创建一个新的特权卡 - CreatePrivilegeCard(session IUserSession, cId string) (res []*pb.UserAssets, code pb.ErrorCode) + CreatePrivilegeCard(session IUserSession, cId string) (code pb.ErrorCode) // 续费特权卡 RenewPrivilegeCard(session IUserSession, cId string) (res []*pb.UserAssets, code pb.ErrorCode) // 检查特权 diff --git a/modules/modulebase.go b/modules/modulebase.go index e3b4bb115..2af64780c 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -302,7 +302,7 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn return } this.Debugf("消耗玩家资源: %v", attrs) - if count,ok:= attrs[comm.ResDiamond];ok{ + if count, ok := attrs[comm.ResDiamond]; ok { this.ModuleRtask.SendToRtask(session, comm.Rtype104, count) } } @@ -369,7 +369,7 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat } if len(vip) > 0 { //卡片资源 for k := range vip { - _, code = this.ModulePrivilege.CreatePrivilegeCard(session, k) + code = this.ModulePrivilege.CreatePrivilegeCard(session, k) this.Debugf("发放月卡资源: %v [%v]", k, code) } diff --git a/modules/privilege/api_buyyueka.go b/modules/privilege/api_buyyueka.go index a6df9f237..cf9eed6ea 100644 --- a/modules/privilege/api_buyyueka.go +++ b/modules/privilege/api_buyyueka.go @@ -21,6 +21,6 @@ func (this *apiComp) BuyYueka(session comm.IUserSession, req *pb.PrivilegeBuyYue if code = this.BuyYuekaCheck(session, req); code != pb.ErrorCode_Success { return } - _, code = this.module.CreatePrivilegeCard(session, req.CID) + code = this.module.CreatePrivilegeCard(session, req.CID) return } diff --git a/modules/privilege/module.go b/modules/privilege/module.go index 2dd275097..eb3aa4768 100644 --- a/modules/privilege/module.go +++ b/modules/privilege/module.go @@ -64,21 +64,14 @@ func (this *Privilege) EventUserOffline(session comm.IUserSession) { } // 购买了一个新的特权 -func (this *Privilege) CreatePrivilegeCard(session comm.IUserSession, cId string) (res []*pb.UserAssets, code pb.ErrorCode) { +func (this *Privilege) CreatePrivilegeCard(session comm.IUserSession, cId string) (code pb.ErrorCode) { var ( - data *pb.DBPrivilege bFind bool ) - atn := &pb.UserAssets{ - A: "vip", - T: "", - N: 1, - } conf, err := this.configure.GetPrivilegeCard(cId) if err != nil { - code = pb.ErrorCode_ConfigNoFound - return nil, code + return pb.ErrorCode_ConfigNoFound } // 是不是购买过 list, err := this.modelPrivilege.getPrivilegeList(session.GetUserId()) @@ -105,14 +98,13 @@ func (this *Privilege) CreatePrivilegeCard(session comm.IUserSession, cId string this.Errorf("err:%v", err) return } - data = v bFind = true break } } if !bFind { - data = &pb.DBPrivilege{ + data := &pb.DBPrivilege{ Id: primitive.NewObjectID().Hex(), Uid: session.GetUserId(), CId: cId, @@ -125,6 +117,7 @@ func (this *Privilege) CreatePrivilegeCard(session comm.IUserSession, cId string for _, v := range conf.PrivilegeId { data.PrivilegeID = append(data.PrivilegeID, v) } + list = append(list, data) this.modelPrivilege.addNewPrivilegeData(session.GetUserId(), data) this.SendDailyMail(session, cId, 1, conf.PType) } @@ -132,16 +125,6 @@ func (this *Privilege) CreatePrivilegeCard(session comm.IUserSession, cId string if code = this.DispenseRes(session, conf.DisposableReward, true); code != pb.ErrorCode_Success { return } - atn.T = conf.Id - res = append(res, atn) // 加资源 - for _, v := range conf.DisposableReward { - res = append(res, &pb.UserAssets{ - A: v.A, - T: v.T, - N: v.N, - }) - } - // 推送 session.SendMsg(string(this.GetType()), PrivilegeBuyYuekaResp, &pb.PrivilegeGetListResp{Data: list}) return