1
This commit is contained in:
parent
6c6a5943a0
commit
0347d34f7f
@ -1,5 +1,5 @@
|
||||
{
|
||||
"currency_name": "TestToken",
|
||||
"exchange_rate": 50,
|
||||
"exchange_rate": 100,
|
||||
"currency_decimal": 6
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) {
|
||||
Rows []interface{} `json:"rows"`
|
||||
}{}
|
||||
|
||||
currencyMeta := mt.Table.Currency.Get(netId)
|
||||
currencyMeta := mt.Table.Currency.GetByNetId(netId)
|
||||
if currencyMeta == nil {
|
||||
f5.RspErr(c, 2, "server internal error")
|
||||
return
|
||||
@ -39,6 +39,9 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) {
|
||||
tmpmap["diamond"] = tb.GetDiamond()
|
||||
tmpmap["price"] = tb.GetPrice()
|
||||
tmpmap["max_buy_times"] = tb.GetMaxBuyTimes()
|
||||
tmpmap["first_present_diamond"] = tb.GetFirstPresentDiamond()
|
||||
tmpmap["is_first_recharge"] = 1
|
||||
tmpmap["currency_list"] = 1
|
||||
|
||||
rspObj.Rows = append(rspObj.Rows, tmpmap)
|
||||
|
||||
@ -88,7 +91,7 @@ func (this *RechargeApi) BuyWithEmail(c *gin.Context) {
|
||||
func (this *RechargeApi) internalBuy(c *gin.Context,
|
||||
netId int32, goodsId int32, goodsNum int32, accountAddress string, passportAddress string,
|
||||
email string) {
|
||||
currencyMeta := mt.Table.Currency.Get(netId)
|
||||
currencyMeta := mt.Table.Currency.GetByNetIdAddress(netId, "")
|
||||
if currencyMeta == nil {
|
||||
f5.RspErr(c, 2, "server internal error")
|
||||
return
|
||||
|
@ -19,7 +19,7 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
RECHARGE_CURRENCY_MAX_EXCHANGE_RAET = 50
|
||||
RECHARGE_CURRENCY_MAX_EXCHANGE_RAET = 100
|
||||
RECHARGE_CURRENCY_MAX_DECIMAL = 6
|
||||
RECHARGE_CURRENCY_MAX_BUY_NUM = 9999
|
||||
)
|
||||
|
@ -11,6 +11,7 @@ type Currency struct {
|
||||
currencyName string
|
||||
exchangeRate int64
|
||||
currencyDecimal int64
|
||||
contract *Contract
|
||||
}
|
||||
|
||||
type CurrencyTable struct {
|
||||
@ -36,6 +37,10 @@ func (this *Currency) GetCurrencyDecimal() int64 {
|
||||
return this.currencyDecimal
|
||||
}
|
||||
|
||||
func (this *Currency) GetContract() *Contract {
|
||||
return this.contract
|
||||
}
|
||||
|
||||
func (this *Currency) check() {
|
||||
if this.GetExchangeRate() <= 0 {
|
||||
panic("Currency exchange_rate <= 0")
|
||||
@ -55,14 +60,18 @@ func (this *Currency) check() {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *CurrencyTable) Get(netId int32) *Currency {
|
||||
func (this *CurrencyTable) GetByNetId(netId int32) []*Currency {
|
||||
if v, ok := this.netIdHash.Load(netId); ok {
|
||||
return *v
|
||||
return []*Currency{*v}
|
||||
} else {
|
||||
return nil
|
||||
return []*Currency{}
|
||||
}
|
||||
}
|
||||
|
||||
func (this *CurrencyTable) GetByNetIdAddress(netId int32, currencyAddress string) *Currency {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *CurrencyTable) Load() {
|
||||
this.netIdHash = new(q5.ConcurrentMap[int32, *Currency])
|
||||
nets := []int32{}
|
||||
|
@ -93,6 +93,7 @@ type Recharge struct {
|
||||
diamond int32
|
||||
price int32
|
||||
max_buy_times int32
|
||||
first_present_diamond int32
|
||||
|
||||
_flags1_ uint64
|
||||
_flags2_ uint64
|
||||
@ -432,6 +433,14 @@ func (this *Recharge) HasMaxBuyTimes() bool {
|
||||
return (this._flags1_ & (uint64(1) << 4)) > 0
|
||||
}
|
||||
|
||||
func (this *Recharge) GetFirstPresentDiamond() int32 {
|
||||
return this.first_present_diamond
|
||||
}
|
||||
|
||||
func (this *Recharge) HasFirstPresentDiamond() bool {
|
||||
return (this._flags1_ & (uint64(1) << 5)) > 0
|
||||
}
|
||||
|
||||
func (this *Web3ServiceCluster) GetUrl() string {
|
||||
return this.url
|
||||
}
|
||||
@ -514,6 +523,7 @@ func (this *Recharge) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.diamond, "diamond", &this._flags1_, 2, kv)
|
||||
f5.ReadMetaTableField(&this.price, "price", &this._flags1_, 3, kv)
|
||||
f5.ReadMetaTableField(&this.max_buy_times, "max_buy_times", &this._flags1_, 4, kv)
|
||||
f5.ReadMetaTableField(&this.first_present_diamond, "first_present_diamond", &this._flags1_, 5, kv)
|
||||
}
|
||||
|
||||
func (this *Web3ServiceCluster) LoadFromKv(kv map[string]interface{}) {
|
||||
|
@ -76,6 +76,7 @@ message Recharge
|
||||
optional int32 diamond = 2;
|
||||
optional int32 price = 3;
|
||||
optional int32 max_buy_times = 4;
|
||||
optional int32 first_present_diamond = 5;
|
||||
}
|
||||
|
||||
message Web3ServiceCluster
|
||||
|
Loading…
x
Reference in New Issue
Block a user