1
This commit is contained in:
parent
dfa0312eee
commit
941814e687
@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
type Currency struct {
|
type Currency struct {
|
||||||
currencyName string
|
currencyName string
|
||||||
|
contractName string
|
||||||
currencyDecimal int64
|
currencyDecimal int64
|
||||||
contract *Contract
|
contract *Contract
|
||||||
}
|
}
|
||||||
@ -19,8 +20,9 @@ type CurrencyTable struct {
|
|||||||
netIdHash *q5.ConcurrentMap[int32, *q5.ConcurrentMap[string, *Currency]]
|
netIdHash *q5.ConcurrentMap[int32, *q5.ConcurrentMap[string, *Currency]]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Currency) init(currencyName string, currencyDecimal int64) {
|
func (this *Currency) init(currencyName string, contractName string, currencyDecimal int64) {
|
||||||
this.currencyName = currencyName
|
this.currencyName = currencyName
|
||||||
|
this.contractName = contractName
|
||||||
this.currencyDecimal = currencyDecimal
|
this.currencyDecimal = currencyDecimal
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +30,10 @@ func (this *Currency) GetCurrencyName() string {
|
|||||||
return this.currencyName
|
return this.currencyName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Currency) GetContractName() string {
|
||||||
|
return this.contractName
|
||||||
|
}
|
||||||
|
|
||||||
func (this *Currency) GetCurrencyDecimal() int64 {
|
func (this *Currency) GetCurrencyDecimal() int64 {
|
||||||
return this.currencyDecimal
|
return this.currencyDecimal
|
||||||
}
|
}
|
||||||
@ -93,6 +99,7 @@ func (this *CurrencyTable) Load() {
|
|||||||
f5.GetSysLog().Info("load currency %s", fileName)
|
f5.GetSysLog().Info("load currency %s", fileName)
|
||||||
currencysCfg := []struct {
|
currencysCfg := []struct {
|
||||||
CurrencyName string `json:"currency_name"`
|
CurrencyName string `json:"currency_name"`
|
||||||
|
ContractName string `json:"contract_name"`
|
||||||
CurrencyDecimal int64 `json:"currency_decimal"`
|
CurrencyDecimal int64 `json:"currency_decimal"`
|
||||||
}{}
|
}{}
|
||||||
if err := q5.DecodeJson(jsonStr, ¤cysCfg); err != nil {
|
if err := q5.DecodeJson(jsonStr, ¤cysCfg); err != nil {
|
||||||
@ -100,7 +107,7 @@ func (this *CurrencyTable) Load() {
|
|||||||
}
|
}
|
||||||
for _, currencyCfg := range currencysCfg {
|
for _, currencyCfg := range currencysCfg {
|
||||||
p := new(Currency)
|
p := new(Currency)
|
||||||
p.init(currencyCfg.CurrencyName, currencyCfg.CurrencyDecimal)
|
p.init(currencyCfg.CurrencyName, currencyCfg.ContractName, currencyCfg.CurrencyDecimal)
|
||||||
p.check()
|
p.check()
|
||||||
currencysMeta := this.GetByNetId(netId)
|
currencysMeta := this.GetByNetId(netId)
|
||||||
if currencysMeta == nil {
|
if currencysMeta == nil {
|
||||||
@ -128,7 +135,7 @@ func (this *CurrencyTable) PostInit1() {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
contractMeta := Table.Contract.GetByNetIdName(netId, currencyMeta.GetCurrencyName())
|
contractMeta := Table.Contract.GetByNetIdName(netId, currencyMeta.GetContractName())
|
||||||
if contractMeta == nil {
|
if contractMeta == nil {
|
||||||
panic(fmt.Sprintf("currency contract not found"))
|
panic(fmt.Sprintf("currency contract not found"))
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ type Config struct {
|
|||||||
|
|
||||||
type RechargeCurrency struct {
|
type RechargeCurrency struct {
|
||||||
currency_name string
|
currency_name string
|
||||||
|
contract_name string
|
||||||
currency_decimal int64
|
currency_decimal int64
|
||||||
|
|
||||||
_flags1_ uint64
|
_flags1_ uint64
|
||||||
@ -396,6 +397,14 @@ func (this *RechargeCurrency) HasCurrencyName() bool {
|
|||||||
return (this._flags1_ & (uint64(1) << 1)) > 0
|
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *RechargeCurrency) GetContractName() string {
|
||||||
|
return this.contract_name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *RechargeCurrency) HasContractName() bool {
|
||||||
|
return (this._flags1_ & (uint64(1) << 2)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
func (this *RechargeCurrency) GetCurrencyDecimal() int64 {
|
func (this *RechargeCurrency) GetCurrencyDecimal() int64 {
|
||||||
return this.currency_decimal
|
return this.currency_decimal
|
||||||
}
|
}
|
||||||
@ -562,6 +571,7 @@ func (this *Config) LoadFromKv(kv map[string]interface{}) {
|
|||||||
|
|
||||||
func (this *RechargeCurrency) LoadFromKv(kv map[string]interface{}) {
|
func (this *RechargeCurrency) LoadFromKv(kv map[string]interface{}) {
|
||||||
f5.ReadMetaTableField(&this.currency_name, "currency_name", &this._flags1_, 1, kv)
|
f5.ReadMetaTableField(&this.currency_name, "currency_name", &this._flags1_, 1, kv)
|
||||||
|
f5.ReadMetaTableField(&this.contract_name, "contract_name", &this._flags1_, 2, kv)
|
||||||
f5.ReadMetaTableField(&this.currency_decimal, "currency_decimal", &this._flags1_, 3, kv)
|
f5.ReadMetaTableField(&this.currency_decimal, "currency_decimal", &this._flags1_, 3, kv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ message Config
|
|||||||
message RechargeCurrency
|
message RechargeCurrency
|
||||||
{
|
{
|
||||||
optional string currency_name = 1;
|
optional string currency_name = 1;
|
||||||
//optional int64 exchange_rate = 2;
|
optional string contract_name = 2;
|
||||||
optional int64 currency_decimal = 3;
|
optional int64 currency_decimal = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user