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
a5b9e71b
Commit
a5b9e71b
authored
Sep 30, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加接口、逻辑调整
parent
fcf4263f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
803 additions
and
148 deletions
+803
-148
coinTypeApplyConst.ts
src/constant/coinTypeApplyConst.ts
+10
-0
errorCode.ts
src/constant/errorCode.ts
+9
-1
coinType.control.ts
src/functional/mvc/control/coinType.control.ts
+5
-3
coinTypeApply.ts
src/functional/mvc/control/coinTypeApply.ts
+221
-0
commonUserFeeSetting.control.ts
src/functional/mvc/control/commonUserFeeSetting.control.ts
+2
-2
spotPair.control.ts
src/functional/mvc/control/spotPair.control.ts
+6
-4
aclUser.service.ts
src/functional/mvc/service/aclUser.service.ts
+8
-3
coinType.service.ts
src/functional/mvc/service/coinType.service.ts
+17
-38
coinTypeApply.service.ts
src/functional/mvc/service/coinTypeApply.service.ts
+423
-0
commonUserFeeSetting.service.ts
src/functional/mvc/service/commonUserFeeSetting.service.ts
+4
-0
spotPair.service.ts
src/functional/mvc/service/spotPair.service.ts
+25
-57
index.ts
src/functional/router/v1/index.ts
+12
-0
access-limit.ts
src/setting/access-limit.ts
+10
-0
coreSystemUtils.ts
src/utils/coreSystemUtils.ts
+51
-40
No files found.
src/constant/coinTypeApplyConst.ts
0 → 100644
View file @
a5b9e71b
export
const
APPLY_STATUS
=
{
RE_WRITE
:
1
,
// 被驳回
WAIT_VIEW
:
2
,
// 申请待审批
PASS
:
3
,
// 审批通过
CREATE_SYMBOL
:
4
,
// 币种创建完成
TIMER_DEPOSIT
:
5
,
// 充值定时器完成
TIMER_WITHDRAW
:
6
,
// 提现定时器完成
TO_ADMIN
:
7
,
// 增加币种到撮合完成
CANCEL
:
8
,
// 取消
}
\ No newline at end of file
src/constant/errorCode.ts
View file @
a5b9e71b
...
...
@@ -60,5 +60,13 @@ export const ErrorCode = {
COIN_TYPE_NOT_EXIST
:
'30056'
,
//指定币种不存在
PAIR_NOT_EXIST
:
'30057'
,
//指定币对不存在
LIMIT_ERROR
:
'30058'
,
//limit参数必须在10-2000之间
ADD_PAIR_TO_CORE_ERR
:
'30059'
,
//添加币种/交易对提交到撮合失败
ADD_PAIR_TO_CORE_ERR
:
'30059'
,
//币种/交易对提交到撮合失败
SUBMIT_STATUS_ERR
:
'30060'
,
//请确认提交状态
SUBMIT_STATUS_OR_MAIN_ERR
:
'30061'
,
//提交状态有误/非主币
NOT_EDIT
:
'30062'
,
//不是被驳回的申请不可以编辑
COIN_DATA_EXIST
:
'30063'
,
//币种管理中币种已存在
COIN_DATA_NOT_EXIST
:
'30064'
,
//币种管理中币种不存在
NO_CANCEL
:
'30065'
,
//审核已通过不允许撤销
DEPOSIT_WITHDRAW_TM_EXPIRE
:
'30066'
,
//开放充值时间/开放提现时间过短
CURRENT_STATUS_NOT_APPLY
:
'30067'
,
//当前状态不可以审核
}
src/functional/mvc/control/coinType.control.ts
View file @
a5b9e71b
...
...
@@ -70,12 +70,14 @@ export const update = async (req: any, param: AddParam) => {
}
};
export
const
pushToCoreSystem
=
async
(
req
:
any
,
id
:
any
)
=>
{
export
const
pushToCoreSystem
=
async
(
req
:
any
,
param
:
AddParam
)
=>
{
let
func_name
=
"coinTypeCtl.pushToCoreSystem"
;
let
cmd
=
req
.
path
;
try
{
ApiAssert
.
notNull
(
'3000'
,
id
);
let
res
=
await
service
.
pushToCoreSystem
(
id
);
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUserId
=
await
getCurrentUserId
(
req
.
cookies
.
session_id
);
ApiAssert
.
notNull
(
'3000'
,
param
.
id
);
let
res
=
await
service
.
pushToCoreSystem
(
param
.
id
,
currentUserId
,
ip
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
...
...
src/functional/mvc/control/coinTypeApply.ts
0 → 100644
View file @
a5b9e71b
import
*
as
coinTypeApplyService
from
"../service/coinTypeApply.service"
;
import
{
CoinTypeApplyPageVO
,
CoinTypeApplyVO
}
from
"../service/coinTypeApply.service"
;
let
{
logger
,
Res3Utils
,
optionalUtils
:
Optional
,
apiAssertUtils
:
ApiAssert
,
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
import
{
getCurrentUser
,
getCurrentUserId
}
from
"../../../utils/aclUserUtils"
;
let
isIp
=
require
(
'is-ip'
);
/**
* 技术部-上币管理-上币申请-申请上新币列表
* @param req
* @param infoVO
*/
export
const
list
=
async
(
req
:
any
,
pageVO
:
CoinTypeApplyPageVO
)
=>
{
let
func_name
=
"coinTypeApply.control.list"
;
try
{
pageVO
.
page
=
Optional
.
opt
(
pageVO
,
'page'
,
1
);
pageVO
.
size
=
Optional
.
opt
(
pageVO
,
'size'
,
20
);
let
res
=
await
coinTypeApplyService
.
list
(
pageVO
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* 技术部-上币管理-上币申请-已有币种列表
* @param req
* @param infoVO
*/
export
const
listed
=
async
(
req
:
any
,
pageVO
:
CoinTypeApplyPageVO
)
=>
{
let
func_name
=
"coinTypeApply.control.listed"
;
try
{
pageVO
.
page
=
Optional
.
opt
(
pageVO
,
'page'
,
1
);
pageVO
.
size
=
Optional
.
opt
(
pageVO
,
'size'
,
20
);
let
res
=
await
coinTypeApplyService
.
listed
(
pageVO
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* 技术部-上币管理-上币申请-交易浏览器列表
* @param req
* @param infoVO
*/
export
const
exploreUrlList
=
async
(
req
:
any
,
pageVO
:
CoinTypeApplyPageVO
)
=>
{
let
func_name
=
"coinTypeApply.control.exploreUrlList"
;
try
{
let
res
=
await
coinTypeApplyService
.
exploreUrlList
();
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* 技术部-上币管理-上币申请-申请上新币
* @param req
* @param authConfigVO
*/
export
const
apply
=
async
(
req
:
any
,
coinTypeApplyVO
:
CoinTypeApplyVO
)
=>
{
let
func_name
=
"coinTypeApply.control.apply"
;
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUser
=
await
getCurrentUser
(
req
.
cookies
.
session_id
);
await
paramValid
(
coinTypeApplyVO
);
let
res
=
await
coinTypeApplyService
.
apply
(
coinTypeApplyVO
,
currentUser
,
ip
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* 技术部-上币管理-上币申请-编辑上新币
* @param req
* @param authConfigVO
*/
export
const
edit
=
async
(
req
:
any
,
coinTypeApplyVO
:
CoinTypeApplyVO
)
=>
{
let
func_name
=
"coinTypeApply.control.edit"
;
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUser
=
await
getCurrentUser
(
req
.
cookies
.
session_id
);
if
(
!
coinTypeApplyVO
.
id
)
{
throw
ErrorCode
.
PARAM_MISS
}
await
paramValid
(
coinTypeApplyVO
);
let
res
=
await
coinTypeApplyService
.
edit
(
coinTypeApplyVO
,
currentUser
,
ip
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* 技术部-上币管理-上币申请-撤销申请上币
* @param req
* @param authConfigVO
*/
export
const
cancelSelf
=
async
(
req
:
any
,
coinTypeApplyVO
:
CoinTypeApplyVO
)
=>
{
let
func_name
=
"coinTypeApply.control.cancelSelf"
;
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUser
=
await
getCurrentUser
(
req
.
cookies
.
session_id
);
if
(
!
coinTypeApplyVO
.
id
)
{
throw
ErrorCode
.
PARAM_MISS
}
let
res
=
await
coinTypeApplyService
.
cancelSelf
(
coinTypeApplyVO
.
id
,
coinTypeApplyVO
.
reason
,
currentUser
,
ip
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* 技术部-上币管理-上币申请-驳回申请上币
* @param req
* @param authConfigVO
*/
export
const
rewrite
=
async
(
req
:
any
,
coinTypeApplyVO
:
CoinTypeApplyVO
)
=>
{
let
func_name
=
"coinTypeApply.control.rewrite"
;
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUser
=
await
getCurrentUser
(
req
.
cookies
.
session_id
);
if
(
!
coinTypeApplyVO
.
id
)
{
throw
ErrorCode
.
PARAM_MISS
}
let
res
=
await
coinTypeApplyService
.
rewrite
(
coinTypeApplyVO
.
id
,
coinTypeApplyVO
.
reason
,
currentUser
,
ip
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* 技术部-上币管理-上币申请-管理员取消申请上新币
* @param req
* @param authConfigVO
*/
export
const
cancel
=
async
(
req
:
any
,
coinTypeApplyVO
:
CoinTypeApplyVO
)
=>
{
let
func_name
=
"coinTypeApply.control.cancel"
;
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUser
=
await
getCurrentUser
(
req
.
cookies
.
session_id
);
if
(
!
coinTypeApplyVO
.
id
)
{
throw
ErrorCode
.
PARAM_MISS
}
let
res
=
await
coinTypeApplyService
.
cancel
(
coinTypeApplyVO
.
id
,
coinTypeApplyVO
.
reason
,
currentUser
,
ip
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* 技术部-上币管理-上币申请-审核申请上新币
* @param req
* @param authConfigVO
*/
export
const
review
=
async
(
req
:
any
,
coinTypeApplyVO
:
CoinTypeApplyVO
)
=>
{
let
func_name
=
"coinTypeApply.control.review"
;
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUser
=
await
getCurrentUser
(
req
.
cookies
.
session_id
);
if
(
!
coinTypeApplyVO
.
id
)
{
throw
ErrorCode
.
PARAM_MISS
}
let
res
=
await
coinTypeApplyService
.
review
(
coinTypeApplyVO
.
id
,
currentUser
,
ip
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
async
function
paramValid
(
coinTypeApplyVO
:
CoinTypeApplyVO
)
{
if
(
!
coinTypeApplyVO
.
symbol
||
!
coinTypeApplyVO
.
name
||
!
coinTypeApplyVO
.
original_decimals
||
!
coinTypeApplyVO
.
valid_decimals
||
!
coinTypeApplyVO
.
deposit_confirm_count
||
!
coinTypeApplyVO
.
safe_confirm_count
||
!
coinTypeApplyVO
.
withdraw_fee
||
!
coinTypeApplyVO
.
withdraw_min
||
!
coinTypeApplyVO
.
max_transfer_amount
)
{
throw
ErrorCode
.
PARAM_MISS
;
}
if
(
!
coinTypeApplyVO
.
is_erc20
)
{
coinTypeApplyVO
.
is_erc20
=
0
}
let
tm
=
datetimeUtils
.
add
(
new
Date
(),
datetimeUtils
.
SECONED
*
10
);
if
(
!
coinTypeApplyVO
.
tm_enable_deposit
||
datetimeUtils
.
between
(
coinTypeApplyVO
.
tm_enable_deposit
,
tm
)
<
0
)
{
throw
ErrorCode
.
PARAM_MISS
;
}
if
(
!
coinTypeApplyVO
.
tm_enable_withdraw
||
datetimeUtils
.
between
(
coinTypeApplyVO
.
tm_enable_withdraw
,
tm
)
<
0
)
{
throw
ErrorCode
.
PARAM_MISS
;
}
}
src/functional/mvc/control/commonUserFeeSetting.control.ts
View file @
a5b9e71b
...
...
@@ -219,8 +219,8 @@ async function updateParamValid(commonUserFeeVO: CommonUserFeeVO) {
*/
async
function
paramCheck
(
beginTime
:
any
,
expireTime
:
any
,
type
:
number
,
userId
:
number
)
{
//结束时间最少需要是一小时后;开始时间和结束时间最少需要间隔一小时
if
(
!
datetimeUtils
.
between
(
expireTime
,
new
Date
())
>
datetimeUtils
.
HOUR
||
!
datetimeUtils
.
between
(
expireTime
,
beginTime
)
>
datetimeUtils
.
HOUR
)
{
if
(
datetimeUtils
.
between
(
expireTime
,
new
Date
())
<
datetimeUtils
.
HOUR
||
datetimeUtils
.
between
(
expireTime
,
beginTime
)
<
datetimeUtils
.
HOUR
)
{
throw
ErrorCode
.
PARAM_MISS
;
}
if
(
isNaN
(
Number
(
type
))
||
!
FEE_TYPE_LIST
.
includes
(
Number
(
type
)))
{
...
...
src/functional/mvc/control/spotPair.control.ts
View file @
a5b9e71b
...
...
@@ -60,13 +60,15 @@ export const update = async (req: any, param: AddParam) => {
}
};
export
const
pushToCoreSystem
=
async
(
req
:
any
,
id
:
any
)
=>
{
//提交到撮合
export
const
pushToCoreSystem
=
async
(
req
:
any
,
param
:
AddParam
)
=>
{
let
func_name
=
"spotPairCtl.pushToCoreSystem"
;
let
cmd
=
req
.
path
;
try
{
ApiAssert
.
notNull
(
'3000'
,
id
);
let
res
=
await
service
.
pushToCoreSystem
(
id
);
ApiAssert
.
notNull
(
'3000'
,
param
.
id
);
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUserId
=
await
getCurrentUserId
(
req
.
cookies
.
session_id
);
let
res
=
await
service
.
pushToCoreSystem
(
param
.
id
,
currentUserId
,
ip
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
...
...
src/functional/mvc/service/aclUser.service.ts
View file @
a5b9e71b
...
...
@@ -70,10 +70,11 @@ export interface AclUserInfoPageVO extends AclUserInfoVO {
export
const
list
=
async
(
aclUserInfoPageVO
:
AclUserInfoPageVO
)
=>
{
let
where
=
{}
if
(
!
aclUserInfoPageVO
.
account
)
{
where
=
{};
where
=
{
del_flag
:
0
};
}
else
if
(
!
isNaN
(
Number
(
aclUserInfoPageVO
.
account
)))
{
where
=
{
del_flag
:
0
,
[
madAdminOrmDB
.
Op
.
or
]:
{
user_id
:
Number
(
aclUserInfoPageVO
.
account
),
account
:
{
[
madAdminOrmDB
.
Op
.
like
]:
`
${
aclUserInfoPageVO
.
account
}
%`
},
...
...
@@ -83,6 +84,7 @@ export const list = async (aclUserInfoPageVO: AclUserInfoPageVO) => {
}
else
{
where
=
{
del_flag
:
0
,
[
madAdminOrmDB
.
Op
.
or
]:
{
account
:
{
[
madAdminOrmDB
.
Op
.
like
]:
`
${
aclUserInfoPageVO
.
account
}
%`
},
email
:
{
[
madAdminOrmDB
.
Op
.
like
]:
`
${
aclUserInfoPageVO
.
account
}
%`
},
...
...
@@ -215,7 +217,7 @@ export const update = async (aclUserInfoVO: AclUserInfoVO, session_id: any) => {
if
(
aclUserInfoVO
.
allow_ips
!=
dbInfo
.
allow_ips
)
{
updateInfo
[
'allow_ips'
]
=
aclUserInfoVO
.
allow_ips
}
if
(
aclUserInfoVO
.
pwd
&&
aclUserInfoVO
.
pwd
!=
dbInfo
.
pwd
)
{
if
(
aclUserInfoVO
.
pwd
&&
aclUserInfoVO
.
pwd
!=
dbInfo
.
pwd
)
{
let
encrypted
=
await
AuthCommon
.
getPasswordEncrypt
(
aclUserInfoVO
.
pwd
,
dbInfo
.
pwd_salt
);
updateInfo
[
'pwd'
]
=
encrypted
;
updateInfo
[
'pwd_status'
]
=
1
;
...
...
@@ -226,6 +228,9 @@ export const update = async (aclUserInfoVO: AclUserInfoVO, session_id: any) => {
if
(
aclUserInfoVO
.
totp_encrypt
!=
dbInfo
.
totp_encrypt
)
{
updateInfo
[
'totp_encrypt'
]
=
aclUserInfoVO
.
totp_encrypt
}
if
(
aclUserInfoVO
.
del_flag
!=
dbInfo
.
del_flag
)
{
updateInfo
[
'del_flag'
]
=
aclUserInfoVO
.
del_flag
}
let
tx
;
...
...
@@ -365,7 +370,7 @@ export const optLogList = async (aclUserInfoPageVO: AclUserInfoPageVO) => {
module
:
{
[
madAdminOrmDB
.
Op
.
like
]:
`%
${
aclUserInfoPageVO
.
condition
}
%`
},
}
}
if
(
aclUserInfoPageVO
.
from_time
&&
aclUserInfoPageVO
.
to_time
){
if
(
aclUserInfoPageVO
.
from_time
&&
aclUserInfoPageVO
.
to_time
)
{
where
[
'createdAt'
]
=
{
[
ormDB
.
Op
.
between
]:
[
aclUserInfoPageVO
.
from_time
,
aclUserInfoPageVO
.
to_time
]
}
}
...
...
src/functional/mvc/service/coinType.service.ts
View file @
a5b9e71b
...
...
@@ -126,34 +126,7 @@ export async function list(param: ListParam) {
export
const
save
=
async
(
param
:
AddParam
,
currentUserId
:
any
,
ip
:
any
)
=>
{
param
.
updatedAt
=
new
Date
();
param
.
createdAt
=
new
Date
();
let
tx
;
try
{
tx
=
await
ormDB
.
transaction
();
let
insertInfo
=
await
coinType
.
prototype
.
create
(
param
,
{
transaction
:
tx
});
//TODO:目前方便调试先注释掉,之后正式测试时候需要解开注释
/*//提交到撮合
if (param.is_main) {
let optResult = await addCoin2Core(insertInfo.general_name, insertInfo.id);
if (!optResult) {
throw ErrorCode.ADD_PAIR_TO_CORE_ERR;
}
await coinType.prototype.update({ main_status: 1 }, {
where: {
id: insertInfo.id
}
})
}*/
await
tx
.
commit
();
}
catch
(
e
)
{
logger
.
error
(
'coinTypeService.save.error:'
+
e
);
if
(
tx
)
{
await
tx
.
rollback
();
}
throw
e
;
}
await
coinType
.
prototype
.
create
(
param
);
//管理后台操作日志
addOptLog
(
currentUserId
,
0
,
'币种管理新增'
,
ip
,
JSON
.
stringify
(
param
),
'币种管理'
);
return
'ok'
;
...
...
@@ -179,23 +152,29 @@ export const update = async (param: AddParam, currentUserId: any, ip: any) => {
return
'ok'
;
};
export
const
pushToCoreSystem
=
async
(
id
:
any
)
=>
{
export
const
pushToCoreSystem
=
async
(
id
:
any
,
currentUserId
:
any
,
ip
:
any
)
=>
{
let
where
=
{
id
:
id
,
main_status
:
0
,
is_main
:
1
};
let
cfg
=
await
coinType
.
prototype
.
find
({
where
:
where
,
raw
:
true
});
if
(
cfg
)
{
let
symbol
=
cfg
.
general_name
;
let
optResult
=
await
addCoin2Core
(
symbol
,
cfg
.
id
);
if
(
optResult
)
{
await
coinType
.
prototype
.
update
({
main_status
:
1
},
{
where
:
where
})
}
if
(
!
cfg
)
{
throw
ErrorCode
.
SUBMIT_STATUS_OR_MAIN_ERR
;
}
let
symbol
=
cfg
.
general_name
;
let
optResult
=
await
addCoin2Core
(
symbol
,
cfg
.
id
);
if
(
!
optResult
.
is_success
)
{
//管理后台操作日志
addOptLog
(
currentUserId
,
0
,
'提交币种到撮合-失败'
,
ip
,
`symbol:
${
symbol
}
,error_msg:
${
optResult
.
err_msg
}
`
,
'币种管理'
);
throw
ErrorCode
.
ADD_PAIR_TO_CORE_ERR
;
}
await
coinType
.
prototype
.
update
({
main_status
:
1
},
{
where
:
where
});
//管理后台操作日志
addOptLog
(
currentUserId
,
0
,
'提交币种到撮合-成功'
,
ip
,
`symbol:
${
symbol
}
`
,
'币种管理'
);
return
'ok'
;
};
...
...
src/functional/mvc/service/coinTypeApply.service.ts
0 → 100644
View file @
a5b9e71b
This diff is collapsed.
Click to expand it.
src/functional/mvc/service/commonUserFeeSetting.service.ts
View file @
a5b9e71b
...
...
@@ -74,6 +74,9 @@ export async function list(pageVO: CommonUserFeePageVO) {
if
(
pageVO
.
export
)
{
let
resList
=
await
commonUserFeeSetting
.
prototype
.
findAll
({
where
:
{
status
:
{
[
ormDB
.
Op
.
ne
]:
4
}
},
order
:
[[
'id'
,
'desc'
]],
raw
:
true
});
...
...
@@ -83,6 +86,7 @@ export async function list(pageVO: CommonUserFeePageVO) {
if
(
pageVO
.
user_id
)
{
where
.
user_id
=
pageVO
.
user_id
;
}
where
.
status
=
{
[
ormDB
.
Op
.
ne
]:
4
};
if
(
pageVO
.
type
)
{
where
.
type
=
pageVO
.
type
;
}
...
...
src/functional/mvc/service/spotPair.service.ts
View file @
a5b9e71b
...
...
@@ -80,46 +80,8 @@ export async function list(param: ListParam) {
export
const
save
=
async
(
param
:
AddParam
,
currentUserId
:
any
,
ip
:
any
)
=>
{
param
.
updatedAt
=
new
Date
();
param
.
createdAt
=
new
Date
();
let
tx
;
try
{
tx
=
await
madSpotOrmDB
.
transaction
();
//数据库新增
let
insertInfo
=
await
spotPairs
.
prototype
.
create
(
param
,
{
transaction
:
tx
});
//TODO:目前方便调试先注释掉,之后正式测试时候需要解开注释
/*//提交到撮合
let symbol = insertInfo.symbol;
let sps = symbol.split("_");
let base = sps[0];
let quote = sps[1]
let toCoreParam = {
"base": base, "quote": quote, "symbol": symbol, "name": symbol,
"price_scale": insertInfo.price_scale, "quantity_scale": insertInfo.quantity_scale,
"maker_fee": insertInfo.maker_fee, "taker_fee": insertInfo.taker_fee
}
let optResult = await addPairToCore(toCoreParam);
if (!optResult) {
throw ErrorCode.ADD_PAIR_TO_CORE_ERR;
}
if (!insertInfo.id) {
throw ErrorCode.DATA_NOT_EXIST
}
await spotPairs.prototype.update({ status: 1 }, {
where: {
id: insertInfo.id
},
transaction: tx
});*/
await
tx
.
commit
();
}
catch
(
e
)
{
logger
.
error
(
'spotPairService.save.error:'
+
e
);
if
(
tx
)
{
await
tx
.
rollback
();
}
throw
e
;
}
await
spotPairs
.
prototype
.
create
(
param
);
//管理后台操作日志
addOptLog
(
currentUserId
,
0
,
'交易对配置新增'
,
ip
,
JSON
.
stringify
(
param
),
'交易对配置'
);
return
'ok'
;
...
...
@@ -157,30 +119,36 @@ export const update = async (param: AddParam, currentUserId: any, ip: any) => {
return
'ok'
;
};
export
const
pushToCoreSystem
=
async
(
id
:
any
)
=>
{
export
const
pushToCoreSystem
=
async
(
id
:
any
,
currentUserId
:
any
,
ip
:
any
)
=>
{
let
where
=
{
id
:
id
,
status
:
0
};
let
cfg
=
await
spotPairs
.
prototype
.
find
({
where
:
where
,
raw
:
true
});
if
(
cfg
)
{
let
symbol
=
cfg
.
symbol
;
let
sps
=
symbol
.
split
(
"_"
);
let
base
=
sps
[
0
];
let
quote
=
sps
[
1
]
let
param
=
{
"base"
:
base
,
"quote"
:
quote
,
"symbol"
:
symbol
,
"name"
:
symbol
,
"price_scale"
:
cfg
.
price_scale
,
"quantity_scale"
:
cfg
.
quantity_scale
,
"maker_fee"
:
cfg
.
maker_fee
,
"taker_fee"
:
cfg
.
taker_fee
}
let
optResult
=
await
addPairToCore
(
param
);
if
(
optResult
)
{
await
spotPairs
.
prototype
.
update
({
status
:
1
},
{
where
:
where
});
}
if
(
!
cfg
)
{
throw
ErrorCode
.
SUBMIT_STATUS_ERR
;
}
let
symbol
=
cfg
.
symbol
;
let
sps
=
symbol
.
split
(
"_"
);
let
base
=
sps
[
0
];
let
quote
=
sps
[
1
]
let
param
=
{
"base"
:
base
,
"quote"
:
quote
,
"symbol"
:
symbol
,
"name"
:
symbol
,
"price_scale"
:
cfg
.
price_scale
,
"quantity_scale"
:
cfg
.
quantity_scale
,
"maker_fee"
:
cfg
.
maker_fee
,
"taker_fee"
:
cfg
.
taker_fee
}
let
optResult
=
await
addPairToCore
(
param
);
if
(
!
optResult
.
is_success
)
{
//管理后台操作日志
addOptLog
(
currentUserId
,
0
,
'提交交易对到撮合-失败'
,
ip
,
`pair:
${
symbol
}
,error_msg:
${
optResult
.
err_msg
}
`
,
'交易对配置'
);
throw
ErrorCode
.
ADD_PAIR_TO_CORE_ERR
;
}
await
spotPairs
.
prototype
.
update
({
status
:
1
},
{
where
:
where
});
//管理后台操作日志
addOptLog
(
currentUserId
,
0
,
'提交交易对到撮合-成功'
,
ip
,
JSON
.
stringify
(
param
),
'交易对配置'
);
return
'ok'
;
};
...
...
src/functional/router/v1/index.ts
View file @
a5b9e71b
...
...
@@ -42,6 +42,7 @@ import * as contractMarketMakerCtrl from "../../mvc/control/contractMarketMaker.
import
*
as
contractLimitTradeCtrl
from
"../../mvc/control/contractLimitTrade.control"
;
import
*
as
contractAgentCtrl
from
"../../mvc/control/contractAgent.control"
;
import
*
as
depositAndWithdrawCtrl
from
"../../mvc/control/depositAndWithdraw.control"
;
import
*
as
coinTypeApplyCtrl
from
"../../mvc/control/coinTypeApply"
;
const
getFunc
=
{
'user/info'
:
userController
.
getUserInfo
,
...
...
@@ -224,6 +225,17 @@ const postFunc = {
'custom/fund/deposit/record/list'
:
depositAndWithdrawCtrl
.
depositList
,
//客服部-资金管理-提现管理
'custom/fund/withdraw/record/list'
:
depositAndWithdrawCtrl
.
withdrawList
,
//技术部-上币管理-上币申请
'tech/apply/new/coin/list'
:
coinTypeApplyCtrl
.
list
,
//申请上新币列表
'tech/apply/new/coin/apply'
:
coinTypeApplyCtrl
.
apply
,
//申请上新币
'tech/apply/new/coin/apply/cancel/self'
:
coinTypeApplyCtrl
.
cancelSelf
,
//撤销申请上新币
'tech/apply/new/coin/apply/edit'
:
coinTypeApplyCtrl
.
edit
,
//编辑申请上新币
'tech/apply/new/coin/apply/review'
:
coinTypeApplyCtrl
.
review
,
//审核申请上新币
'tech/apply/new/coin/apply/rewrite'
:
coinTypeApplyCtrl
.
rewrite
,
//驳回申请上新币
'tech/apply/new/coin/apply/cancel'
:
coinTypeApplyCtrl
.
cancel
,
//管理员取消申请上新币
'tech/apply/new/coin/explore/url/list'
:
coinTypeApplyCtrl
.
exploreUrlList
,
//交易浏览器列表
'tech/apply/new/coin/listed'
:
coinTypeApplyCtrl
.
listed
,
//已有币种列表
};
// TODO 这里先和 nodejs 的注册路由方式保持一样,后面在调整。
...
...
src/setting/access-limit.ts
View file @
a5b9e71b
...
...
@@ -175,6 +175,16 @@ let cmdWhiteList = {
'custom/fund/deposit/record/list'
:
1
,
//客服部-资金管理-提现管理
'custom/fund/withdraw/record/list'
:
1
,
//技术部-上币管理-上币申请
'tech/apply/new/coin/list'
:
1
,
'tech/apply/new/coin/apply'
:
1
,
'tech/apply/new/coin/apply/cancel/self'
:
1
,
'tech/apply/new/coin/apply/edit'
:
1
,
'tech/apply/new/coin/apply/review'
:
1
,
'tech/apply/new/coin/apply/rewrite'
:
1
,
'tech/apply/new/coin/apply/cancel'
:
1
,
'tech/apply/new/coin/explore/url/list'
:
1
,
'tech/apply/new/coin/listed'
:
1
,
};
...
...
src/utils/coreSystemUtils.ts
View file @
a5b9e71b
...
...
@@ -3,16 +3,17 @@ import { coinType } from "@madex/ex-ts-dao";
const
axios
=
require
(
"axios"
);
const
_
=
require
(
"lodash"
);
import
configSetting
from
"./../../config"
import
configSetting
from
"./../../config"
const
webadmin_endpoint
=
configSetting
.
webadmin_endpoint
let
{
logger
}
=
require
(
'@madex/ex-js-public'
);
// { id: 1, symbol: 'BTC' }
export
const
getCoinFromCore
=
async
(
symbol
)
=>
{
export
const
getCoinFromCore
=
async
(
symbol
)
=>
{
const
url
=
`
${
webadmin_endpoint
}
/asset/by_symbol?symbol=
${
symbol
}
`
let
{
data
}
=
await
axios
.
get
(
url
);
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"getCoinFromCore"
,
data
.
msg
);
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"getCoinFromCore"
,
data
.
msg
);
return
null
}
return
data
.
result
[
0
];
...
...
@@ -26,11 +27,11 @@ export const getCoinFromCore = async(symbol)=> {
// 'quantity-scale': 2,
// 'quantity-increment': '0'
// }
export
const
getPairFromCore
=
async
(
symbol
,
market
=
"spot"
)
=>
{
export
const
getPairFromCore
=
async
(
symbol
,
market
=
"spot"
)
=>
{
const
url
=
`
${
webadmin_endpoint
}
/pair/by_symbol?symbol=
${
symbol
}
&market=
${
market
}
`
let
{
data
}
=
await
axios
.
get
(
url
);
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"getPairFromCore"
,
data
.
msg
);
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"getPairFromCore"
,
data
.
msg
);
return
null
}
return
data
.
result
[
0
]
...
...
@@ -38,27 +39,27 @@ export const getPairFromCore = async(symbol,market="spot")=> {
// res:
// [{"name":"BTC","asset":1,"balance":"10","holds":"0"}]
export
const
getUserAccountFromCore
=
async
(
userId
,
withName
=
true
)
=>
{
export
const
getUserAccountFromCore
=
async
(
userId
,
withName
=
true
)
=>
{
const
url
=
`
${
webadmin_endpoint
}
/account/list?user_id=
${
userId
}
`
let
{
data
}
=
await
axios
.
get
(
url
);
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"get
PairFromCore"
,
data
.
msg
);
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"get
UserAccountFromCore"
,
data
.
msg
);
return
null
}
let
assets
=
data
.
result
let
assets
=
data
.
result
let
asset_id
=
_
.
map
(
assets
,
'asset'
);
let
asset_id
=
_
.
map
(
assets
,
'asset'
);
if
(
withName
)
{
let
names
=
await
coinType
.
prototype
.
findAll
({
attributes
:
[
'general_name'
,
'asset_id'
],
where
:{
attributes
:
[
'general_name'
,
'asset_id'
],
where
:
{
asset_id
,
is_main
:
1
is_main
:
1
},
raw
:
true
raw
:
true
})
let
m
=
_
.
keyBy
(
names
,
'asset_id'
);
let
m
=
_
.
keyBy
(
names
,
'asset_id'
);
for
(
const
item
of
assets
)
{
if
(
m
[
item
.
asset
])
{
item
.
name
=
m
[
item
.
asset
].
general_name
...
...
@@ -79,12 +80,12 @@ export const getUserAccountFromCore = async(userId,withName = true)=> {
// limit, / 数量
// res:
// [{"orderId":"4611689316962271233","clientOrderId":"","createTime":"1725261917795","product":"BTC_USDT","type":1,"side":"buy","quantity":"1","stf":"disabled","price":"9999.0000","visibleQty":"1","timeInForce":"gtc","cancelAfter":0,"postOnly":false,"status":"accepted","executedQty":"0","fillCount":0,"fills":[],"fees":[],"updateTime":"1725261917795"},{"orderId":"4611689316962271234","clientOrderId":"","createTime":"1725261919337","product":"BTC_USDT","type":1,"side":"buy","quantity":"1","stf":"disabled","price":"9998.0000","visibleQty":"1","timeInForce":"gtc","cancelAfter":0,"postOnly":false,"status":"accepted","executedQty":"0","fillCount":0,"fills":[],"fees":[],"updateTime":"1725261919337"}]
export
const
getUserOrdersFromCore
=
async
(
params
)
=>
{
export
const
getUserOrdersFromCore
=
async
(
params
)
=>
{
// let params = new URLSearchParams();
const
url
=
`
${
webadmin_endpoint
}
/order/list`
let
{
data
}
=
await
axios
.
get
(
url
,
{
params
});
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"get
PairFromCore"
,
data
.
msg
);
let
{
data
}
=
await
axios
.
get
(
url
,
{
params
});
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"get
UserOrdersFromCore"
,
data
.
msg
);
return
null
}
return
data
.
result
...
...
@@ -98,12 +99,12 @@ export const getUserOrdersFromCore = async(params)=> {
// after, // update_id
// limit, / 数量
// order_id 可选
export
const
getUserFillsFromCore
=
async
(
params
)
=>
{
export
const
getUserFillsFromCore
=
async
(
params
)
=>
{
// let params = new URLSearchParams();
const
url
=
`
${
webadmin_endpoint
}
/fill/list`
let
{
data
}
=
await
axios
.
get
(
url
,
{
params
});
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"getUserFillsFromCore"
,
data
.
msg
);
let
{
data
}
=
await
axios
.
get
(
url
,
{
params
});
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"getUserFillsFromCore"
,
data
.
msg
);
return
null
}
return
data
.
result
...
...
@@ -112,27 +113,37 @@ export const getUserFillsFromCore = async(params)=> {
// getUserOrdersFromCore({user_id:1})
export
const
addCoin2Core
=
async
(
symbol
,
id
)
=>
{
export
const
addCoin2Core
=
async
(
symbol
,
id
)
=>
{
let
res
=
{
is_success
:
true
,
err_msg
:
""
}
const
url
=
`
${
webadmin_endpoint
}
/asset/add`
let
body
=
{
"symbol"
:
symbol
,
"id"
:
id
,
let
body
=
{
"symbol"
:
symbol
,
"id"
:
id
,
}
let
{
data
}
=
await
axios
.
post
(
url
,
body
);
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"getUserFillsFromCore"
,
data
.
msg
);
return
false
let
{
data
}
=
await
axios
.
post
(
url
,
body
);
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"addCoin2Core"
,
data
.
msg
);
res
.
is_success
=
false
;
res
.
err_msg
=
data
.
msg
;
}
return
true
;
return
res
;
}
export
const
addPairToCore
=
async
(
body
)
=>
{
export
const
addPairToCore
=
async
(
body
)
=>
{
let
res
=
{
is_success
:
true
,
err_msg
:
""
}
const
url
=
`
${
webadmin_endpoint
}
/pair/add_product`
let
{
data
}
=
await
axios
.
post
(
url
,
body
);
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"getUserFillsFromCore"
,
data
.
msg
);
return
false
let
{
data
}
=
await
axios
.
post
(
url
,
body
);
if
(
data
.
state
!=
0
)
{
logger
.
error
(
"addPairToCore"
,
data
.
msg
);
res
.
is_success
=
false
;
res
.
err_msg
=
data
.
msg
;
}
return
true
;
return
res
;
}
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