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
0e5fee07
Commit
0e5fee07
authored
Nov 11, 2024
by
1486327116
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
5f24a20e
92f02e46
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
167 additions
and
89 deletions
+167
-89
errorCode.ts
src/constant/errorCode.ts
+6
-5
commonUserFeeSetting.control.ts
src/functional/mvc/control/commonUserFeeSetting.control.ts
+4
-0
mUserSubscribe.control.ts
src/functional/mvc/control/mUserSubscribe.control.ts
+0
-3
commonUserFeeSetting.service.ts
src/functional/mvc/service/commonUserFeeSetting.service.ts
+37
-56
mUserMailLog.service.ts
src/functional/mvc/service/mUserMailLog.service.ts
+0
-2
mUserManage.service.ts
src/functional/mvc/service/mUserManage.service.ts
+2
-2
mUserSubscribe.service.ts
src/functional/mvc/service/mUserSubscribe.service.ts
+2
-2
spotData.service.ts
src/functional/mvc/service/spotData.service.ts
+81
-9
index.ts
src/functional/router/v1/index.ts
+1
-1
robotUtils.ts
src/utils/robotUtils.ts
+34
-9
No files found.
src/constant/errorCode.ts
View file @
0e5fee07
...
...
@@ -38,12 +38,12 @@ export const ErrorCode = {
UID_ILLEGALITY
:
'30035'
,
//UID不合法
UID_TOO_MUCH
:
'30036'
,
//UID过多
SPOT_NO_ASSETS
:
'30037'
,
//用户
现货
账户未有资产记录
U_NO_ASSETS
:
'30038'
,
//用户
U本位合约
账户未有资产记录
COIN_NO_ASSETS
:
'30039'
,
//用户
币本位合约
账户未有资产记录
SPOT_FEE_NEED_SET
:
'30040'
,
//
币币
费率需要设置
SPOT_NO_ASSETS
:
'30037'
,
//用户
钱包
账户未有资产记录
U_NO_ASSETS
:
'30038'
,
//用户
统一
账户未有资产记录
COIN_NO_ASSETS
:
'30039'
,
//用户
统一
账户未有资产记录
SPOT_FEE_NEED_SET
:
'30040'
,
//
现货
费率需要设置
CONTRACT_FEE_NEED_SET
:
'30041'
,
//合约费率需要设置
SON_NOT_ADD_FEE
:
'30042'
,
//子账户不能添加
为市商
SON_NOT_ADD_FEE
:
'30042'
,
//子账户不能添加
费率
LEVEL_NOT_EXIST
:
'30043'
,
//指定等级不存在
ONLY_ONE_FEE
:
'30044'
,
//只能有一条未提交的费率设置
ONLY_UN_SUBMIT_UPDATE
:
'30045'
,
//只有未提交的记录可以修改
...
...
@@ -76,4 +76,5 @@ export const ErrorCode = {
EXIST_ACTIVE_PAIR
:
'30072'
,
//已存在生效或即将生效的该交易对费率配置
FEE_EX_OR_DEL
:
'30073'
,
//费率设置已过期或已删除,不可以修改
PAIR_FORMAT_ERR
:
'30074'
,
//交易对格式错误
PAIR_NOT_SUPPORT
:
'30075'
,
//暂不支持此交易对
}
src/functional/mvc/control/commonUserFeeSetting.control.ts
View file @
0e5fee07
...
...
@@ -136,6 +136,10 @@ async function addParamValid(commonUserFeeVO: CommonUserFeeVO) {
if
(
!
userId
||
!
beginTime
||
!
expireTime
||
!
pair
||
!
applicant
||
!
makerFee
||
!
takerFee
)
{
throw
ErrorCode
.
PARAM_MISS
;
}
//撮合目前只支持 all 后续支持单个币对 可放开
if
(
pair
!=
'all'
){
throw
ErrorCode
.
PAIR_NOT_SUPPORT
;
}
await
checkMaker
(
commonUserFeeVO
);
await
paramCheck
(
beginTime
,
expireTime
,
Number
(
type
),
userId
);
...
...
src/functional/mvc/control/mUserSubscribe.control.ts
View file @
0e5fee07
...
...
@@ -30,7 +30,6 @@ export const list = async (req: any, queryVO: QueryVO) => {
/**
* 删除订阅
* TODO: 关于status 字段 从老管理后台来看 0 代表无效 1 代表有效 但是数据库备注 0 有效 1 无效 以哪个为准?
* @param req
* @param authConfigVO
*/
...
...
@@ -52,7 +51,6 @@ export const del = async (req: any, queryVO: QueryVO) => {
/**
* 订阅统计
* TODO: 关于status 字段 从老管理后台来看 0 代表无效 1 代表有效 但是数据库备注 0 有效 1 无效 以哪个为准?
* @param req
* @param authConfigVO
*/
...
...
@@ -111,7 +109,6 @@ export const mailDetail = async (req: any, userMailLogVO: UserMailLogVO) => {
/**
* 邮件发送
* TODO: 关于status 字段 从老管理后台来看 0 代表无效 1 代表有效 但是数据库备注 0 有效 1 无效 service里面又查询 status = 0 的 ???
* @param req
* @param userMailLogVO
*/
...
...
src/functional/mvc/service/commonUserFeeSetting.service.ts
View file @
0e5fee07
...
...
@@ -153,32 +153,32 @@ export async function add(commonUserFeeVO: CommonUserFeeVO, currentUserId: any,
let
pair
=
dbInfo
.
pair
;
let
type
=
dbInfo
.
type
;
let
now
=
new
Date
();
let
insertDb
List
:
any
=
[]
;
let
insertDb
One
:
any
;
let
rateLog
s
=
await
buildSubmitItems
(
pair
,
dbInfo
,
now
,
dbInfo
.
user_channel
,
type
);
let
rateLog
=
await
buildSubmitItem
(
pair
,
dbInfo
,
now
,
dbInfo
.
user_channel
);
//提交到log表
if
(
type
==
FEE_TYPE
.
FEE_TYPE_SPOT
)
{
insertDb
List
=
await
feeRateSpotLog
.
prototype
.
bulkCreate
(
rateLogs
,
{
insertDb
One
=
await
feeRateSpotLog
.
prototype
.
create
(
rateLog
,
{
transaction
:
tx
});
}
else
if
(
type
==
FEE_TYPE
.
FEE_TYPE_BASE_COIN_CONTRACT
)
{
//币本位
insertDb
List
=
await
feeRateBaseCoinContractLog
.
prototype
.
bulkCreate
(
rateLogs
,
{
insertDb
One
=
await
feeRateBaseCoinContractLog
.
prototype
.
create
(
rateLog
,
{
transaction
:
tx
});
}
else
{
//U本位
insertDb
List
=
await
feeRateContractLog
.
prototype
.
bulkCreate
(
rateLogs
,
{
insertDb
One
=
await
feeRateContractLog
.
prototype
.
create
(
rateLog
,
{
transaction
:
tx
});
}
let
id
s
=
insertDbList
.
map
(
item
=>
item
.
id
)
;
let
id
=
insertDbOne
.
id
;
await
commonUserFeeSetting
.
prototype
.
update
({
fee_log_ids
:
id
s
.
toString
(),
fee_log_ids
:
id
.
toString
(),
update_time
:
new
Date
()
},
{
where
:
{
...
...
@@ -225,31 +225,31 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an
let
tx
;
try
{
tx
=
await
ormDB
.
transaction
();
let
feeLogId
s
:
any
;
let
feeLogId
:
any
;
//这四项修改需要 重新写入 rate_log
if
(
commonUserFeeVO
.
maker_fee
!=
dbInfo
.
maker_fee
||
commonUserFeeVO
.
taker_fee
!=
dbInfo
.
taker_fee
||
commonUserFeeVO
.
begin_time
!=
dbInfo
.
begin_time
||
commonUserFeeVO
.
expire_time
!=
dbInfo
.
expire_time
)
{
let
insertDb
List
:
any
;
let
rateLog
s
=
await
buildSubmitItems
(
pair
,
commonUserFeeVO
,
new
Date
(),
Number
(
commonUserFeeVO
.
user_channel
),
type
);
let
insertDb
One
:
any
;
let
rateLog
=
await
buildSubmitItem
(
pair
,
commonUserFeeVO
,
new
Date
(),
Number
(
commonUserFeeVO
.
user_channel
)
);
//提交到log表
if
(
type
==
FEE_TYPE
.
FEE_TYPE_SPOT
)
{
insertDb
List
=
await
feeRateSpotLog
.
prototype
.
bulkCreate
(
rateLogs
,
{
insertDb
One
=
await
feeRateSpotLog
.
prototype
.
create
(
rateLog
,
{
transaction
:
tx
});
}
else
if
(
type
==
FEE_TYPE
.
FEE_TYPE_BASE_COIN_CONTRACT
)
{
//币本位
insertDb
List
=
await
feeRateBaseCoinContractLog
.
prototype
.
bulkCreate
(
rateLogs
,
{
insertDb
One
=
await
feeRateBaseCoinContractLog
.
prototype
.
create
(
rateLog
,
{
transaction
:
tx
});
}
else
{
//U本位
insertDb
List
=
await
feeRateContractLog
.
prototype
.
bulkCreate
(
rateLogs
,
{
insertDb
One
=
await
feeRateContractLog
.
prototype
.
create
(
rateLog
,
{
transaction
:
tx
});
}
feeLogId
s
=
insertDbList
.
map
(
item
=>
item
.
id
)
;
feeLogId
=
insertDbOne
.
id
;
}
...
...
@@ -264,7 +264,7 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an
amount_require_usdt
:
commonUserFeeVO
.
amount_require_usdt
,
applicant
:
commonUserFeeVO
.
applicant
,
update_time
:
new
Date
(),
fee_log_ids
:
feeLogId
s
?
feeLogIds
.
toString
()
:
dbInfo
.
fee_log_ids
,
fee_log_ids
:
feeLogId
?
feeLogId
.
toString
()
:
dbInfo
.
fee_log_ids
,
},
{
where
:
{
id
:
Number
(
commonUserFeeVO
.
id
)
...
...
@@ -461,51 +461,32 @@ async function getDbFeeSetting(user_id: number | any, type: number | any, user_c
return
dbInfo
;
}
async
function
buildSubmitItems
(
pair
:
string
,
dbInfo
:
any
,
now
:
Date
,
user_channel
:
number
,
type
:
number
)
{
let
pairList
:
any
;
if
(
pair
==
'all'
)
{
if
(
type
==
FEE_TYPE
.
FEE_TYPE_SPOT
)
{
pairList
=
await
getAllSpotPairs
();
}
else
{
//TODO:币本位和U本位的交易对怎么区分?
pairList
=
await
getAllContractPairs
();
}
async
function
buildSubmitItem
(
pair
:
string
,
dbInfo
:
any
,
now
:
Date
,
user_channel
:
number
)
{
let
item
=
{
user_id
:
dbInfo
.
user_id
,
pair
:
pair
,
fee_model
:
FEE_MODEL_SPOT_DEFAULT
,
maker_fee
:
dbInfo
.
maker_fee
,
taker_fee
:
dbInfo
.
taker_fee
,
beginAt
:
dbInfo
.
begin_time
,
expireAt
:
dbInfo
.
expire_time
,
is_check
:
FEE_RATE_LOG_STATUS
.
CHECK_STATUS_UNCHECK
,
comment
:
""
,
createdAt
:
now
,
updatedAt
:
now
}
else
{
pairList
=
[
pair
]
//项目方
if
(
user_channel
==
2
)
{
item
.
comment
=
COMMENT_MAKER_FEE_SUBMIT
}
let
itemList
:
any
=
[];
for
(
let
onePair
of
pairList
)
{
let
item
=
{
user_id
:
dbInfo
.
user_id
,
pair
:
onePair
,
fee_model
:
FEE_MODEL_SPOT_DEFAULT
,
maker_fee
:
dbInfo
.
maker_fee
,
taker_fee
:
dbInfo
.
taker_fee
,
beginAt
:
dbInfo
.
begin_time
,
expireAt
:
dbInfo
.
expire_time
,
is_check
:
FEE_RATE_LOG_STATUS
.
CHECK_STATUS_UNCHECK
,
comment
:
""
,
createdAt
:
now
,
updatedAt
:
now
}
//项目方
if
(
user_channel
==
2
)
{
item
.
comment
=
COMMENT_MAKER_FEE_SUBMIT
}
else
if
(
user_channel
==
3
)
{
item
.
comment
=
COMMENT_KOL_FEE_SUBMIT
}
else
{
item
.
comment
=
COMMENT_USER_FEE_SUBMIT
}
itemList
.
push
(
item
);
else
if
(
user_channel
==
3
)
{
item
.
comment
=
COMMENT_KOL_FEE_SUBMIT
}
else
{
item
.
comment
=
COMMENT_USER_FEE_SUBMIT
}
return
itemList
;
return
item
;
}
async
function
checkSpotPair
(
pair
:
string
)
{
...
...
src/functional/mvc/service/mUserMailLog.service.ts
View file @
0e5fee07
...
...
@@ -62,7 +62,6 @@ export async function mailDetail(id: number | undefined) {
export
async
function
mailSend
(
userMailLogVO
:
UserMailLogVO
,
currentUserId
:
any
,
ip
:
string
|
undefined
)
{
let
where
=
{
//TODO:0 ? 1 ???
status
:
0
};
if
(
userMailLogVO
.
user_id
)
{
...
...
@@ -95,7 +94,6 @@ export async function mailSend(userMailLogVO: UserMailLogVO, currentUserId: any,
}
for
(
let
sub
of
toAddrRes
)
{
//TODO:老管理后台就没有模版 ???
sendEmail
(
sub
.
sub
,
sub
.
user_id
,
""
,
params
,
userMailLogVO
.
lang
);
}
...
...
src/functional/mvc/service/mUserManage.service.ts
View file @
0e5fee07
...
...
@@ -428,8 +428,8 @@ async function buildReturnData(pageData: any, fill_user_info: boolean, fill_coin
real_name
:
item
.
real_name
?
item
.
real_name
:
""
,
email
:
item
.
email
?
item
.
email
:
""
,
register_date
:
item
.
createdAt
?
item
.
createdAt
:
""
,
spot_balance
:
0
,
//TODO:现货余额
contract_balance
:
0
,
//TODO:永续合约余额
spot_balance
:
0
,
contract_balance
:
0
,
assets_total
:
assets_total
,
//总资产
wallet_account_balance
:
wallet_account_balance
,
//钱包账户余额
trade_account_balance
:
trade_account_balance
,
//交易账户余额
...
...
src/functional/mvc/service/mUserSubscribe.service.ts
View file @
0e5fee07
...
...
@@ -62,7 +62,7 @@ export async function del(id: number, currentUserId: any, ip: string | undefined
}
await
userSub
.
prototype
.
update
({
status
:
0
,
status
:
1
,
//0 有效 1 无效
},
{
where
:
{
id
:
Number
(
id
)
...
...
@@ -84,7 +84,7 @@ export async function count() {
let
dbInfoList
=
await
userSub
.
prototype
.
findAll
({
where
:
{
status
:
1
status
:
0
},
raw
:
true
});
...
...
src/functional/mvc/service/spotData.service.ts
View file @
0e5fee07
...
...
@@ -3,7 +3,10 @@ import {
userLog
,
userInfo
,
userRealName
,
mainUserBills
mainUserBills
,
dwsUserDailyTrade
,
dwsUserDailyFee
,
dwsMadOrmDB
}
from
"@madex/ex-ts-dao"
;
import
BigNumber
from
"bignumber.js"
;
...
...
@@ -61,13 +64,51 @@ export async function increaseUserList(pageVO: QueryVO) {
export
async
function
tradeUserList
(
pageVO
:
QueryVO
)
{
//TODO:
let
res
=
{
count
:
0
,
rows
:
[]
}
return
res
let
where
:
any
=
{
type
:
0
,
//UTC 0
category
:
1
,
//现货
[
dwsMadOrmDB
.
Op
.
and
]:
[
{
trade_date
:
{
[
dwsMadOrmDB
.
Op
.
gte
]:
pageVO
.
from_time
}
},
{
trade_date
:
{
[
dwsMadOrmDB
.
Op
.
lt
]:
pageVO
.
to_time
},
}]
};
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'
)],
where
:
where
,
limit
:
pageVO
.
size
,
offset
:
(
Number
(
pageVO
.
page
)
-
1
)
*
Number
(
pageVO
.
size
),
order
:
[[
dwsMadOrmDB
.
literal
(
'trade_amount'
),
"desc"
]],
group
:
[
'user_id'
],
raw
:
true
});
resList
.
count
=
resList
.
count
.
length
;
let
uids
=
resList
.
rows
.
map
(
item
=>
item
.
user_id
);
if
(
uids
){
where
[
"user_id"
]
=
uids
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'
)],
where
:
where
,
order
:
[[
"trade_amount"
,
"desc"
]],
group
:
[
'user_id'
],
raw
:
true
});
let
uids
=
resList
.
map
(
item
=>
item
.
user_id
);
if
(
uids
){
where
[
"user_id"
]
=
uids
await
dealFeeData
(
where
,
resList
);
}
}
return
resList
;
}
export
async
function
activeUserList
(
pageVO
:
QueryVO
)
{
...
...
@@ -278,8 +319,24 @@ async function increaseUserCount(pageVO: QueryVO) {
}
async
function
tradeUserCount
(
pageVO
:
QueryVO
)
{
//TODO:查询交易数据
return
0
;
let
where
:
any
=
{
type
:
0
,
//UTC 0
category
:
1
,
//现货
[
dwsMadOrmDB
.
Op
.
and
]:
[
{
trade_date
:
{
[
dwsMadOrmDB
.
Op
.
gte
]:
pageVO
.
from_time
}
},
{
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
});
return
dbList
.
length
;
}
...
...
@@ -417,6 +474,21 @@ async function dealDepositAndWithdrawReturnData(resList: 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'
)],
where
:
where
,
group
:[
'user_id'
],
raw
:
true
});
let
fee_map
:
any
=
{};
for
(
let
item
of
dbFeeList
)
{
fee_map
[
item
.
user_id
]
=
item
.
fee_amount
;
}
for
(
let
item
of
dbList
)
{
item
.
fee_amount
=
fee_map
[
item
.
user_id
]
?
fee_map
[
item
.
user_id
]
:
0
}
}
...
...
src/functional/router/v1/index.ts
View file @
0e5fee07
...
...
@@ -266,7 +266,7 @@ const postFunc = {
'tech/apply/new/cron/coin/add/withdraw'
:
cronApplyCtrl
.
addWithdraw
,
//增加新币提现定时器
//运营部-现货-现货数据
'operate/spot/data/increase/user/list'
:
spotDataCtrl
.
increaseUserList
,
'operate/spot/data/trade/user/list'
:
spotDataCtrl
.
tradeUserList
,
//TODO
'operate/spot/data/trade/user/list'
:
spotDataCtrl
.
tradeUserList
,
'operate/spot/data/active/user/list'
:
spotDataCtrl
.
activeUserList
,
'operate/spot/data/user/deposit/list'
:
spotDataCtrl
.
userDepositList
,
'operate/spot/data/user/withdraw/list'
:
spotDataCtrl
.
userWithdrawList
,
...
...
src/utils/robotUtils.ts
View file @
0e5fee07
let
{
debug
,
logger
}
=
require
(
'@madex/ex-js-public'
);
const
{
larkRobotUtils
:
LarkRobotUtils
,
}
=
require
(
"@madex/ex-js-common"
)
let
config
=
require
(
'../../config'
);
let
axios
=
require
(
'axios'
);
debug
=
config
.
env
===
"development"
;
let
COMMON_KEY
=
"9e06e260-6c2f-49d4-98b4-e08ef096f6f5"
;
//测试
/**
* Lark 地址
*/
let
LARK_URL_PRE
=
"https://open.larksuite.com/open-apis/bot/v2/hook/"
;
/**
* 生产:pro
*/
let
COMMON_KEY
=
"d9f2dc6e-52cf-4933-92f1-dab9c249aa28"
;
/**
* 测试:dev
*/
if
(
debug
)
{
COMMON_KEY
=
"
9e06e260-6c2f-49d4-98b4-e08ef096f6f5
"
;
COMMON_KEY
=
"
d98c9942-ff6f-4e71-a77f-41647ff19ff0
"
;
}
export
const
ROBOT_KEYS
=
{
COMMON_KEY
:
COMMON_KEY
}
...
...
@@ -27,7 +38,9 @@ export const ROBOT_KEYS = {
* @param _func_name_ 报错方法(可选)
*/
export
const
sendRobotMessage
=
async
function
(
url
:
string
,
content
:
any
,
_func_name_
?:
string
)
{
if
(
!
_func_name_
)
{
_func_name_
=
''
;
}
if
(
typeof
content
!=
'string'
)
{
if
(
content
&&
content
.
sql
)
{
content
=
`backend._func_name_
${
_func_name_
}
,
${
content
.
sql
}
`
;
...
...
@@ -55,5 +68,17 @@ export const sendRobotMessage = async function (url: string, content: any, _func
async
function
doSend
(
url
:
string
,
content
:
any
)
{
logger
.
info
(
'robot message'
,
url
,
content
);
await
LarkRobotUtils
.
sendTextSimple
(
url
,
content
).
catch
()
let
URL
=
LARK_URL_PRE
+
url
;
try
{
let
response
=
await
axios
.
post
(
URL
,
{
msg_type
:
"text"
,
content
:
{
text
:
content
}
});
if
(
response
&&
response
.
data
)
{
return
response
.
data
}
}
catch
(
e
)
{
logger
.
error
(
'robot send error'
,
URL
,
content
);
}
}
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