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
f84ae4ca
Commit
f84ae4ca
authored
Nov 20, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
交易对 相关接口 增加字段 增加定时器
parent
390ab468
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
202 additions
and
26 deletions
+202
-26
errorCode.ts
src/constant/errorCode.ts
+4
-0
cronApply.control.ts
src/functional/mvc/control/cronApply.control.ts
+55
-0
contractPair.service.ts
src/functional/mvc/service/contractPair.service.ts
+7
-0
cronApply.service.ts
src/functional/mvc/service/cronApply.service.ts
+106
-10
pairApply.service.ts
src/functional/mvc/service/pairApply.service.ts
+18
-14
spotPair.service.ts
src/functional/mvc/service/spotPair.service.ts
+8
-0
index.ts
src/functional/router/v1/index.ts
+2
-2
access-limit.ts
src/setting/access-limit.ts
+2
-0
No files found.
src/constant/errorCode.ts
View file @
f84ae4ca
...
...
@@ -78,4 +78,8 @@ export const ErrorCode = {
PAIR_FORMAT_ERR
:
'30074'
,
//交易对格式错误
PAIR_NOT_SUPPORT
:
'30075'
,
//暂不支持此交易对
FEE_TOO_LOW_OR_HIGH
:
'30076'
,
//设置的费率过高/过低
PAIR_IS_ACTIVE
:
'30077'
,
//交易对已是激活状态
PAIR_IS_NOT_ACTIVE
:
'30078'
,
//交易对已是未激活状态
PAIR_IS_HIDE
:
'30079'
,
//交易对已是隐藏状态
PAIR_IS_NOT_HIDE
:
'30080'
,
//交易对已是未隐藏状态
}
src/functional/mvc/control/cronApply.control.ts
View file @
f84ae4ca
...
...
@@ -105,3 +105,58 @@ export const addWithdraw = async (req: any, cronApplyVO: CronApplyVO) => {
/**
* 技术部-交易上下线管理-增加交易对激活定时器
* @param req
* @param authConfigVO
*/
export
const
addPairActive
=
async
(
req
:
any
,
cronApplyVO
:
CronApplyVO
)
=>
{
let
func_name
=
"cronApply.control.addPairActive"
;
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUser
=
await
getCurrentUser
(
req
.
cookies
.
session_id
);
if
(
!
cronApplyVO
.
trigger_symbol
||
!
cronApplyVO
.
trigger_time
||
cronApplyVO
.
is_active
==
undefined
)
{
throw
ErrorCode
.
PARAM_MISS
}
let
tm
=
datetimeUtils
.
add
(
new
Date
(),
datetimeUtils
.
SECONED
*
5
);
if
(
datetimeUtils
.
between
(
cronApplyVO
.
trigger_time
,
tm
)
<
0
)
{
throw
ErrorCode
.
PARAM_MISS
;
}
let
res
=
await
cronApplyService
.
addPairActive
(
cronApplyVO
,
currentUser
,
ip
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* 技术部-交易上下线管理-增加交易对隐藏定时器
* @param req
* @param authConfigVO
*/
export
const
addPairHide
=
async
(
req
:
any
,
cronApplyVO
:
CronApplyVO
)
=>
{
let
func_name
=
"cronApply.control.addPairHide"
;
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUser
=
await
getCurrentUser
(
req
.
cookies
.
session_id
);
if
(
!
cronApplyVO
.
trigger_symbol
||
!
cronApplyVO
.
trigger_time
||
cronApplyVO
.
is_hide
==
undefined
)
{
throw
ErrorCode
.
PARAM_MISS
}
let
tm
=
datetimeUtils
.
add
(
new
Date
(),
datetimeUtils
.
SECONED
*
5
);
if
(
datetimeUtils
.
between
(
cronApplyVO
.
trigger_time
,
tm
)
<
0
)
{
throw
ErrorCode
.
PARAM_MISS
;
}
let
res
=
await
cronApplyService
.
addPairHide
(
cronApplyVO
,
currentUser
,
ip
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
src/functional/mvc/service/contractPair.service.ts
View file @
f84ae4ca
...
...
@@ -82,6 +82,10 @@ export interface AddParam {
view_precision
?:
number
is_active
?:
number
is_hide
?:
number
createdAt
?:
Date
|
any
,
updatedAt
?:
Date
|
any
,
...
...
@@ -158,6 +162,9 @@ export const update = async (param: AddParam, currentUserId: any, ip: any) => {
if
(
param
.
quantity_increment
)
{
updateInfo
[
'quantity_increment'
]
=
param
.
quantity_increment
}
updateInfo
[
'is_active'
]
=
param
.
is_active
?
param
.
is_active
:
0
;
updateInfo
[
'is_hide'
]
=
param
.
is_hide
?
param
.
is_hide
:
0
;
await
contractPairs
.
prototype
.
update
(
updateInfo
,
{
where
:
{
...
...
src/functional/mvc/service/cronApply.service.ts
View file @
f84ae4ca
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
{
PAIR_APPLY_STATUS
}
from
"../../../constant/pairApplyConst"
;
...
...
@@ -21,6 +21,10 @@ export interface CronApplyVO {
status
?:
number
;
is_active
?:
number
;
is_hide
?:
number
;
createdAt
?:
Date
|
any
,
updatedAt
?:
Date
|
any
,
...
...
@@ -76,12 +80,12 @@ export async function del(id: number, currentUser: any, ip: string | undefined)
export
async
function
addDeposit
(
cronApplyVO
:
CronApplyVO
,
currentUser
:
any
,
ip
:
any
)
{
let
dbCoin
=
await
coinType
.
prototype
.
findOne
({
where
:{
symbol
:
cronApplyVO
.
trigger_symbol
where
:
{
symbol
:
cronApplyVO
.
trigger_symbol
},
raw
:
true
raw
:
true
});
if
(
!
dbCoin
){
if
(
!
dbCoin
)
{
throw
ErrorCode
.
COIN_DATA_NOT_EXIST
}
cronApplyVO
.
trigger_type
=
1
;
...
...
@@ -96,16 +100,15 @@ export async function addDeposit(cronApplyVO: CronApplyVO, currentUser: any, ip:
}
export
async
function
addWithdraw
(
cronApplyVO
:
CronApplyVO
,
currentUser
:
any
,
ip
:
any
)
{
let
dbCoin
=
await
coinType
.
prototype
.
findOne
({
where
:{
symbol
:
cronApplyVO
.
trigger_symbol
where
:
{
symbol
:
cronApplyVO
.
trigger_symbol
},
raw
:
true
raw
:
true
});
if
(
!
dbCoin
){
if
(
!
dbCoin
)
{
throw
ErrorCode
.
COIN_DATA_NOT_EXIST
}
cronApplyVO
.
trigger_type
=
1
;
...
...
@@ -120,5 +123,98 @@ export async function addWithdraw(cronApplyVO: CronApplyVO, currentUser: any, ip
}
export
async
function
addPairActive
(
cronApplyVO
:
CronApplyVO
,
currentUser
:
any
,
ip
:
any
)
{
let
pair
=
String
(
cronApplyVO
.
trigger_symbol
);
let
dbPair
:
any
;
//合约
if
(
pair
.
endsWith
(
"_SWAP"
))
{
dbPair
=
await
contractPairs
.
prototype
.
findOne
({
where
:
{
symbol
:
pair
},
raw
:
true
});
}
else
{
dbPair
=
await
spotPairs
.
prototype
.
findOne
({
where
:
{
symbol
:
pair
},
raw
:
true
});
}
if
(
!
dbPair
)
{
throw
ErrorCode
.
PAIR_NOT_EXIST
}
if
(
dbPair
.
is_active
==
1
&&
cronApplyVO
.
is_active
==
1
)
{
throw
ErrorCode
.
PAIR_IS_ACTIVE
;
}
if
(
dbPair
.
is_active
==
0
&&
cronApplyVO
.
is_active
!=
1
)
{
throw
ErrorCode
.
PAIR_IS_NOT_ACTIVE
;
}
delete
cronApplyVO
.
is_active
;
cronApplyVO
.
trigger_type
=
2
;
cronApplyVO
.
trigger_action
=
cronApplyVO
.
is_active
==
1
?
2011
:
2010
;
cronApplyVO
.
status
=
0
;
cronApplyVO
.
createdAt
=
new
Date
();
cronApplyVO
.
updatedAt
=
new
Date
();
await
systemTrigger
.
prototype
.
create
(
cronApplyVO
);
//管理后台操作日志
addOptLog
(
currentUser
.
userId
,
0
,
'增加交易对激活定时器'
,
ip
,
JSON
.
stringify
(
cronApplyVO
),
'交易上下线管理'
);
return
'success'
;
}
export
async
function
addPairHide
(
cronApplyVO
:
CronApplyVO
,
currentUser
:
any
,
ip
:
any
)
{
let
pair
=
String
(
cronApplyVO
.
trigger_symbol
);
let
dbPair
:
any
;
//合约
if
(
pair
.
endsWith
(
"_SWAP"
))
{
dbPair
=
await
contractPairs
.
prototype
.
findOne
({
where
:
{
symbol
:
pair
},
raw
:
true
});
}
else
{
dbPair
=
await
spotPairs
.
prototype
.
findOne
({
where
:
{
symbol
:
pair
},
raw
:
true
});
}
if
(
!
dbPair
)
{
throw
ErrorCode
.
PAIR_NOT_EXIST
}
if
(
dbPair
.
is_hide
==
1
&&
cronApplyVO
.
is_hide
==
1
)
{
throw
ErrorCode
.
PAIR_IS_HIDE
;
}
if
(
dbPair
.
is_hide
==
0
&&
cronApplyVO
.
is_hide
!=
1
)
{
throw
ErrorCode
.
PAIR_IS_NOT_HIDE
;
}
delete
cronApplyVO
.
is_hide
;
cronApplyVO
.
trigger_type
=
2
;
cronApplyVO
.
trigger_action
=
cronApplyVO
.
is_active
==
1
?
2021
:
2020
;
cronApplyVO
.
status
=
0
;
cronApplyVO
.
createdAt
=
new
Date
();
cronApplyVO
.
updatedAt
=
new
Date
();
await
systemTrigger
.
prototype
.
create
(
cronApplyVO
);
//管理后台操作日志
addOptLog
(
currentUser
.
userId
,
0
,
'增加交易对隐藏定时器'
,
ip
,
JSON
.
stringify
(
cronApplyVO
),
'交易上下线管理'
);
return
'success'
;
}
src/functional/mvc/service/pairApply.service.ts
View file @
f84ae4ca
...
...
@@ -75,6 +75,10 @@ export interface PairApplyVO {
reason
?:
string
;
is_active
?:
number
is_hide
?:
number
createdAt
?:
Date
|
any
,
updatedAt
?:
Date
|
any
,
...
...
@@ -90,7 +94,6 @@ export interface PairApplyPageVO extends PairApplyVO {
symbol
?:
string
;
is_active
?:
number
;
}
...
...
@@ -282,6 +285,8 @@ export async function review(id: any, currentUser: any, ip: string | undefined)
max_order_size
:
dbApply
.
max_order_size
,
min_order_value
:
dbApply
.
min_order_value
,
max_order_value
:
dbApply
.
max_order_value
,
is_active
:
dbApply
.
is_active
,
is_hide
:
dbApply
.
is_hide
,
status
:
0
,
createdAt
:
new
Date
(),
updatedAt
:
new
Date
(),
...
...
@@ -398,24 +403,23 @@ export async function review(id: any, currentUser: any, ip: string | undefined)
}
else
if
(
status
==
PAIR_APPLY_STATUS
.
ADMIN_ISSUE_PAIR
)
{
//7-8
//检查交易对是否存在
await
checkPairExist
(
pair
,
type
);
let
dbPair
=
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,
trigger_action: 2011,
trigger_time: tm_active,
status: 0,
createdAt: new Date(),
updatedAt: new Date(),
});
*/
if
(
!
dbPair
.
is_active
){
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
,
pair
);
}
...
...
src/functional/mvc/service/spotPair.service.ts
View file @
f84ae4ca
...
...
@@ -59,6 +59,10 @@ export interface AddParam {
max_order_value
?:
number
is_active
?:
number
is_hide
?:
number
createdAt
?:
Date
|
any
,
updatedAt
?:
Date
|
any
,
...
...
@@ -136,6 +140,10 @@ export const update = async (param: AddParam, currentUserId: any, ip: any) => {
if
(
param
.
quantity_increment
)
{
updateInfo
[
'quantity_increment'
]
=
param
.
quantity_increment
}
updateInfo
[
'is_active'
]
=
param
.
is_active
?
param
.
is_active
:
0
;
updateInfo
[
'is_hide'
]
=
param
.
is_hide
?
param
.
is_hide
:
0
;
await
spotPairs
.
prototype
.
update
(
updateInfo
,
{
where
:
{
...
...
src/functional/router/v1/index.ts
View file @
f84ae4ca
...
...
@@ -263,8 +263,8 @@ const postFunc = {
//技术部-交易上下线管理-申请审核定时器
'tech/apply/new/cron/list'
:
cronApplyCtrl
.
list
,
//审核上币定时器信息列表
'tech/apply/new/cron/delete'
:
cronApplyCtrl
.
del
,
//删除审核上币定时器
//'tech/apply/new/cron/pair/add/active': cronApplyCtrl.addActive,//TODO:增加激活交易对定时器 原来有 is_active is_hide 的逻辑 现在spot_pairs 没有相关字段 ???
//'tech/apply/new/cron/pair/add/hide': cronApplyCtrl.addHide,//TODO:增加隐藏交易对定时器 原来有 is_active is_hide 的逻辑 现在spot_pairs 没有相关字段 ???
'tech/apply/new/cron/pair/add/active'
:
cronApplyCtrl
.
addPairActive
,
//增加激活交易对定时器
'tech/apply/new/cron/pair/add/hide'
:
cronApplyCtrl
.
addPairHide
,
//增加隐藏交易对定时器
'tech/apply/new/cron/coin/add/deposit'
:
cronApplyCtrl
.
addDeposit
,
//增加新币充值定时器
'tech/apply/new/cron/coin/add/withdraw'
:
cronApplyCtrl
.
addWithdraw
,
//增加新币提现定时器
//运营部-现货-现货数据
...
...
src/setting/access-limit.ts
View file @
f84ae4ca
...
...
@@ -205,6 +205,8 @@ let cmdWhiteList = {
'tech/apply/new/cron/delete'
:
1
,
'tech/apply/new/cron/coin/add/deposit'
:
1
,
'tech/apply/new/cron/coin/add/withdraw'
:
1
,
'tech/apply/new/cron/pair/add/active'
:
1
,
'tech/apply/new/cron/pair/add/hide'
:
1
,
//运营部-现货-现货数据
'operate/spot/data/increase/user/list'
:
1
,
'operate/spot/data/trade/user/list'
:
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