feat: implement gas and delivery admin systems

This commit is contained in:
david
2026-07-30 14:16:58 +08:00
parent 1093385f95
commit f5ecc0d973
252 changed files with 49385 additions and 363 deletions

View File

@@ -3,6 +3,7 @@ package config
import (
"net"
"net/url"
"git.apinb.com/bsm-sdk/core/conf"
)
@@ -10,9 +11,15 @@ import (
// Spec 是 Platform API 的运行配置。
var Spec SrvConfig
// WalletConfig 保存钱包后台资金操作限制
// GlobalConfig 保存多个管理端共用的运行参数
type GlobalConfig struct {
UserRegisterURL string `yaml:"UserRegisterURL"`
ManualRechargeMaxAmount int64 `yaml:"ManualRechargeMaxAmount"`
}
// WalletConfig 是平台既有钱包逻辑的内部兼容视图,值由 Global 注入。
type WalletConfig struct {
ManualRechargeMaxAmount int64 `yaml:"ManualRechargeMaxAmount"`
ManualRechargeMaxAmount int64 `yaml:"-"`
}
// SrvConfig 与 sample/server 配置结构保持一致。
@@ -21,7 +28,8 @@ type SrvConfig struct {
Databases *conf.DBConf `yaml:"Databases"`
Rpc map[string]conf.RpcConf `yaml:"Rpc"`
Apm *conf.ApmConf `yaml:"APM"`
Wallet WalletConfig `yaml:"Wallet"`
Global GlobalConfig `yaml:"Global"`
Wallet WalletConfig `yaml:"-"`
}
// New 初始化 BSM 配置并校验服务监听地址。
@@ -31,8 +39,13 @@ func New(srvKey string) {
Spec.BindIP = conf.CheckIP(Spec.BindIP)
Spec.Addr = net.JoinHostPort(Spec.BindIP, Spec.Port)
conf.NotNil(Spec.Service, Spec.Cache)
if Spec.Wallet.ManualRechargeMaxAmount <= 0 {
panic("Wallet.ManualRechargeMaxAmount must be greater than zero")
if Spec.Global.ManualRechargeMaxAmount <= 0 {
panic("Global.ManualRechargeMaxAmount must be greater than zero")
}
Spec.Wallet.ManualRechargeMaxAmount = Spec.Global.ManualRechargeMaxAmount
registerURL, err := url.ParseRequestURI(Spec.Global.UserRegisterURL)
if err != nil || (registerURL.Scheme != "http" && registerURL.Scheme != "https") || registerURL.Host == "" {
panic("Global.UserRegisterURL must be a valid HTTP or HTTPS URL")
}
conf.PrintInfo(Spec.Addr)
}