From 0347d34f7f7fdb465129ac01463675adc5eca09e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 16 Aug 2024 17:15:45 +0800 Subject: [PATCH] 1 --- .../config/currencys/13473/currency.json | 2 +- server/marketserver/api/v1/recharge/recharge.go | 7 +++++-- server/marketserver/constant/constant.go | 2 +- server/marketserver/mt/Currency.go | 15 ++++++++++++--- server/marketserver/mtb/mtb.auto_gen.go | 10 ++++++++++ server/marketserver/proto/mt.proto | 1 + 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/bin/marketserver/config/currencys/13473/currency.json b/bin/marketserver/config/currencys/13473/currency.json index 5016b3e6..694fbc47 100644 --- a/bin/marketserver/config/currencys/13473/currency.json +++ b/bin/marketserver/config/currencys/13473/currency.json @@ -1,5 +1,5 @@ { "currency_name": "TestToken", - "exchange_rate": 50, + "exchange_rate": 100, "currency_decimal": 6 } diff --git a/server/marketserver/api/v1/recharge/recharge.go b/server/marketserver/api/v1/recharge/recharge.go index e6c0af39..6640faac 100644 --- a/server/marketserver/api/v1/recharge/recharge.go +++ b/server/marketserver/api/v1/recharge/recharge.go @@ -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 diff --git a/server/marketserver/constant/constant.go b/server/marketserver/constant/constant.go index 03ac120b..c1911232 100644 --- a/server/marketserver/constant/constant.go +++ b/server/marketserver/constant/constant.go @@ -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 ) diff --git a/server/marketserver/mt/Currency.go b/server/marketserver/mt/Currency.go index 68c349a7..b5d15fb8 100644 --- a/server/marketserver/mt/Currency.go +++ b/server/marketserver/mt/Currency.go @@ -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{} diff --git a/server/marketserver/mtb/mtb.auto_gen.go b/server/marketserver/mtb/mtb.auto_gen.go index 3c227b39..f91f1ea3 100644 --- a/server/marketserver/mtb/mtb.auto_gen.go +++ b/server/marketserver/mtb/mtb.auto_gen.go @@ -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{}) { diff --git a/server/marketserver/proto/mt.proto b/server/marketserver/proto/mt.proto index f69e6874..19ac74ab 100644 --- a/server/marketserver/proto/mt.proto +++ b/server/marketserver/proto/mt.proto @@ -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