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
3b6a2bc3
Commit
3b6a2bc3
authored
Jan 14, 2025
by
1486327116
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
f58533b7
93003e52
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
9 deletions
+109
-9
abkFeeStatistics.control.ts
src/functional/mvc/control/v2/abkFeeStatistics.control.ts
+1
-1
abkCommonService.ts
src/functional/mvc/service/v2/abkCommonService.ts
+2
-0
abkFeeStatistics.service.ts
src/functional/mvc/service/v2/abkFeeStatistics.service.ts
+106
-8
No files found.
src/functional/mvc/control/v2/abkFeeStatistics.control.ts
View file @
3b6a2bc3
...
...
@@ -13,7 +13,7 @@ export const gatherData = async (req: any, commonParam: CommonParam) => {
let
func_name
=
"abkFeeStatistics.control.gatherData"
;
try
{
beforeQueryCheckTime
(
commonParam
);
let
res
=
await
abkFeeStatisticsService
.
gatherData
(
commonParam
.
from_time
,
commonParam
.
to_time
);
let
res
=
await
abkFeeStatisticsService
.
gatherData
(
commonParam
.
from_time
,
commonParam
.
to_time
,
commonParam
.
query_except_fee
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
...
...
src/functional/mvc/service/v2/abkCommonService.ts
View file @
3b6a2bc3
...
...
@@ -22,6 +22,8 @@ export interface CommonParam {
asset_id
?:
any
category_id
?:
any
//分类id
query_except_fee
?:
any
//是否查询 除了 手续费之外的数据
}
export
function
setPageAndSize
(
commonParam
:
CommonParam
)
{
...
...
src/functional/mvc/service/v2/abkFeeStatistics.service.ts
View file @
3b6a2bc3
import
{
madAdminOrmDB
,
coinAddress
,
coinType
,
abkFeeStatistics
,
ormDB
,
coinWithdraw
,
mdUserDailyFee
,
partnerFullUser
,
syncExFill
,
dwdExOrder
mdUserDailyFee
,
partnerFullUser
,
syncExFill
,
dwdExOrder
,
coinTx
,
abkWalletDailySnap
}
from
"@madex/ex-ts-dao"
;
import
BigNumber
from
"bignumber.js"
;
import
{
any
}
from
"async"
;
...
...
@@ -18,8 +19,9 @@ let _ = require('lodash');
* 首页数据概览
* @param from_time
* @param to_time
* @param query_except_fee 是否查询 除 手续费之外的数据
*/
export
async
function
gatherData
(
from_time
:
any
,
to_time
:
any
)
{
export
async
function
gatherData
(
from_time
:
any
,
to_time
:
any
,
query_except_fee
:
any
)
{
let
where
:
any
=
{
[
ormDB
.
Op
.
and
]:
[
{
...
...
@@ -70,13 +72,17 @@ export async function gatherData(from_time: any, to_time: any) {
let
all_data
=
buildOneResult
(
all_common_fee
,
all_common_back
,
all_crm_fee
,
all_crm_back
);
//总手续费+提现手续费
all_data
.
total_fee
=
all_data
.
total_fee
.
add
(
withdraw_total_fee
);
return
{
all_data
,
spot_data
,
lpc_data
,
ipc_data
,
withdraw_data
:
withdraw_total_fee
let
res
=
{
all_data
,
spot_data
,
lpc_data
,
ipc_data
,
withdraw_data
:
withdraw_total_fee
};
//除了手续费之外的数据 2025-01-13 增加
//是否查询 除 手续费 之外的数据
if
(
Number
(
query_except_fee
))
{
let
otherData
=
await
getExceptFeeData
(
from_time
,
to_time
);
res
[
'wallet_in_out_data'
]
=
otherData
.
wallet_in_out_data
;
res
[
'deposit_withdraw_data'
]
=
otherData
.
deposit_withdraw_data
;
}
return
res
;
}
...
...
@@ -613,4 +619,96 @@ async function getTotalWithdrawFeeByDtGroup(from_time: any, to_time: any) {
};
}
/**
* 查询除 手续费之外的数据
* 钱包流入流出数据、充提数据、运营数据
* @param from_time
* @param to_time
*/
async
function
getExceptFeeData
(
from_time
:
any
,
to_time
:
any
)
{
let
tickerMap
=
{};
let
opAnd
=
{
createdAt
:
{
[
ormDB
.
Op
.
gte
]:
from_time
,
[
ormDB
.
Op
.
lt
]:
to_time
}
};
//充值数据
let
depositTask
=
coinTx
.
prototype
.
findAll
({
attributes
:
[
'coin_symbol'
,
ormDB
.
literal
(
'sum(amount) as amount'
),],
where
:
{
[
ormDB
.
Op
.
and
]:
opAnd
,
status
:
{
[
ormDB
.
Op
.
gt
]:
0
}
//已确认
},
group
:
[
'coin_symbol'
],
raw
:
true
});
//提现数据
let
withdrawTask
=
coinWithdraw
.
prototype
.
findAll
({
attributes
:
[
'coin_symbol'
,
ormDB
.
literal
(
'sum(amount) as amount'
),],
where
:
{
[
ormDB
.
Op
.
and
]:
opAnd
,
status
:
3
//发币完成
},
group
:
[
'coin_symbol'
],
raw
:
true
});
//钱包流入流出数据
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'
],
raw
:
true
});
//总充值
let
total_deposit
=
new
BigNumber
(
0
);
//总提现
let
total_withdraw
=
new
BigNumber
(
0
);
//总流入
let
total_wallet_in
=
new
BigNumber
(
0
);
//总流出
let
total_wallet_out
=
new
BigNumber
(
0
);
let
[
depositList
,
withdrawList
,
walletList
]
=
await
Promise
.
all
([
depositTask
,
withdrawTask
,
walletTask
]);
for
(
let
item
of
depositList
)
{
let
coinSymbol
=
item
.
coin_symbol
;
let
amount
=
item
.
amount
;
let
usdt_rate
=
tickerMap
[
coinSymbol
]
?
tickerMap
[
coinSymbol
]
:
await
tickerUtils
.
rateCoin2USDT
(
coinSymbol
);
tickerMap
[
coinSymbol
]
=
usdt_rate
;
total_deposit
=
total_deposit
.
add
(
new
BigNumber
(
amount
).
mul
(
new
BigNumber
(
usdt_rate
)));
}
for
(
let
item
of
withdrawList
)
{
let
coinSymbol
=
item
.
coin_symbol
;
let
amount
=
item
.
amount
;
let
usdt_rate
=
tickerMap
[
coinSymbol
]
?
tickerMap
[
coinSymbol
]
:
await
tickerUtils
.
rateCoin2USDT
(
coinSymbol
);
tickerMap
[
coinSymbol
]
=
usdt_rate
;
total_withdraw
=
total_withdraw
.
add
(
new
BigNumber
(
amount
).
mul
(
new
BigNumber
(
usdt_rate
)));
}
for
(
let
item
of
walletList
)
{
let
in_amount
=
item
.
in_amount
;
let
out_amount
=
item
.
out_amount
;
total_wallet_in
=
total_wallet_in
.
add
(
new
BigNumber
(
in_amount
));
total_wallet_out
=
total_wallet_out
.
add
(
new
BigNumber
(
out_amount
));
}
//运营数据 TODO:未决定方案
return
{
wallet_in_out_data
:
{
wallet_in
:
total_wallet_in
,
wallet_out
:
total_wallet_out
,
wallet_in_out
:
total_wallet_in
.
sub
(
total_wallet_out
),
},
deposit_withdraw_data
:
{
deposit
:
total_deposit
,
withdraw
:
total_withdraw
,
deposit_withdraw
:
total_deposit
.
sub
(
total_withdraw
),
}
}
}
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