From 508b858acadea9eea0b06461247f5867954d20ee Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sun, 23 Jan 2022 20:16:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=BB=98=E8=AE=A4=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/rpc/pb/model_server_bill.pb.go | 34 ++++++++++++------- pkg/rpc/protos/models/model_server_bill.proto | 1 + pkg/systemconfigs/settings.go | 1 + pkg/userconfigs/user_finance_config.go | 19 +++++++++++ 4 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 pkg/userconfigs/user_finance_config.go diff --git a/pkg/rpc/pb/model_server_bill.pb.go b/pkg/rpc/pb/model_server_bill.pb.go index b68fac9..5d213ac 100644 --- a/pkg/rpc/pb/model_server_bill.pb.go +++ b/pkg/rpc/pb/model_server_bill.pb.go @@ -40,6 +40,7 @@ type ServerBill struct { TotalTrafficBytes int64 `protobuf:"varint,8,opt,name=totalTrafficBytes,proto3" json:"totalTrafficBytes,omitempty"` BandwidthPercentileBytes int64 `protobuf:"varint,9,opt,name=bandwidthPercentileBytes,proto3" json:"bandwidthPercentileBytes,omitempty"` BandwidthPercentile int32 `protobuf:"varint,10,opt,name=bandwidthPercentile,proto3" json:"bandwidthPercentile,omitempty"` + PriceType string `protobuf:"bytes,11,opt,name=priceType,proto3" json:"priceType,omitempty"` UserPlan *UserPlan `protobuf:"bytes,30,opt,name=userPlan,proto3" json:"userPlan,omitempty"` Plan *Plan `protobuf:"bytes,31,opt,name=plan,proto3" json:"plan,omitempty"` User *User `protobuf:"bytes,32,opt,name=user,proto3" json:"user,omitempty"` @@ -148,6 +149,13 @@ func (x *ServerBill) GetBandwidthPercentile() int32 { return 0 } +func (x *ServerBill) GetPriceType() string { + if x != nil { + return x.PriceType + } + return "" +} + func (x *ServerBill) GetUserPlan() *UserPlan { if x != nil { return x.UserPlan @@ -188,7 +196,7 @@ var file_models_model_server_bill_proto_rawDesc = []byte{ 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0xe4, 0x03, 0x0a, 0x0a, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x42, 0x69, 0x6c, 0x6c, 0x12, 0x0e, + 0x82, 0x04, 0x0a, 0x0a, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x42, 0x69, 0x6c, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, @@ -209,17 +217,19 @@ var file_models_model_server_bill_proto_rawDesc = []byte{ 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x13, 0x62, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x13, 0x62, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, - 0x74, 0x68, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x12, 0x28, 0x0a, 0x08, - 0x75, 0x73, 0x65, 0x72, 0x50, 0x6c, 0x61, 0x6e, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, - 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6c, 0x61, 0x6e, 0x52, 0x08, 0x75, 0x73, - 0x65, 0x72, 0x50, 0x6c, 0x61, 0x6e, 0x12, 0x1c, 0x0a, 0x04, 0x70, 0x6c, 0x61, 0x6e, 0x18, 0x1f, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x52, 0x04, - 0x70, 0x6c, 0x61, 0x6e, 0x12, 0x1c, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x20, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, - 0x65, 0x72, 0x12, 0x22, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x21, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x06, - 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x68, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, + 0x70, 0x72, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x70, 0x72, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x75, 0x73, + 0x65, 0x72, 0x50, 0x6c, 0x61, 0x6e, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, + 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6c, 0x61, 0x6e, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, + 0x50, 0x6c, 0x61, 0x6e, 0x12, 0x1c, 0x0a, 0x04, 0x70, 0x6c, 0x61, 0x6e, 0x18, 0x1f, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x52, 0x04, 0x70, 0x6c, + 0x61, 0x6e, 0x12, 0x1c, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x20, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, + 0x12, 0x22, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x21, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/rpc/protos/models/model_server_bill.proto b/pkg/rpc/protos/models/model_server_bill.proto index 89ecd00..d7b245a 100644 --- a/pkg/rpc/protos/models/model_server_bill.proto +++ b/pkg/rpc/protos/models/model_server_bill.proto @@ -19,6 +19,7 @@ message ServerBill { int64 totalTrafficBytes = 8; int64 bandwidthPercentileBytes = 9; int32 bandwidthPercentile = 10; + string priceType = 11; UserPlan userPlan = 30; Plan plan = 31; diff --git a/pkg/systemconfigs/settings.go b/pkg/systemconfigs/settings.go index 36aa3ed..f1dc082 100644 --- a/pkg/systemconfigs/settings.go +++ b/pkg/systemconfigs/settings.go @@ -16,6 +16,7 @@ const ( SettingCodeUserUIConfig SettingCode = "userUIConfig" // 用户界面配置 SettingCodeUserRegisterConfig SettingCode = "userRegisterConfig" // 用户注册配置 SettingCodeUserServerConfig SettingCode = "userServerConfig" // 用户服务设置 + SettingCodeUserFinanceConfig SettingCode = "userFinanceConfig" // 用户财务设置 SettingCodeNSAccessLogSetting SettingCode = "nsAccessLogSetting" // NS相关全局配置 SettingCodeNSNodeMonitor SettingCode = "nsNodeMonitor" // 监控NS节点状态 diff --git a/pkg/userconfigs/user_finance_config.go b/pkg/userconfigs/user_finance_config.go new file mode 100644 index 0000000..4af2ac1 --- /dev/null +++ b/pkg/userconfigs/user_finance_config.go @@ -0,0 +1,19 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package userconfigs + +import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + +// UserFinanceConfig 财务相关设置 +type UserFinanceConfig struct { + IsOn bool `yaml:"isOn" json:"isOn"` + PriceType serverconfigs.PlanPriceType `yaml:"priceType" json:"priceType"` + TrafficPriceConfig *serverconfigs.PlanTrafficPriceConfig `yaml:"trafficPrice" json:"trafficPrice"` + BandwidthPriceConfig *serverconfigs.PlanBandwidthPriceConfig `yaml:"bandwidthPrice" json:"bandwidthPrice"` +} + +func DefaultUserFinanceConfig() *UserFinanceConfig { + return &UserFinanceConfig{ + PriceType: serverconfigs.PlanPriceTypeBandwidth, + } +}