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
d41ae882
Commit
d41ae882
authored
Oct 16, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上交易对申请逻辑调整、增加接口、部分逻辑接口调整
parent
17c356ce
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
356 additions
and
184 deletions
+356
-184
errorCode.ts
src/constant/errorCode.ts
+1
-0
contractPair.control.ts
src/functional/mvc/control/contractPair.control.ts
+10
-2
mUserAssets.control.ts
src/functional/mvc/control/mUserAssets.control.ts
+48
-0
pairApply.control.ts
src/functional/mvc/control/pairApply.control.ts
+14
-28
appVersion.service.ts
src/functional/mvc/service/appVersion.service.ts
+2
-0
coinType.service.ts
src/functional/mvc/service/coinType.service.ts
+1
-1
contractPair.service.ts
src/functional/mvc/service/contractPair.service.ts
+4
-0
cronApply.service.ts
src/functional/mvc/service/cronApply.service.ts
+0
-1
depositAndWithdraw.service.ts
src/functional/mvc/service/depositAndWithdraw.service.ts
+1
-1
mUserAssets.service.ts
src/functional/mvc/service/mUserAssets.service.ts
+38
-1
pairApply.service.ts
src/functional/mvc/service/pairApply.service.ts
+189
-146
spotPair.service.ts
src/functional/mvc/service/spotPair.service.ts
+5
-0
index.ts
src/functional/router/v1/index.ts
+4
-2
access-limit.ts
src/setting/access-limit.ts
+4
-2
coinTypeUtils.ts
src/utils/coinTypeUtils.ts
+35
-0
No files found.
src/constant/errorCode.ts
View file @
d41ae882
...
...
@@ -75,4 +75,5 @@ export const ErrorCode = {
NO_TRIGGER_DEL
:
'30071'
,
//只有未触发的任务可以删除
EXIST_ACTIVE_PAIR
:
'30072'
,
//已存在生效或即将生效的该交易对费率配置
FEE_EX_OR_DEL
:
'30073'
,
//费率设置已过期或已删除,不可以修改
PAIR_FORMAT_ERR
:
'30074'
,
//交易对格式错误
}
src/functional/mvc/control/contractPair.control.ts
View file @
d41ae882
...
...
@@ -25,14 +25,22 @@ export const save = async (req: any, param: AddParam) => {
let
func_name
=
"contactPairCtl.save"
;
let
cmd
=
req
.
path
;
try
{
ApiAssert
.
notNull
(
'3000'
,
param
.
base
);
ApiAssert
.
notNull
(
'3000'
,
param
.
quote
);
ApiAssert
.
notNull
(
'3000'
,
param
.
symbol
);
ApiAssert
.
notNull
(
'3000'
,
param
.
name
);
ApiAssert
.
notNull
(
'3000'
,
param
.
index
);
ApiAssert
.
notNull
(
'3000'
,
param
.
settlement_asset
);
ApiAssert
.
notNull
(
'3000'
,
param
.
price_scale
);
ApiAssert
.
notNull
(
'3000'
,
param
.
quantity_scale
);
ApiAssert
.
notNull
(
'3000'
,
param
.
maker_fee
);
ApiAssert
.
notNull
(
'3000'
,
param
.
taker_fee
);
ApiAssert
.
notNull
(
'3000'
,
param
.
default_initial_margin
);
ApiAssert
.
notNull
(
'3000'
,
param
.
base_initial_margin
);
ApiAssert
.
notNull
(
'3000'
,
param
.
base_maintenance_margin
);
ApiAssert
.
notNull
(
'3000'
,
param
.
base_interest
);
ApiAssert
.
notNull
(
'3000'
,
param
.
quote_interest
);
ApiAssert
.
notNull
(
'3000'
,
param
.
impact_notional
);
ApiAssert
.
notNull
(
'3000'
,
param
.
base_risk_limit
);
ApiAssert
.
notNull
(
'3000'
,
param
.
risk_limit_step
);
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUserId
=
await
getCurrentUserId
(
req
.
cookies
.
session_id
);
let
res
=
await
service
.
save
(
param
,
currentUserId
,
ip
);
...
...
src/functional/mvc/control/mUserAssets.control.ts
View file @
d41ae882
...
...
@@ -70,3 +70,51 @@ export const tradeAssetsDetail = async (req: any, queryVO: QueryVO) => {
}
};
/**
* 充值记录
* @param req
* @param infoVO
*/
export
const
depositList
=
async
(
req
:
any
,
queryVO
:
QueryVO
)
=>
{
let
func_name
=
"mUserAssetsCtrl.depositList"
;
try
{
queryVO
.
page
=
Optional
.
opt
(
queryVO
,
'page'
,
1
);
queryVO
.
size
=
Optional
.
opt
(
queryVO
,
'size'
,
20
);
if
(
!
queryVO
.
user_id
){
throw
ErrorCode
.
PARAM_MISS
}
let
res
=
await
mUserAssetsService
.
depositList
(
queryVO
.
user_id
,
Number
(
queryVO
.
page
),
Number
(
queryVO
.
size
));
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* 提现记录
* @param req
* @param infoVO
*/
export
const
withdrawList
=
async
(
req
:
any
,
queryVO
:
QueryVO
)
=>
{
let
func_name
=
"mUserAssetsCtrl.withdrawList"
;
try
{
queryVO
.
page
=
Optional
.
opt
(
queryVO
,
'page'
,
1
);
queryVO
.
size
=
Optional
.
opt
(
queryVO
,
'size'
,
20
);
if
(
!
queryVO
.
user_id
){
throw
ErrorCode
.
PARAM_MISS
}
let
res
=
await
mUserAssetsService
.
withdrawList
(
queryVO
.
user_id
,
Number
(
queryVO
.
page
),
Number
(
queryVO
.
size
));
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
src/functional/mvc/control/pairApply.control.ts
View file @
d41ae882
...
...
@@ -46,25 +46,6 @@ export const listed = async (req: any, pageVO: PairApplyPageVO) => {
}
};
/**
* 技术部-交易上下线管理-已有交易区列表
* @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
...
...
@@ -201,18 +182,23 @@ export const review = async (req: any, pairApplyVO: PairApplyVO) => {
async
function
paramValid
(
pairApplyVO
:
PairApplyVO
)
{
if
(
!
pairApplyVO
.
coin_symbol
||
!
pairApplyVO
.
currency_
symbol
||
!
pairApplyVO
.
decimal
||
!
pairApplyVO
.
qtyPrecision
||
!
pairApplyVO
.
weight
||
!
pairApplyVO
.
baseMinValu
e
||
!
pairApplyVO
.
quoteMinValu
e
)
{
if
(
!
pairApplyVO
.
type
||
!
pairApplyVO
.
symbol
||
!
pairApplyVO
.
name
||
!
pairApplyVO
.
price_scale
||
!
pairApplyVO
.
quantity_scale
||
!
pairApplyVO
.
maker_fe
e
||
!
pairApplyVO
.
taker_fe
e
)
{
throw
ErrorCode
.
PARAM_MISS
;
}
if
(
!
pairApplyVO
.
pair_type
)
{
pairApplyVO
.
pair_type
=
0
//申请上合约交易对
if
(
pairApplyVO
.
type
==
2
)
{
if
(
!
pairApplyVO
.
settlement_asset
||
!
pairApplyVO
.
default_initial_margin
||
!
pairApplyVO
.
base_initial_margin
||
!
pairApplyVO
.
base_maintenance_margin
||
!
pairApplyVO
.
base_interest
||
!
pairApplyVO
.
quote_interest
||
!
pairApplyVO
.
impact_notional
||
!
pairApplyVO
.
base_risk_limit
||
!
pairApplyVO
.
risk_limit_step
)
{
throw
ErrorCode
.
PARAM_MISS
;
}
if
(
!
pairApplyVO
.
area_id
)
{
pairApplyVO
.
area_id
=
0
}
if
(
!
pairApplyVO
.
business_area_id
)
{
pairApplyVO
.
business_area_id
=
0
}
...
...
src/functional/mvc/service/appVersion.service.ts
View file @
d41ae882
...
...
@@ -24,6 +24,8 @@ export interface AppVersionVO {
comment_en
?:
string
;
comment_ja
?:
string
;
platform
?:
number
,
grayscale_value
?:
number
,
...
...
src/functional/mvc/service/coinType.service.ts
View file @
d41ae882
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import
{
coinType
,
ormDB
,
spotPairs
}
from
"@madex/ex-ts-dao"
;
import
{
addCoin2Core
,
addPairToCore
}
from
"../../../utils/coreSystemUtils"
;
import
{
addCoin2Core
}
from
"../../../utils/coreSystemUtils"
;
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
import
{
addOptLog
}
from
"./userOptLog.service"
;
...
...
src/functional/mvc/service/contractPair.service.ts
View file @
d41ae882
...
...
@@ -4,6 +4,7 @@ import { NUMBER } from "sequelize";
import
{
addPairToCore
}
from
"../../../utils/coreSystemUtils"
;
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
import
{
addOptLog
}
from
"./userOptLog.service"
;
import
{
checkPairInCoinType
}
from
"../../../utils/coinTypeUtils"
;
let
{
logger
,
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
...
...
@@ -109,6 +110,9 @@ export async function list(param: ListParam) {
}
export
const
save
=
async
(
param
:
AddParam
,
currentUserId
:
any
,
ip
:
any
)
=>
{
//检查交易对中的币种是否存在于coin_type 中
await
checkPairInCoinType
(
String
(
param
.
symbol
));
param
.
updatedAt
=
new
Date
();
param
.
createdAt
=
new
Date
();
let
dbInfo
=
await
contractPairs
.
prototype
.
findOne
({
...
...
src/functional/mvc/service/cronApply.service.ts
View file @
d41ae882
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"
;
...
...
src/functional/mvc/service/depositAndWithdraw.service.ts
View file @
d41ae882
...
...
@@ -102,7 +102,7 @@ export async function withdrawList(pageVO: QueryVO) {
return
resList
;
}
async
function
dealReturnData
(
resList
:
any
)
{
export
async
function
dealReturnData
(
resList
:
any
)
{
if
(
resList
.
rows
.
length
)
{
let
usdtTickerMap
=
{};
for
(
let
item
of
resList
.
rows
)
{
...
...
src/functional/mvc/service/mUserAssets.service.ts
View file @
d41ae882
import
{
ormDB
,
mainUserAsset
}
from
"@madex/ex-ts-dao"
;
import
{
ormDB
,
mainUserAsset
,
coinTx
,
coinWithdraw
}
from
"@madex/ex-ts-dao"
;
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
import
BigNumber
from
"bignumber.js"
;
import
{
any
}
from
"async"
;
import
{
getUserAccountFromCore
}
from
"../../../utils/coreSystemUtils"
;
import
{
dealReturnData
}
from
"./depositAndWithdraw.service"
;
let
_
=
require
(
'lodash'
);
...
...
@@ -288,6 +289,42 @@ export async function tradeAssetByUids(uids: number[]) {
}
export
async
function
depositList
(
user_id
:
number
,
page
:
number
,
size
:
number
)
{
let
where
=
{
user_id
:
user_id
};
let
resList
=
await
coinTx
.
prototype
.
findAndCount
({
where
:
where
,
limit
:
size
,
offset
:
(
Number
(
page
)
-
1
)
*
Number
(
size
),
order
:
[[
"createdAt"
,
"desc"
]],
raw
:
true
});
await
dealReturnData
(
resList
);
return
resList
;
}
export
async
function
withdrawList
(
user_id
:
number
,
page
:
number
,
size
:
number
)
{
let
where
=
{
user_id
:
user_id
};
let
resList
=
await
coinWithdraw
.
prototype
.
findAndCount
({
where
:
where
,
limit
:
size
,
offset
:
(
Number
(
page
)
-
1
)
*
Number
(
size
),
order
:
[[
"createdAt"
,
"desc"
]],
raw
:
true
});
await
dealReturnData
(
resList
);
return
resList
;
}
...
...
src/functional/mvc/service/pairApply.service.ts
View file @
d41ae882
import
{
exPairApply
,
coinType
,
ormDB
,
systemTrigger
,
spotPairs
,
exTradeArea
,
exBusinessAreaRouter
}
from
"@madex/ex-ts-dao"
;
import
{
exPairApply
,
coinType
,
ormDB
,
systemTrigger
,
spotPairs
,
exTradeArea
,
exBusinessAreaRouter
,
contractPairs
}
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"
;
import
{
checkPairInCoinType
}
from
"../../../utils/coinTypeUtils"
;
import
{
pairs
}
from
"rxjs"
;
let
_
=
require
(
'lodash'
);
...
...
@@ -12,37 +14,57 @@ let { logger, datetimeUtils } = require('@madex/ex-js-public');
export
interface
PairApplyVO
{
id
?:
number
;
coin_symbol
?:
string
;
type
?:
number
;
currency_
symbol
?:
string
;
symbol
?:
string
;
maker_rat
e
?:
string
;
nam
e
?:
string
;
taker_rate
?:
string
;
business_area_id
?:
number
;
p
air_typ
e
?:
number
;
p
rice_scal
e
?:
number
;
area_id
?:
number
;
quantity_scale
?:
number
;
business_area_id
?:
number
;
maker_fee
?:
string
;
decimal
?:
number
;
taker_fee
?:
string
;
qtyPrecision
?:
number
;
price_increment
?:
number
;
weigh
t
?:
number
;
quantity_incremen
t
?:
number
;
tm_active
?:
Date
|
any
;
view_precision
?:
number
min_order_size
?:
number
max_order_size
?:
number
min_order_value
?:
number
max_order_value
?:
number
settlement_asset
?:
string
;
funding_times_perday
?:
number
;
default_initial_margin
?:
number
;
//"0.01",
base_initial_margin
?:
number
;
//"0.01",
base_maintenance_margin
?:
number
;
//"0.01",
base
MinValue
?:
string
;
base
_interest
:
number
;
//"0.0003",
baseMaxValue
?:
string
;
quote_interest
?:
number
;
//"0.0006",
quoteMinValue
?:
string
;
impact_notional
?:
number
;
// "600000",
quoteMaxValue
?:
string
;
base_risk_limit
?:
number
;
// "1000000",
quoteIncrement
?:
string
;
risk_limit_step
?:
number
;
//"1000000",
tm_active
?:
Date
|
any
;
applyer
?:
number
;
...
...
@@ -98,48 +120,12 @@ export async function listed(pageVO: PairApplyPageVO) {
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"
;
//检查交易对中的币种是否存在于coin_type 中
await
checkPairInCoinType
(
String
(
pairApplyVO
.
symbol
));
pairApplyVO
.
applyer
=
currentUser
.
account
;
pairApplyVO
.
status
=
PAIR_APPLY_STATUS
.
WAIT_VIEW
;
...
...
@@ -165,8 +151,8 @@ export async function apply(pairApplyVO: PairApplyVO, currentUser: any, ip: stri
else
{
await
exPairApply
.
prototype
.
create
(
pairApplyVO
);
}
sendMsg
(
pairApplyVO
.
status
,
pairApplyVO
.
coin_symbol
+
'_'
+
pairApplyVO
.
currency_symbol
);
//管理后台操作日志
sendMsg
(
pairApplyVO
.
status
,
String
(
pairApplyVO
.
symbol
)
);
//管理后台操作日志
addOptLog
(
currentUser
.
userId
,
0
,
'新增上新交易对申请'
,
ip
,
JSON
.
stringify
(
pairApplyVO
),
'交易上下线管理'
);
return
'success'
;
}
...
...
@@ -181,22 +167,17 @@ export async function edit(pairApplyVO: PairApplyVO, currentUser: any, ip: strin
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
},
let
dbApply2
=
await
exPairApply
.
prototype
.
findOne
({
where
:
{
symbol
:
pairApplyVO
.
symbol
,
id
:
{
[
ormDB
.
Op
.
ne
]:
pairApplyVO
.
id
}
},
raw
:
true
});
if
(
!
dbCurrency
)
{
throw
ErrorCode
.
CURRENT_COIN_DATA_NOT_EXIST
;
}
if
(
dbApply2
)
{
throw
ErrorCode
.
DATA_EXIST
;
}
//检查交易对中的币种是否存在于coin_type 中
await
checkPairInCoinType
(
String
(
pairApplyVO
.
symbol
));
pairApplyVO
.
applyer
=
dbApply
.
applyer
;
pairApplyVO
.
updatedAt
=
new
Date
();
...
...
@@ -205,7 +186,7 @@ export async function edit(pairApplyVO: PairApplyVO, currentUser: any, ip: strin
id
:
Number
(
pairApplyVO
.
id
)
}
});
sendMsg
(
Number
(
pairApplyVO
.
status
),
pairApplyVO
.
coin_symbol
+
'_'
+
pairApplyVO
.
currency_symbol
);
sendMsg
(
Number
(
pairApplyVO
.
status
),
String
(
pairApplyVO
.
symbol
)
);
//管理后台操作日志
addOptLog
(
currentUser
.
userId
,
0
,
'上新交易对申请编辑'
,
ip
,
JSON
.
stringify
(
pairApplyVO
),
'交易上下线管理'
);
return
'success'
;
...
...
@@ -223,7 +204,7 @@ export async function cancelSelf(id: any, reason: any, currentUser: any, ip: str
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
);
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
CANCEL
,
currentUser
.
account
,
String
(
reason
),
dbApply
.
symbol
);
//管理后台操作日志
addOptLog
(
currentUser
.
userId
,
0
,
'撤销上新交易对申请'
,
ip
,
JSON
.
stringify
(
dbApply
),
'交易上下线管理'
);
return
'success'
;
...
...
@@ -238,7 +219,7 @@ export async function rewrite(id: any, reason: any, currentUser: any, ip: string
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
);
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
RE_WRITE
,
currentUser
.
account
,
String
(
reason
),
dbApply
.
symbol
);
//管理后台操作日志
addOptLog
(
currentUser
.
userId
,
0
,
'驳回上新交易对申请'
,
ip
,
JSON
.
stringify
(
dbApply
),
'交易上下线管理'
);
return
'success'
;
...
...
@@ -253,7 +234,7 @@ export async function cancel(id: any, reason: any, currentUser: any, ip: string
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
);
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
CANCEL
,
currentUser
.
account
,
String
(
reason
),
dbApply
.
symbol
);
//管理后台操作日志
addOptLog
(
currentUser
.
userId
,
0
,
'管理员取消上新交易对申请'
,
ip
,
JSON
.
stringify
(
dbApply
),
'交易上下线管理'
);
return
'success'
;
...
...
@@ -271,126 +252,163 @@ export async function review(id: any, currentUser: any, ip: string | undefined)
let
reason
=
""
;
//1被驳回 2申请待审批 3审批通过 4交易对创建完成 5交易对增加到撮合完成 6等待撮合系统重启 7发布交易对到撮合完成 8交易对激活定时器完成 9取消
let
status
=
Number
(
dbApply
.
status
)
let
pair
=
dbApply
.
coin_symbol
+
'_'
+
dbApply
.
currency_symbol
;
let
pair
=
dbApply
.
symbol
;
let
base
=
pair
.
split
(
'_'
)[
0
];
let
quote
=
pair
.
split
(
'_'
)[
1
];
//1 现货 2 合约
let
type
=
dbApply
.
type
;
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
);
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
PASS
,
currentUser
.
account
,
reason
,
pair
);
}
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
;
}
//检查交易对中的币种是否存在于coin_type 中
await
checkPairInCoinType
(
pair
);
//检查交易对是否存在
await
checkPairExist
(
pair
,
type
);
let
insertInfo
=
{
symbol
:
pair
,
base
:
dbApply
.
coin_symbol
,
quote
:
dbApply
.
currency_symbol
,
name
:
pair
,
price_scale
:
dbApply
.
decimal
,
quantity_scale
:
dbApply
.
q
tyPrecision
,
price_scale
:
dbApply
.
price_scale
,
quantity_scale
:
dbApply
.
q
uantity_scale
,
maker_fee
:
dbApply
.
maker_fee
,
taker_fee
:
dbApply
.
taker_fee
,
price_increment
:
dbApply
.
price_increment
,
quantity_increment
:
dbApply
.
quantity_increment
,
view_precision
:
dbApply
.
view_precision
,
min_order_size
:
dbApply
.
min_order_size
,
max_order_size
:
dbApply
.
max_order_size
,
min_order_value
:
dbApply
.
min_order_value
,
max_order_value
:
dbApply
.
max_order_value
,
status
:
0
,
createdAt
:
new
Date
(),
updatedAt
:
new
Date
(),
}
//TODO:是否插入此表
//现货
if
(
type
==
1
)
{
insertInfo
[
'base'
]
=
base
;
insertInfo
[
'quote'
]
=
quote
;
await
spotPairs
.
prototype
.
create
(
insertInfo
);
}
else
{
//合约
insertInfo
[
'index'
]
=
pair
;
insertInfo
[
'settlement_asset'
]
=
dbApply
.
settlement_asset
;
insertInfo
[
'funding_times_perday'
]
=
dbApply
.
funding_times_perday
;
insertInfo
[
'default_initial_margin'
]
=
dbApply
.
default_initial_margin
;
insertInfo
[
'base_initial_margin'
]
=
dbApply
.
base_initial_margin
;
insertInfo
[
'base_maintenance_margin'
]
=
dbApply
.
base_maintenance_margin
;
insertInfo
[
'base_interest'
]
=
dbApply
.
base_interest
;
insertInfo
[
'quote_interest'
]
=
dbApply
.
quote_interest
;
insertInfo
[
'impact_notional'
]
=
dbApply
.
impact_notional
;
insertInfo
[
'base_risk_limit'
]
=
dbApply
.
base_risk_limit
;
insertInfo
[
'risk_limit_step'
]
=
dbApply
.
risk_limit_step
;
await
contractPairs
.
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
);
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
CREATE_PAIR
,
currentUser
.
account
,
reason
,
pair
);
}
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
=
{
//检查交易对是否存在
let
dbPair
=
await
checkPairExist
(
pair
,
type
);
let
param
:
any
;
//现货
if
(
type
==
1
)
{
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
}
}
else
{
param
=
{
"market_type"
:
2
,
"base"
:
base
,
"quote"
:
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
,
"default_initial_margin"
:
dbPair
.
default_initial_margin
,
"base_initial_margin"
:
dbPair
.
base_initial_margin
,
"base_maintenance_margin"
:
dbPair
.
base_maintenance_margin
,
"settlement_asset"
:
dbPair
.
settlement_asset
,
"index"
:
dbPair
.
symbol
,
"base_interest"
:
dbPair
.
base_interest
,
"quote_interest"
:
dbPair
.
quote_interest
,
"impact_notional"
:
dbPair
.
impact_notional
,
"base_risk_limit"
:
dbPair
.
base_risk_limit
,
"risk_limit_step"
:
dbPair
.
risk_limit_step
,
"funding_times_perday"
:
dbPair
.
funding_times_perday
}
}
if
(
dbPair
.
min_order_size
)
{
param
[
"min_order_size"
]
=
dbPair
.
min_order_size
;
}
if
(
dbPair
.
max_order_size
)
{
param
[
"max_order_size"
]
=
dbPair
.
max_order_size
;
}
if
(
dbPair
.
min_order_value
)
{
param
[
"min_order_value"
]
=
dbPair
.
min_order_value
;
}
if
(
dbPair
.
max_order_value
)
{
param
[
"max_order_value"
]
=
dbPair
.
max_order_value
;
}
let
optResult
=
await
addPairToCore
(
param
);
if
(
!
optResult
.
is_success
)
{
throw
ErrorCode
.
ADD_PAIR_TO_CORE_ERR
;
}
//现货
if
(
type
==
1
)
{
await
spotPairs
.
prototype
.
update
({
status
:
1
},
{
where
:
{
id
:
dbPair
.
id
}
});
}
else
{
//合约
await
contractPairs
.
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
);
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
ADMIN_ADD_PAIR
,
currentUser
.
account
,
reason
,
pair
);
}
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
);
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
WAIT_ADMIN_RESTART
,
currentUser
.
account
,
reason
,
pair
);
}
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
;
}
//检查交易对是否存在
await
checkPairExist
(
pair
,
type
);
//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
);
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
ADMIN_ISSUE_PAIR
,
currentUser
.
account
,
reason
,
pair
);
}
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
;
}
//检查交易对是否存在
await
checkPairExist
(
pair
,
type
);
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
;
}
//TODO:需要确认 trigger_type 等字段
await
systemTrigger
.
prototype
.
create
({
trigger_symbol
:
pair
,
trigger_type
:
2
,
...
...
@@ -401,7 +419,7 @@ export async function review(id: any, currentUser: any, ip: string | undefined)
updatedAt
:
new
Date
(),
});
reason
=
"交易对激活定时器完成"
;
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
TIMER_ACTIVE
,
currentUser
.
account
,
reason
,
dbApply
.
coin_symbol
,
dbApply
.
currency_symbol
);
await
updateApply
(
Number
(
id
),
PAIR_APPLY_STATUS
.
TIMER_ACTIVE
,
currentUser
.
account
,
reason
,
pair
);
}
else
{
throw
ErrorCode
.
CURRENT_STATUS_NOT_APPLY
...
...
@@ -412,7 +430,7 @@ export async function review(id: any, currentUser: any, ip: string | undefined)
return
'success'
;
}
async
function
updateApply
(
id
:
number
,
status
:
number
,
checker
:
string
,
reason
:
string
,
coin_symbol
:
string
,
currency_
symbol
:
string
)
{
async
function
updateApply
(
id
:
number
,
status
:
number
,
checker
:
string
,
reason
:
string
,
symbol
:
string
)
{
let
updateInfo
=
{
status
:
status
,
checker
:
checker
,
...
...
@@ -424,7 +442,7 @@ async function updateApply(id: number, status: number, checker: string, reason:
id
:
id
}
});
sendMsg
(
status
,
coin_symbol
+
'_'
+
currency_
symbol
);
sendMsg
(
status
,
symbol
);
}
//TODO:发送lark消息
...
...
@@ -463,3 +481,28 @@ async function sendMsg(status: number, symbol: string) {
}
}
/**
* 检查交易对是否存在
* @param pair
*/
async
function
checkPairExist
(
pair
:
string
,
type
:
number
)
{
let
dbPair
:
any
;
//现货
if
(
type
==
1
)
{
dbPair
=
await
spotPairs
.
prototype
.
findOne
({
where
:
{
symbol
:
pair
},
raw
:
true
});
}
else
{
//合约
dbPair
=
await
contractPairs
.
prototype
.
findOne
({
where
:
{
symbol
:
pair
},
raw
:
true
});
}
if
(
!
dbPair
)
{
throw
ErrorCode
.
PAIR_NOT_EXIST
;
}
return
dbPair
;
}
src/functional/mvc/service/spotPair.service.ts
View file @
d41ae882
...
...
@@ -4,6 +4,7 @@ import { NUMBER } from "sequelize";
import
{
addPairToCore
}
from
"../../../utils/coreSystemUtils"
;
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
import
{
addOptLog
}
from
"./userOptLog.service"
;
import
{
checkPairInCoinType
}
from
"../../../utils/coinTypeUtils"
;
let
{
logger
,
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
...
...
@@ -86,6 +87,10 @@ export async function list(param: ListParam) {
}
export
const
save
=
async
(
param
:
AddParam
,
currentUserId
:
any
,
ip
:
any
)
=>
{
//检查交易对中的币种是否存在于coin_type 中
await
checkPairInCoinType
(
String
(
param
.
symbol
));
param
.
updatedAt
=
new
Date
();
param
.
createdAt
=
new
Date
();
let
dbInfo
=
await
spotPairs
.
prototype
.
findOne
({
...
...
src/functional/router/v1/index.ts
View file @
d41ae882
...
...
@@ -149,6 +149,8 @@ const postFunc = {
'mUser/manage/walletAsset/detail'
:
mUserAssetsCtrl
.
walletAssetDetail
,
//Madex 用户管理 ->钱包账户资产详情
'mUser/manage/asset/distribution'
:
mUserAssetsCtrl
.
assetDistribution
,
//Madex 用户管理 ->资产分布
'mUser/manage/tradeAsset/detail'
:
mUserAssetsCtrl
.
tradeAssetsDetail
,
//Madex 用户管理 ->交易账户资产详情
'mUser/manage/deposit/list'
:
mUserAssetsCtrl
.
depositList
,
//Madex 用户管理 -> 充值记录
'mUser/manage/withdraw/list'
:
mUserAssetsCtrl
.
withdrawList
,
//Madex 用户管理 -> 提现记录
'mUser/manage/order/pending/list'
:
orderPendingAndHistoryCtrl
.
pendingList
,
//Madex 用户管理 ->当前委托
'mUser/manage/order/history/list'
:
orderPendingAndHistoryCtrl
.
historyList
,
//Madex 用户管理 ->历史委托
'mUser/manage/order/detail/list'
:
orderPendingAndHistoryCtrl
.
detailList
,
//Madex 用户管理 ->成交记录
...
...
@@ -251,8 +253,8 @@ const postFunc = {
'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
,
//已有交易对列表
//
'tech/apply/new/pair/trade/area/list': pairApplyCtrl.tradeAreaList,//已有交易区列表
//
'tech/apply/new/pair/listed': pairApplyCtrl.listed,//已有交易对列表
//技术部-交易上下线管理-申请审核定时器
'tech/apply/new/cron/list'
:
cronApplyCtrl
.
list
,
//审核上币定时器信息列表
'tech/apply/new/cron/delete'
:
cronApplyCtrl
.
del
,
//删除审核上币定时器
...
...
src/setting/access-limit.ts
View file @
d41ae882
...
...
@@ -100,6 +100,8 @@ let cmdWhiteList = {
'mUser/manage/walletAsset/detail'
:
1
,
'mUser/manage/asset/distribution'
:
1
,
'mUser/manage/tradeAsset/detail'
:
1
,
'mUser/manage/deposit/list'
:
1
,
'mUser/manage/withdraw/list'
:
1
,
'mUser/manage/order/pending/list'
:
1
,
'mUser/manage/order/history/list'
:
1
,
'mUser/manage/order/detail/list'
:
1
,
...
...
@@ -196,8 +198,8 @@ let cmdWhiteList = {
'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
,
//
'tech/apply/new/pair/trade/area/list': 1,
//
'tech/apply/new/pair/listed': 1,
//技术部-交易上下线管理-申请审核定时器
'tech/apply/new/cron/list'
:
1
,
'tech/apply/new/cron/delete'
:
1
,
...
...
src/utils/coinTypeUtils.ts
0 → 100644
View file @
d41ae882
import
{
ErrorCode
}
from
"../constant/errorCode"
;
import
{
coinType
}
from
"@madex/ex-ts-dao"
;
/**
* 检查交易对中的币种是否存在于coin_type 中
* @param pair
*/
export
const
checkPairInCoinType
=
async
function
(
pair
:
string
)
{
if
(
!
pair
)
{
throw
ErrorCode
.
PARAM_MISS
;
}
let
coin_symbol
=
pair
.
split
(
'_'
)[
0
];
let
currency_symbol
=
pair
.
split
(
'_'
)[
1
];
if
(
!
coin_symbol
||
!
currency_symbol
)
{
throw
ErrorCode
.
PAIR_FORMAT_ERR
;
}
let
dbSymbolTask
=
coinType
.
prototype
.
findOne
({
where
:
{
symbol
:
coin_symbol
},
raw
:
true
});
let
dbCurrencyTask
=
coinType
.
prototype
.
findOne
({
where
:
{
symbol
:
currency_symbol
},
raw
:
true
});
let
[
dbSymbol
,
dbCurrency
]
=
await
Promise
.
all
([
dbSymbolTask
,
dbCurrencyTask
]);
if
(
!
dbSymbol
)
{
throw
ErrorCode
.
COIN_DATA_NOT_EXIST
;
}
if
(
!
dbCurrency
)
{
throw
ErrorCode
.
CURRENT_COIN_DATA_NOT_EXIST
;
}
}
\ No newline at end of file
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