Commit 0fc3c283 authored by ml's avatar ml

增加消息机器人

补充部分TODO
锁定解锁账户修改
parent 4ab30d3f
{ {
"customBaseDir" :"/var/tmp/mytoken/", "customBaseDir" :"/var/tmp/madex/backend/",
"customDefaultAtt" :{ "customDefaultAtt" :{
"type": "file", "type": "file",
"maxLogSize": "10M", "maxLogSize": "10M",
......
...@@ -103,30 +103,6 @@ let checkFeeModel = async function (fee_model) { ...@@ -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 checkFeeRate = async function (fee_rate) {
let _func_name_ = 'spotRpcUtils.checkFeeRate'; let _func_name_ = 'spotRpcUtils.checkFeeRate';
...@@ -137,43 +113,10 @@ let checkFeeRate = async function (fee_rate) { ...@@ -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) { export const changeUserSpotFee = async function (user_id, symbol, fee_model, maker_fee, taker_fee, logId) {
let is_success = true; let is_success = true;
await checkFeeModel(fee_model); 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({ let asset = await mainUserAsset.prototype.findOne({
where: { where: {
user_id user_id
...@@ -206,14 +149,6 @@ export const changeUserContractFee = async function (user_id, symbol, fee_model, ...@@ -206,14 +149,6 @@ export const changeUserContractFee = async function (user_id, symbol, fee_model,
let is_success = true; let is_success = true;
await checkPair(symbol, 2); 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({ let asset = await mainUserAsset.prototype.findOne({
where: { where: {
user_id user_id
......
...@@ -3,6 +3,7 @@ import { FEE_STATUS } from "../../src/constant/marketMakerConst"; ...@@ -3,6 +3,7 @@ import { FEE_STATUS } from "../../src/constant/marketMakerConst";
const logger = require('@bibox/bibox_public').logger; const logger = require('@bibox/bibox_public').logger;
import * as RobotUtil from "../../src/utils/robotUtils";
let OP = ormDB.Op; let OP = ormDB.Op;
...@@ -102,9 +103,9 @@ export const userFeeSettingStatusUpdate = async function (id, status) { ...@@ -102,9 +103,9 @@ export const userFeeSettingStatusUpdate = async function (id, status) {
logger.warn("task.fee.setting.status.update.model.userFeeSettingStatusUpdate data update success."); logger.warn("task.fee.setting.status.update.model.userFeeSettingStatusUpdate data update success.");
} }
catch (e) { catch (e) {
logger.error("task.fee.setting.status.update.model.userFeeSettingStatusUpdate data update fail! " + let msg = `task.fee.setting.status.update.model.userFeeSettingStatusUpdate data update fail! id: ${id}, status: ${status}`;
"id: %s, status: %s", id, status); logger.error(msg);
//TODO:发lark RobotUtil.sendRobotMessage(RobotUtil.ROBOT_KEYS.COMMON_KEY, msg);
} }
}; };
...@@ -107,7 +107,7 @@ async function projectMaker() { ...@@ -107,7 +107,7 @@ async function projectMaker() {
// 获取交易对USDT交易量 // 获取交易对USDT交易量
async function getDealOneDayInUSDT(startTime, endTime) { async function getDealOneDayInUSDT(startTime, endTime) {
let price = await tickerUtils.rateCoin2USDT('BTC'); let price = await tickerUtils.rateCoin2USDT('BTC');
//TODO:查哪里??? //TODO:查询交易数据
/*let priceRes = await ex_kline.find({ /*let priceRes = await ex_kline.find({
attributes: [[ormDBSpot.literal('AVG(close)'), 'closePrice']], attributes: [[ormDBSpot.literal('AVG(close)'), 'closePrice']],
where: { where: {
......
...@@ -202,9 +202,11 @@ async function paramCheck(beginTime: any, expireTime: any, type: number, userId: ...@@ -202,9 +202,11 @@ async function paramCheck(beginTime: any, expireTime: any, type: number, userId:
} }
} }
else if (type == FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT) { 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; throw ErrorCode.COIN_NO_ASSETS;
} }*/
} }
} }
...@@ -216,7 +218,6 @@ async function checkMaker(commonUserFeeVO: CommonUserFeeVO) { ...@@ -216,7 +218,6 @@ async function checkMaker(commonUserFeeVO: CommonUserFeeVO) {
} }
//项目方 //项目方
if (userChannel == 2) { if (userChannel == 2) {
//TODO:校验该用户是不是市商
let statisPeriod = commonUserFeeVO.statis_period; let statisPeriod = commonUserFeeVO.statis_period;
let amount_require_usdt = commonUserFeeVO.amount_require_usdt; let amount_require_usdt = commonUserFeeVO.amount_require_usdt;
if (!statisPeriod || Number(statisPeriod) < 0 || Number(statisPeriod) > 30) { if (!statisPeriod || Number(statisPeriod) < 0 || Number(statisPeriod) > 30) {
......
...@@ -90,7 +90,6 @@ export const updateUserEmail = async (req: any, queryVO: QueryVO) => { ...@@ -90,7 +90,6 @@ export const updateUserEmail = async (req: any, queryVO: QueryVO) => {
* @param req * @param req
* @param queryVO * @param queryVO
*/ */
//TODO: 前端需要弹窗选择锁定当前账户 还是 当前账户及其所有子账户
export const lockAccount = async (req: any, queryVO: QueryVO) => { export const lockAccount = async (req: any, queryVO: QueryVO) => {
let func_name = "mUserManageCtrl.lockAccount"; let func_name = "mUserManageCtrl.lockAccount";
try { try {
...@@ -119,7 +118,6 @@ export const lockAccount = async (req: any, queryVO: QueryVO) => { ...@@ -119,7 +118,6 @@ export const lockAccount = async (req: any, queryVO: QueryVO) => {
* @param req * @param req
* @param queryVO * @param queryVO
*/ */
//TODO: 前端需要弹窗选择锁定当前账户 还是 当前账户及其所有子账户
export const unlockAccount = async (req: any, queryVO: QueryVO) => { export const unlockAccount = async (req: any, queryVO: QueryVO) => {
let func_name = "mUserManageCtrl.unlockAccount"; let func_name = "mUserManageCtrl.unlockAccount";
try { try {
......
...@@ -27,7 +27,7 @@ export const list = async (req: any, pageVO: PairApplyPageVO) => { ...@@ -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 req
* @param infoVO * @param infoVO
......
...@@ -114,7 +114,10 @@ async function paramValid(systemTriggerVO: SystemTriggerVO) { ...@@ -114,7 +114,10 @@ async function paramValid(systemTriggerVO: SystemTriggerVO) {
} }
} }
else { 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({ let dbInfo = await spotPairs.prototype.findOne({
where: { where: {
symbol: symbolOrPair symbol: symbolOrPair
......
...@@ -317,7 +317,6 @@ export const saveRole = async (aclRoleVO: AclRoleVO) => { ...@@ -317,7 +317,6 @@ export const saveRole = async (aclRoleVO: AclRoleVO) => {
export const delRole = async (id: number | any, currentUserId: number) => { export const delRole = async (id: number | any, currentUserId: number) => {
//TODO: 此逻辑要不要加
/*if ([1, 2, 3, 4].includes(Number(id))) { /*if ([1, 2, 3, 4].includes(Number(id))) {
throw 'err:固有角色,无法删除' throw 'err:固有角色,无法删除'
}*/ }*/
......
...@@ -7,6 +7,7 @@ import { addCoin2Core } from "../../../utils/coreSystemUtils"; ...@@ -7,6 +7,7 @@ import { addCoin2Core } from "../../../utils/coreSystemUtils";
let _ = require('lodash'); let _ = require('lodash');
let { logger, datetimeUtils } = require('@madex/ex-js-public'); let { logger, datetimeUtils } = require('@madex/ex-js-public');
import * as RobotUtil from "../../../utils/robotUtils";
export interface CoinTypeApplyVO { export interface CoinTypeApplyVO {
...@@ -391,7 +392,6 @@ async function updateApply(id: number, status: number, checker: string, reason: ...@@ -391,7 +392,6 @@ async function updateApply(id: number, status: number, checker: string, reason:
sendMsg(status, symbol); sendMsg(status, symbol);
} }
//TODO:发送lark消息
async function sendMsg(status: number, symbol: string) { async function sendMsg(status: number, symbol: string) {
let content = ""; let content = "";
if (status == APPLY_STATUS.RE_WRITE) { if (status == APPLY_STATUS.RE_WRITE) {
...@@ -420,7 +420,7 @@ async function sendMsg(status: number, symbol: string) { ...@@ -420,7 +420,7 @@ async function sendMsg(status: number, symbol: string) {
} }
if (content) { if (content) {
//TODO:发lark RobotUtil.sendRobotMessage(RobotUtil.ROBOT_KEYS.COMMON_KEY, content);
} }
} }
...@@ -216,7 +216,8 @@ export async function lockAccount(currentUserId: number, m_user_id: any, ip: any ...@@ -216,7 +216,8 @@ export async function lockAccount(currentUserId: number, m_user_id: any, ip: any
comment = `ip:${ip},锁定用户:${fatherUserId}`; comment = `ip:${ip},锁定用户:${fatherUserId}`;
} }
else { 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); let temp = await getFatherUserId(m_user_id);
if (!temp) { if (!temp) {
throw ErrorCode.DAD_ACCOUNT_NOT_EXIST; throw ErrorCode.DAD_ACCOUNT_NOT_EXIST;
...@@ -275,7 +276,8 @@ export async function unlockAccount(currentUserId: number, m_user_id: any, ip: a ...@@ -275,7 +276,8 @@ export async function unlockAccount(currentUserId: number, m_user_id: any, ip: a
comment = `ip:${ip},解锁用户:${fatherUserId}`; comment = `ip:${ip},解锁用户:${fatherUserId}`;
} }
else { 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); let temp = await getFatherUserId(m_user_id);
if (!temp) { if (!temp) {
throw ErrorCode.DAD_ACCOUNT_NOT_EXIST; throw ErrorCode.DAD_ACCOUNT_NOT_EXIST;
......
...@@ -5,6 +5,7 @@ import { addCoin2Core, addPairToCore } from "../../../utils/coreSystemUtils"; ...@@ -5,6 +5,7 @@ import { addCoin2Core, addPairToCore } from "../../../utils/coreSystemUtils";
import { PAIR_APPLY_STATUS } from "../../../constant/pairApplyConst"; import { PAIR_APPLY_STATUS } from "../../../constant/pairApplyConst";
import { checkPairInCoinType } from "../../../utils/coinTypeUtils"; import { checkPairInCoinType } from "../../../utils/coinTypeUtils";
import { pairs } from "rxjs"; import { pairs } from "rxjs";
import * as RobotUtil from "../../../utils/robotUtils";
let _ = require('lodash'); let _ = require('lodash');
...@@ -445,7 +446,6 @@ async function updateApply(id: number, status: number, checker: string, reason: ...@@ -445,7 +446,6 @@ async function updateApply(id: number, status: number, checker: string, reason:
sendMsg(status, symbol); sendMsg(status, symbol);
} }
//TODO:发送lark消息
async function sendMsg(status: number, symbol: string) { async function sendMsg(status: number, symbol: string) {
// 1被驳回2申请待审批3审批通过4交易对创建完成5交易对增加到撮合完成6等待撮合系统重启7发布交易对到撮合完成8交易对激活定时器完成9取消 // 1被驳回2申请待审批3审批通过4交易对创建完成5交易对增加到撮合完成6等待撮合系统重启7发布交易对到撮合完成8交易对激活定时器完成9取消
let content = ""; let content = "";
...@@ -477,7 +477,8 @@ async function sendMsg(status: number, symbol: string) { ...@@ -477,7 +477,8 @@ async function sendMsg(status: number, symbol: string) {
content = "申请上交易对,被取消:" + symbol + ",流程结束"; content = "申请上交易对,被取消:" + symbol + ",流程结束";
} }
if (content != null) { if (content != null) {
//TODO:发lark RobotUtil.sendRobotMessage(RobotUtil.ROBOT_KEYS.COMMON_KEY, content);
} }
} }
......
import { mainUserAsset } from "@madex/ex-ts-dao"; import { mainUserAsset } from "@madex/ex-ts-dao";
import { getUserAccountFromCore } from "./coreSystemUtils";
let blockCoin = "BIX0"; let blockCoin = "BIX0";
...@@ -13,13 +14,11 @@ export const spotCheck = async function (user_id: number) { ...@@ -13,13 +14,11 @@ export const spotCheck = async function (user_id: number) {
} }
export const baseCoinCheck = async function (user_id: number) { export const baseCoinCheck = async function (user_id: number) {
//TODO:后面补齐查询币本位资产逻辑 let resList = await getUserAccountFromCore(user_id);
let exist = {}; return resList.length;
return exist;
} }
export const baseUCheck = async function (user_id: number) { export const baseUCheck = async function (user_id: number) {
//TODO:后面补齐查询U本位资产逻辑 let resList = await getUserAccountFromCore(user_id);
let exist = {}; return resList.length;
return exist;
} }
\ No newline at end of file
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()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment