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
55eb492a
Commit
55eb492a
authored
Oct 08, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加接口、逻辑调整
parent
a892a03e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
729 additions
and
0 deletions
+729
-0
errorCode.ts
src/constant/errorCode.ts
+3
-0
pairApplyConst.ts
src/constant/pairApplyConst.ts
+11
-0
pairApply.ts
src/functional/mvc/control/pairApply.ts
+225
-0
coinTypeApply.service.ts
src/functional/mvc/service/coinTypeApply.service.ts
+3
-0
pairApply.service.ts
src/functional/mvc/service/pairApply.service.ts
+465
-0
index.ts
src/functional/router/v1/index.ts
+11
-0
access-limit.ts
src/setting/access-limit.ts
+11
-0
No files found.
src/constant/errorCode.ts
View file @
55eb492a
...
...
@@ -69,4 +69,7 @@ export const ErrorCode = {
NO_CANCEL
:
'30065'
,
//审核已通过不允许撤销
DEPOSIT_WITHDRAW_TM_EXPIRE
:
'30066'
,
//开放充值时间/开放提现时间过短
CURRENT_STATUS_NOT_APPLY
:
'30067'
,
//当前状态不可以审核
CURRENT_COIN_DATA_NOT_EXIST
:
'30068'
,
//币种管理中计价币种不存在
PAIR_EXIST
:
'30069'
,
//交易对对已存在
ACTIVE_TM_EXPIRE
:
'30070'
,
//交易时间过短
}
src/constant/pairApplyConst.ts
0 → 100644
View file @
55eb492a
export
const
PAIR_APPLY_STATUS
=
{
RE_WRITE
:
1
,
// 被驳回
WAIT_VIEW
:
2
,
// 申请待审批
PASS
:
3
,
// 审批通过
CREATE_PAIR
:
4
,
// 交易对创建完成
ADMIN_ADD_PAIR
:
5
,
// 交易对增加到撮合完成
WAIT_ADMIN_RESTART
:
6
,
// 等待撮合系统重启
ADMIN_ISSUE_PAIR
:
7
,
// 发布交易对到撮合完成
TIMER_ACTIVE
:
8
,
// 交易对激活定时器完成
CANCEL
:
9
,
// 取消
}
\ No newline at end of file
src/functional/mvc/control/pairApply.ts
0 → 100644
View file @
55eb492a
import
*
as
pairApplyService
from
"../service/pairApply.service"
;
import
{
PairApplyVO
,
PairApplyPageVO
}
from
"../service/pairApply.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
:
PairApplyPageVO
)
=>
{
let
func_name
=
"pairApply.control.list"
;
try
{
pageVO
.
page
=
Optional
.
opt
(
pageVO
,
'page'
,
1
);
pageVO
.
size
=
Optional
.
opt
(
pageVO
,
'size'
,
20
);
let
res
=
await
pairApplyService
.
list
(
pageVO
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* TODO:现在查询的是spot_pairs 原来是ex_pair 后期是否需要调整?
* 技术部-交易上下线管理-已有交易对列表
* @param req
* @param infoVO
*/
export
const
listed
=
async
(
req
:
any
,
pageVO
:
PairApplyPageVO
)
=>
{
let
func_name
=
"pairApply.control.listed"
;
try
{
pageVO
.
page
=
Optional
.
opt
(
pageVO
,
'page'
,
1
);
pageVO
.
size
=
Optional
.
opt
(
pageVO
,
'size'
,
20
);
let
res
=
await
pairApplyService
.
listed
(
pageVO
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* 技术部-交易上下线管理-已有交易区列表
* @param req
* @param infoVO
*/
export
const
tradeAreaList
=
async
(
req
:
any
,
pageVO
:
PairApplyPageVO
)
=>
{
let
func_name
=
"pairApply.control.tradeAreaList"
;
try
{
pageVO
.
page
=
Optional
.
opt
(
pageVO
,
'page'
,
1
);
pageVO
.
size
=
Optional
.
opt
(
pageVO
,
'size'
,
20
);
let
res
=
await
pairApplyService
.
tradeAreaList
(
pageVO
);
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
,
pairApplyVO
:
PairApplyVO
)
=>
{
let
func_name
=
"pairApply.control.apply"
;
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUser
=
await
getCurrentUser
(
req
.
cookies
.
session_id
);
await
paramValid
(
pairApplyVO
);
let
res
=
await
pairApplyService
.
apply
(
pairApplyVO
,
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
,
pairApplyVO
:
PairApplyVO
)
=>
{
let
func_name
=
"pairApply.control.edit"
;
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUser
=
await
getCurrentUser
(
req
.
cookies
.
session_id
);
if
(
!
pairApplyVO
.
id
)
{
throw
ErrorCode
.
PARAM_MISS
}
await
paramValid
(
pairApplyVO
);
let
res
=
await
pairApplyService
.
edit
(
pairApplyVO
,
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
,
pairApplyVO
:
PairApplyVO
)
=>
{
let
func_name
=
"pairApply.control.cancelSelf"
;
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUser
=
await
getCurrentUser
(
req
.
cookies
.
session_id
);
if
(
!
pairApplyVO
.
id
)
{
throw
ErrorCode
.
PARAM_MISS
}
let
res
=
await
pairApplyService
.
cancelSelf
(
pairApplyVO
.
id
,
pairApplyVO
.
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
,
pairApplyVO
:
PairApplyVO
)
=>
{
let
func_name
=
"pairApply.control.rewrite"
;
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUser
=
await
getCurrentUser
(
req
.
cookies
.
session_id
);
if
(
!
pairApplyVO
.
id
)
{
throw
ErrorCode
.
PARAM_MISS
}
let
res
=
await
pairApplyService
.
rewrite
(
pairApplyVO
.
id
,
pairApplyVO
.
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
,
pairApplyVO
:
PairApplyVO
)
=>
{
let
func_name
=
"pairApply.control.cancel"
;
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUser
=
await
getCurrentUser
(
req
.
cookies
.
session_id
);
if
(
!
pairApplyVO
.
id
)
{
throw
ErrorCode
.
PARAM_MISS
}
let
res
=
await
pairApplyService
.
cancel
(
pairApplyVO
.
id
,
pairApplyVO
.
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
,
pairApplyVO
:
PairApplyVO
)
=>
{
let
func_name
=
"pairApply.control.review"
;
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUser
=
await
getCurrentUser
(
req
.
cookies
.
session_id
);
if
(
!
pairApplyVO
.
id
)
{
throw
ErrorCode
.
PARAM_MISS
}
let
res
=
await
pairApplyService
.
review
(
pairApplyVO
.
id
,
currentUser
,
ip
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
async
function
paramValid
(
pairApplyVO
:
PairApplyVO
)
{
if
(
!
pairApplyVO
.
coin_symbol
||
!
pairApplyVO
.
currency_symbol
||
!
pairApplyVO
.
decimal
||
!
pairApplyVO
.
qtyPrecision
||
!
pairApplyVO
.
weight
||
!
pairApplyVO
.
baseMinValue
||
!
pairApplyVO
.
quoteMinValue
)
{
throw
ErrorCode
.
PARAM_MISS
;
}
if
(
!
pairApplyVO
.
pair_type
)
{
pairApplyVO
.
pair_type
=
0
}
if
(
!
pairApplyVO
.
area_id
)
{
pairApplyVO
.
area_id
=
0
}
if
(
!
pairApplyVO
.
business_area_id
)
{
pairApplyVO
.
business_area_id
=
0
}
let
tm
=
datetimeUtils
.
add
(
new
Date
(),
datetimeUtils
.
SECONED
*
10
);
if
(
!
pairApplyVO
.
tm_active
||
datetimeUtils
.
between
(
pairApplyVO
.
tm_active
,
tm
)
<
0
)
{
throw
ErrorCode
.
PARAM_MISS
;
}
}
src/functional/mvc/service/coinTypeApply.service.ts
View file @
55eb492a
...
...
@@ -361,6 +361,9 @@ export async function review(id: any, currentUser: any, ip: string | undefined)
if
(
!
res
.
is_success
)
{
throw
ErrorCode
.
ADD_PAIR_TO_CORE_ERR
;
}
await
coinType
.
prototype
.
update
({
main_status
:
1
},
{
where
:
{
id
:
dbSymbol
.
id
}
});
reason
=
"增加币种到撮合完成"
;
await
updateApply
(
Number
(
id
),
APPLY_STATUS
.
TO_ADMIN
,
currentUser
.
account
,
reason
,
dbApply
.
symbol
);
}
...
...
src/functional/mvc/service/pairApply.service.ts
0 → 100644
View file @
55eb492a
import
{
exPairApply
,
coinType
,
ormDB
,
systemTrigger
,
spotPairs
,
exTradeArea
,
exBusinessAreaRouter
}
from
"@madex/ex-ts-dao"
;
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
import
{
addOptLog
}
from
"./userOptLog.service"
;
import
{
addCoin2Core
,
addPairToCore
}
from
"../../../utils/coreSystemUtils"
;
import
{
PAIR_APPLY_STATUS
}
from
"../../../constant/pairApplyConst"
;
let
_
=
require
(
'lodash'
);
let
{
logger
,
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
export
interface
PairApplyVO
{
id
?:
number
;
coin_symbol
?:
string
;
currency_symbol
?:
string
;
maker_rate
?:
string
;
taker_rate
?:
string
;
pair_type
?:
number
;
area_id
?:
number
;
business_area_id
?:
number
;
decimal
?:
number
;
qtyPrecision
?:
number
;
weight
?:
number
;
tm_active
?:
Date
|
any
;
baseMinValue
?:
string
;
baseMaxValue
?:
string
;
quoteMinValue
?:
string
;
quoteMaxValue
?:
string
;
quoteIncrement
?:
string
;
applyer
?:
number
;
checker
?:
number
;
status
?:
number
;
reason
?:
string
;
createdAt
?:
Date
|
any
,
updatedAt
?:
Date
|
any
,
}
export
interface
PairApplyPageVO
extends
PairApplyVO
{
page
?:
number
,
size
?:
number
,
symbol
?:
string
;
is_active
?:
number
;
}
export
async
function
list
(
pageVO
:
PairApplyPageVO
)
{
let
resList
=
await
exPairApply
.
prototype
.
findAndCount
({
limit
:
pageVO
.
size
,
offset
:
(
Number
(
pageVO
.
page
)
-
1
)
*
Number
(
pageVO
.
size
),
order
:
[[
'status'
,
'asc'
],
[
"id"
,
"desc"
]],
raw
:
true
});
return
resList
;
}
export
async
function
listed
(
pageVO
:
PairApplyPageVO
)
{
let
where
=
{};
if
(
pageVO
.
symbol
)
{
where
[
'symbol'
]
=
pageVO
.
symbol
;
}
//TODO:是否查询此表 还是ex_pair ???
let
resList
=
await
spotPairs
.
prototype
.
findAndCount
({
where
:
where
,
limit
:
pageVO
.
size
,
offset
:
(
Number
(
pageVO
.
page
)
-
1
)
*
Number
(
pageVO
.
size
),
order
:
[[
"id"
,
"desc"
]],
raw
:
true
});
return
resList
;
}
export
async
function
tradeAreaList
(
pageVO
:
PairApplyPageVO
)
{
let
where
=
{};
if
(
pageVO
.
coin_symbol
)
{
where
[
'coin_symbol'
]
=
pageVO
.
coin_symbol
;
}
if
(
pageVO
.
is_active
||
pageVO
.
is_active
===
0
)
{
where
[
'is_active'
]
=
pageVO
.
is_active
;
}
let
resList
=
await
exTradeArea
.
prototype
.
findAndCount
({
where
:
where
,
limit
:
pageVO
.
size
,
offset
:
(
Number
(
pageVO
.
page
)
-
1
)
*
Number
(
pageVO
.
size
),
order
:
[[
"id"
,
"desc"
]],
raw
:
true
});
return
resList
;
}
export
async
function
apply
(
pairApplyVO
:
PairApplyVO
,
currentUser
:
any
,
ip
:
string
|
undefined
)
{
let
dbSymbol
=
await
coinType
.
prototype
.
findOne
({
where
:
{
symbol
:
pairApplyVO
.
coin_symbol
},
raw
:
true
});
if
(
!
dbSymbol
)
{
throw
ErrorCode
.
COIN_DATA_NOT_EXIST
;
}
let
dbCurrency
=
await
coinType
.
prototype
.
findOne
({
where
:
{
symbol
:
pairApplyVO
.
currency_symbol
},
raw
:
true
});
if
(
!
dbCurrency
)
{
throw
ErrorCode
.
CURRENT_COIN_DATA_NOT_EXIST
;
}
pairApplyVO
.
maker_rate
=
"0.001"
;
pairApplyVO
.
taker_rate
=
"0.002"
;
pairApplyVO
.
baseMaxValue
=
"100000000"
;
pairApplyVO
.
quoteMaxValue
=
"100000000"
;
pairApplyVO
.
applyer
=
currentUser
.
account
;
pairApplyVO
.
status
=
PAIR_APPLY_STATUS
.
WAIT_VIEW
;
pairApplyVO
.
createdAt
=
new
Date
();
pairApplyVO
.
updatedAt
=
new
Date
();
if
(
Number
(
pairApplyVO
.
id
)
>
0
)
{
//update
let
dbApply
=
await
exPairApply
.
prototype
.
findOne
({
where
:
{
id
:
pairApplyVO
.
id
},
raw
:
true
});
if
(
!
dbApply
)
{
throw
ErrorCode
.
DATA_NOT_EXIST
;
}
if
(
dbApply
.
status
!=
PAIR_APPLY_STATUS
.
RE_WRITE
)
{
throw
ErrorCode
.
NOT_EDIT
}
await
exPairApply
.
prototype
.
update
(
pairApplyVO
,
{
where
:
{
id
:
Number
(
pairApplyVO
.
id
)
}
});
}
else
{
await
exPairApply
.
prototype
.
create
(
pairApplyVO
);
}
sendMsg
(
pairApplyVO
.
status
,
pairApplyVO
.
coin_symbol
+
'_'
+
pairApplyVO
.
currency_symbol
);
//管理后台操作日志
addOptLog
(
currentUser
.
userId
,
0
,
'新增上新交易对申请'
,
ip
,
JSON
.
stringify
(
pairApplyVO
),
'交易上下线管理'
);
return
'success'
;
}
export
async
function
edit
(
pairApplyVO
:
PairApplyVO
,
currentUser
:
any
,
ip
:
string
|
undefined
)
{
let
dbApply
=
await
exPairApply
.
prototype
.
findOne
({
where
:
{
id
:
pairApplyVO
.
id
},
raw
:
true
});
if
(
!
dbApply
)
{
throw
ErrorCode
.
DATA_NOT_EXIST
;
}
if
(
Number
(
pairApplyVO
.
status
)
>=
PAIR_APPLY_STATUS
.
CREATE_PAIR
)
{
let
dbSymbol
=
await
coinType
.
prototype
.
findOne
({
where
:
{
symbol
:
pairApplyVO
.
coin_symbol
},
raw
:
true
});
if
(
!
dbSymbol
)
{
throw
ErrorCode
.
COIN_DATA_NOT_EXIST
;
}
let
dbCurrency
=
await
coinType
.
prototype
.
findOne
({
where
:
{
symbol
:
pairApplyVO
.
currency_symbol
},
raw
:
true
});
if
(
!
dbCurrency
)
{
throw
ErrorCode
.
CURRENT_COIN_DATA_NOT_EXIST
;
}
}
pairApplyVO
.
applyer
=
dbApply
.
applyer
;
pairApplyVO
.
updatedAt
=
new
Date
();
await
exPairApply
.
prototype
.
update
(
pairApplyVO
,
{
where
:
{
id
:
Number
(
pairApplyVO
.
id
)
}
});
sendMsg
(
Number
(
pairApplyVO
.
status
),
pairApplyVO
.
coin_symbol
+
'_'
+
pairApplyVO
.
currency_symbol
);
//管理后台操作日志
addOptLog
(
currentUser
.
userId
,
0
,
'上新交易对申请编辑'
,
ip
,
JSON
.
stringify
(
pairApplyVO
),
'交易上下线管理'
);
return
'success'
;
}
export
async
function
cancelSelf
(
id
:
any
,
reason
:
any
,
currentUser
:
any
,
ip
:
string
|
undefined
)
{
let
dbApply
=
await
exPairApply
.
prototype
.
findOne
({
where
:
{
id
:
id
},
raw
:
true
});
if
(
!
dbApply
)
{
throw
ErrorCode
.
DATA_NOT_EXIST
;
}
if
(
dbApply
.
status
>=
PAIR_APPLY_STATUS
.
PASS
)
{
throw
ErrorCode
.
NO_CANCEL
;
}
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
CANCEL
,
currentUser
.
account
,
String
(
reason
),
dbApply
.
coin_symbol
,
dbApply
.
currency_symbol
);
//管理后台操作日志
addOptLog
(
currentUser
.
userId
,
0
,
'撤销上新交易对申请'
,
ip
,
JSON
.
stringify
(
dbApply
),
'交易上下线管理'
);
return
'success'
;
}
export
async
function
rewrite
(
id
:
any
,
reason
:
any
,
currentUser
:
any
,
ip
:
string
|
undefined
)
{
let
dbApply
=
await
exPairApply
.
prototype
.
findOne
({
where
:
{
id
:
id
},
raw
:
true
});
if
(
!
dbApply
)
{
throw
ErrorCode
.
DATA_NOT_EXIST
;
}
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
RE_WRITE
,
currentUser
.
account
,
String
(
reason
),
dbApply
.
coin_symbol
,
dbApply
.
currency_symbol
);
//管理后台操作日志
addOptLog
(
currentUser
.
userId
,
0
,
'驳回上新交易对申请'
,
ip
,
JSON
.
stringify
(
dbApply
),
'交易上下线管理'
);
return
'success'
;
}
export
async
function
cancel
(
id
:
any
,
reason
:
any
,
currentUser
:
any
,
ip
:
string
|
undefined
)
{
let
dbApply
=
await
exPairApply
.
prototype
.
findOne
({
where
:
{
id
:
id
},
raw
:
true
});
if
(
!
dbApply
)
{
throw
ErrorCode
.
DATA_NOT_EXIST
;
}
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
CANCEL
,
currentUser
.
account
,
String
(
reason
),
dbApply
.
coin_symbol
,
dbApply
.
currency_symbol
);
//管理后台操作日志
addOptLog
(
currentUser
.
userId
,
0
,
'管理员取消上新交易对申请'
,
ip
,
JSON
.
stringify
(
dbApply
),
'交易上下线管理'
);
return
'success'
;
}
export
async
function
review
(
id
:
any
,
currentUser
:
any
,
ip
:
string
|
undefined
)
{
let
dbApply
=
await
exPairApply
.
prototype
.
findOne
({
where
:
{
id
:
id
},
raw
:
true
});
if
(
!
dbApply
)
{
throw
ErrorCode
.
DATA_NOT_EXIST
;
}
let
reason
=
""
;
//1被驳回 2申请待审批 3审批通过 4交易对创建完成 5交易对增加到撮合完成 6等待撮合系统重启 7发布交易对到撮合完成 8交易对激活定时器完成 9取消
let
status
=
Number
(
dbApply
.
status
)
let
pair
=
dbApply
.
coin_symbol
+
'_'
+
dbApply
.
currency_symbol
;
if
(
status
==
PAIR_APPLY_STATUS
.
WAIT_VIEW
)
{
//2-3
reason
=
"审核通过"
;
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
PASS
,
currentUser
.
account
,
reason
,
dbApply
.
coin_symbol
,
dbApply
.
currency_symbol
);
}
else
if
(
status
==
PAIR_APPLY_STATUS
.
PASS
)
{
//3-4
let
dbSymbol
=
await
coinType
.
prototype
.
findOne
({
where
:
{
symbol
:
dbApply
.
coin_symbol
},
raw
:
true
});
if
(
!
dbSymbol
)
{
throw
ErrorCode
.
COIN_DATA_NOT_EXIST
;
}
let
dbCurrency
=
await
coinType
.
prototype
.
findOne
({
where
:
{
symbol
:
dbApply
.
currency_symbol
},
raw
:
true
});
if
(
!
dbCurrency
)
{
throw
ErrorCode
.
CURRENT_COIN_DATA_NOT_EXIST
;
}
//TODO:确定是否查此表 原逻辑 查询ex_pair
let
dbPair
=
await
spotPairs
.
prototype
.
findOne
({
where
:
{
symbol
:
pair
},
raw
:
true
});
if
(
dbPair
)
{
throw
ErrorCode
.
PAIR_EXIST
;
}
let
insertInfo
=
{
symbol
:
pair
,
base
:
dbApply
.
coin_symbol
,
quote
:
dbApply
.
currency_symbol
,
name
:
pair
,
price_scale
:
dbApply
.
decimal
,
quantity_scale
:
dbApply
.
qtyPrecision
,
maker_fee
:
dbApply
.
maker_fee
,
taker_fee
:
dbApply
.
taker_fee
,
status
:
0
,
createdAt
:
new
Date
(),
updatedAt
:
new
Date
(),
}
//TODO:是否插入此表
await
spotPairs
.
prototype
.
create
(
insertInfo
);
let
areaRouterInfo
=
{
pair
:
pair
,
area_id
:
dbApply
.
business_area_id
,
weight
:
dbApply
.
weight
,
createdAt
:
new
Date
(),
updatedAt
:
new
Date
(),
}
await
exBusinessAreaRouter
.
prototype
.
create
(
areaRouterInfo
);
reason
=
"交易对创建完成"
;
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
CREATE_PAIR
,
currentUser
.
account
,
reason
,
dbApply
.
coin_symbol
,
dbApply
.
currency_symbol
);
}
else
if
(
status
==
PAIR_APPLY_STATUS
.
CREATE_PAIR
)
{
//4-5
//TODO:确定是否查此表 原逻辑 查询ex_pair
let
dbPair
=
await
spotPairs
.
prototype
.
findOne
({
where
:
{
symbol
:
pair
},
raw
:
true
});
if
(
!
dbPair
)
{
throw
ErrorCode
.
PAIR_NOT_EXIST
;
}
let
param
=
{
"base"
:
dbPair
.
base
,
"quote"
:
dbPair
.
quote
,
"symbol"
:
dbPair
.
symbol
,
"name"
:
dbPair
.
symbol
,
"price_scale"
:
dbPair
.
price_scale
,
"quantity_scale"
:
dbPair
.
quantity_scale
,
"maker_fee"
:
dbPair
.
maker_fee
,
"taker_fee"
:
dbPair
.
taker_fee
}
let
optResult
=
await
addPairToCore
(
param
);
if
(
!
optResult
.
is_success
)
{
throw
ErrorCode
.
ADD_PAIR_TO_CORE_ERR
;
}
await
spotPairs
.
prototype
.
update
({
status
:
1
},
{
where
:
{
id
:
dbPair
.
id
}
});
reason
=
"交易对增加到撮合完成"
;
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
ADMIN_ADD_PAIR
,
currentUser
.
account
,
reason
,
dbApply
.
coin_symbol
,
dbApply
.
currency_symbol
);
}
else
if
(
status
==
PAIR_APPLY_STATUS
.
ADMIN_ADD_PAIR
)
{
//5-6
reason
=
"等待撮合系统重启"
;
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
WAIT_ADMIN_RESTART
,
currentUser
.
account
,
reason
,
dbApply
.
coin_symbol
,
dbApply
.
currency_symbol
);
}
else
if
(
status
==
PAIR_APPLY_STATUS
.
WAIT_ADMIN_RESTART
)
{
//6-7
//TODO:确定是否查此表 原逻辑 查询ex_pair
let
dbPair
=
await
spotPairs
.
prototype
.
findOne
({
where
:
{
symbol
:
pair
},
raw
:
true
});
if
(
!
dbPair
)
{
throw
ErrorCode
.
PAIR_NOT_EXIST
;
}
//TODO:新撮合是否需要此操作 初始化
/*String errStr = spotRpcService.initPair1(dbpair);
if (errStr != null) {
return ResponseResult.failure("admin rpc fail: " + errStr);
}*/
reason
=
"发布交易对到撮合完成"
;
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
ADMIN_ISSUE_PAIR
,
currentUser
.
account
,
reason
,
dbApply
.
coin_symbol
,
dbApply
.
currency_symbol
);
}
else
if
(
status
==
PAIR_APPLY_STATUS
.
ADMIN_ISSUE_PAIR
)
{
//7-8
//TODO:确定是否查此表 原逻辑 查询ex_pair
let
dbPair
=
await
spotPairs
.
prototype
.
findOne
({
where
:
{
symbol
:
pair
},
raw
:
true
});
if
(
!
dbPair
)
{
throw
ErrorCode
.
PAIR_NOT_EXIST
;
}
let
tm
=
datetimeUtils
.
add
(
new
Date
(),
datetimeUtils
.
SECONED
);
let
tm_active
=
dbApply
.
tm_active
;
if
(
datetimeUtils
.
between
(
tm_active
,
tm
)
<
0
)
{
throw
ErrorCode
.
ACTIVE_TM_EXPIRE
;
}
await
systemTrigger
.
prototype
.
create
({
trigger_symbol
:
pair
,
trigger_type
:
2
,
trigger_action
:
2011
,
trigger_time
:
tm_active
,
status
:
0
,
createdAt
:
new
Date
(),
updatedAt
:
new
Date
(),
});
reason
=
"交易对激活定时器完成"
;
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
TIMER_ACTIVE
,
currentUser
.
account
,
reason
,
dbApply
.
coin_symbol
,
dbApply
.
currency_symbol
);
}
else
{
throw
ErrorCode
.
CURRENT_STATUS_NOT_APPLY
}
//管理后台操作日志
addOptLog
(
currentUser
.
userId
,
0
,
'上新交易对申请审核'
,
ip
,
`msg:
${
reason
}
,dbInfo:
${
JSON
.
stringify
(
dbApply
)}
`
,
'交易上下线管理'
);
return
'success'
;
}
async
function
updateApply
(
id
:
number
,
status
:
number
,
checker
:
string
,
reason
:
string
,
coin_symbol
:
string
,
currency_symbol
:
string
)
{
let
updateInfo
=
{
status
:
status
,
checker
:
checker
,
reason
:
reason
?
reason
:
""
,
updatedAt
:
new
Date
()
}
await
exPairApply
.
prototype
.
update
(
updateInfo
,
{
where
:
{
id
:
id
}
});
sendMsg
(
status
,
coin_symbol
+
'_'
+
currency_symbol
);
}
//TODO:发送lark消息
async
function
sendMsg
(
status
:
number
,
symbol
:
string
)
{
// 1被驳回2申请待审批3审批通过4交易对创建完成5交易对增加到撮合完成6等待撮合系统重启7发布交易对到撮合完成8交易对激活定时器完成9取消
let
content
=
""
;
if
(
status
==
PAIR_APPLY_STATUS
.
RE_WRITE
)
{
content
=
"申请上交易对,被驳回:"
+
symbol
;
}
else
if
(
status
==
PAIR_APPLY_STATUS
.
WAIT_VIEW
)
{
content
=
"申请上交易对:"
+
symbol
;
}
else
if
(
status
==
PAIR_APPLY_STATUS
.
PASS
)
{
content
=
"申请上交易对,审批通过:"
+
symbol
+
",下一步交易对创建"
;
}
else
if
(
status
==
PAIR_APPLY_STATUS
.
CREATE_PAIR
)
{
content
=
"申请上交易对,交易对创建完成:"
+
symbol
+
",下一步增加到撮合"
;
}
else
if
(
status
==
PAIR_APPLY_STATUS
.
ADMIN_ADD_PAIR
)
{
content
=
"申请上交易对,增加到撮合完成:"
+
symbol
+
",下一步等待撮合系统重启(不需要真的重启撮合)"
;
}
else
if
(
status
==
PAIR_APPLY_STATUS
.
WAIT_ADMIN_RESTART
)
{
content
=
"申请上交易对,撮合系统重启完成(不需要真的重启撮合):"
+
symbol
+
",下一步发布交易对到撮合"
;
}
else
if
(
status
==
PAIR_APPLY_STATUS
.
ADMIN_ISSUE_PAIR
)
{
content
=
"申请上交易对,发布交易对到撮合完成:"
+
symbol
+
",下一步激活定时器"
;
}
else
if
(
status
==
PAIR_APPLY_STATUS
.
TIMER_ACTIVE
)
{
content
=
"申请上交易对,激活定时器完成:"
+
symbol
+
",流程结束"
;
}
else
if
(
status
==
PAIR_APPLY_STATUS
.
CANCEL
)
{
content
=
"申请上交易对,被取消:"
+
symbol
+
",流程结束"
;
}
if
(
content
!=
null
)
{
//TODO:发lark
}
}
src/functional/router/v1/index.ts
View file @
55eb492a
...
...
@@ -43,6 +43,7 @@ import * as contractLimitTradeCtrl from "../../mvc/control/contractLimitTrade.co
import
*
as
contractAgentCtrl
from
"../../mvc/control/contractAgent.control"
;
import
*
as
depositAndWithdrawCtrl
from
"../../mvc/control/depositAndWithdraw.control"
;
import
*
as
coinTypeApplyCtrl
from
"../../mvc/control/coinTypeApply"
;
import
*
as
pairApplyCtrl
from
"../../mvc/control/pairApply"
;
const
getFunc
=
{
'user/info'
:
userController
.
getUserInfo
,
...
...
@@ -236,6 +237,16 @@ const postFunc = {
'tech/apply/new/coin/apply/cancel'
:
coinTypeApplyCtrl
.
cancel
,
//管理员取消申请上新币
'tech/apply/new/coin/explore/url/list'
:
coinTypeApplyCtrl
.
exploreUrlList
,
//交易浏览器列表
'tech/apply/new/coin/listed'
:
coinTypeApplyCtrl
.
listed
,
//已有币种列表
//技术部-交易上下线管理-申请上新交易对
'tech/apply/new/pair/list'
:
pairApplyCtrl
.
list
,
//申请上交易对列表
'tech/apply/new/pair/apply'
:
pairApplyCtrl
.
apply
,
//申请上新交易对
'tech/apply/new/pair/apply/cancel/self'
:
pairApplyCtrl
.
cancelSelf
,
//撤销申请上新交易对
'tech/apply/new/pair/apply/edit'
:
pairApplyCtrl
.
edit
,
//编辑申请上新交易对
'tech/apply/new/pair/apply/review'
:
pairApplyCtrl
.
review
,
//审核申请上新交易对
'tech/apply/new/pair/apply/rewrite'
:
pairApplyCtrl
.
rewrite
,
//驳回申请上新交易对
'tech/apply/new/pair/apply/cancel'
:
pairApplyCtrl
.
cancel
,
//管理员取消申请上新交易对
'tech/apply/new/pair/trade/area/list'
:
pairApplyCtrl
.
tradeAreaList
,
//已有交易区列表
'tech/apply/new/pair/listed'
:
pairApplyCtrl
.
listed
,
//已有交易对列表
};
// TODO 这里先和 nodejs 的注册路由方式保持一样,后面在调整。
...
...
src/setting/access-limit.ts
View file @
55eb492a
'use strict'
;
import
*
as
ReqUtils
from
"../utils/req-utils"
;
import
*
as
pairApplyCtrl
from
"../functional/mvc/control/pairApply"
;
const
{
Res3Utils
,
...
...
@@ -185,6 +186,16 @@ let cmdWhiteList = {
'tech/apply/new/coin/apply/cancel'
:
1
,
'tech/apply/new/coin/explore/url/list'
:
1
,
'tech/apply/new/coin/listed'
:
1
,
//技术部-交易上下线管理-申请上新交易对
'tech/apply/new/pair/list'
:
1
,
'tech/apply/new/pair/apply'
:
1
,
'tech/apply/new/pair/apply/cancel/self'
:
1
,
'tech/apply/new/pair/apply/edit'
:
1
,
'tech/apply/new/pair/apply/review'
:
1
,
'tech/apply/new/pair/apply/rewrite'
:
1
,
'tech/apply/new/pair/apply/cancel'
:
1
,
'tech/apply/new/pair/trade/area/list'
:
1
,
'tech/apply/new/pair/listed'
:
1
,
};
...
...
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