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
6bf92bde
Commit
6bf92bde
authored
Nov 21, 2024
by
1486327116
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
849b087c
6f79f66b
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
274 additions
and
38 deletions
+274
-38
task.system.trigger.service.ts
cron/service/task.system.trigger.service.ts
+72
-12
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.
cron/service/task.system.trigger.service.ts
View file @
6bf92bde
'use strict'
;
import
{
ormDB
,
coinType
,
systemTrigger
}
from
"@madex/ex-ts-dao"
;
import
{
ormDB
,
coinType
,
systemTrigger
,
contractPairs
,
spotPairs
}
from
"@madex/ex-ts-dao"
;
let
{
redisUtilsCommon
}
=
require
(
'@madex/ex-js-common'
)
...
...
@@ -79,13 +79,28 @@ export const getExPairUnTriggers = async function () {
}
export
const
doExPairTrigger
=
async
function
(
trigId
:
any
,
ex_pair
:
any
,
action
:
any
)
{
let
rtn
:
any
=
false
;
export
const
doExPairTrigger
=
async
function
(
trigId
:
any
,
pair
:
string
,
action
:
any
)
{
let
rtn
:
any
=
false
;
try
{
//TODO:目前交易对 没有激活 隐藏相关字段了 之后有的话 再补充
//let pair = await exPair.prototype.findOne({ where: { pair: ex_pair }, raw: true });
let
pair
=
null
;
if
(
!
pair
)
{
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
)
{
//交易对不存在,标记触发失败
await
systemTrigger
.
prototype
.
update
({
status
:
TRIGGER_STATUS_FAIL
},
{
where
:
{
id
:
trigId
,
status
:
0
}
});
rtn
=
false
;
...
...
@@ -117,8 +132,20 @@ export const doExPairTrigger = async function (trigId: any, ex_pair: any, action
try
{
console
.
log
(
'start transaction'
);
t
=
await
ormDB
.
transaction
();
//TODO: 目前交易对 没有激活 隐藏相关字段了 之后有的话 再补充
//await exPair.prototype.update(target_value, { where: { pair: ex_pair }, transaction: t });
if
(
pair
.
endsWith
(
"_SWAP"
))
{
await
contractPairs
.
prototype
.
update
(
target_value
,
{
where
:
{
id
:
dbPair
.
id
},
});
}
else
{
await
contractPairs
.
prototype
.
update
(
target_value
,
{
where
:
{
id
:
dbPair
.
id
},
});
}
await
systemTrigger
.
prototype
.
update
({
status
:
TRIGGER_STATUS_SUCCESS
},
{
where
:
{
id
:
trigId
,
status
:
0
},
transaction
:
t
});
await
t
.
commit
();
rtn
=
true
;
...
...
@@ -212,9 +239,42 @@ export const doCoinTypeTrigger = async function (trigId: any, coinSymbol: any, a
export
const
updateRedisPairs
=
async
function
()
{
console
.
log
(
'updateRedisPairs'
);
try
{
//TODO:没有了
//let list = await exPair.prototype.findAll({ where: { is_active: 1 } });
// redisUtilsCommon.writeSync(KEY_PAIR_LIST, JSON.stringify(list));
let
task1
=
spotPairs
.
prototype
.
findAll
({
where
:
{
is_active
:
1
},
raw
:
true
,
});
let
task2
=
contractPairs
.
prototype
.
findAll
({
where
:
{
is_active
:
1
},
raw
:
true
,
});
let
[
spotList
,
contractList
]
=
await
Promise
.
all
([
task1
,
task2
]);
let
list
:
any
=
[];
for
(
let
item
of
spotList
)
{
let
temp
=
{
id
:
item
.
id
,
pair
:
item
.
symbol
,
is_hide
:
item
.
is_hide
,
decimal
:
item
.
price_scale
,
amount_scale
:
item
.
quantity_scale
,
}
list
.
push
(
temp
);
}
for
(
let
item
of
contractList
)
{
let
temp
=
{
id
:
item
.
id
,
pair
:
item
.
symbol
,
is_hide
:
item
.
is_hide
,
decimal
:
item
.
price_scale
,
amount_scale
:
item
.
quantity_scale
,
}
list
.
push
(
temp
);
}
redisUtilsCommon
.
writeSync
(
KEY_PAIR_LIST
,
JSON
.
stringify
(
list
));
}
catch
(
e
)
{
console
.
error
(
e
);
...
...
src/constant/errorCode.ts
View file @
6bf92bde
...
...
@@ -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 @
6bf92bde
...
...
@@ -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 @
6bf92bde
...
...
@@ -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 @
6bf92bde
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 @
6bf92bde
...
...
@@ -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 @
6bf92bde
...
...
@@ -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 @
6bf92bde
...
...
@@ -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 @
6bf92bde
...
...
@@ -207,6 +207,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