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
ecacde12
Commit
ecacde12
authored
Dec 31, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资产管理后台-修改
parent
c6ad8c8d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
129 additions
and
9 deletions
+129
-9
task.abk.asset.check.warning.service.ts
cron/service/task.abk.asset.check.warning.service.ts
+73
-0
task.abk.asset.check.warning.ts
cron/task/task.abk.asset.check.warning.ts
+33
-0
fianceAccount.service.ts
src/functional/mvc/service/fianceAccount.service.ts
+8
-2
abkFeeStatistics.service.ts
src/functional/mvc/service/v2/abkFeeStatistics.service.ts
+4
-4
robotUtils.ts
src/utils/robotUtils.ts
+11
-3
No files found.
cron/service/task.abk.asset.check.warning.service.ts
0 → 100644
View file @
ecacde12
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"
;
let
{
logger
,
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
/**
* 余额和
* 资金转入转出检查并告警
*/
export
const
balanceAndFundingInOutCheck
=
async
function
(
start_time
:
number
,
end_time
:
number
)
{
//账户
let
accountList
=
await
financeAccountDataUtils
.
getAccountInfoList
();
if
(
!
accountList
.
length
)
{
return
;
}
//转入转出数据
let
inOutDataList
=
await
finAccDwDataUtils
.
getDepositAndWithdrawDataByAccounts
(
accountList
,
start_time
,
end_time
);
//余额、初始资金数据
let
balanceDataList
=
await
financeAccountDataUtils
.
getFundingDataByAccounts
(
accountList
);
let
warningValueMap
:
any
=
{};
for
(
let
account
of
accountList
)
{
warningValueMap
[
account
.
id
]
=
account
;
}
let
balanceMap
:
any
=
{};
for
(
let
oneData
of
balanceDataList
)
{
let
{
category_id
,
account_id
,
balance_usdt
}
=
oneData
;
let
warning_value
=
warningValueMap
[
account_id
]
?
warningValueMap
[
account_id
].
balance_warning
:
0
;
let
account_name
=
warningValueMap
[
account_id
]
?
warningValueMap
[
account_id
].
account
:
"未知账户名"
;
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
);
}
balanceMap
[
account_id
]
=
balance_usdt
;
}
let
tickerMap
=
{};
for
(
let
oneData
of
inOutDataList
)
{
let
{
account_id
,
symbol
,
change
,
bill_type
,
time
}
=
oneData
;
let
usdt_rate
=
tickerMap
[
symbol
]
?
tickerMap
[
symbol
]
:
await
tickerUtils
.
rateCoin2USDT
(
symbol
);
tickerMap
[
symbol
]
=
usdt_rate
;
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
);
}
}
function
getPlatformName
(
platform
:
any
)
{
let
name
=
""
switch
(
platform
)
{
case
1
:
name
=
"KTX"
;
break
;
case
2
:
name
=
"Binance"
;
break
;
case
3
:
name
=
"OKEX"
;
break
;
default
:
name
=
"未知平台"
;
break
;
}
return
name
;
}
cron/task/task.abk.asset.check.warning.ts
0 → 100644
View file @
ecacde12
'use strict'
;
/**
* 资产管理后台-钱包对账、程序自动对账告警
*/
const
schedule
=
require
(
'node-schedule'
);
let
{
logger
,
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
import
*
as
service
from
"../service/task.abk.asset.check.warning.service"
;
let
running1
=
false
;
/**
* 程序自动对账
* 每10分钟跑一次
*/
let
autoCheckJob
=
schedule
.
scheduleJob
(
'0 */10 * * * *'
,
async
function
()
{
logger
.
info
(
'autoCheckJob start'
);
if
(
!
running1
)
{
try
{
running1
=
true
;
let
now
=
new
Date
();
let
end_time_ts
=
now
.
getTime
();
let
start_time_ts
=
datetimeUtils
.
sub
(
now
,
datetimeUtils
.
DAY
*
10
).
getTime
();
await
service
.
balanceAndFundingInOutCheck
(
start_time_ts
,
end_time_ts
);
logger
.
info
(
"autoCheckJob job finish"
);
}
catch
(
e
)
{
logger
.
info
(
e
)
}
running1
=
false
;
}
});
autoCheckJob
.
invoke
();
\ No newline at end of file
src/functional/mvc/service/fianceAccount.service.ts
View file @
ecacde12
...
@@ -118,9 +118,12 @@ export async function add(financeAccountVO: FinanceAccountVO, currentUserId: any
...
@@ -118,9 +118,12 @@ export async function add(financeAccountVO: FinanceAccountVO, currentUserId: any
//默认可用
//默认可用
financeAccountVO
.
status
=
1
;
financeAccountVO
.
status
=
1
;
}
}
if
(
!
financeAccountVO
.
balance_warning
){
if
(
!
financeAccountVO
.
balance_warning
)
{
financeAccountVO
.
balance_warning
=
0
;
financeAccountVO
.
balance_warning
=
0
;
}
}
if
(
!
financeAccountVO
.
uid
)
{
financeAccountVO
.
uid
=
0
;
}
await
financeAccount
.
prototype
.
create
(
financeAccountVO
);
await
financeAccount
.
prototype
.
create
(
financeAccountVO
);
//管理后台操作日志
//管理后台操作日志
...
@@ -153,9 +156,12 @@ export async function update(financeAccountVO: FinanceAccountVO, currentUserId:
...
@@ -153,9 +156,12 @@ export async function update(financeAccountVO: FinanceAccountVO, currentUserId:
throw
ErrorCode
.
CATEGORY_HAVE_SAME_ACCOUNT
;
throw
ErrorCode
.
CATEGORY_HAVE_SAME_ACCOUNT
;
}
}
if
(
!
financeAccountVO
.
balance_warning
){
if
(
!
financeAccountVO
.
balance_warning
)
{
financeAccountVO
.
balance_warning
=
0
;
financeAccountVO
.
balance_warning
=
0
;
}
}
if
(
!
financeAccountVO
.
uid
)
{
financeAccountVO
.
uid
=
0
;
}
financeAccountVO
.
updatedAt
=
new
Date
();
financeAccountVO
.
updatedAt
=
new
Date
();
await
financeAccount
.
prototype
.
update
(
financeAccountVO
,
{
await
financeAccount
.
prototype
.
update
(
financeAccountVO
,
{
...
...
src/functional/mvc/service/v2/abkFeeStatistics.service.ts
View file @
ecacde12
...
@@ -61,11 +61,11 @@ export async function gatherData(from_time: any, to_time: any) {
...
@@ -61,11 +61,11 @@ export async function gatherData(from_time: any, to_time: any) {
let
lpc_data
=
buildOneResult
(
commonData
.
lpc_fee_usdt
,
commonData
.
lpc_back_usdt
,
crmData
.
lpc_fee_usdt
,
crmData
.
lpc_back_usdt
);
let
lpc_data
=
buildOneResult
(
commonData
.
lpc_fee_usdt
,
commonData
.
lpc_back_usdt
,
crmData
.
lpc_fee_usdt
,
crmData
.
lpc_back_usdt
);
let
ipc_data
=
buildOneResult
(
commonData
.
ipc_fee_usdt
,
commonData
.
ipc_back_usdt
,
crmData
.
ipc_fee_usdt
,
crmData
.
ipc_back_usdt
);
let
ipc_data
=
buildOneResult
(
commonData
.
ipc_fee_usdt
,
commonData
.
ipc_back_usdt
,
crmData
.
ipc_fee_usdt
,
crmData
.
ipc_back_usdt
);
let
all_common_fee
=
new
BigNumber
(
commonData
.
spot_fee_usdt
).
add
(
new
BigNumber
(
commonData
.
lpc_fee_usdt
)).
add
(
new
BigNumber
(
commonData
.
ipc_fee_usdt
)).
add
(
withdraw_common_user_fee
);
let
all_common_fee
=
new
BigNumber
(
commonData
.
spot_fee_usdt
||
0
).
add
(
new
BigNumber
(
commonData
.
lpc_fee_usdt
||
0
)).
add
(
new
BigNumber
(
commonData
.
ipc_fee_usdt
||
0
)).
add
(
withdraw_common_user_fee
||
0
);
let
all_common_back
=
new
BigNumber
(
commonData
.
spot_back_usdt
).
add
(
new
BigNumber
(
commonData
.
lpc_back_usdt
)).
add
(
new
BigNumber
(
commonData
.
ipc_back_usdt
));
let
all_common_back
=
new
BigNumber
(
commonData
.
spot_back_usdt
||
0
).
add
(
new
BigNumber
(
commonData
.
lpc_back_usdt
||
0
)).
add
(
new
BigNumber
(
commonData
.
ipc_back_usdt
||
0
));
let
all_crm_fee
=
new
BigNumber
(
crmData
.
spot_fee_usdt
).
add
(
new
BigNumber
(
crmData
.
lpc_fee_usdt
)).
add
(
new
BigNumber
(
crmData
.
ipc_fee_usdt
)).
add
(
withdraw_crm_user_fee
);
let
all_crm_fee
=
new
BigNumber
(
crmData
.
spot_fee_usdt
||
0
).
add
(
new
BigNumber
(
crmData
.
lpc_fee_usdt
||
0
)).
add
(
new
BigNumber
(
crmData
.
ipc_fee_usdt
||
0
)).
add
(
withdraw_crm_user_fee
||
0
);
let
all_crm_back
=
new
BigNumber
(
crmData
.
spot_back_usdt
).
add
(
new
BigNumber
(
crmData
.
ipc_back_usdt
)).
add
(
new
BigNumber
(
crmData
.
ipc_back_usdt
));
let
all_crm_back
=
new
BigNumber
(
crmData
.
spot_back_usdt
||
0
).
add
(
new
BigNumber
(
crmData
.
ipc_back_usdt
||
0
)).
add
(
new
BigNumber
(
crmData
.
ipc_back_usdt
||
0
));
let
all_data
=
buildOneResult
(
all_common_fee
,
all_common_back
,
all_crm_fee
,
all_crm_back
);
let
all_data
=
buildOneResult
(
all_common_fee
,
all_common_back
,
all_crm_fee
,
all_crm_back
);
//总手续费+提现手续费
//总手续费+提现手续费
...
...
src/utils/robotUtils.ts
View file @
ecacde12
...
@@ -3,12 +3,12 @@ let {
...
@@ -3,12 +3,12 @@ let {
logger
logger
}
=
require
(
'@madex/ex-js-public'
);
}
=
require
(
'@madex/ex-js-public'
);
let
config
=
require
(
'../../config'
)
;
import
Config
from
"../../config"
;
let
axios
=
require
(
'axios'
);
let
axios
=
require
(
'axios'
);
debug
=
config
.
env
=
==
"development"
;
debug
=
Config
.
node_env
==
"development"
;
/**
/**
* Lark 地址
* Lark 地址
...
@@ -20,16 +20,24 @@ let LARK_URL_PRE = "https://open.larksuite.com/open-apis/bot/v2/hook/";
...
@@ -20,16 +20,24 @@ let LARK_URL_PRE = "https://open.larksuite.com/open-apis/bot/v2/hook/";
*/
*/
let
COMMON_KEY
=
"d9f2dc6e-52cf-4933-92f1-dab9c249aa28"
;
let
COMMON_KEY
=
"d9f2dc6e-52cf-4933-92f1-dab9c249aa28"
;
/**
* 资产管理后台通知
*/
let
ABK_KEY
=
"d0edce37-1798-4648-bd87-45b7a5ae5c64"
;
/**
/**
* 测试:dev
* 测试:dev
*/
*/
if
(
debug
)
{
if
(
debug
)
{
COMMON_KEY
=
"d98c9942-ff6f-4e71-a77f-41647ff19ff0"
;
COMMON_KEY
=
"d98c9942-ff6f-4e71-a77f-41647ff19ff0"
;
ABK_KEY
=
"d98c9942-ff6f-4e71-a77f-41647ff19ff0"
;
}
}
export
const
ROBOT_KEYS
=
{
export
const
ROBOT_KEYS
=
{
COMMON_KEY
:
COMMON_KEY
COMMON_KEY
:
COMMON_KEY
,
ABK_KEY
:
ABK_KEY
,
}
}
/**
/**
*
*
...
...
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