Commit 55654328 authored by ml's avatar ml

增加接口、逻辑调整

parent 55eb492a
......@@ -72,4 +72,5 @@ export const ErrorCode = {
CURRENT_COIN_DATA_NOT_EXIST:'30068',//币种管理中计价币种不存在
PAIR_EXIST:'30069',//交易对对已存在
ACTIVE_TM_EXPIRE:'30070',//交易时间过短
NO_TRIGGER_DEL:'30071',//只有未触发的任务可以删除
}
import * as cronApplyService from "../service/cronApply.service";
import { CronApplyPageVO, CronApplyVO } from "../service/cronApply.service";
let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert, datetimeUtils } = require('@madex/ex-js-public');
import { ErrorCode } from "../../../constant/errorCode";
import { getCurrentUser, getCurrentUserId } from "../../../utils/aclUserUtils";
let isIp = require('is-ip');
/**
* 技术部-交易上下线管理-审核上币定时器信息列表
* @param req
* @param infoVO
*/
export const list = async (req: any, pageVO: CronApplyPageVO) => {
let func_name = "cronApply.control.list";
try {
pageVO.page = Optional.opt(pageVO, 'page', 1);
pageVO.size = Optional.opt(pageVO, 'size', 20);
let res = await cronApplyService.list(pageVO);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 技术部-交易上下线管理-删除审核上币定时器
* @param req
* @param authConfigVO
*/
export const del = async (req: any, cronApplyVO: CronApplyVO) => {
let func_name = "cronApply.control.del";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUser = await getCurrentUser(req.cookies.session_id);
if (!cronApplyVO.id) {
throw ErrorCode.PARAM_MISS;
}
let res = await cronApplyService.del(cronApplyVO.id, currentUser, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 技术部-交易上下线管理-增加新币充值定时器
* @param req
* @param authConfigVO
*/
export const addDeposit = async (req: any, cronApplyVO: CronApplyVO) => {
let func_name = "cronApply.control.addDeposit";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUser = await getCurrentUser(req.cookies.session_id);
if (!cronApplyVO.trigger_symbol || !cronApplyVO.trigger_time) {
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.addDeposit(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 addWithdraw = async (req: any, cronApplyVO: CronApplyVO) => {
let func_name = "cronApply.control.addWithdraw";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUser = await getCurrentUser(req.cookies.session_id);
if (!cronApplyVO.trigger_symbol || !cronApplyVO.trigger_time) {
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.addWithdraw(cronApplyVO, currentUser, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
......@@ -325,7 +325,7 @@ export async function submit(id: number, currentUserId: any, ip: string | undefi
}
else if (type == FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT) {//币本位
if (pair.toLowerCase() == "all") {
//TODO:币本位币对查询 enable = 1 的
//TODO:币本位币对查询 enable = 1 的 pairList = 数据库查询结果
let pairList = [];
let insertList: any = [];
let ids: any = [];
......@@ -351,7 +351,7 @@ export async function submit(id: number, currentUserId: any, ip: string | undefi
}
else {//U本位
if (pair.toLowerCase() == "all") {
//TODO:U本位币对查询 enable = 1 的
//TODO:U本位币对查询 enable = 1 的 pairList = 数据库查询结果
let pairList = [];
let insertList: any = [];
let ids: any = [];
......
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";
let _ = require('lodash');
let { logger, datetimeUtils } = require('@madex/ex-js-public');
export interface CronApplyVO {
id?: number;
trigger_symbol?: string;
trigger_type?: number;
trigger_action?: number;
trigger_time?: Date | any;
status?: number;
createdAt?: Date | any,
updatedAt?: Date | any,
}
export interface CronApplyPageVO extends CronApplyVO {
page?: number,
size?: number,
}
export async function list(pageVO: CronApplyPageVO) {
let resList = await systemTrigger.prototype.findAndCount({
limit: pageVO.size,
offset: (Number(pageVO.page) - 1) * Number(pageVO.size),
order: [["id", "desc"]],
raw: true
});
return resList;
}
export async function del(id: number, currentUser: any, ip: string | undefined) {
let dbInfo = await systemTrigger.prototype.findOne({
where: { id: id },
raw: true
});
if (!dbInfo) {
throw ErrorCode.DATA_NOT_EXIST
}
if (dbInfo && dbInfo.status != 0) {
throw ErrorCode.NO_TRIGGER_DEL
}
await systemTrigger.prototype.destroy({
where: {
id: id
}
});
//管理后台操作日志
addOptLog(currentUser.userId, 0, '删除审核上币定时器', ip, JSON.stringify(dbInfo), '交易上下线管理');
return 'success';
}
export async function addDeposit(cronApplyVO: CronApplyVO, currentUser: any, ip: any) {
let dbCoin = await coinType.prototype.findOne({
where:{
symbol:cronApplyVO.trigger_symbol
},
raw:true
});
if (!dbCoin){
throw ErrorCode.COIN_DATA_NOT_EXIST
}
cronApplyVO.trigger_type = 1;
cronApplyVO.trigger_action = 1021;
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 addWithdraw(cronApplyVO: CronApplyVO, currentUser: any, ip: any) {
let dbCoin = await coinType.prototype.findOne({
where:{
symbol:cronApplyVO.trigger_symbol
},
raw:true
});
if (!dbCoin){
throw ErrorCode.COIN_DATA_NOT_EXIST
}
cronApplyVO.trigger_type = 1;
cronApplyVO.trigger_action = 1031;
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';
}
......@@ -44,6 +44,7 @@ import * as contractAgentCtrl from "../../mvc/control/contractAgent.control";
import * as depositAndWithdrawCtrl from "../../mvc/control/depositAndWithdraw.control";
import * as coinTypeApplyCtrl from "../../mvc/control/coinTypeApply";
import * as pairApplyCtrl from "../../mvc/control/pairApply";
import * as cronApplyCtrl from "../../mvc/control/cronApply";
const getFunc = {
'user/info': userController.getUserInfo,
......@@ -247,6 +248,14 @@ const postFunc = {
'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/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/coin/add/deposit': cronApplyCtrl.addDeposit,//增加新币充值定时器
'tech/apply/new/cron/coin/add/withdraw': cronApplyCtrl.addWithdraw,//增加新币提现定时器
};
// TODO 这里先和 nodejs 的注册路由方式保持一样,后面在调整。
......
......@@ -189,13 +189,18 @@ let cmdWhiteList = {
//技术部-交易上下线管理-申请上新交易对
'tech/apply/new/pair/list': 1,
'tech/apply/new/pair/apply': 1,
'tech/apply/new/pair/apply/cancel/self':1,
'tech/apply/new/pair/apply/cancel/self': 1,
'tech/apply/new/pair/apply/edit': 1,
'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/cron/list': 1,
'tech/apply/new/cron/delete': 1,
'tech/apply/new/cron/coin/add/deposit': 1,
'tech/apply/new/cron/coin/add/withdraw': 1,
};
......
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