From f189f23f0dd9b53230d5c15be96c07b9fbabff8f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 27 Jun 2024 16:37:12 +0800 Subject: [PATCH] 1 --- server/backtask/service/bc_currency.go | 11 +++++++++-- server/backtask/task/webhook.go | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/server/backtask/service/bc_currency.go b/server/backtask/service/bc_currency.go index 76d809dc..6b647f52 100644 --- a/server/backtask/service/bc_currency.go +++ b/server/backtask/service/bc_currency.go @@ -8,7 +8,6 @@ import ( "math/big" "mt" "strings" - "fmt" ) const DECIMALS = 10000 @@ -21,6 +20,7 @@ type vsCurrency struct { type bcCurrency struct { nameHash *q5.ConcurrentMap[string, int64] addressHash *q5.ConcurrentMap[string, int64] + lastRefreshOkTime int64 } func (this *bcCurrency) init() () { @@ -66,8 +66,8 @@ func (this *bcCurrency) refreshExchangeRate() () { jccommon.BC_CURRENCY_VS_URL, map[string]string{}, func (rsp f5.HttpCliResponse) { - fmt.Println("bcCurrency refreshPrice22", rsp.GetErr()) if rsp.GetErr() != nil { + f5.GetSysLog().Info("bcCurrency refreshPrice error%s", rsp.GetErr()) return } if q5.DecodeJson(rsp.GetRawData(), &rspObj) == nil { @@ -91,6 +91,9 @@ func (this *bcCurrency) updatePrice(l []vsCurrency) { this.addressHash.Store(address, int64(val.CurrentPrice * DECIMALS)) } } + if len(l) > 0 { + this.lastRefreshOkTime = f5.GetApp().GetRealSeconds() + } f5.GetSysLog().Info("bcCurrency updatePrice %s", q5.EncodeJson(l)) } @@ -102,3 +105,7 @@ func (this *bcCurrency) getAddressByName(name string) string { return "" } } + +func (this *bcCurrency) GetLastRefreshOkTime() int64 { + return this.lastRefreshOkTime +} diff --git a/server/backtask/task/webhook.go b/server/backtask/task/webhook.go index 52cb940c..46bd1f06 100644 --- a/server/backtask/task/webhook.go +++ b/server/backtask/task/webhook.go @@ -139,7 +139,8 @@ func (this* webHook) orderUpdatedCb(ds *f5.DataSet) bool { srcPriceAmount := p.Data.Buy[0].Amount srcPriceContractAddress := p.Data.Buy[0].ContractAddress srcPriceItemType := p.Data.Buy[0].ItemType - currentPrice, price := service.BcCurrency.ExchangeUSD(srcPriceAmount, srcPriceContractAddress, srcPriceItemType) + srcPriceExchangeRate, price := service.BcCurrency.ExchangeUSD( + srcPriceAmount, srcPriceContractAddress, srcPriceItemType) commonFields := [][]string{ {"order_id", p.Data.Id}, {"chain", p.Chain}, @@ -157,7 +158,7 @@ func (this* webHook) orderUpdatedCb(ds *f5.DataSet) bool { {"src_price_contract_address", srcPriceContractAddress}, {"src_price_item_type", srcPriceItemType}, {"price", price}, - {"current_price", q5.ToString(currentPrice)}, + {"src_price_exchange_rate", q5.ToString(srcPriceExchangeRate)}, } updateFields := commonFields[0:] insertFields := commonFields[0:]