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
d2c4f160
Commit
d2c4f160
authored
Nov 11, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
费率、现货数据折线图
parent
0e5fee07
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
249 additions
and
82 deletions
+249
-82
task.fee.rate.log.model.ts
cron/model/task.fee.rate.log.model.ts
+63
-14
task_fee_rate_base_coin_contract_log.ts
cron/task/task_fee_rate_base_coin_contract_log.ts
+1
-9
task_fee_rate_contract_log.ts
cron/task/task_fee_rate_contract_log.ts
+1
-9
task_fee_rate_spot_log.ts
cron/task/task_fee_rate_spot_log.ts
+2
-10
errorCode.ts
src/constant/errorCode.ts
+1
-0
commonUserFeeSetting.control.ts
src/functional/mvc/control/commonUserFeeSetting.control.ts
+10
-0
depositAndWithdraw.service.ts
src/functional/mvc/service/depositAndWithdraw.service.ts
+1
-1
spotData.service.ts
src/functional/mvc/service/spotData.service.ts
+170
-39
No files found.
cron/model/task.fee.rate.log.model.ts
View file @
d2c4f160
...
...
@@ -10,10 +10,11 @@ import {
feeRateSpotLog
,
feeRateContractLog
,
commonUserFeeSetting
,
feeRateBaseCoinContractLog
,
spotPairs
,
contractPairs
feeRateBaseCoinContractLog
,
spotPairs
,
contractPairs
,
userProductFee
}
from
"@madex/ex-ts-dao"
;
import
{
FEE_RATE_LOG_STATUS
}
from
"../../src/constant/feeRateLogConst"
;
import
{
changeTradingFee
,
getPairFromCore
}
from
"../../src/utils/coreSystemUtils"
;
import
{
changeTradingFee
,
getPairFromCore
,
getUserAccountFromCore
}
from
"../../src/utils/coreSystemUtils"
;
let
BigNumber
=
require
(
'bignumber.js'
);
...
...
@@ -113,10 +114,16 @@ let checkFeeRate = async function (fee_rate) {
};
export
const
changeUserSpotFee
=
async
function
(
user_id
,
symbol
,
fee_model
,
maker_fee
,
taker_fee
,
logId
)
{
let
pair
=
symbol
===
'all'
?
''
:
symbol
;
let
is_success
=
true
;
await
checkFeeModel
(
fee_model
);
let
product_type
=
pair
==
'all'
?
'spot'
:
'single'
;
//生效的费率 与要设置的费率 比对做校验 现在分不开 现货 合约 先不校验 之后分开了 再校验
/* let feeExist = await cancelIfFeeExist(user_id, product_type, symbol, maker_fee, taker_fee);
if (feeExist) {
return is_success;
}*/
let
asset
=
await
mainUserAsset
.
prototype
.
findOne
({
where
:
{
user_id
...
...
@@ -134,28 +141,43 @@ export const changeUserSpotFee = async function (user_id, symbol, fee_model, mak
logger
.
warn
(
' task.fee.rate.log.model.changeUserSpotFee '
,
` taker_fee fee_rate error
${
taker_fee
}
`
);
throw
'3000'
;
}
await
checkPair
(
symbol
,
1
);
if
(
pair
)
{
await
checkPair
(
symbol
,
1
);
}
await
checkUser
(
user_id
);
await
sleep
(
1000
);
//请求撮合 修改费率
let
res
=
await
changeTradingFee
(
symbol
,
user_id
,
maker_fee
,
taker_fee
);
let
res
=
await
changeTradingFee
(
pair
,
user_id
,
maker_fee
,
taker_fee
);
return
res
.
is_success
;
};
export
const
changeUserContractFee
=
async
function
(
user_id
,
symbol
,
fee_model
,
maker_fee
,
taker_fee
,
logId
)
{
let
_func_name_
=
'task.fee.rate.log.model.changeUserContractFee'
;
let
pair
=
symbol
===
'all'
?
''
:
symbol
;
let
is_success
=
true
;
await
checkPair
(
symbol
,
2
);
let
asset
=
await
mainUserAsset
.
prototype
.
findOne
({
where
:
{
user_id
},
raw
:
true
})
if
(
!
asset
)
{
let
product_type
=
pair
==
'all'
?
'lpc'
:
'single'
;
//生效的费率 与要设置的费率 比对做校验 现在分不开 现货 合约 先不校验 之后分开了 再校验
/*let feeExist = await cancelIfFeeExist(user_id, product_type, symbol, maker_fee, taker_fee);
if (feeExist) {
return is_success;
}*/
if
(
pair
)
{
await
checkPair
(
symbol
,
2
);
}
//查询交易账户资产
let
asset
:
any
;
try
{
asset
=
await
getUserAccountFromCore
(
user_id
);
}
catch
(
e
)
{
logger
.
error
(
'changeUserContractFee.getUserAccountFromCore.error:'
+
e
);
}
if
(
!
asset
||
!
asset
.
length
)
{
return
is_success
;
}
if
(
maker_fee
<
-
0.0003
)
{
// 最大返0.0003
...
...
@@ -172,7 +194,7 @@ export const changeUserContractFee = async function (user_id, symbol, fee_model,
await
sleep
(
1000
);
//请求撮合 修改费率
let
res
=
await
changeTradingFee
(
symbol
,
user_id
,
maker_fee
,
taker_fee
);
let
res
=
await
changeTradingFee
(
pair
,
user_id
,
maker_fee
,
taker_fee
);
return
res
.
is_success
;
};
...
...
@@ -194,3 +216,30 @@ async function getMainAccountUserId(user_id: number) {
let
father_id
=
dbSon
?
dbSon
.
father_id
:
user_id
;
return
father_id
;
}
async
function
cancelIfFeeExist
(
user_id
,
product_type
,
pair
,
maker_fee
,
taker_fee
)
{
let
condition
=
{
user_id
,
product
:
pair
==
'all'
?
''
:
pair
,
product_type
}
let
dbFee
=
await
userProductFee
.
prototype
.
findOne
({
where
:
condition
,
raw
:
true
});
if
(
dbFee
&&
dbFee
.
maker_fee
==
maker_fee
&&
dbFee
.
taker_fee
==
taker_fee
)
{
return
true
;
}
//现货默认费率
if
(
product_type
==
'spot'
&&
maker_fee
==
0.001
&&
taker_fee
==
0.002
)
{
return
true
;
}
//合约默认费率
if
(
product_type
==
'lpc'
&&
maker_fee
==
0.0004
&&
taker_fee
==
0.0006
)
{
return
true
;
}
return
false
;
}
cron/task/task_fee_rate_base_coin_contract_log.ts
View file @
d2c4f160
...
...
@@ -21,15 +21,7 @@ const oneMonth = oneDay * 30;
let
inJob
=
false
;
let
limit
=
3000
;
/**
* 注意:
* fee_rate_spot_log
* fee_rate_contract_log
* fee_rate_base_coin_contract_log
* 相关表中不支持 all 或 ALL 交易对
* 管理后台配置用户费率的 all 交易对也是分多个交易对来处理的
* 即(common_user_fee_setting 中的 all 分多个交易对 设置到 fee_rate_log 表中)
*/
let
setFeeRateJob
=
schedule
.
scheduleJob
(
'*/30 * * * * *'
,
function
()
{
if
(
inJob
)
{
...
...
cron/task/task_fee_rate_contract_log.ts
View file @
d2c4f160
...
...
@@ -23,15 +23,7 @@ const oneMonth = oneDay * 30;
let
inJob
=
false
;
let
limit
=
3000
;
/**
* 注意:
* fee_rate_spot_log
* fee_rate_contract_log
* fee_rate_base_coin_contract_log
* 相关表中不支持 all 或 ALL 交易对
* 管理后台配置用户费率的 all 交易对也是分多个交易对来处理的
* 即(common_user_fee_setting 中的 all 分多个交易对 设置到 fee_rate_log 表中)
*/
let
setFeeRateJob
=
schedule
.
scheduleJob
(
'*/30 * * * * *'
,
function
()
{
if
(
inJob
)
{
...
...
cron/task/task_fee_rate_spot_log.ts
View file @
d2c4f160
...
...
@@ -22,15 +22,7 @@ const oneMonth = oneDay * 30;
let
inJob
=
false
;
let
limit
=
3000
;
/**
* 注意:
* fee_rate_spot_log
* fee_rate_contract_log
* fee_rate_base_coin_contract_log
* 相关表中不支持all 或 ALL 交易对
* 管理后台配置用户费率的 all 交易对也是分多个交易对来处理的
* 即(common_user_fee_setting 中的 all 分多个交易对 设置到 fee_rate_log 表中)
*/
let
setFeeRateJob
=
schedule
.
scheduleJob
(
'*/30 * * * * *'
,
function
()
{
if
(
inJob
)
{
...
...
@@ -240,7 +232,7 @@ async function setExpiredDefault() {
raw
:
true
,
});
let
defaultFeeObj
=
{},
max_maker_rate
=
0.001
,
max_taker_rate
=
0.002
;
// 2020.5.9
let
activePairs
:
any
=
[];
let
activePairs
:
any
=
[
'all'
];
for
(
let
i
=
0
;
i
<
defaultPairFee
.
length
;
i
++
)
{
let
{
symbol
,
maker_fee
,
taker_fee
}
=
defaultPairFee
[
i
];
...
...
src/constant/errorCode.ts
View file @
d2c4f160
...
...
@@ -77,4 +77,5 @@ export const ErrorCode = {
FEE_EX_OR_DEL
:
'30073'
,
//费率设置已过期或已删除,不可以修改
PAIR_FORMAT_ERR
:
'30074'
,
//交易对格式错误
PAIR_NOT_SUPPORT
:
'30075'
,
//暂不支持此交易对
FEE_TOO_LOW_OR_HIGH
:
'30076'
,
//设置的费率过高/过低
}
src/functional/mvc/control/commonUserFeeSetting.control.ts
View file @
d2c4f160
...
...
@@ -140,6 +140,16 @@ async function addParamValid(commonUserFeeVO: CommonUserFeeVO) {
if
(
pair
!=
'all'
){
throw
ErrorCode
.
PAIR_NOT_SUPPORT
;
}
//校验费率范围
if
(
type
==
FEE_TYPE
.
FEE_TYPE_SPOT
){
if
(
Number
(
makerFee
)
<
0.0002
||
Number
(
takerFee
)
<
0.0005
){
throw
ErrorCode
.
FEE_TOO_LOW_OR_HIGH
;
}
}
else
{
if
(
Number
(
makerFee
)
<
-
0.00015
||
Number
(
takerFee
)
<
0.00035
){
throw
ErrorCode
.
FEE_TOO_LOW_OR_HIGH
;
}
}
await
checkMaker
(
commonUserFeeVO
);
await
paramCheck
(
beginTime
,
expireTime
,
Number
(
type
),
userId
);
...
...
src/functional/mvc/service/depositAndWithdraw.service.ts
View file @
d2c4f160
...
...
@@ -108,7 +108,7 @@ export async function dealReturnData(resList: any) {
for
(
let
item
of
resList
.
rows
)
{
let
symbol
=
item
.
coin_symbol
;
let
amount
=
item
.
amount
;
let
usdt
=
usdtTickerMap
[
symbol
]
?
usdtTickerMap
[
symbol
]
:
await
tickerUtils
.
_
rateCoin2USDT
(
symbol
);
let
usdt
=
usdtTickerMap
[
symbol
]
?
usdtTickerMap
[
symbol
]
:
await
tickerUtils
.
rateCoin2USDT
(
symbol
);
usdtTickerMap
[
symbol
]
=
usdt
;
item
.
equal_usdt
=
new
BigNumber
(
usdt
).
mul
(
amount
);
}
...
...
src/functional/mvc/service/spotData.service.ts
View file @
d2c4f160
...
...
@@ -13,6 +13,7 @@ import BigNumber from "bignumber.js";
let
_
=
require
(
'lodash'
);
let
{
tickerUtils
}
=
require
(
'@madex/ex-js-common'
);
let
{
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
export
interface
QueryVO
{
...
...
@@ -65,9 +66,9 @@ export async function increaseUserList(pageVO: QueryVO) {
export
async
function
tradeUserList
(
pageVO
:
QueryVO
)
{
let
where
:
any
=
{
type
:
0
,
//UTC 0
category
:
1
,
//现货
let
where
:
any
=
{
type
:
0
,
//UTC 0
category
:
1
,
//现货
[
dwsMadOrmDB
.
Op
.
and
]:
[
{
trade_date
:
{
[
dwsMadOrmDB
.
Op
.
gte
]:
pageVO
.
from_time
}
...
...
@@ -79,7 +80,7 @@ export async function tradeUserList(pageVO: QueryVO) {
let
resList
:
any
=
[];
if
(
!
pageVO
.
is_export
)
{
resList
=
await
dwsUserDailyTrade
.
prototype
.
findAndCount
({
attributes
:
[
'user_id'
,
dwsMadOrmDB
.
literal
(
'sum(equal_usdt + equal_usdt_free) as trade_amount'
)],
attributes
:
[
'user_id'
,
dwsMadOrmDB
.
literal
(
'sum(equal_usdt + equal_usdt_free) as trade_amount'
)],
where
:
where
,
limit
:
pageVO
.
size
,
offset
:
(
Number
(
pageVO
.
page
)
-
1
)
*
Number
(
pageVO
.
size
),
...
...
@@ -89,23 +90,23 @@ export async function tradeUserList(pageVO: QueryVO) {
});
resList
.
count
=
resList
.
count
.
length
;
let
uids
=
resList
.
rows
.
map
(
item
=>
item
.
user_id
);
if
(
uids
){
if
(
uids
)
{
where
[
"user_id"
]
=
uids
await
dealFeeData
(
where
,
resList
.
rows
);
await
dealFeeData
(
where
,
resList
.
rows
);
}
}
else
{
//导出不分页
resList
=
await
dwsUserDailyTrade
.
prototype
.
findAll
({
attributes
:
[
'user_id'
,
dwsMadOrmDB
.
literal
(
'sum(equal_usdt + equal_usdt_free) as trade_amount'
)],
attributes
:
[
'user_id'
,
dwsMadOrmDB
.
literal
(
'sum(equal_usdt + equal_usdt_free) as trade_amount'
)],
where
:
where
,
order
:
[[
"trade_amount"
,
"desc"
]],
group
:
[
'user_id'
],
raw
:
true
});
let
uids
=
resList
.
map
(
item
=>
item
.
user_id
);
if
(
uids
){
if
(
uids
)
{
where
[
"user_id"
]
=
uids
await
dealFeeData
(
where
,
resList
);
await
dealFeeData
(
where
,
resList
);
}
}
return
resList
;
...
...
@@ -288,15 +289,63 @@ export async function userDepositAndWithdrawList(pageVO: QueryVO) {
export
async
function
gatherData
(
pageVO
:
QueryVO
)
{
let
[
increase
Count
,
tradeCount
,
activeCount
,
depositAndWithdraw
]
=
let
[
increase
Obj
,
tradeObj
,
activeObj
,
depositAndWithdrawObj
]
=
await
Promise
.
all
([
increaseUserCount
(
pageVO
),
tradeUserCount
(
pageVO
),
activeUserCount
(
pageVO
),
depositAndWithdrawCount
(
pageVO
)]);
//处理日期
let
daysArr
=
getAllDay
(
pageVO
.
from_time
,
pageVO
.
to_time
);
let
increase_data
:
any
=
[];
let
trade_data
:
any
=
[];
let
active_data
:
any
=
[];
let
deposit_data
:
any
=
[];
let
withdraw_data
:
any
=
[];
let
deposit_withdraw_data
:
any
=
[];
for
(
let
item
of
daysArr
)
{
increase_data
.
push
({
time
:
item
,
data
:
increaseObj
.
increaseDataMap
[
item
]
||
0
})
trade_data
.
push
({
time
:
item
,
data
:
tradeObj
.
tradeDataMap
[
item
]
||
0
})
active_data
.
push
({
time
:
item
,
data
:
activeObj
.
activeDataMap
[
item
]
||
0
})
deposit_data
.
push
({
time
:
item
,
data
:
depositAndWithdrawObj
.
depositDataMap
[
item
]
||
0
})
withdraw_data
.
push
({
time
:
item
,
data
:
depositAndWithdrawObj
.
withdrawDataMap
[
item
]
||
0
})
deposit_withdraw_data
.
push
({
time
:
item
,
data
:
depositAndWithdrawObj
.
depositWithdrawDataMap
[
item
]
||
0
})
}
return
{
increase
:
increaseCount
,
trade
:
tradeCount
,
active
:
activeCount
,
deposit
:
depositAndWithdraw
.
deposit
,
withdraw
:
depositAndWithdraw
.
withdraw
,
deposit_withdraw
:
depositAndWithdraw
.
deposit_withdraw
,
increase
:
increaseObj
.
increaseCount
,
increase_data
,
trade
:
tradeObj
.
tradeCount
,
trade_data
,
active
:
activeObj
.
activeCount
,
active_data
,
deposit
:
depositAndWithdrawObj
.
deposit
,
deposit_data
,
withdraw
:
depositAndWithdrawObj
.
withdraw
,
withdraw_data
,
deposit_withdraw
:
depositAndWithdrawObj
.
deposit_withdraw
,
deposit_withdraw_data
}
}
...
...
@@ -311,18 +360,32 @@ async function increaseUserCount(pageVO: QueryVO) {
createdAt
:
{
[
ormDB
.
Op
.
lt
]:
pageVO
.
to_time
},
}]
}
let
count
=
await
userLog
.
prototype
.
count
({
let
dbDataList
=
await
userLog
.
prototype
.
findAll
({
attributes
:
[
ormDB
.
literal
(
`DATE_FORMAT(createdAt,'%Y-%m-%d') AS dt`
),
ormDB
.
literal
(
'COUNT(1) AS count'
)
],
where
:
where
,
group
:
[
`dt`
],
raw
:
true
});
return
count
;
let
dataMap
:
any
=
{};
let
count
=
0
;
for
(
let
item
of
dbDataList
)
{
count
+=
item
.
count
;
dataMap
[
item
.
dt
]
=
item
.
count
;
}
return
{
increaseCount
:
count
,
increaseDataMap
:
dataMap
};
}
async
function
tradeUserCount
(
pageVO
:
QueryVO
)
{
let
where
:
any
=
{
type
:
0
,
//UTC 0
category
:
1
,
//现货
let
where
:
any
=
{
type
:
0
,
//UTC 0
category
:
1
,
//现货
[
dwsMadOrmDB
.
Op
.
and
]:
[
{
trade_date
:
{
[
dwsMadOrmDB
.
Op
.
gte
]:
pageVO
.
from_time
}
...
...
@@ -331,18 +394,36 @@ async function tradeUserCount(pageVO: QueryVO) {
trade_date
:
{
[
dwsMadOrmDB
.
Op
.
lt
]:
pageVO
.
to_time
},
}]
};
let
dbList
=
await
dwsUserDailyTrade
.
prototype
.
findAll
({
attributes
:[
dwsMadOrmDB
.
literal
(
'distinct(user_id) as user_id'
)],
where
:
where
,
raw
:
true
let
dbDataList
=
await
dwsUserDailyTrade
.
prototype
.
findAll
({
attributes
:
[
'user_id'
,
dwsMadOrmDB
.
literal
(
`DATE_FORMAT(trade_date,'%Y-%m-%d') AS dt`
),
dwsMadOrmDB
.
literal
(
'sum(equal_usdt + equal_usdt_free) AS amount'
)],
where
:
where
,
group
:
[
`dt`
,
'user_id'
],
raw
:
true
});
return
dbList
.
length
;
let
uidList
:
any
=
[];
let
dataMap
:
any
=
[];
for
(
let
item
of
dbDataList
)
{
if
(
!
uidList
.
includes
)
{
uidList
.
push
(
item
.
user_id
)
}
dataMap
[
item
.
dt
]
=
dataMap
[
item
.
dt
]
?
Number
(
dataMap
[
item
.
dt
])
+
Number
(
item
.
amount
)
:
Number
(
item
.
amount
)
}
return
{
tradeCount
:
uidList
.
length
,
tradeDataMap
:
dataMap
};
}
async
function
activeUserCount
(
pageVO
:
QueryVO
)
{
let
count_sql
=
`SELECT
COUNT(*
) AS num
let
count_sql
=
`SELECT
DATE_FORMAT(t2.createdAt, '%Y-%m-%d') AS dt, COUNT(t2.user_id
) AS num
FROM user_log AS t1
INNER JOIN
(SELECT user_id, MAX(createdAt) AS createdAt
...
...
@@ -350,11 +431,20 @@ async function activeUserCount(pageVO: QueryVO) {
WHERE type = 0
AND createdAt >= '
${
pageVO
.
from_time
}
'
AND createdAt < '
${
pageVO
.
to_time
}
'
GROUP BY user_id) AS t2 ON t1.user_id = t2.user_id AND t1.createdAt = t2.createdAt`
;
GROUP BY user_id) AS t2 ON t1.user_id = t2.user_id AND t1.createdAt = t2.createdAt
GROUP BY dt`
;
let
dbDataList
=
await
ormDB
.
query
(
count_sql
,
{
raw
:
true
,
type
:
ormDB
.
QueryTypes
.
SELECT
});
let
dbCount
=
await
ormDB
.
query
(
count_sql
,
{
raw
:
true
,
type
:
ormDB
.
QueryTypes
.
SELECT
});
let
count
=
dbCount
[
0
].
num
;
return
count
;
let
count
=
0
;
let
dataMap
:
any
=
{}
for
(
let
item
of
dbDataList
)
{
count
+=
item
.
num
;
dataMap
[
item
.
dt
]
=
item
.
num
;
}
return
{
activeCount
:
count
,
activeDataMap
:
dataMap
};
}
async
function
depositAndWithdrawCount
(
pageVO
:
QueryVO
)
{
...
...
@@ -362,6 +452,9 @@ async function depositAndWithdrawCount(pageVO: QueryVO) {
deposit
:
new
BigNumber
(
0
),
withdraw
:
new
BigNumber
(
0
),
deposit_withdraw
:
new
BigNumber
(
0
),
depositDataMap
:
{},
withdrawDataMap
:
{},
depositWithdrawDataMap
:
{},
}
let
where
=
{
type
:
{
[
ormDB
.
Op
.
in
]:
[
100
,
102
]
},
//充值、提现
...
...
@@ -375,13 +468,17 @@ async function depositAndWithdrawCount(pageVO: QueryVO) {
}];
let
amountList
=
await
mainUserBills
.
prototype
.
findAll
({
attributes
:
[
'symbol'
,
ormDB
.
literal
(
`DATE_FORMAT(createdAt,'%Y-%m-%d') AS dt`
),
ormDB
.
literal
(
'sum(case when type = 100 then ABS(`change`) else 0 end) as deposit_amount'
),
ormDB
.
literal
(
'sum(case when type = 102 then ABS(`change`) else 0 end) as withdraw_amount'
),
],
where
:
where
,
group
:
[
'symbol'
],
group
:
[
`dt`
,
'symbol'
],
raw
:
true
});
let
depositDataMap
:
any
=
{};
let
withdrawDataMap
:
any
=
{};
let
depositWithdrawDataMap
:
any
=
{};
if
(
amountList
.
length
)
{
let
deposit_usdt
=
new
BigNumber
(
0
);
let
withdraw_usdt
=
new
BigNumber
(
0
);
...
...
@@ -389,18 +486,31 @@ async function depositAndWithdrawCount(pageVO: QueryVO) {
let
symbol
=
item
.
symbol
;
let
deposit_amount
=
item
.
deposit_amount
;
let
withdraw_amount
=
item
.
withdraw_amount
;
let
usdt
=
await
tickerUtils
.
_
rateCoin2USDT
(
symbol
);
let
usdt
=
await
tickerUtils
.
rateCoin2USDT
(
symbol
);
let
deposit_amount_usdt
=
new
BigNumber
(
deposit_amount
).
mul
(
new
BigNumber
(
usdt
));
deposit_usdt
=
deposit_usdt
.
add
(
deposit_amount_usdt
);
depositDataMap
[
item
.
dt
]
=
depositDataMap
[
item
.
dt
]
?
depositDataMap
[
item
.
dt
].
add
(
deposit_amount_usdt
)
:
deposit_amount_usdt
;
let
withdraw_amount_usdt
=
new
BigNumber
(
withdraw_amount
).
mul
(
new
BigNumber
(
usdt
));
withdraw_usdt
=
withdraw_usdt
.
add
(
withdraw_amount_usdt
);
withdrawDataMap
[
item
.
dt
]
=
withdrawDataMap
[
item
.
dt
]
?
withdrawDataMap
[
item
.
dt
].
add
(
withdraw_amount_usdt
)
:
withdraw_amount_usdt
;
let
d_w_usdt
=
deposit_amount_usdt
.
sub
(
withdraw_amount_usdt
);
depositWithdrawDataMap
[
item
.
dt
]
=
depositWithdrawDataMap
[
item
.
dt
]
?
depositWithdrawDataMap
[
item
.
dt
].
add
(
d_w_usdt
)
:
d_w_usdt
;
}
let
deposit_withdraw_usdt
=
deposit_usdt
.
sub
(
withdraw_usdt
);
res
.
deposit
=
deposit_usdt
;
res
.
withdraw
=
withdraw_usdt
;
res
.
deposit_withdraw
=
deposit_withdraw_usdt
;
res
.
depositDataMap
=
depositDataMap
;
res
.
withdrawDataMap
=
withdrawDataMap
;
res
.
depositWithdrawDataMap
=
depositWithdrawDataMap
;
}
return
res
;
}
...
...
@@ -451,7 +561,7 @@ async function dealDepositOrWithdrawReturnData(resList: any) {
for
(
let
item
of
resList
)
{
let
symbol
=
item
.
symbol
;
let
change
=
item
.
change
;
let
usdt
=
usdtTickerMap
[
symbol
]
?
usdtTickerMap
[
symbol
]
:
await
tickerUtils
.
_
rateCoin2USDT
(
symbol
);
let
usdt
=
usdtTickerMap
[
symbol
]
?
usdtTickerMap
[
symbol
]
:
await
tickerUtils
.
rateCoin2USDT
(
symbol
);
usdtTickerMap
[
symbol
]
=
usdt
;
item
.
equal_usdt
=
new
BigNumber
(
usdt
).
mul
(
change
);
}
...
...
@@ -465,7 +575,7 @@ async function dealDepositAndWithdrawReturnData(resList: any) {
let
symbol
=
item
.
symbol
;
let
deposit_amount
=
item
.
deposit_amount
;
let
withdraw_amount
=
item
.
withdraw_amount
;
let
usdt
=
usdtTickerMap
[
symbol
]
?
usdtTickerMap
[
symbol
]
:
await
tickerUtils
.
_
rateCoin2USDT
(
symbol
);
let
usdt
=
usdtTickerMap
[
symbol
]
?
usdtTickerMap
[
symbol
]
:
await
tickerUtils
.
rateCoin2USDT
(
symbol
);
usdtTickerMap
[
symbol
]
=
usdt
;
item
.
deposit_usdt
=
new
BigNumber
(
usdt
).
mul
(
deposit_amount
);
item
.
withdraw_usdt
=
new
BigNumber
(
usdt
).
mul
(
withdraw_amount
);
...
...
@@ -474,14 +584,14 @@ async function dealDepositAndWithdrawReturnData(resList: any) {
}
}
async
function
dealFeeData
(
where
:
any
,
dbList
:
any
)
{
async
function
dealFeeData
(
where
:
any
,
dbList
:
any
)
{
let
dbFeeList
=
await
dwsUserDailyFee
.
prototype
.
findAll
({
attributes
:
[
'user_id'
,
dwsMadOrmDB
.
literal
(
'sum(equalusdt_amount) as fee_amount'
)],
attributes
:
[
'user_id'
,
dwsMadOrmDB
.
literal
(
'sum(equalusdt_amount) as fee_amount'
)],
where
:
where
,
group
:[
'user_id'
],
group
:
[
'user_id'
],
raw
:
true
});
let
fee_map
:
any
=
{};
let
fee_map
:
any
=
{};
for
(
let
item
of
dbFeeList
)
{
fee_map
[
item
.
user_id
]
=
item
.
fee_amount
;
}
...
...
@@ -490,6 +600,27 @@ async function dealFeeData(where:any,dbList:any){
}
}
/**
* 获取开始到结束每一天
* @param start
* @param end
*/
function
getAllDay
(
start
:
any
,
end
:
any
)
{
let
startTime
=
datetimeUtils
.
trim
(
start
,
'd'
);
let
endTime
=
datetimeUtils
.
trim
(
end
,
'd'
);
let
dateArr
:
any
=
[];
while
((
endTime
.
getTime
()
-
startTime
.
getTime
())
>
0
)
{
let
year
=
startTime
.
getFullYear
();
let
month
=
(
startTime
.
getMonth
()
+
1
).
toString
().
length
===
1
?
"0"
+
(
parseInt
(
startTime
.
getMonth
().
toString
(),
10
)
+
1
)
:
(
startTime
.
getMonth
()
+
1
);
let
day
=
startTime
.
getDate
().
toString
().
length
===
1
?
"0"
+
startTime
.
getDate
()
:
startTime
.
getDate
();
dateArr
.
push
(
year
+
"-"
+
month
+
"-"
+
day
);
startTime
.
setDate
(
startTime
.
getDate
()
+
1
);
}
return
dateArr
;
}
//let allDay = getAllDay("2024-11-11T00:00:00.000Z","2024-11-11T23:59:59.999Z");
...
...
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