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
0fc3c283
Commit
0fc3c283
authored
Nov 05, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加消息机器人
补充部分TODO 锁定解锁账户修改
parent
4ab30d3f
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
88 additions
and
90 deletions
+88
-90
log4js.json
config/log4js.json
+1
-1
task.fee.rate.log.model.ts
cron/model/task.fee.rate.log.model.ts
+0
-65
task.fee.setting.status.update.model.ts
cron/model/task.fee.setting.status.update.model.ts
+4
-3
task.market.maker.statis.service.ts
cron/service/task.market.maker.statis.service.ts
+1
-1
commonUserFeeSetting.control.ts
src/functional/mvc/control/commonUserFeeSetting.control.ts
+4
-3
mUserManage.control.ts
src/functional/mvc/control/mUserManage.control.ts
+0
-2
pairApply.control.ts
src/functional/mvc/control/pairApply.control.ts
+1
-1
systemTrigger.control.ts
src/functional/mvc/control/systemTrigger.control.ts
+4
-1
aclRoleAuth.service.ts
src/functional/mvc/service/aclRoleAuth.service.ts
+0
-1
coinTypeApply.service.ts
src/functional/mvc/service/coinTypeApply.service.ts
+2
-2
mUserManage.service.ts
src/functional/mvc/service/mUserManage.service.ts
+4
-2
pairApply.service.ts
src/functional/mvc/service/pairApply.service.ts
+3
-2
feeRateCheckValidUtils.ts
src/utils/feeRateCheckValidUtils.ts
+5
-6
robotUtils.ts
src/utils/robotUtils.ts
+59
-0
No files found.
config/log4js.json
View file @
0fc3c283
{
"customBaseDir"
:
"/var/tmp/m
ytoken/"
,
"customBaseDir"
:
"/var/tmp/m
adex/backend/"
,
"customDefaultAtt"
:{
"type"
:
"file"
,
"maxLogSize"
:
"10M"
,
...
...
cron/model/task.fee.rate.log.model.ts
View file @
0fc3c283
...
...
@@ -103,30 +103,6 @@ let checkFeeModel = async function (fee_model) {
}
};
let
cancelIfSpotFeeExist
=
async
function
(
user_id
,
pair
,
maker_fee
,
taker_fee
,
logId
)
{
//TODO:原来获取正在生效的用户费率查此表 现在 ???
/* let dbFee = await DAO.spotUserFee.prototype.findOne({
where: {
user_id,
pair,
},
raw: true,
});*/
let
feeExist
=
false
;
/*if (dbFee) {
if (dbFee.maker_fee == maker_fee && dbFee.taker_fee == taker_fee) {
feeExist = true;
}
}
else if (maker_fee == 0.001 && taker_fee == 0.002) {
feeExist = true;
}*/
if
(
feeExist
)
{
throw
'fee exist'
;
}
}
let
checkFeeRate
=
async
function
(
fee_rate
)
{
let
_func_name_
=
'spotRpcUtils.checkFeeRate'
;
...
...
@@ -137,43 +113,10 @@ let checkFeeRate = async function (fee_rate) {
};
let
cancelIfContractFeeExist
=
async
function
(
user_id
,
pair
,
maker_fee
,
taker_fee
,
logId
)
{
//TODO:原来获取正在生效的用户费率查此表 现在 ???
/*let dbFee = await baseUUser.prototype.findOne({
where : {
user_id,
pair,
},
raw : true,
});*/
let
feeExist
=
false
;
/*if (dbFee) {
if (dbFee.maker_fee == maker_fee && dbFee.taker_fee == taker_fee) {
feeExist = true;
}
} else if (maker_fee == 0.0004 && taker_fee == 0.00060){
feeExist = true;
}*/
if
(
feeExist
)
{
throw
'fee exist'
;
}
}
export
const
changeUserSpotFee
=
async
function
(
user_id
,
symbol
,
fee_model
,
maker_fee
,
taker_fee
,
logId
)
{
let
is_success
=
true
;
await
checkFeeModel
(
fee_model
);
try
{
await
cancelIfSpotFeeExist
(
user_id
,
symbol
,
maker_fee
,
taker_fee
,
logId
);
}
catch
(
error
)
{
if
(
error
==
'fee exist'
)
{
return
is_success
;
}
}
let
asset
=
await
mainUserAsset
.
prototype
.
findOne
({
where
:
{
user_id
...
...
@@ -206,14 +149,6 @@ export const changeUserContractFee = async function (user_id, symbol, fee_model,
let
is_success
=
true
;
await
checkPair
(
symbol
,
2
);
try
{
await
cancelIfContractFeeExist
(
user_id
,
symbol
,
maker_fee
,
taker_fee
,
logId
);
}
catch
(
error
)
{
if
(
error
==
'fee exist'
)
{
return
is_success
;
}
}
let
asset
=
await
mainUserAsset
.
prototype
.
findOne
({
where
:
{
user_id
...
...
cron/model/task.fee.setting.status.update.model.ts
View file @
0fc3c283
...
...
@@ -3,6 +3,7 @@ import { FEE_STATUS } from "../../src/constant/marketMakerConst";
const
logger
=
require
(
'@bibox/bibox_public'
).
logger
;
import
*
as
RobotUtil
from
"../../src/utils/robotUtils"
;
let
OP
=
ormDB
.
Op
;
...
...
@@ -102,9 +103,9 @@ export const userFeeSettingStatusUpdate = async function (id, status) {
logger
.
warn
(
"task.fee.setting.status.update.model.userFeeSettingStatusUpdate data update success."
);
}
catch
(
e
)
{
l
ogger
.
error
(
"task.fee.setting.status.update.model.userFeeSettingStatusUpdate data update fail! "
+
"id: %s, status: %s"
,
id
,
status
);
//TODO:发lark
l
et
msg
=
`task.fee.setting.status.update.model.userFeeSettingStatusUpdate data update fail! id:
${
id
}
, status:
${
status
}
`
;
logger
.
error
(
msg
);
RobotUtil
.
sendRobotMessage
(
RobotUtil
.
ROBOT_KEYS
.
COMMON_KEY
,
msg
);
}
};
cron/service/task.market.maker.statis.service.ts
View file @
0fc3c283
...
...
@@ -107,7 +107,7 @@ async function projectMaker() {
// 获取交易对USDT交易量
async
function
getDealOneDayInUSDT
(
startTime
,
endTime
)
{
let
price
=
await
tickerUtils
.
rateCoin2USDT
(
'BTC'
);
//TODO:查
哪里???
//TODO:查
询交易数据
/*let priceRes = await ex_kline.find({
attributes: [[ormDBSpot.literal('AVG(close)'), 'closePrice']],
where: {
...
...
src/functional/mvc/control/commonUserFeeSetting.control.ts
View file @
0fc3c283
...
...
@@ -202,9 +202,11 @@ async function paramCheck(beginTime: any, expireTime: any, type: number, userId:
}
}
else
if
(
type
==
FEE_TYPE
.
FEE_TYPE_BASE_COIN_CONTRACT
)
{
if
(
!
await
baseCoinCheck
(
userId
))
{
//TODO:暂不支持币本位的 因为不知道怎么区分交易对,之后需要再放开即可
throw
ErrorCode
.
PARAM_MISS
;
/*if (!await baseCoinCheck(userId)) {
throw ErrorCode.COIN_NO_ASSETS;
}
}
*/
}
}
...
...
@@ -216,7 +218,6 @@ async function checkMaker(commonUserFeeVO: CommonUserFeeVO) {
}
//项目方
if
(
userChannel
==
2
)
{
//TODO:校验该用户是不是市商
let
statisPeriod
=
commonUserFeeVO
.
statis_period
;
let
amount_require_usdt
=
commonUserFeeVO
.
amount_require_usdt
;
if
(
!
statisPeriod
||
Number
(
statisPeriod
)
<
0
||
Number
(
statisPeriod
)
>
30
)
{
...
...
src/functional/mvc/control/mUserManage.control.ts
View file @
0fc3c283
...
...
@@ -90,7 +90,6 @@ export const updateUserEmail = async (req: any, queryVO: QueryVO) => {
* @param req
* @param queryVO
*/
//TODO: 前端需要弹窗选择锁定当前账户 还是 当前账户及其所有子账户
export
const
lockAccount
=
async
(
req
:
any
,
queryVO
:
QueryVO
)
=>
{
let
func_name
=
"mUserManageCtrl.lockAccount"
;
try
{
...
...
@@ -119,7 +118,6 @@ export const lockAccount = async (req: any, queryVO: QueryVO) => {
* @param req
* @param queryVO
*/
//TODO: 前端需要弹窗选择锁定当前账户 还是 当前账户及其所有子账户
export
const
unlockAccount
=
async
(
req
:
any
,
queryVO
:
QueryVO
)
=>
{
let
func_name
=
"mUserManageCtrl.unlockAccount"
;
try
{
...
...
src/functional/mvc/control/pairApply.control.ts
View file @
0fc3c283
...
...
@@ -27,7 +27,7 @@ export const list = async (req: any, pageVO: PairApplyPageVO) => {
};
/**
* TODO:现在查询的是spot_pairs 原来是ex_pair 后期是否需要调整?
* TODO:现在
没用 之后需要 再确认 现在
查询的是spot_pairs 原来是ex_pair 后期是否需要调整?
* 技术部-交易上下线管理-已有交易对列表
* @param req
* @param infoVO
...
...
src/functional/mvc/control/systemTrigger.control.ts
View file @
0fc3c283
...
...
@@ -114,7 +114,10 @@ async function paramValid(systemTriggerVO: SystemTriggerVO) {
}
}
else
{
//TODO:之前查的 ex_pair 现在查询的是 spot_pairs 是否需要补充别的查询合约交易对的逻辑???
//TODO: 这个需要确定下 之前的有 激活 隐藏 开启/关闭充值 开启/关闭提现 开启/关闭划转 现在没有对应的 激活 隐藏对应的字段了
// 之前的 只有 ex_pair 现在现货和合约是分开的 查询的是 spot_pairs 是否需要补充别的查询合约交易对的逻辑???
// 触发活动(coin_type:1xxx -- is_active=0 : 1010,is_active=1 :1011 ,enable_deposit=0:1020,enable_deposit=1:1021, enable_withdraw=0:1030,enable_withdraw=1:1031,enable_transfer=0:1040,enable_transfer=1:1041;
// ex_pair:2xxx -- is_active=0:2010,is_active=1:2011, is_hide=0:2020,is_hide=1:2021)
let
dbInfo
=
await
spotPairs
.
prototype
.
findOne
({
where
:
{
symbol
:
symbolOrPair
...
...
src/functional/mvc/service/aclRoleAuth.service.ts
View file @
0fc3c283
...
...
@@ -317,7 +317,6 @@ export const saveRole = async (aclRoleVO: AclRoleVO) => {
export
const
delRole
=
async
(
id
:
number
|
any
,
currentUserId
:
number
)
=>
{
//TODO: 此逻辑要不要加
/*if ([1, 2, 3, 4].includes(Number(id))) {
throw 'err:固有角色,无法删除'
}*/
...
...
src/functional/mvc/service/coinTypeApply.service.ts
View file @
0fc3c283
...
...
@@ -7,6 +7,7 @@ import { addCoin2Core } from "../../../utils/coreSystemUtils";
let
_
=
require
(
'lodash'
);
let
{
logger
,
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
import
*
as
RobotUtil
from
"../../../utils/robotUtils"
;
export
interface
CoinTypeApplyVO
{
...
...
@@ -391,7 +392,6 @@ async function updateApply(id: number, status: number, checker: string, reason:
sendMsg
(
status
,
symbol
);
}
//TODO:发送lark消息
async
function
sendMsg
(
status
:
number
,
symbol
:
string
)
{
let
content
=
""
;
if
(
status
==
APPLY_STATUS
.
RE_WRITE
)
{
...
...
@@ -420,7 +420,7 @@ async function sendMsg(status: number, symbol: string) {
}
if
(
content
)
{
//TODO:发lark
RobotUtil
.
sendRobotMessage
(
RobotUtil
.
ROBOT_KEYS
.
COMMON_KEY
,
content
);
}
}
src/functional/mvc/service/mUserManage.service.ts
View file @
0fc3c283
...
...
@@ -216,7 +216,8 @@ export async function lockAccount(currentUserId: number, m_user_id: any, ip: any
comment
=
`ip:
${
ip
}
,锁定用户:
${
fatherUserId
}
`
;
}
else
{
if
(
dnUidUserInfo
.
user_type
==
userInfo
.
USER_TYPE
.
SON
)
{
let
sonType
=
userInfo
.
USER_TYPE
.
SON
;
if
(
dnUidUserInfo
.
user_type
==
sonType
)
{
let
temp
=
await
getFatherUserId
(
m_user_id
);
if
(
!
temp
)
{
throw
ErrorCode
.
DAD_ACCOUNT_NOT_EXIST
;
...
...
@@ -275,7 +276,8 @@ export async function unlockAccount(currentUserId: number, m_user_id: any, ip: a
comment
=
`ip:
${
ip
}
,解锁用户:
${
fatherUserId
}
`
;
}
else
{
if
(
dnUidUserInfo
.
user_type
==
userInfo
.
USER_TYPE
.
SON
)
{
let
sonType
=
userInfo
.
USER_TYPE
.
SON
;
if
(
dnUidUserInfo
.
user_type
==
sonType
)
{
let
temp
=
await
getFatherUserId
(
m_user_id
);
if
(
!
temp
)
{
throw
ErrorCode
.
DAD_ACCOUNT_NOT_EXIST
;
...
...
src/functional/mvc/service/pairApply.service.ts
View file @
0fc3c283
...
...
@@ -5,6 +5,7 @@ import { addCoin2Core, addPairToCore } from "../../../utils/coreSystemUtils";
import
{
PAIR_APPLY_STATUS
}
from
"../../../constant/pairApplyConst"
;
import
{
checkPairInCoinType
}
from
"../../../utils/coinTypeUtils"
;
import
{
pairs
}
from
"rxjs"
;
import
*
as
RobotUtil
from
"../../../utils/robotUtils"
;
let
_
=
require
(
'lodash'
);
...
...
@@ -445,7 +446,6 @@ async function updateApply(id: number, status: number, checker: string, reason:
sendMsg
(
status
,
symbol
);
}
//TODO:发送lark消息
async
function
sendMsg
(
status
:
number
,
symbol
:
string
)
{
// 1被驳回2申请待审批3审批通过4交易对创建完成5交易对增加到撮合完成6等待撮合系统重启7发布交易对到撮合完成8交易对激活定时器完成9取消
let
content
=
""
;
...
...
@@ -477,7 +477,8 @@ async function sendMsg(status: number, symbol: string) {
content
=
"申请上交易对,被取消:"
+
symbol
+
",流程结束"
;
}
if
(
content
!=
null
)
{
//TODO:发lark
RobotUtil
.
sendRobotMessage
(
RobotUtil
.
ROBOT_KEYS
.
COMMON_KEY
,
content
);
}
}
...
...
src/utils/feeRateCheckValidUtils.ts
View file @
0fc3c283
import
{
mainUserAsset
}
from
"@madex/ex-ts-dao"
;
import
{
getUserAccountFromCore
}
from
"./coreSystemUtils"
;
let
blockCoin
=
"BIX0"
;
...
...
@@ -13,13 +14,11 @@ export const spotCheck = async function (user_id: number) {
}
export
const
baseCoinCheck
=
async
function
(
user_id
:
number
)
{
//TODO:后面补齐查询币本位资产逻辑
let
exist
=
{};
return
exist
;
let
resList
=
await
getUserAccountFromCore
(
user_id
);
return
resList
.
length
;
}
export
const
baseUCheck
=
async
function
(
user_id
:
number
)
{
//TODO:后面补齐查询U本位资产逻辑
let
exist
=
{};
return
exist
;
let
resList
=
await
getUserAccountFromCore
(
user_id
);
return
resList
.
length
;
}
\ No newline at end of file
src/utils/robotUtils.ts
0 → 100644
View file @
0fc3c283
let
{
debug
,
logger
}
=
require
(
'@madex/ex-js-public'
);
const
{
larkRobotUtils
:
LarkRobotUtils
,
}
=
require
(
"@madex/ex-js-common"
)
let
config
=
require
(
'../../config'
);
debug
=
config
.
env
===
"development"
;
let
COMMON_KEY
=
"9e06e260-6c2f-49d4-98b4-e08ef096f6f5"
;
//测试
if
(
debug
)
{
COMMON_KEY
=
"9e06e260-6c2f-49d4-98b4-e08ef096f6f5"
;
}
export
const
ROBOT_KEYS
=
{
COMMON_KEY
:
COMMON_KEY
}
/**
*
* @param url 机器人链接 (必填)
* @param content 发送内容(必填)
* @param _func_name_ 报错方法(可选)
*/
export
const
sendRobotMessage
=
async
function
(
url
:
string
,
content
:
any
,
_func_name_
?:
string
)
{
if
(
typeof
content
!=
'string'
)
{
if
(
content
&&
content
.
sql
)
{
content
=
`backend._func_name_
${
_func_name_
}
,
${
content
.
sql
}
`
;
}
else
if
(
content
&&
content
.
message
)
{
content
=
`backend._func_name_
${
_func_name_
}
,
${
content
.
message
}
`
;
}
else
{
content
=
`backend._func_name_
${
_func_name_
}
,
${
JSON
.
stringify
(
content
)}
`
;
}
}
else
{
content
=
`backend._func_name_
${
_func_name_
}
,
${
content
}
`
;
}
if
(
debug
)
{
content
=
`backend.测试.
${
content
}
`
;
await
doSend
(
COMMON_KEY
,
content
);
}
else
{
await
doSend
(
url
,
content
);
}
}
async
function
doSend
(
url
:
string
,
content
:
any
)
{
logger
.
info
(
'robot message'
,
url
,
content
);
await
LarkRobotUtils
.
sendTextSimple
(
url
,
content
).
catch
()
}
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