فهرست منبع

每日数据统计

DevYK 2 سال پیش
والد
کامیت
7bf98226d2
5فایلهای تغییر یافته به همراه326 افزوده شده و 115 حذف شده
  1. 10 11
      config/dev_config.js
  2. 211 94
      model/server_data_statistics.js
  3. 4 4
      routes/sdk.js
  4. 1 1
      test/db_test.js
  5. 100 5
      test/sample.js

+ 10 - 11
config/dev_config.js

@@ -19,7 +19,7 @@ const account_config = {
     TRANSFER_GAS: true,
     FEISHU_URL: 'https://open.feishu.cn/open-apis/bot/v2/hook/18dfe21f-b1bd-46ca-a8c7-c85e1c84f02d',
     CZZ_BASEURL: "https://internal-block-payout-test.denet.me",
-    STATISTICS_URL:'https://testapi.denetme.net/denet/wallet/stat/getMoneyStat?date='
+    STATISTICS_URL: 'https://testapi.denetme.net/denet/wallet/stat/getMoneyStat?date='
 }
 
 const reids_token_config = {
@@ -47,7 +47,6 @@ const http_log_report_config = {
 // 设置数据库配置文件
 const db_config = {
     // 数据库配置
-
     mysql: {
         DATABASE: 'denet_chain',   //数据库名称
         DATABASE_MY_NODE: 'bnb_block_sync',   //自建 node 存储
@@ -60,6 +59,13 @@ const db_config = {
         POOL_SIZE: 5,
     },
 
+    redis: {
+        PORT: 6379, // Redis port
+        HOST: "denet-test.y2slbl.clustercfg.memorydb.us-east-1.amazonaws.com", // Redis host
+        USERNAME: null, // needs Redis >= 6
+        PASSWORD: null,
+    },
+
     // 线上数据库配置
     // mysql: {
     //     DATABASE: 'denet_chain',   //数据库名称
@@ -75,17 +81,10 @@ const db_config = {
 
     // redis: {
     //     PORT: 6379, // Redis port
-    //     HOST: "r-bp1ps6my7lzg8rdhwxpi.redis.rds.aliyuncs.com", // Redis host
+    //     HOST: "denet-chain-prod.y2slbl.clustercfg.memorydb.us-east-1.amazonaws.com", // Redis host
     //     USERNAME: null,
-    //     PASSWORD: "Wqsd@2019"
+    //     PASSWORD: null,
     // },
-
-    redis: {
-        PORT: 6379, // Redis port
-        HOST: "denet-test.y2slbl.clustercfg.memorydb.us-east-1.amazonaws.com", // Redis host
-        USERNAME: null, // needs Redis >= 6
-        PASSWORD: null,
-    },
 }
 
 // 设置 moralis sdk 配置文件

+ 211 - 94
model/server_data_statistics.js

@@ -7,6 +7,13 @@ var utils = require("../model/utils");
 const axios = require('axios');
 var { account_config } = require('../config/config.js');
 const { max } = require('moment');
+
+// 拿到飞书写入的 token
+const feishu_write_table_token_url = 'https://open.feishu.cn/open-apis/auth/v3/app_access_token/internal'
+const feishu_write_table_data_url = 'https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/shtcnp6zbrsep1Sz3Cvk7NXRpDg/values_batch_update'
+const feishu_insert_table_url = 'https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/shtcnp6zbrsep1Sz3Cvk7NXRpDg/insert_dimension_range'
+const reportTime = '08:00:00'
+
 //########################################### 出入金数据统计 ########################################
 
 const http_request_get = async (data) => {
@@ -69,6 +76,24 @@ async function computeAddressPrice(total_in_coins) {
     }
 }
 
+function getBscEnv() {
+    var bsc_env
+    switch (process.env.NODE_ENV) {
+        case 'dev':
+        case 'test':
+            // bsc_env = 'bsc_testnet'
+            bsc_env = 'bsc_mainnet'
+            break
+        case 'prd':
+            bsc_env = 'bsc_mainnet'
+            break
+        default:
+            bsc_env = 'bsc_mainnet'
+            break
+    }
+    return bsc_env;
+}
+
 
 
 async function filterCollectCoinsLists(collect_ret, filterTypt) {
@@ -77,7 +102,7 @@ async function filterCollectCoinsLists(collect_ret, filterTypt) {
     for (let index = 0; index < collect_ret.results.length; index++) {
         const element = collect_ret.results[index];
         if (element.chain == null || element.chain == filterTypt) {
-            var before_gas_fee = element.before_gas_fee ? BigInt(element.before_gas_fee) : BigInt('0')
+            var before_gas_fee = element.before_gas_fee ? BigInt(element.before_gas_fee) : element.chain == 'czz' ? BigInt(21000 * 2000000000) : BigInt(21000 * 5000000000)
             total_gas_fee = BigInt(element.total_gas_fee) + BigInt(before_gas_fee) + BigInt(total_gas_fee)
             if (element.transfers) {
                 var opts = JSON.parse(element.transfers)
@@ -106,19 +131,7 @@ async function filterCollectCoinsLists(collect_ret, filterTypt) {
     //计算总的价格
     await computeAddressPrice(total_in_coins)
 
-    var bsc_env
-    switch (process.env.NODE_ENV) {
-        case 'dev':
-        case 'test':
-            bsc_env = 'bsc_testnet'
-            break
-        case 'prd':
-            bsc_env = 'bsc_mainnet'
-            break
-        default:
-            bsc_env = 'bsc_mainnet'
-            break
-    }
+    var bsc_env = getBscEnv()
 
     //获取 total gas
     try {
@@ -148,6 +161,16 @@ async function filterCollectCoinsLists(collect_ret, filterTypt) {
     } catch (error) {
         logger.error('total_gas_fee', error)
     }
+
+
+    if (!total_in_coins.get('0x0000000000000000000000000000000000000000')) {
+        total_in_coins.set('0x0000000000000000000000000000000000000000', {
+            amount: 0,
+            usdPrice: 0,
+            chain: filterTypt,
+            totalUsdPrice: 0
+        })
+    }
     return {
         map: total_in_coins,
         totalGasFee: total_gas_fee //总入金所消耗的 gas fee
@@ -176,7 +199,7 @@ async function getSLGas() {
                     bgf = pre_gas_obj.amount
                 }
 
-                logger.info('getSLGas item', bgf, pre_gas_obj, element)
+                // logger.info('getSLGas item', bgf, pre_gas_obj, element)
                 if (maps.get(pre_gas_obj.chain)) {
                     maps.get(pre_gas_obj.chain).sl_gas_fee = BigInt(maps.get(pre_gas_obj.chain).sl_gas_fee) + (BigInt(pre_gas_obj.amount) - BigInt(bgf))
                 } else {
@@ -190,19 +213,7 @@ async function getSLGas() {
         }
     }
 
-    var bsc_env
-    switch (process.env.NODE_ENV) {
-        case 'dev':
-        case 'test':
-            bsc_env = 'bsc_testnet'
-            break
-        case 'prd':
-            bsc_env = 'bsc_mainnet'
-            break
-        default:
-            bsc_env = 'bsc_mainnet'
-            break
-    }
+    var bsc_env = getBscEnv()
 
     logger.info('getSLGas', maps)
 
@@ -233,7 +244,8 @@ async function getSLGas() {
 
     return {
         bsc: bsc_sl,
-        czz: czz_sl
+        czz: czz_sl,
+        total: bsc_sl + czz_sl
     }
 }
 
@@ -241,19 +253,7 @@ async function getCollectCoinsOutInfo(startTime, endTime) {
     var collect_ret = await collect_coins_db.query_collect_total_fee(startTime, endTime);
     logger.info('getCollectCoinsOutInfo query_collect_total_fee', startTime, endTime)
 
-    var bsc_env
-    switch (process.env.NODE_ENV) {
-        case 'dev':
-        case 'test':
-            bsc_env = 'bsc_testnet'
-            break
-        case 'prd':
-            bsc_env = 'bsc_mainnet'
-            break
-        default:
-            bsc_env = 'bsc_mainnet'
-            break
-    }
+    var bsc_env = getBscEnv()
 
     var bsc_envnet = await filterCollectCoinsLists(collect_ret, bsc_env)
     logger.info('getCollectCoinsOutInfo bsc_env', bsc_env, bsc_envnet)
@@ -336,25 +336,13 @@ async function getWithdrawOutInfo(startTime, endTime) {
         }
     }
 
-    var bsc_env
-    switch (process.env.NODE_ENV) {
-        case 'dev':
-        case 'test':
-            bsc_env = 'bsc_testnet'
-            break
-        case 'prd':
-            bsc_env = 'bsc_mainnet'
-            break
-        default:
-            bsc_env = 'bsc_mainnet'
-            break
-    }
+    var bsc_env = getBscEnv()
 
     //计算总消耗的 gas
     var keys = withdraw_gas_map.keys();
     var total_gas_fee = 0
     for (key of keys) {
-        console.log(key, withdraw_gas_map.get(key));  // map.get(key)可得value值。
+        // console.log(key, withdraw_gas_map.get(key));  // map.get(key)可得value值。
         var value = withdraw_gas_map.get(key).total_gas_fee
         //获取币价
         try {
@@ -385,7 +373,7 @@ async function getWithdrawOutInfo(startTime, endTime) {
             try {
                 var outs = await filterWithdrawTotalOutFee(key, withdraw_ret)
                 withdraw_gas_map.get(key).total_withdraw = outs
-                logger.error('withdraw_gas_map.get(key).total_withdraw outs', outs)
+                // logger.error('withdraw_gas_map.get(key).total_withdraw outs', outs)
                 if (outs) {
                     for (ckey of outs.keys()) {
                         var item = outs.get(ckey);
@@ -407,19 +395,7 @@ async function getWithdrawOutInfo(startTime, endTime) {
 async function updateBalance(obj, type) {
     var price
     if (type == 'bsc') {
-        var bsc_env
-        switch (process.env.NODE_ENV) {
-            case 'dev':
-            case 'test':
-                bsc_env = 'bsc_testnet'
-                break
-            case 'prd':
-                bsc_env = 'bsc_mainnet'
-                break
-            default:
-                bsc_env = 'bsc_mainnet'
-                break
-        }
+        var bsc_env = getBscEnv()
         price = await moralis.getAllTotkenPrice({ chain: bsc_env })
     } else if (type == 'czz') {
         price = await moralis.getAllTotkenPrice({ chain: 'czz' })
@@ -430,6 +406,9 @@ async function updateBalance(obj, type) {
     }
     var priceItem = moralis.findTokenPriceItem('0x0000000000000000000000000000000000000000', price, price)
 
+    if (!obj.native.balance) {
+        obj.native.balance = '0'
+    }
     if (obj.native) {
         obj.native.usdPrice = parseFloat(obj.native.balance) / parseFloat(10 ** 18) * priceItem.usdPrice
         logger.info('findTokenPriceItem 0x0000000000000000000000000000000000000000 ', obj, priceItem, type)
@@ -442,6 +421,8 @@ async function updateBalance(obj, type) {
             priceItem = moralis.findTokenPriceItem(element.token_address, price)
             logger.info('findTokenPriceItem element ', priceItem, element.token_address)
             if (priceItem) {
+                if (!element.decimals || element.decimals == 0)
+                    element.decimals = 18
                 element.usdPrice = parseFloat(element.balance) / parseFloat(10 ** element.decimals) * priceItem.usdPrice
                 tokenTotal += element.usdPrice
             }
@@ -450,37 +431,34 @@ async function updateBalance(obj, type) {
     return {
         nativeTotal: obj.native.usdPrice,
         tokenTotal: tokenTotal,
+        total: parseFloat(obj.native.usdPrice) + parseFloat(tokenTotal)
     }
 }
 
 async function getAllBalance() {
-    var bsc_env
-    switch (process.env.NODE_ENV) {
-        case 'dev':
-        case 'test':
-            bsc_env = 'bsc_testnet'
-            break
-        case 'prd':
-            bsc_env = 'bsc_mainnet'
-            break
-        default:
-            bsc_env = 'bsc_mainnet'
-            break
-    }
+    var bsc_env = getBscEnv()
     var company = await moralis.queryCompanyInfoFromId(0)
+    logger.info('getAllBalance company', company)
     var bsc_balance = await moralis.getAccountAllCoins({
         chain: bsc_env,
         address: company.user_address
     })
+    logger.info('getAccountAllCoins bsc_balance', bsc_balance)
     var bscb = await updateBalance(bsc_balance, 'bsc')
+    logger.info('getAccountAllCoins updateBalance bscb', bscb)
     var czz_balance = await moralis.getAccountAllCoins({
         chain: 'czz',
         address: company.user_address
     })
+    logger.info('getAccountAllCoins czz_balance', czz_balance)
     var czzb = await updateBalance(czz_balance, 'czz')
+
+    logger.info('getAccountAllCoins updateBalance czzb', czzb)
+
     return {
         bsc: bscb,
-        czz: czzb
+        czz: czzb,
+        totalBalance: bscb.total + czzb.total
     }
 }
 
@@ -517,26 +495,30 @@ async function getStatisticsInfo() {
 
     //获取散落 gas 
     var totalSLGas = await getSLGas()
+    logger.info('getSLGas ret', totalSLGas)
 
     return {
+        updateTime: utils.getLastDay('YYYY-MM-DD'),
+        todayTotalProfit: parseFloat(data.data.incomeUSDTotal) - parseFloat(collectCoinsOut.totalGasFee + withdrawOut.totalGasFee),
         todayTotalOutGasFee: collectCoinsOut.totalGasFee + withdrawOut.totalGasFee,             //今日总支出的 gas fee
-        todayCanNotWithdrawUSD: data.data.canNotWithdrawUSD,                                    //今日不可提现余额
-        todayCanWithdrawUSD: data.data.canWithdrawUSD,                                          //今日可提现余额
-        todayIncomeUSDTotal: data.data.incomeUSDTotal,                                          //今日总收入
-        todayIncomeUSDFee: data.data.incomeUSDFee,                                              //今日固定收入
+        canNotWithdrawUSD: parseFloat(data.data.canNotWithdrawUSD),                                    //不可提现余额
+        canWithdrawUSD: parseFloat(data.data.canWithdrawUSD),                                          //可提现余额
+        todayIncomeUSDTotal: parseFloat(data.data.incomeUSDTotal),                                          //今日总收入
+        todayIncomeUSDFee: parseFloat(data.data.incomeUSDFee),                                              //今日固定收入
         totalOutGasFee: totalCollectCoinsOut.totalGasFee + totalWithdrawOut.totalGasFee,        //总支出 gas fee
         totalWithdrawGasFee: totalWithdrawOut.totalGasFee,                                      //总提币 gas fee
         totalCollectCoinsGasFee: totalCollectCoinsOut.totalGasFee,                              //总归集 gas fee
-        totalInFee: totalCollectCoinsOut.totalInFee,
+        totalInFee: totalCollectCoinsOut.totalInFee,                                            //总入金
         totalNativeInFee: {
             bsc: totalCollectCoinsOut.bsc.get('0x0000000000000000000000000000000000000000').totalUsdPrice,
             czz: totalCollectCoinsOut.czz.get('0x0000000000000000000000000000000000000000').totalUsdPrice
         },                                                                                      //总 native 入金
         totalOutFee: totalWithdrawOut.totalWithdraw,                                            //总出金
-        totalBalances: curBalances,                                                             //总余额
+        totalBalances: curBalances.totalBalance,                                                             //总余额
         ylGasBalance: {                                                                         //预留 gas 费余额  native 总余额 - 总入金
             bsc: curBalances.bsc.nativeTotal - totalCollectCoinsOut.bsc.get('0x0000000000000000000000000000000000000000').totalUsdPrice,
-            czz: curBalances.czz.nativeTotal - totalCollectCoinsOut.czz.get('0x0000000000000000000000000000000000000000').totalUsdPrice
+            czz: curBalances.czz.nativeTotal - totalCollectCoinsOut.czz.get('0x0000000000000000000000000000000000000000').totalUsdPrice,
+            total: (curBalances.bsc.nativeTotal - totalCollectCoinsOut.bsc.get('0x0000000000000000000000000000000000000000').totalUsdPrice) + (curBalances.czz.nativeTotal - totalCollectCoinsOut.czz.get('0x0000000000000000000000000000000000000000').totalUsdPrice)
         },
         slGasBalance: totalSLGas,                                                            //散落 gas 费余额  充值 0.5 gas - 使用 0.3 gas= 散落 0.2gas
     }
@@ -565,18 +547,153 @@ function timeoutFunc(config, func) {
     }, recent - nowTime)
 }
 
+
+
+
+
+const getFeishuToken = async (params) => {
+    return new Promise(resolve => {
+        axios.post(feishu_write_table_token_url,
+            {
+                app_id: "cli_a223f015abbad00e",
+                app_secret: "DMCF6tBwIpeOQPnWrFUMYd6tmjb53C4n"
+            },
+            {
+                timeout: 1 * 60 * 1000,
+                headers: {
+                    'Content-Type': "application/json; charset=utf-8"
+                }
+            })
+            .then(res => {
+                logger.log('getFeishuToken res=>', res.status, res.data);
+                resolve(res.data)
+            }).catch(err => {
+                logger.error('getFeishuToken error ', JSON.stringify(err));
+                resolve(JSON.stringify(err))
+            });
+    })
+}
+
+
+function writeTable(app_token, data) {
+    logger.info('writeTable', data)
+    var body = {
+        'valueRanges': [
+            {
+                'range': '0pRQpu!A2:C2',
+                'values': [
+                    [data.totalCollectCoinsGasFee, //归集总 gas
+                    data.totalWithdrawGasFee, //提币总 gas
+                    data.totalOutGasFee], //总支出 gas
+                ]
+            },
+            {
+                'range': '1ygrMB!A2:B2',
+                'values': [
+                    [
+                        data.totalInFee, //总入金
+                        data.totalOutFee,//总出金
+                    ],
+                ]
+            },
+            {
+                'range': 'BMjMDr!A3:J3',
+                'values': [
+                    [
+                        data.updateTime,      //更新时间
+                        data.todayTotalProfit,//今日总利润
+                        data.todayIncomeUSDTotal,//今日总收入
+                        data.todayIncomeUSDFee,//今日固定手续费收入
+                        data.todayTotalOutGasFee,//今日总 gas 支出
+                        data.totalBalances, //总余额
+                        data.canNotWithdrawUSD, //不可提现余额
+                        data.canWithdrawUSD,//可提现余额
+                        data.ylGasBalance.total,//预留 gas
+                        data.slGasBalance.total,//散落 gas
+                    ],
+                ]
+            }
+        ]
+    }
+    return new Promise(resolve => {
+        axios.post(feishu_write_table_data_url,
+            body,
+            {
+                timeout: 1 * 60 * 1000,
+                headers: {
+                    'Content-Type': "application/json; charset=utf-8",
+                    'Authorization': 'Bearer ' + app_token
+                }
+            })
+            .then(res => {
+                logger.log('writeTable res=>', res.status, res.data);
+                resolve(res.data)
+            }).catch(err => {
+                logger.error('writeTable error ', JSON.stringify(err));
+                resolve(JSON.stringify(err))
+            });
+    })
+}
+
+async function insertTableRows(app_token) {
+    var body = {
+        dimension: {
+            sheetId: 'BMjMDr',
+            majorDimension: 'ROWS',
+            startIndex: 2,
+            endIndex: 3,
+        },
+        inheritStyle: 'AFTER'
+    }
+    return new Promise(resolve => {
+        axios.post(feishu_insert_table_url,
+            JSON.stringify(body),
+            {
+                timeout: 1 * 60 * 1000,
+                headers: {
+                    'Content-Type': "application/json; charset=utf-8",
+                    'Authorization': 'Bearer ' + app_token
+                }
+            })
+            .then(res => {
+                console.log('res=>', res.status, res.data);
+                resolve(res.data)
+            }).catch(err => {
+                logger.error('error ', JSON.stringify(err));
+                resolve(JSON.stringify(err))
+            });
+    })
+}
+
+async function exec(data) {
+    var app = await getFeishuToken()
+    await insertTableRows(app.app_access_token)
+    await writeTable(app.app_access_token, data)
+}
+
+async function report2FeishuTable() {
+    try {
+        logger.info('report2FeishuTable')
+        var data = await getStatisticsInfo();
+        logger.info('getStatisticsInfo', data)
+        await exec(data)
+    } catch (error) {
+        logger.error('report2FeishuTable', error.toString())
+    }
+
+}
+
 timeoutFunc({
 
     interval: 1, //间隔天数,间隔为整数
 
     runNow: false, //是否立即运行
 
-    time: "08:00:00" //执行的时间点 时在0~23之间
+    time: reportTime //执行的时间点 时在0~23之间
 
 }, func => {
-    getStatisticsInfo()
+    report2FeishuTable()
 })
-
 module.exports = {
     getStatisticsInfo
 }

+ 4 - 4
routes/sdk.js

@@ -829,10 +829,10 @@ check_czz_withdraw_task();
 bsc_log_monitoring()
 
 if (process.env.NODE_ENV == 'dev' || process.env.NODE_ENV == 'test') {
-    timer_transfer_bsc_task()
-    timer_transfer_czz_task()
-    timer_collect_conis_bsc_task()
-    timer_collect_conis_czz_task()
+    // timer_transfer_bsc_task()
+    // timer_transfer_czz_task()
+    // timer_collect_conis_bsc_task()
+    // timer_collect_conis_czz_task()
 }
 
 module.exports = router

+ 1 - 1
test/db_test.js

@@ -161,7 +161,7 @@ async function getInfo3() {
     console.error("getStatisticsInfo", await statistics.getStatisticsInfo())
 
 }
-getInfo3()
+// getInfo3()
 // getInfo2()
 // query()
 module.exports = router

+ 100 - 5
test/sample.js

@@ -1,9 +1,9 @@
 var CryptoJS = require("crypto-js");
-
+const axios = require('axios');
 
 function decryptPrivityKey(message) {
-    var encrypted = message; 
-    var key = process.env.DENET_CRYPT_KEY 
+    var encrypted = message;
+    var key = process.env.DENET_CRYPT_KEY
     var iv = process.env.DENET_CRYPT_IV
     if (!key || !iv) {
         console.error('decryptPrivityKey key or iv is empty?');
@@ -14,8 +14,8 @@ function decryptPrivityKey(message) {
     iv = CryptoJS.enc.Utf8.parse(iv)
     var decrypted = CryptoJS.AES.decrypt(encrypted
         , key
-        , { iv: iv, mode: CryptoJS.mode.CBC}
-        );
+        , { iv: iv, mode: CryptoJS.mode.CBC }
+    );
     console.log('decrypted decrypt ==', decrypted);
     var de_pk = decrypted.toString(CryptoJS.enc.Utf8);
     console.log('decrypted==', de_pk);
@@ -25,6 +25,101 @@ function decryptPrivityKey(message) {
 // decryptPrivityKey('bnUvrSKmU3l7zONP+hIH1BOMhNVfIBUgEziWb2tGiUgn63FZVdzXC9E1DT+Mx3B+nqrzUAqd60I/8rLobYYl+0TSR3Ri1o0iX/hcxqs/0yg=')
 
 
+const getFeishuToken = async (params) => {
+    return new Promise(resolve => {
+        axios.post('https://open.feishu.cn/open-apis/auth/v3/app_access_token/internal',
+            {
+                app_id: "cli_a223f015abbad00e",
+                app_secret: "DMCF6tBwIpeOQPnWrFUMYd6tmjb53C4n"
+            },
+            {
+                timeout: 1 * 60 * 1000,
+                headers: {
+                    'Content-Type': "application/json; charset=utf-8"
+                }
+            })
+            .then(res => {
+                console.log('res=>', res.status, res.data);
+                resolve(res.data)
+            }).catch(err => {
+                logger.error('http_request_post withdraw_czz error ', JSON.stringify(err));
+                resolve(JSON.stringify(err))
+            });
+    })
+}
+
+
+function writeTable(app_token) {
+    var body = {
+        'valueRanges': [
+            {
+                'range': '072d4e!A1:B1',
+                'values': [
+                    ['2022/06/15 11:43:23', 1],
+                ]
+            }
+        ]
+    }
+    return new Promise(resolve => {
+        axios.post('https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/shtcnsS7N9KS6pVUvR9qvj8mYpb/values_batch_update',
+            body,
+            {
+                timeout: 1 * 60 * 1000,
+                headers: {
+                    'Content-Type': "application/json; charset=utf-8",
+                    'Authorization': 'Bearer ' + app_token
+                }
+            })
+            .then(res => {
+                console.log('res=>', res.status, res.data);
+                resolve(res.data)
+            }).catch(err => {
+                console.error('error ', JSON.stringify(err));
+                resolve(JSON.stringify(err))
+            });
+    })
+}
+
+async function insertTableRows(app_token) {
+    var body = {
+        dimension: {
+            sheetId: '072d4e',
+            majorDimension: 'ROWS',
+            startIndex: 0,
+            endIndex: 1,
+        },
+        inheritStyle: 'AFTER'
+    }
+    return new Promise(resolve => {
+        axios.post('https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/shtcnsS7N9KS6pVUvR9qvj8mYpb/insert_dimension_range',
+            JSON.stringify(body),
+            {
+                timeout: 1 * 60 * 1000,
+                headers: {
+                    'Content-Type': "application/json; charset=utf-8",
+                    'Authorization': 'Bearer ' + app_token
+                }
+            })
+            .then(res => {
+                console.log('res=>', res.status, res.data);
+                resolve(res.data)
+            }).catch(err => {
+                console.error('error ', JSON.stringify(err));
+                resolve(JSON.stringify(err))
+            });
+    })
+}
+
+async function exec() {
+    var app = await getFeishuToken()
+    await insertTableRows(app.app_access_token)
+    await writeTable(app.app_access_token)
+}
+
+
+exec()
+
+