Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
ts-api-demo
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wmvm
ts-api-demo
Commits
4974661c
Commit
4974661c
authored
Dec 31, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资产管理后台-对账预警相关定时任务
parent
ecacde12
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
4 deletions
+94
-4
task.abk.asset.check.warning.service.ts
cron/service/task.abk.asset.check.warning.service.ts
+21
-3
task.abk.asset.check.warning.ts
cron/task/task.abk.asset.check.warning.ts
+21
-1
assetCheck.service.ts
src/functional/mvc/service/v2/assetCheck.service.ts
+52
-0
No files found.
cron/service/task.abk.asset.check.warning.service.ts
View file @
4974661c
...
...
@@ -2,6 +2,7 @@ import BigNumber from "bignumber.js";
let
{
authCommon
:
AuthCommon
,
redisUtilsCommon
:
RedisClient
,
financeAccountDataUtils
,
finAccDwDataUtils
,
tickerUtils
}
=
require
(
'@madex/ex-js-common'
);
import
{
ROBOT_KEYS
,
sendRobotMessage
}
from
"../../src/utils/robotUtils"
;
import
{
siteAssetsNoPage
}
from
"../../src/functional/mvc/service/v2/assetCheck.service"
;
let
{
logger
,
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
...
...
@@ -33,7 +34,7 @@ export const balanceAndFundingInOutCheck = async function (start_time: number, e
let
platform_name
=
warningValueMap
[
account_id
]
?
getPlatformName
(
warningValueMap
[
account_id
].
platform
)
:
"未知平台"
;
if
(
Number
(
balance_usdt
)
<=
Number
(
warning_value
))
{
let
msg
=
`\n做市资金余额低于预设值\n时间:
${
new
Date
().
toLocaleString
()}
\n账户ID:
${
account_id
}
\n账户名:
${
account_name
}
\n平台:
${
platform_name
}
\n当前余额:
${
Number
(
balance_usdt
)}
\n预设值:
${
Number
(
warning_value
)}
`
;
sendRobotMessage
(
ROBOT_KEYS
.
ABK_KEY
,
msg
);
await
sendRobotMessage
(
ROBOT_KEYS
.
ABK_KEY
,
msg
);
}
balanceMap
[
account_id
]
=
balance_usdt
;
}
...
...
@@ -46,8 +47,8 @@ export const balanceAndFundingInOutCheck = async function (start_time: number, e
let
change_usdt
=
new
BigNumber
(
change
).
mul
(
new
BigNumber
(
usdt_rate
));
let
account_name
=
warningValueMap
[
account_id
]
?
warningValueMap
[
account_id
].
account
:
"未知账户名"
;
let
platform_name
=
warningValueMap
[
account_id
]
?
getPlatformName
(
warningValueMap
[
account_id
].
platform
)
:
"未知平台"
;
let
msg
=
`\n资产变动\n时间:
${
new
Date
(
time
).
toLocaleString
()}
\n
${
bill_type
==
1
?
"转入做市账户"
:
"从做市账户转出"
}
\n账户ID:
${
account_id
}
\n账户名:
${
account_name
}
\n平台:
${
platform_name
}
\n币种:
${
symbol
}
\n数量:
${
Number
(
change
)}
\n估值(U):
${
Number
(
change_usdt
)}
\n当前账户余额(U):
${
Number
(
balanceMap
[
account_id
])}
`
;
sendRobotMessage
(
ROBOT_KEYS
.
ABK_KEY
,
msg
);
let
msg
=
`\n资产变动\n时间:
${
new
Date
(
Number
(
time
)
).
toLocaleString
()}
\n
${
bill_type
==
1
?
"转入做市账户"
:
"从做市账户转出"
}
\n账户ID:
${
account_id
}
\n账户名:
${
account_name
}
\n平台:
${
platform_name
}
\n币种:
${
symbol
}
\n数量:
${
Number
(
change
)}
\n估值(U):
${
Number
(
change_usdt
)}
\n当前账户余额(U):
${
Number
(
balanceMap
[
account_id
])}
`
;
await
sendRobotMessage
(
ROBOT_KEYS
.
ABK_KEY
,
msg
);
}
...
...
@@ -71,3 +72,20 @@ function getPlatformName(platform: any) {
}
return
name
;
}
/**
* 站内资产和钱包资产对账
*/
export
const
walletAssetAndSiteAssetCheck
=
async
function
()
{
let
dbDataList
=
await
siteAssetsNoPage
();
for
(
let
item
of
dbDataList
)
{
let
{
asset_id
,
symbol
,
chain_type
,
site_assets
,
total_wallet_assets
}
=
item
;
let
site_assets_number
=
new
BigNumber
(
site_assets
).
toNumber
().
toFixed
(
4
);
let
total_wallet_assets_number
=
new
BigNumber
(
total_wallet_assets
).
toNumber
().
toFixed
(
4
);
//账不平 发送lark
if
(
site_assets_number
!=
total_wallet_assets_number
)
{
let
msg
=
`\n站内钱包对账错误\n时间:
${
new
Date
().
toLocaleString
()}
\n链名:
${
chain_type
}
\n币名:
${
symbol
}
\n站内数量:
${
site_assets_number
}
\n钱包数量:
${
total_wallet_assets_number
}
\n差值:
${
Number
(
site_assets_number
)
-
Number
(
total_wallet_assets_number
)}
`
await
sendRobotMessage
(
ROBOT_KEYS
.
ABK_KEY
,
msg
);
}
}
}
\ No newline at end of file
cron/task/task.abk.asset.check.warning.ts
View file @
4974661c
...
...
@@ -8,6 +8,7 @@ let { logger, datetimeUtils } = require('@madex/ex-js-public');
import
*
as
service
from
"../service/task.abk.asset.check.warning.service"
;
let
running1
=
false
;
let
running2
=
false
;
/**
* 程序自动对账
...
...
@@ -30,4 +31,23 @@ let autoCheckJob = schedule.scheduleJob('0 */10 * * * *', async function () {
running1
=
false
;
}
});
autoCheckJob
.
invoke
();
\ No newline at end of file
/**
* 钱包自动对账
* 每10分钟跑一次
*/
let
walletAssetCheckJob
=
schedule
.
scheduleJob
(
'0 */10 * * * *'
,
async
function
()
{
logger
.
info
(
'walletAssetCheckJob start'
);
if
(
!
running2
)
{
try
{
running2
=
true
;
await
service
.
walletAssetAndSiteAssetCheck
();
logger
.
info
(
"walletAssetCheckJob job finish"
);
}
catch
(
e
)
{
logger
.
info
(
e
)
}
running2
=
false
;
}
});
src/functional/mvc/service/v2/assetCheck.service.ts
View file @
4974661c
...
...
@@ -472,6 +472,58 @@ export async function autoCheckList() {
}
export
async
function
siteAssetsNoPage
()
{
let
dbDataList
=
await
coinType
.
prototype
.
findAll
({
attributes
:
[
ormDB
.
literal
(
'DISTINCT(asset_id) as asset_id'
)],
where
:
{
main_status
:
2
//已经提交到撮合
},
order
:
[[
'asset_id'
,
'asc'
]],
raw
:
true
});
if
(
!
dbDataList
.
length
)
{
return
[];
}
let
asset_ids
=
dbDataList
.
map
(
item
=>
item
.
asset_id
);
let
dbCoinList
=
await
coinType
.
prototype
.
findAll
({
attributes
:
[
'id'
,
'asset_id'
,
'symbol'
,
'chain_type'
],
where
:
{
asset_id
:
asset_ids
},
order
:
[[
'asset_id'
,
'asc'
],
[
'id'
,
'asc'
]],
raw
:
true
});
let
coinMap
:
any
=
{};
for
(
let
item
of
dbCoinList
)
{
//同名币 asset_id 一样 id 不一样
if
(
!
coinMap
[
item
.
asset_id
])
{
coinMap
[
item
.
asset_id
]
=
item
}
}
let
[
mainAssetsMap
,
tradeAssetsMap
,
{
hotWalletMap
,
coldWalletMap
,
totalWalletMap
}]
=
await
Promise
.
all
([
getSiteMainAssetsGroupBy
(
asset_ids
,
'asset_id'
),
getSiteTradeAssetsGroupBy
(
asset_ids
,
'asset_id'
),
getSiteWalletAssetsGroupBy
(
asset_ids
,
'asset_id'
)]);
for
(
let
item
of
dbDataList
)
{
let
assetId
=
item
.
asset_id
;
item
.
symbol
=
coinMap
[
assetId
]
?
coinMap
[
assetId
].
symbol
:
""
;
item
.
chain_type
=
coinMap
[
assetId
]
?
coinMap
[
assetId
].
chain_type
:
""
;
item
.
site_assets
=
(
mainAssetsMap
[
assetId
]
?
mainAssetsMap
[
assetId
]
:
new
BigNumber
(
0
)).
add
(
tradeAssetsMap
[
assetId
]
?
tradeAssetsMap
[
assetId
]
:
new
BigNumber
(
0
)
);
item
.
total_wallet_assets
=
totalWalletMap
[
assetId
]
?
totalWalletMap
[
assetId
]
:
new
BigNumber
(
0
);
item
.
hot_wallet_assets
=
hotWalletMap
[
assetId
]
?
hotWalletMap
[
assetId
]
:
new
BigNumber
(
0
);
item
.
cold_wallet_assets
=
coldWalletMap
[
assetId
]
?
coldWalletMap
[
assetId
]
:
new
BigNumber
(
0
);
}
return
dbDataList
;
}
async
function
getCoinTypeMapByCoinOrAssetIds
(
coin_ids
:
any
[],
asset_ids
?:
any
[])
{
let
map
:
any
=
{};
let
where
:
any
=
{};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment