|  | @@ -221,14 +221,14 @@ async function computeTransferGasFree(obj, my_account_all_coins, tokenPrices) {
 | 
	
		
			
				|  |  |      //得到 20 币 满足 1美刀的 count
 | 
	
		
			
				|  |  |      if (Array.isArray(my_account_all_coins.other) && my_account_all_coins.other.length > 0) {
 | 
	
		
			
				|  |  |          my_account_all_coins.other.forEach(element => {
 | 
	
		
			
				|  |  | -            logger.debug('20 element=', element);
 | 
	
		
			
				|  |  | +            logger.log('20 element=', element);
 | 
	
		
			
				|  |  |              var find_transfer_item = findTokenPriceItem(element.token_address, tokenPrices);
 | 
	
		
			
				|  |  |              if (find_transfer_item) {
 | 
	
		
			
				|  |  |                  var total_all_usdprice = calculate_total_usdprice(element.balance, element.decimals, find_transfer_item.usdPrice);
 | 
	
		
			
				|  |  | -                logger.debug('findTokenPriceItem ret=', element.token_address, find_transfer_item, total_all_usdprice);
 | 
	
		
			
				|  |  | +                logger.log('findTokenPriceItem ret=', element.token_address, find_transfer_item, total_all_usdprice);
 | 
	
		
			
				|  |  |                  if (find_transfer_item && total_all_usdprice > 1.0) {
 | 
	
		
			
				|  |  |                      tokenCount += 1;
 | 
	
		
			
				|  |  | -                    logger.debug('token > 1.0', tokenCount, element.token_address);
 | 
	
		
			
				|  |  | +                    logger.log('token > 1.0', tokenCount, element.token_address);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      var obj_20 = {
 | 
	
		
			
				|  |  |                          chain: obj.chain,
 | 
	
	
		
			
				|  | @@ -265,13 +265,13 @@ async function computeTransferGasFree(obj, my_account_all_coins, tokenPrices) {
 | 
	
		
			
				|  |  |          nativeAllBalance = my_account_all_coins.native.balance
 | 
	
		
			
				|  |  |      var nativeCount = 0
 | 
	
		
			
				|  |  |      var nativePriceItem = findTokenPriceItem('0x0000000000000000000000000000000000000000', tokenPrices);//todo 线上环境需要换
 | 
	
		
			
				|  |  | -    logger.debug('native nativePriceItem=', nativePriceItem, nativeAllBalance);
 | 
	
		
			
				|  |  | +    logger.log('native nativePriceItem=', nativePriceItem, nativeAllBalance);
 | 
	
		
			
				|  |  |      if (nativePriceItem) {
 | 
	
		
			
				|  |  |          var total_all_usdprice = calculate_total_usdprice(nativeAllBalance, '18', nativePriceItem.usdPrice);
 | 
	
		
			
				|  |  | -        logger.debug('native total_all_usdprice=', total_all_usdprice);
 | 
	
		
			
				|  |  | +        logger.log('native total_all_usdprice=', total_all_usdprice);
 | 
	
		
			
				|  |  |          if (total_all_usdprice > 1.0) {
 | 
	
		
			
				|  |  |              nativeCount = 1;
 | 
	
		
			
				|  |  | -            logger.debug('native > 1.0', tokenCount);
 | 
	
		
			
				|  |  | +            logger.log('native > 1.0', tokenCount);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              var lastBnbFree = await redis.readRedis(reids_token_config.LAST_TOTAL_BNB_FREE)
 | 
	
		
			
				|  |  |              logger.log('LAST_TOTAL_BNB_FREE=', lastBnbFree);
 | 
	
	
		
			
				|  | @@ -542,6 +542,7 @@ async function queryCollectBalance(address, chain) {
 | 
	
		
			
				|  |  |   * @param {*} obj 
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  const collectCoins = async (obj) => {
 | 
	
		
			
				|  |  | +    logger.log('fun collectCoins in =', obj)
 | 
	
		
			
				|  |  |      var chain = obj.chain;
 | 
	
		
			
				|  |  |      //1、拿到当前账户所有的币
 | 
	
		
			
				|  |  |      //2、是否满足交易费 如果不满足则 归集地址转移 币count * 手续费 到充币地址
 | 
	
	
		
			
				|  | @@ -551,7 +552,7 @@ const collectCoins = async (obj) => {
 | 
	
		
			
				|  |  |      var logParams = {};
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      var my_account_all_coins = await getAccountAllCoins(obj);
 | 
	
		
			
				|  |  | -    logger.log('getAccountAllCoins=', my_account_all_coins)
 | 
	
		
			
				|  |  | +    logger.log('collectCoins getAccountAllCoins=', my_account_all_coins)
 | 
	
		
			
				|  |  |      if (!my_account_all_coins.native && !my_account_all_coins.other) {
 | 
	
		
			
				|  |  |          return 'getAccountAllCoins error.' + my_account_all_coins
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -563,14 +564,14 @@ const collectCoins = async (obj) => {
 | 
	
		
			
				|  |  |      if (process.env.NODE_ENV == 'dev') {
 | 
	
		
			
				|  |  |          var test_json = '{"tokenPrice": [{"contract": "0x0000000000000000000000000000000000000000", "usdPrice": 400}, {"contract": "0x03716F32f72c692a0B355fa04639669E3341B94e", "usdPrice": 0.1}]}'
 | 
	
		
			
				|  |  |          obj.tokenPrices = JSON.parse(test_json);
 | 
	
		
			
				|  |  | -        logger.log('dev tokenPrices=', obj.tokenPrices)
 | 
	
		
			
				|  |  | +       
 | 
	
		
			
				|  |  |      } else {
 | 
	
		
			
				|  |  |          obj.tokenPrices = await redis.readRedis(reids_token_config.TOKENPRICE)
 | 
	
		
			
				|  |  |          if (!obj.tokenPrices) return 'readRedis error'
 | 
	
		
			
				|  |  |          if (typeof obj.tokenPrices == 'string')
 | 
	
		
			
				|  |  |              obj.tokenPrices = JSON.parse(obj.tokenPrices);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +    logger.log('tokenPrices=', obj.tokenPrices)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      obj.chain = chain;
 | 
	
		
			
				|  |  |      //计算 gas 费用 是否需要归集
 | 
	
	
		
			
				|  | @@ -587,9 +588,6 @@ const collectCoins = async (obj) => {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      logger.log('computeTransferGasFree=', transFerGasFree)
 | 
	
		
			
				|  |  |      logger.log(' logParams.transfers=', logParams.transfers)
 | 
	
		
			
				|  |  | -    if (transFerGasFree) {
 | 
	
		
			
				|  |  | -        // return
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      //是否需要归集
 | 
	
		
			
				|  |  |      if (transFerGasFree.totalCount > 0) {
 | 
	
	
		
			
				|  | @@ -616,7 +614,6 @@ const collectCoins = async (obj) => {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if (!isTransferSucceed(ret)) return ret;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              var transfer = getTransferGasFree('native', ret)
 | 
	
		
			
				|  |  |              logger.log('getTransferGasFree transfer =', transfer)
 | 
	
		
			
				|  |  |              if (transfer && transfer.nativeValue > 0) {
 | 
	
	
		
			
				|  | @@ -625,7 +622,6 @@ const collectCoins = async (obj) => {
 | 
	
		
			
				|  |  |                  my_account_all_coins.native.balance = tempNativeValue.toString();
 | 
	
		
			
				|  |  |                  logger.log('udpateNativeValue=', tempNativeValue);
 | 
	
		
			
				|  |  |              } else return "get native value error."
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          obj.chain = chain;
 | 
	
	
		
			
				|  | @@ -655,7 +651,7 @@ async function execCollectCoinsTask() {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  function pushCollectConisObj(obj) {
 | 
	
		
			
				|  |  | -    logger.debug('collectCoinsArrays length=', collectCoinsArrays.length, collectCoinsArrays)
 | 
	
		
			
				|  |  | +    logger.log('collectCoinsArrays length=', collectCoinsArrays.length, collectCoinsArrays)
 | 
	
		
			
				|  |  |      if (collectCoinsArrays.length > 0) {
 | 
	
		
			
				|  |  |          var findItem = collectCoinsArrays.find(element => {
 | 
	
		
			
				|  |  |              return (obj.address == element.address)
 | 
	
	
		
			
				|  | @@ -812,14 +808,14 @@ function setTransfersDataType(type, ret) {
 | 
	
		
			
				|  |  |  //hash 0xe09ba3a4c9f7a8902e01af68d0f1f91906f3f7db1195227e61c45c0e86b2630a
 | 
	
		
			
				|  |  |  async function getTokenTransfers(opt) {
 | 
	
		
			
				|  |  |      await initMasterSDK();
 | 
	
		
			
				|  |  | -    logger.debug("fun getTokenTransfers in ", opt);
 | 
	
		
			
				|  |  | +    logger.log("fun getTokenTransfers in ", opt);
 | 
	
		
			
				|  |  |      const options = {};
 | 
	
		
			
				|  |  |      options.type = 'all';
 | 
	
		
			
				|  |  |      options.chain = 'bsc_mainnet';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      if (opt.chain != null) {
 | 
	
		
			
				|  |  |          options.chain = utils.getChainName(opt.chain);
 | 
	
		
			
				|  |  | -        logger.log('getTokenTransfers=', options.chain);
 | 
	
		
			
				|  |  | +        logger.log('getTokenTransfers getChainName =', options.chain);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      if (opt.order != null) {
 | 
	
	
		
			
				|  | @@ -847,7 +843,7 @@ async function getTokenTransfers(opt) {
 | 
	
		
			
				|  |  |          options.type = 'transaction_hash';
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    logger.debug('getTokenTransfers-->>>', options);
 | 
	
		
			
				|  |  | +    logger.log('getTokenTransfers >>>>>', options);
 | 
	
		
			
				|  |  |      if (options.type == 'all') {//查询主流币和 20 币所有的交易
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  |              if (opt.address != null) {
 | 
	
	
		
			
				|  | @@ -855,24 +851,26 @@ async function getTokenTransfers(opt) {
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  return toJson(ERROR_CODE_001, null, "please check address parameter is ok ?");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +            logger.log('getTokenTransfers account getTransactions>>>>>', options);
 | 
	
		
			
				|  |  |              //主流币
 | 
	
		
			
				|  |  |              var t_1 = await Moralis.Web3API.account.getTransactions(options);
 | 
	
		
			
				|  |  | -            logger.debug('getTokenTransfers-->>> t_1', t_1);
 | 
	
		
			
				|  |  | +            logger.log('getTokenTransfers native ret -->>> t_1', t_1);
 | 
	
		
			
				|  |  |              setTransfersDataType('native', t_1.result)
 | 
	
		
			
				|  |  |              //20币
 | 
	
		
			
				|  |  |              //token 获取交易记录如果没有时间有些地址会失败
 | 
	
		
			
				|  |  | -            if (!options.to_date) {
 | 
	
		
			
				|  |  | -                options.to_date = '2099-01-01'
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +            // if (!options.to_date) {
 | 
	
		
			
				|  |  | +            //     options.to_date = '2099-01-01'
 | 
	
		
			
				|  |  | +            // }
 | 
	
		
			
				|  |  | +            logger.log('getTokenTransfers account getTokenTransfers>>>>>', options);
 | 
	
		
			
				|  |  |              var t_2 = await Moralis.Web3API.account.getTokenTransfers(options);
 | 
	
		
			
				|  |  | -            logger.debug('getTokenTransfers-->>> t_2', options, t_2);
 | 
	
		
			
				|  |  | +            logger.log('getTokenTransfers token ret -->>> t_2', t_2);
 | 
	
		
			
				|  |  |              setTransfersDataType('token', t_2.result)
 | 
	
		
			
				|  |  |              let arr = t_1.result;
 | 
	
		
			
				|  |  |              let arr1 = t_2.result;
 | 
	
		
			
				|  |  |              if (Array.isArray(arr1) && Array.isArray(arr)) {
 | 
	
		
			
				|  |  |                  let arr2 = arr.concat(arr1);
 | 
	
		
			
				|  |  |                  t_1.result = arr2;
 | 
	
		
			
				|  |  | -                logger.debug('getTokenTransfers-->>> concat t_1', t_1);
 | 
	
		
			
				|  |  | +                logger.log('getTokenTransfers-->>> concat t_1', t_1);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              //将结果排序
 | 
	
	
		
			
				|  | @@ -881,7 +879,7 @@ async function getTokenTransfers(opt) {
 | 
	
		
			
				|  |  |                  let t2 = new Date(Date.parse(b.block_timestamp))
 | 
	
		
			
				|  |  |                  return t2.getTime() - t1.getTime()
 | 
	
		
			
				|  |  |              })
 | 
	
		
			
				|  |  | -            logger.debug('getTokenTransfers-->>> sort t_1', t_1);
 | 
	
		
			
				|  |  | +            logger.log('getTokenTransfers-->>> sort t_1', t_1);
 | 
	
		
			
				|  |  |              return toJson(SUCCEED_CODE, t_1, null);
 | 
	
		
			
				|  |  |          } catch (error) {
 | 
	
		
			
				|  |  |              logger.error("getTransactions error:", error)
 | 
	
	
		
			
				|  | @@ -889,8 +887,10 @@ async function getTokenTransfers(opt) {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      } else if (options.type == 'transaction_hash') {//根据哈希查询
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  | +            logger.log('transaction_hash getTransaction options-->>> ', options);
 | 
	
		
			
				|  |  |              //native
 | 
	
		
			
				|  |  |              const transaction = await Moralis.Web3API.native.getTransaction(options);
 | 
	
		
			
				|  |  | +            logger.log('transaction_hash getTransaction ret-->>> ', transaction);
 | 
	
		
			
				|  |  |              var arr = [];
 | 
	
		
			
				|  |  |              if (transaction)
 | 
	
		
			
				|  |  |                  arr.push(transaction)
 |