添加vip信息
This commit is contained in:
parent
d318cdf003
commit
cca6e26626
@ -283,6 +283,8 @@ type (
|
|||||||
CheckPrivilege(session IUserSession, cId string) (privilege *pb.DBPrivilege)
|
CheckPrivilege(session IUserSession, cId string) (privilege *pb.DBPrivilege)
|
||||||
// 查询玩家当前所有特权 返回特权id
|
// 查询玩家当前所有特权 返回特权id
|
||||||
QueryPrivilege(session IUserSession) (privilegeID []int32)
|
QueryPrivilege(session IUserSession) (privilegeID []int32)
|
||||||
|
// 获得vip
|
||||||
|
AddVipData(session IUserSession)
|
||||||
}
|
}
|
||||||
//武馆
|
//武馆
|
||||||
IMartialhall interface {
|
IMartialhall interface {
|
||||||
|
@ -10,6 +10,7 @@ const (
|
|||||||
PrivilegeGetListResp = "getlist"
|
PrivilegeGetListResp = "getlist"
|
||||||
PrivilegeBuyYuekaResp = "buyyueka"
|
PrivilegeBuyYuekaResp = "buyyueka"
|
||||||
PrivilegeBuyGiftResp = "buygift"
|
PrivilegeBuyGiftResp = "buygift"
|
||||||
|
PrivilegeVipListResp = "viplist"
|
||||||
)
|
)
|
||||||
|
|
||||||
type apiComp struct {
|
type apiComp struct {
|
||||||
|
24
modules/privilege/api_viplist.go
Normal file
24
modules/privilege/api_viplist.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package privilege
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
//参数校验
|
||||||
|
func (this *apiComp) VipListCheck(session comm.IUserSession, req *pb.PrivilegeVipListReq) (code pb.ErrorCode) {
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
///获取特权列表
|
||||||
|
func (this *apiComp) VipList(session comm.IUserSession, req *pb.PrivilegeVipListReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
|
list, err := this.module.modelVip.getVipList(session.GetUserId())
|
||||||
|
if err != nil {
|
||||||
|
this.module.Errorf("can't get privilege list :%v", err)
|
||||||
|
}
|
||||||
|
session.SendMsg(string(this.module.GetType()), PrivilegeGetListResp, &pb.PrivilegeVipListResp{Data: list})
|
||||||
|
return
|
||||||
|
}
|
@ -6,7 +6,9 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/mgo"
|
"go_dreamfactory/lego/sys/mgo"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"go_dreamfactory/sys/configure"
|
||||||
|
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
"go.mongodb.org/mongo-driver/x/bsonx"
|
"go.mongodb.org/mongo-driver/x/bsonx"
|
||||||
)
|
)
|
||||||
@ -44,11 +46,20 @@ func (this *ModelVip) modifyVipData(uid string, data map[string]interface{}) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 增加vip信息
|
// 增加vip信息
|
||||||
func (this *ModelVip) addVipData(uId string, vip *pb.DBVip) (err error) {
|
func (this *ModelVip) addVipData(uId string) (vip *pb.DBVip, err error) {
|
||||||
|
|
||||||
if err = this.Add(uId, vip); err != nil {
|
vip, err = this.getVipList(uId)
|
||||||
this.module.Errorf("err:%v", err)
|
if err != nil {
|
||||||
return err
|
return vip, err
|
||||||
}
|
}
|
||||||
return nil
|
if vip.Id == "" {
|
||||||
|
vip.Id = primitive.NewObjectID().Hex()
|
||||||
|
vip.CTime = configure.Now().Unix()
|
||||||
|
if err = this.Add(uId, vip); err != nil {
|
||||||
|
this.module.Errorf("err:%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
@ -261,3 +261,9 @@ func (this *Privilege) SendDailyMail(session comm.IUserSession, cId string, coun
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
func (this *Privilege) AddVipData(session comm.IUserSession) {
|
||||||
|
vip, err := this.modelVip.addVipData(session.GetUserId())
|
||||||
|
if err != nil { // 推送
|
||||||
|
session.SendMsg(string(this.GetType()), PrivilegeGetListResp, &pb.PrivilegeVipListResp{Data: vip})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -205,6 +205,10 @@ func (this *ModelUser) ChangeVipExp(event interface{}, next func(event interface
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
if ul.viplv == 0 && vipLv > 0 { // 新获得了vip
|
||||||
|
this.module.ModulePrivilege.AddVipData(ul.session)
|
||||||
|
}
|
||||||
// 推送玩家vip 经验变化
|
// 推送玩家vip 经验变化
|
||||||
ul.session.SendMsg(string(this.module.GetType()), UserSubTypeVipChangedPush,
|
ul.session.SendMsg(string(this.module.GetType()), UserSubTypeVipChangedPush,
|
||||||
&pb.UserVipChangedPush{
|
&pb.UserVipChangedPush{
|
||||||
|
@ -296,6 +296,91 @@ func (x *PrivilegeBuyGiftResp) GetData() *DBVip {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PrivilegeVipListReq struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *PrivilegeVipListReq) Reset() {
|
||||||
|
*x = PrivilegeVipListReq{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_privilege_privilege_msg_proto_msgTypes[6]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *PrivilegeVipListReq) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*PrivilegeVipListReq) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *PrivilegeVipListReq) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_privilege_privilege_msg_proto_msgTypes[6]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use PrivilegeVipListReq.ProtoReflect.Descriptor instead.
|
||||||
|
func (*PrivilegeVipListReq) Descriptor() ([]byte, []int) {
|
||||||
|
return file_privilege_privilege_msg_proto_rawDescGZIP(), []int{6}
|
||||||
|
}
|
||||||
|
|
||||||
|
type PrivilegeVipListResp struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Data *DBVip `protobuf:"bytes,1,opt,name=data,proto3" json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *PrivilegeVipListResp) Reset() {
|
||||||
|
*x = PrivilegeVipListResp{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_privilege_privilege_msg_proto_msgTypes[7]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *PrivilegeVipListResp) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*PrivilegeVipListResp) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *PrivilegeVipListResp) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_privilege_privilege_msg_proto_msgTypes[7]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use PrivilegeVipListResp.ProtoReflect.Descriptor instead.
|
||||||
|
func (*PrivilegeVipListResp) Descriptor() ([]byte, []int) {
|
||||||
|
return file_privilege_privilege_msg_proto_rawDescGZIP(), []int{7}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *PrivilegeVipListResp) GetData() *DBVip {
|
||||||
|
if x != nil {
|
||||||
|
return x.Data
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var File_privilege_privilege_msg_proto protoreflect.FileDescriptor
|
var File_privilege_privilege_msg_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_privilege_privilege_msg_proto_rawDesc = []byte{
|
var file_privilege_privilege_msg_proto_rawDesc = []byte{
|
||||||
@ -320,8 +405,12 @@ var file_privilege_privilege_msg_proto_rawDesc = []byte{
|
|||||||
0x22, 0x32, 0x0a, 0x14, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x42, 0x75, 0x79,
|
0x22, 0x32, 0x0a, 0x14, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x42, 0x75, 0x79,
|
||||||
0x47, 0x69, 0x66, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61,
|
0x47, 0x69, 0x66, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61,
|
||||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x44, 0x42, 0x56, 0x69, 0x70, 0x52, 0x04,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x44, 0x42, 0x56, 0x69, 0x70, 0x52, 0x04,
|
||||||
0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
|
0x64, 0x61, 0x74, 0x61, 0x22, 0x15, 0x0a, 0x13, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67,
|
||||||
0x6f, 0x74, 0x6f, 0x33,
|
0x65, 0x56, 0x69, 0x70, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x32, 0x0a, 0x14, 0x50,
|
||||||
|
0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x56, 0x69, 0x70, 0x4c, 0x69, 0x73, 0x74, 0x52,
|
||||||
|
0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
|
0x0b, 0x32, 0x06, 0x2e, 0x44, 0x42, 0x56, 0x69, 0x70, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42,
|
||||||
|
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -336,7 +425,7 @@ func file_privilege_privilege_msg_proto_rawDescGZIP() []byte {
|
|||||||
return file_privilege_privilege_msg_proto_rawDescData
|
return file_privilege_privilege_msg_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_privilege_privilege_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
var file_privilege_privilege_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||||
var file_privilege_privilege_msg_proto_goTypes = []interface{}{
|
var file_privilege_privilege_msg_proto_goTypes = []interface{}{
|
||||||
(*PrivilegeGetListReq)(nil), // 0: PrivilegeGetListReq
|
(*PrivilegeGetListReq)(nil), // 0: PrivilegeGetListReq
|
||||||
(*PrivilegeGetListResp)(nil), // 1: PrivilegeGetListResp
|
(*PrivilegeGetListResp)(nil), // 1: PrivilegeGetListResp
|
||||||
@ -344,18 +433,21 @@ var file_privilege_privilege_msg_proto_goTypes = []interface{}{
|
|||||||
(*PrivilegeBuyYuekaResp)(nil), // 3: PrivilegeBuyYuekaResp
|
(*PrivilegeBuyYuekaResp)(nil), // 3: PrivilegeBuyYuekaResp
|
||||||
(*PrivilegeBuyGiftReq)(nil), // 4: PrivilegeBuyGiftReq
|
(*PrivilegeBuyGiftReq)(nil), // 4: PrivilegeBuyGiftReq
|
||||||
(*PrivilegeBuyGiftResp)(nil), // 5: PrivilegeBuyGiftResp
|
(*PrivilegeBuyGiftResp)(nil), // 5: PrivilegeBuyGiftResp
|
||||||
(*DBPrivilege)(nil), // 6: DBPrivilege
|
(*PrivilegeVipListReq)(nil), // 6: PrivilegeVipListReq
|
||||||
(*DBVip)(nil), // 7: DBVip
|
(*PrivilegeVipListResp)(nil), // 7: PrivilegeVipListResp
|
||||||
|
(*DBPrivilege)(nil), // 8: DBPrivilege
|
||||||
|
(*DBVip)(nil), // 9: DBVip
|
||||||
}
|
}
|
||||||
var file_privilege_privilege_msg_proto_depIdxs = []int32{
|
var file_privilege_privilege_msg_proto_depIdxs = []int32{
|
||||||
6, // 0: PrivilegeGetListResp.data:type_name -> DBPrivilege
|
8, // 0: PrivilegeGetListResp.data:type_name -> DBPrivilege
|
||||||
6, // 1: PrivilegeBuyYuekaResp.data:type_name -> DBPrivilege
|
8, // 1: PrivilegeBuyYuekaResp.data:type_name -> DBPrivilege
|
||||||
7, // 2: PrivilegeBuyGiftResp.data:type_name -> DBVip
|
9, // 2: PrivilegeBuyGiftResp.data:type_name -> DBVip
|
||||||
3, // [3:3] is the sub-list for method output_type
|
9, // 3: PrivilegeVipListResp.data:type_name -> DBVip
|
||||||
3, // [3:3] is the sub-list for method input_type
|
4, // [4:4] is the sub-list for method output_type
|
||||||
3, // [3:3] is the sub-list for extension type_name
|
4, // [4:4] is the sub-list for method input_type
|
||||||
3, // [3:3] is the sub-list for extension extendee
|
4, // [4:4] is the sub-list for extension type_name
|
||||||
0, // [0:3] is the sub-list for field type_name
|
4, // [4:4] is the sub-list for extension extendee
|
||||||
|
0, // [0:4] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_privilege_privilege_msg_proto_init() }
|
func init() { file_privilege_privilege_msg_proto_init() }
|
||||||
@ -437,6 +529,30 @@ func file_privilege_privilege_msg_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
file_privilege_privilege_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*PrivilegeVipListReq); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_privilege_privilege_msg_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*PrivilegeVipListResp); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
type x struct{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
@ -444,7 +560,7 @@ func file_privilege_privilege_msg_proto_init() {
|
|||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_privilege_privilege_msg_proto_rawDesc,
|
RawDescriptor: file_privilege_privilege_msg_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 6,
|
NumMessages: 8,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user