1
This commit is contained in:
parent
1a68b97855
commit
f189f23f0d
@ -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
|
||||
}
|
||||
|
@ -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:]
|
||||
|
Loading…
x
Reference in New Issue
Block a user