diff --git a/modules/privilege/api_buyyueka.go b/modules/privilege/api_buyyueka.go index 765a7d7fa..abff06327 100644 --- a/modules/privilege/api_buyyueka.go +++ b/modules/privilege/api_buyyueka.go @@ -17,7 +17,7 @@ func (this *apiComp) BuyYuekaCheck(session comm.IUserSession, req *pb.PrivilegeB return } -///获取特权列表 +/// 此协议不用 走正常充值逻辑 func (this *apiComp) BuyYueka(session comm.IUserSession, req *pb.PrivilegeBuyYuekaReq) (errdata *pb.ErrorData) { if errdata = this.BuyYuekaCheck(session, req); errdata != nil { return diff --git a/modules/privilege/configure.go b/modules/privilege/configure.go index f7e5a1d59..de4578900 100644 --- a/modules/privilege/configure.go +++ b/modules/privilege/configure.go @@ -53,19 +53,18 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp return } -// 接口调整 稍后补充 -func (this *configureComp) GetPrivilegeCard(id string) (data *cfg.GamePrivilegeCardData, err error) { - // var ( - // v interface{} - // ) - // if v, err = this.GetConfigure(game_privilegecard); err == nil { - // if configure, ok := v.(*cfg.GamePrivilegeCard); ok { - // if data = configure.Get(id); data != nil { - // return - // } - // } - // } - err = comm.NewNotFoundConfErr(moduleName, game_privilegecard, id) +func (this *configureComp) GetPrivilegeCard(itype int32) (data *cfg.GamePrivilegeCardData, err error) { + var ( + v interface{} + ) + if v, err = this.GetConfigure(game_privilegecard); err == nil { + if configure, ok := v.(*cfg.GamePrivilegeCard); ok { + if data = configure.Get(itype); data != nil { + return + } + } + } + err = comm.NewNotFoundConfErr(moduleName, game_privilegecard, itype) return } @@ -95,3 +94,19 @@ func (this *configureComp) GetPrivilegeByType(iType int32) (result map[int32]int return result } + +func (this *configureComp) GetPrivilegeCardByPid(pid string) (itype int32) { + + if v, err := this.GetConfigure(game_privilegecard); err == nil { + if configure, ok := v.(*cfg.GamePrivilegeCard); ok { + for _, v := range configure.GetDataList() { + if v.Id == pid { + itype = v.PType + return + } + } + } + } + + return +} diff --git a/modules/privilege/module.go b/modules/privilege/module.go index e2d6dae76..e69ed2f2b 100644 --- a/modules/privilege/module.go +++ b/modules/privilege/module.go @@ -70,11 +70,13 @@ func (this *Privilege) EventUserOffline(uid, sessionid string) { } // 购买了一个新的特权 -func (this *Privilege) Delivery(session comm.IUserSession, cId string) (errdata *pb.ErrorData, items []*pb.UserAssets) { +func (this *Privilege) Delivery(session comm.IUserSession, pid string) (errdata *pb.ErrorData, items []*pb.UserAssets) { var ( bFind bool + cId int32 ) - + // 通过计费点获取 + cId = this.configure.GetPrivilegeCardByPid(pid) conf, err := this.configure.GetPrivilegeCard(cId) if err != nil { errdata = &pb.ErrorData{ @@ -199,7 +201,7 @@ func (this *Privilege) Delivery(session comm.IUserSession, cId string) (errdata } // 续费特权 -func (this *Privilege) RenewPrivilegeCard(session comm.IUserSession, cId string) (errdata *pb.ErrorData) { +func (this *Privilege) RenewPrivilegeCard(session comm.IUserSession, cId int32) (errdata *pb.ErrorData) { list, err := this.modelPrivilege.getPrivilegeList(session.GetUserId()) if err != nil { return @@ -246,7 +248,7 @@ func (this *Privilege) RenewPrivilegeCard(session comm.IUserSession, cId string) } // 查询特权特权 -func (this *Privilege) CheckPrivilege(session comm.IUserSession, cId string) bool { +func (this *Privilege) CheckPrivilege(session comm.IUserSession, cId int32) bool { list, err := this.modelPrivilege.getPrivilegeList(session.GetUserId()) if err != nil { return false @@ -331,7 +333,7 @@ func (this *Privilege) CheckDailyPrivilegeMail(session comm.IUserSession) { return } -func (this *Privilege) SendDailyMail(session comm.IUserSession, cId string, count int32, pType int32) { +func (this *Privilege) SendDailyMail(session comm.IUserSession, cId int32, count int32, pType int32) { conf, err := this.configure.GetPrivilegeCard(cId) if err != nil { return diff --git a/pb/privilege_db.pb.go b/pb/privilege_db.pb.go index 4f7392184..ebf4e6846 100644 --- a/pb/privilege_db.pb.go +++ b/pb/privilege_db.pb.go @@ -28,7 +28,7 @@ type DBPrivilege struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID - CId string `protobuf:"bytes,3,opt,name=cId,proto3" json:"cId" bson:"cId"` //计费点数ID + CId int32 `protobuf:"varint,3,opt,name=cId,proto3" json:"cId" bson:"cId"` //月卡类型 CTime int64 `protobuf:"varint,4,opt,name=cTime,proto3" json:"cTime" bson:"cTime"` ////购买时间 ETime int64 `protobuf:"varint,5,opt,name=eTime,proto3" json:"eTime" bson:"eTime"` ////到期时间 RewardTime int64 `protobuf:"varint,6,opt,name=rewardTime,proto3" json:"rewardTime" bson:"rewardTime"` //每日奖励时间 @@ -80,11 +80,11 @@ func (x *DBPrivilege) GetUid() string { return "" } -func (x *DBPrivilege) GetCId() string { +func (x *DBPrivilege) GetCId() int32 { if x != nil { return x.CId } - return "" + return 0 } func (x *DBPrivilege) GetCTime() int64 { @@ -250,7 +250,7 @@ var file_privilege_privilege_db_proto_rawDesc = []byte{ 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, - 0x12, 0x10, 0x0a, 0x03, 0x63, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, + 0x12, 0x10, 0x0a, 0x03, 0x63, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x63, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1e,