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
4977e47e
Commit
4977e47e
authored
Jan 14, 2025
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资管后台-钱包流入流出详细数据
parent
3b6a2bc3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
2 deletions
+108
-2
assetCheck.control.ts
src/functional/mvc/control/v2/assetCheck.control.ts
+22
-0
assetCheck.service.ts
src/functional/mvc/service/v2/assetCheck.service.ts
+85
-2
index.ts
src/functional/router/v2/index.ts
+1
-0
No files found.
src/functional/mvc/control/v2/assetCheck.control.ts
View file @
4977e47e
...
...
@@ -179,4 +179,26 @@ export const autoCheckList = async (req: any, commonParam: CommonParam) => {
/**
* 钱包流入流出列表
* @param req
* @param commonParam
*/
export
const
walletInOutList
=
async
(
req
:
any
,
commonParam
:
CommonParam
)
=>
{
let
func_name
=
"assetCheck.control.walletInOutList"
;
try
{
setPageAndSize
(
commonParam
);
beforeQueryCheckTime
(
commonParam
);
let
res
=
await
assetCheckService
.
walletInOutList
(
commonParam
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
src/functional/mvc/service/v2/assetCheck.service.ts
View file @
4977e47e
...
...
@@ -2,12 +2,12 @@ import {
madAdminOrmDB
,
coinAddress
,
coinType
,
mainUserAsset
,
dwdSpotAssetsApi
,
ormDB
,
coinTx
,
coinWithdraw
,
walletAssets
,
financeAccountCategory
,
financeAccount
,
financeAccountDailyRecord
financeAccountDailyRecord
,
abkWalletDailySnap
}
from
"@madex/ex-ts-dao"
;
import
BigNumber
from
"bignumber.js"
;
import
{
CommonParam
}
from
"./abkCommonService"
;
let
{
logger
,
apiAssertUtils
:
ApiAssert
,
BigNumberUtils
}
=
require
(
'@madex/ex-js-public'
);
let
{
logger
,
apiAssertUtils
:
ApiAssert
,
BigNumberUtils
,
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
let
{
authCommon
:
AuthCommon
,
redisUtilsCommon
:
RedisClient
,
financeAccountDataUtils
,
tickerUtils
}
=
require
(
'@madex/ex-js-common'
);
let
_
=
require
(
'lodash'
);
...
...
@@ -615,4 +615,87 @@ async function getSiteWalletAssetsGroupBy(conditions: any[], group_by_field: str
}
export
async
function
walletInOutList
(
commonParam
:
CommonParam
)
{
let
from_time
=
commonParam
.
from_time
;
let
to_time
=
commonParam
.
to_time
;
let
page
=
Number
(
commonParam
.
page
);
let
size
=
Number
(
commonParam
.
size
);
//查询昨日流入流出 和 总计流入流出
let
opAnd
=
{
createdAt
:
{
[
ormDB
.
Op
.
gte
]:
from_time
,
[
ormDB
.
Op
.
lt
]:
to_time
}
};
let
walletTask
=
abkWalletDailySnap
.
prototype
.
findAll
({
attributes
:
[
'snap_date'
,
ormDB
.
literal
(
'sum(case when change_amount >= 0 then ABS(`change_eq_usdt`) else 0 end) as in_amount'
),
ormDB
.
literal
(
'sum(case when change_amount < 0 then ABS(`change_eq_usdt`) else 0 end) as out_amount'
)],
where
:
{
[
ormDB
.
Op
.
and
]:
opAnd
,
},
group
:
[
'snap_date'
],
order
:
[[
'snap_date'
,
'desc'
]],
raw
:
true
});
//按正常来说 snap_date 倒序 第一个就是昨天的数据
//比较一下日期 如果没有 就先置为 0
let
pageTask
=
abkWalletDailySnap
.
prototype
.
findAndCount
({
where
:
{
[
ormDB
.
Op
.
and
]:
opAnd
,
},
limit
:
size
,
offset
:
(
page
-
1
)
*
size
,
order
:
[[
"snap_date"
,
"desc"
]],
raw
:
true
})
let
[
walletDataList
,
pageData
]
=
await
Promise
.
all
([
walletTask
,
pageTask
]);
let
yesterday_in
=
new
BigNumber
(
0
);
let
yesterday_out
=
new
BigNumber
(
0
);
let
total_in
=
new
BigNumber
(
0
);
let
total_out
=
new
BigNumber
(
0
);
let
today
=
datetimeUtils
.
trim
(
new
Date
(),
'd'
);
let
yesterday
=
datetimeUtils
.
sub
(
today
,
datetimeUtils
.
DAY
);
for
(
let
item
of
walletDataList
)
{
let
inAmount
=
item
.
in_amount
;
let
outAmount
=
item
.
out_amount
;
total_in
=
total_in
.
add
(
new
BigNumber
(
inAmount
));
total_out
=
total_out
.
add
(
new
BigNumber
(
outAmount
));
}
if
(
walletDataList
.
length
&&
walletDataList
[
0
])
{
let
snapDate
=
walletDataList
[
0
].
snap_date
;
let
inAmount
=
walletDataList
[
0
].
in_amount
;
let
outAmount
=
walletDataList
[
0
].
out_amount
;
let
yts
=
new
Date
(
yesterday
).
getTime
();
let
sts
=
new
Date
(
snapDate
).
getTime
();
//库里的最新纪录是昨天的 ,任务定时在跑, 如果不是昨天的 定时任务可能出问题了
if
(
yts
==
sts
)
{
yesterday_in
=
new
BigNumber
(
inAmount
);
yesterday_out
=
new
BigNumber
(
outAmount
);
}
}
let
gather_data
=
{
yesterday_in
,
yesterday_out
,
yesterday_in_out
:
yesterday_in
.
sub
(
yesterday_out
),
total_in
,
total_out
,
total_in_out
:
total_in
.
sub
(
total_out
),
}
pageData
[
'gather_data'
]
=
gather_data
;
return
pageData
;
}
src/functional/router/v2/index.ts
View file @
4977e47e
...
...
@@ -37,6 +37,7 @@ const postFunc = {
'assetCheck/funding/monitor/totalRecords'
:
assetCheckCtrl
.
fundingTotalRecords
,
//资金监控-总记录
'assetCheck/funding/monitor/dailyRecords'
:
assetCheckCtrl
.
fundingDailyRecords
,
//资金监控-每日记录
'assetCheck/auto/checkList'
:
assetCheckCtrl
.
autoCheckList
,
//自动对账列表
'assetCheck/walletInOutList'
:
assetCheckCtrl
.
walletInOutList
,
//钱包流入流出
//收入分析
'abkFeeStatistics/home/gatherData'
:
feeStatisticsCtrl
.
gatherData
,
//首页数据概览
...
...
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