Ver código fonte

过滤币价

DevYK 2 anos atrás
pai
commit
931bca174f
2 arquivos alterados com 25 adições e 5 exclusões
  1. 24 4
      model/moralis_sdk.js
  2. 1 1
      model/server_data_statisticsv2.js

+ 24 - 4
model/moralis_sdk.js

@@ -1183,6 +1183,25 @@ const getAllTokenWithdrawInfoLists = async (obj) => {
     }
 }
 
+function filterZeroPrice(ret) {
+    var newRet = ret
+    try {
+        if (ret && typeof ret == 'string') {
+           var  newret = JSON.parse(ret);
+            if (newret.tokenPrice && Array.isArray(newret.tokenPrice)) {
+                var newPrices = newret.tokenPrice.filter(filter => {
+                    return filter.usdPrice != 0
+                })
+                newret.tokenPrice = newPrices;
+                newRet = JSON.stringify(newret)
+            }
+        }
+    } catch (error) {
+        newRet = ret
+        logger.error('filterZeroPrice', error.toString())
+    }
+    return newRet
+}
 
 
 /**
@@ -1194,7 +1213,8 @@ const getAllTotkenPrice = async (opts) => {
         // logger.log("getAllTotkenPrice in", reids_token_config); // Prints "value"
         var token_price_key = reids_token_config.TOKENPRICE;
         logger.log("getAllTotkenPrice token_price_key=", token_price_key);
-        return await redis.readAppendRedis(token_price_key, opts.chain, '')
+        var ret = await redis.readAppendRedis(token_price_key, opts.chain, '')
+        return filterZeroPrice(ret)
     } catch (error) {
         logger.error("getTotkenPrice=", error);
         return toJson(ERROR_CODE_001, null, error.toString());
@@ -1583,18 +1603,18 @@ function convertChain(chain) {
  * @param {} opts 
  */
 async function getTransferRecord(opts, type, use_moralis_sdk_) {
-  
+
     //是否使用 moralis sdk 进行查询
     var use_moralis_sdk = use_moralis_sdk_
     var temp_opts = { ...opts }
 
     if (temp_opts.chain != utils.CHAIN_NAME.bsc_mainnet && temp_opts.chain != utils.CHAIN_NAME.bsc_testnet) {
         use_moralis_sdk = 0;
-    } 
+    }
     if (use_moralis_sdk == 0) {
         temp_opts.chain = convertChain(temp_opts.chain)
     }
-    logger.info('getTransferRecord>>>>>>>>', opts, type,temp_opts, use_moralis_sdk_,use_moralis_sdk == 0)
+    logger.info('getTransferRecord>>>>>>>>', opts, type, temp_opts, use_moralis_sdk_, use_moralis_sdk == 0)
     if (use_moralis_sdk) {
         var results = []
         if (type == 'native') {

+ 1 - 1
model/server_data_statisticsv2.js

@@ -879,7 +879,7 @@ async function report2FeishuTable(day) {
 async function testNotify() {
     // var app = await getFeishuToken()
     // notify(app, 'oc_b159b9a53dd52206c5cf75677d0cf0ca')
-
+    
     //获取当前账户总余额
     var curBalances = await getAllBalanceV2()
     logger.info('getAllBalanceV2 curBalances', curBalances)