|
@@ -562,7 +562,27 @@ async function getStatisticsInfoV2(day) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+const request = async (url, app_token, data) => {
|
|
|
+ logger.info('request', url, app_token, data)
|
|
|
+ return new Promise(resolve => {
|
|
|
+ axios.post(url,
|
|
|
+ JSON.stringify(data),
|
|
|
+ {
|
|
|
+ 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))
|
|
|
+ });
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
@@ -797,11 +817,24 @@ async function addTableRows(app_token, sheetId, endIndex) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-async function exec(data) {
|
|
|
- var app = await getFeishuToken()
|
|
|
+async function exec(data, app) {
|
|
|
+
|
|
|
|
|
|
await insertTableRows(app.app_access_token, 'BMjMDr', 2, 3)
|
|
|
return await writeTable(app.app_access_token, data)
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+async function notify(app,chain_id) {
|
|
|
+ var content = "{\"zh_cn\":{\"title\":\"出入金数据更新成功\",\"content\":[[{\"tag\":\"text\",\"text\":\"更新时间:\"},{\"tag\":\"text\",\"text\":\"" + utils.getCurrentDate() + "\"}],[{\"tag\":\"text\",\"text\":\"https://st94nif1cq.feishu.cn/sheets/shtcnp6zbrsep1Sz3Cvk7NXRpDg?sheet=BMjMDr:\"}]]}}"
|
|
|
+ var data = {
|
|
|
+ "receive_id": chain_id,
|
|
|
+ "content": content,
|
|
|
+ "msg_type": "post"
|
|
|
+ }
|
|
|
+ await request('https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id', app.app_access_token, data)
|
|
|
}
|
|
|
|
|
|
async function report2FeishuTable(day) {
|
|
@@ -811,7 +844,9 @@ async function report2FeishuTable(day) {
|
|
|
var data = await getStatisticsInfoV2(day);
|
|
|
// data = ''
|
|
|
logger.info('getStatisticsInfo', data)
|
|
|
- var ret = await exec(data)
|
|
|
+ var app = await getFeishuToken()
|
|
|
+ var ret = await exec(data, app)
|
|
|
+ notify(app,'oc_9770d283cd81df887e96795ddfcd9dcd')
|
|
|
logger.error('数据统计完成:', 'https://st94nif1cq.feishu.cn/sheets/shtcnp6zbrsep1Sz3Cvk7NXRpDg?sheet=BMjMDr')
|
|
|
mTokenPriceCache.clear()
|
|
|
} catch (error) {
|
|
@@ -819,6 +854,10 @@ async function report2FeishuTable(day) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+async function testNotify() {
|
|
|
+ var app = await getFeishuToken()
|
|
|
+ notify(app,'oc_b159b9a53dd52206c5cf75677d0cf0ca')
|
|
|
+}
|
|
|
|
|
|
async function test() {
|
|
|
// var ret = await getStatisticsInfoV2(2)
|
|
@@ -830,6 +869,7 @@ async function test() {
|
|
|
}
|
|
|
// test()
|
|
|
// exec()
|
|
|
+// testNotify()
|
|
|
module.exports = {
|
|
|
getStatisticsInfoV2
|
|
|
}
|