Commit d41ae882 authored by ml's avatar ml

上交易对申请逻辑调整、增加接口、部分逻辑接口调整

parent 17c356ce
...@@ -75,4 +75,5 @@ export const ErrorCode = { ...@@ -75,4 +75,5 @@ export const ErrorCode = {
NO_TRIGGER_DEL:'30071',//只有未触发的任务可以删除 NO_TRIGGER_DEL:'30071',//只有未触发的任务可以删除
EXIST_ACTIVE_PAIR:'30072',//已存在生效或即将生效的该交易对费率配置 EXIST_ACTIVE_PAIR:'30072',//已存在生效或即将生效的该交易对费率配置
FEE_EX_OR_DEL:'30073',//费率设置已过期或已删除,不可以修改 FEE_EX_OR_DEL:'30073',//费率设置已过期或已删除,不可以修改
PAIR_FORMAT_ERR:'30074',//交易对格式错误
} }
...@@ -25,14 +25,22 @@ export const save = async (req: any, param: AddParam) => { ...@@ -25,14 +25,22 @@ export const save = async (req: any, param: AddParam) => {
let func_name = "contactPairCtl.save"; let func_name = "contactPairCtl.save";
let cmd = req.path; let cmd = req.path;
try { try {
ApiAssert.notNull('3000', param.base);
ApiAssert.notNull('3000', param.quote);
ApiAssert.notNull('3000', param.symbol); ApiAssert.notNull('3000', param.symbol);
ApiAssert.notNull('3000', param.name); ApiAssert.notNull('3000', param.name);
ApiAssert.notNull('3000', param.index);
ApiAssert.notNull('3000', param.settlement_asset);
ApiAssert.notNull('3000', param.price_scale); ApiAssert.notNull('3000', param.price_scale);
ApiAssert.notNull('3000', param.quantity_scale); ApiAssert.notNull('3000', param.quantity_scale);
ApiAssert.notNull('3000', param.maker_fee); ApiAssert.notNull('3000', param.maker_fee);
ApiAssert.notNull('3000', param.taker_fee); ApiAssert.notNull('3000', param.taker_fee);
ApiAssert.notNull('3000', param.default_initial_margin);
ApiAssert.notNull('3000', param.base_initial_margin);
ApiAssert.notNull('3000', param.base_maintenance_margin);
ApiAssert.notNull('3000', param.base_interest);
ApiAssert.notNull('3000', param.quote_interest);
ApiAssert.notNull('3000', param.impact_notional);
ApiAssert.notNull('3000', param.base_risk_limit);
ApiAssert.notNull('3000', param.risk_limit_step);
let ip = isIp(req.ip) ? req.ip : '*.*.*.*'; let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id); let currentUserId = await getCurrentUserId(req.cookies.session_id);
let res = await service.save(param, currentUserId, ip); let res = await service.save(param, currentUserId, ip);
......
...@@ -70,3 +70,51 @@ export const tradeAssetsDetail = async (req: any, queryVO: QueryVO) => { ...@@ -70,3 +70,51 @@ export const tradeAssetsDetail = async (req: any, queryVO: QueryVO) => {
} }
}; };
/**
* 充值记录
* @param req
* @param infoVO
*/
export const depositList = async (req: any, queryVO: QueryVO) => {
let func_name = "mUserAssetsCtrl.depositList";
try {
queryVO.page = Optional.opt(queryVO, 'page', 1);
queryVO.size = Optional.opt(queryVO, 'size', 20);
if (!queryVO.user_id){
throw ErrorCode.PARAM_MISS
}
let res = await mUserAssetsService.depositList(queryVO.user_id, Number(queryVO.page), Number(queryVO.size));
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 提现记录
* @param req
* @param infoVO
*/
export const withdrawList = async (req: any, queryVO: QueryVO) => {
let func_name = "mUserAssetsCtrl.withdrawList";
try {
queryVO.page = Optional.opt(queryVO, 'page', 1);
queryVO.size = Optional.opt(queryVO, 'size', 20);
if (!queryVO.user_id){
throw ErrorCode.PARAM_MISS
}
let res = await mUserAssetsService.withdrawList(queryVO.user_id, Number(queryVO.page), Number(queryVO.size));
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
...@@ -46,25 +46,6 @@ export const listed = async (req: any, pageVO: PairApplyPageVO) => { ...@@ -46,25 +46,6 @@ export const listed = async (req: any, pageVO: PairApplyPageVO) => {
} }
}; };
/**
* 技术部-交易上下线管理-已有交易区列表
* @param req
* @param infoVO
*/
export const tradeAreaList = async (req: any, pageVO: PairApplyPageVO) => {
let func_name = "pairApply.control.tradeAreaList";
try {
pageVO.page = Optional.opt(pageVO, 'page', 1);
pageVO.size = Optional.opt(pageVO, 'size', 20);
let res = await pairApplyService.tradeAreaList(pageVO);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/** /**
* 技术部-交易上下线管理-申请上新交易对 * 技术部-交易上下线管理-申请上新交易对
* @param req * @param req
...@@ -201,18 +182,23 @@ export const review = async (req: any, pairApplyVO: PairApplyVO) => { ...@@ -201,18 +182,23 @@ export const review = async (req: any, pairApplyVO: PairApplyVO) => {
async function paramValid(pairApplyVO: PairApplyVO) { async function paramValid(pairApplyVO: PairApplyVO) {
if (!pairApplyVO.coin_symbol || !pairApplyVO.currency_symbol if (!pairApplyVO.type || !pairApplyVO.symbol
|| !pairApplyVO.decimal || !pairApplyVO.qtyPrecision || !pairApplyVO.name || !pairApplyVO.price_scale
|| !pairApplyVO.weight || !pairApplyVO.baseMinValue || !pairApplyVO.quantity_scale || !pairApplyVO.maker_fee
|| !pairApplyVO.quoteMinValue) { || !pairApplyVO.taker_fee) {
throw ErrorCode.PARAM_MISS; throw ErrorCode.PARAM_MISS;
} }
if (!pairApplyVO.pair_type) { //申请上合约交易对
pairApplyVO.pair_type = 0 if (pairApplyVO.type == 2) {
} if (!pairApplyVO.settlement_asset || !pairApplyVO.default_initial_margin
if (!pairApplyVO.area_id) { || !pairApplyVO.base_initial_margin || !pairApplyVO.base_maintenance_margin
pairApplyVO.area_id = 0 || !pairApplyVO.base_interest || !pairApplyVO.quote_interest
|| !pairApplyVO.impact_notional || !pairApplyVO.base_risk_limit
|| !pairApplyVO.risk_limit_step) {
throw ErrorCode.PARAM_MISS;
}
} }
if (!pairApplyVO.business_area_id) { if (!pairApplyVO.business_area_id) {
pairApplyVO.business_area_id = 0 pairApplyVO.business_area_id = 0
} }
......
...@@ -24,6 +24,8 @@ export interface AppVersionVO { ...@@ -24,6 +24,8 @@ export interface AppVersionVO {
comment_en?: string; comment_en?: string;
comment_ja?: string;
platform?: number, platform?: number,
grayscale_value?: number, grayscale_value?: number,
......
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上 // @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import { coinType, ormDB, spotPairs } from "@madex/ex-ts-dao"; import { coinType, ormDB, spotPairs } from "@madex/ex-ts-dao";
import { addCoin2Core, addPairToCore } from "../../../utils/coreSystemUtils"; import { addCoin2Core } from "../../../utils/coreSystemUtils";
import { ErrorCode } from "../../../constant/errorCode"; import { ErrorCode } from "../../../constant/errorCode";
import { addOptLog } from "./userOptLog.service"; import { addOptLog } from "./userOptLog.service";
......
...@@ -4,6 +4,7 @@ import { NUMBER } from "sequelize"; ...@@ -4,6 +4,7 @@ import { NUMBER } from "sequelize";
import { addPairToCore } from "../../../utils/coreSystemUtils"; import { addPairToCore } from "../../../utils/coreSystemUtils";
import { ErrorCode } from "../../../constant/errorCode"; import { ErrorCode } from "../../../constant/errorCode";
import { addOptLog } from "./userOptLog.service"; import { addOptLog } from "./userOptLog.service";
import { checkPairInCoinType } from "../../../utils/coinTypeUtils";
let { logger, datetimeUtils } = require('@madex/ex-js-public'); let { logger, datetimeUtils } = require('@madex/ex-js-public');
...@@ -109,6 +110,9 @@ export async function list(param: ListParam) { ...@@ -109,6 +110,9 @@ export async function list(param: ListParam) {
} }
export const save = async (param: AddParam, currentUserId: any, ip: any) => { export const save = async (param: AddParam, currentUserId: any, ip: any) => {
//检查交易对中的币种是否存在于coin_type 中
await checkPairInCoinType(String(param.symbol));
param.updatedAt = new Date(); param.updatedAt = new Date();
param.createdAt = new Date(); param.createdAt = new Date();
let dbInfo = await contractPairs.prototype.findOne({ let dbInfo = await contractPairs.prototype.findOne({
......
import { exPairApply, coinType, ormDB, systemTrigger, spotPairs, exTradeArea, exBusinessAreaRouter } from "@madex/ex-ts-dao"; import { exPairApply, coinType, ormDB, systemTrigger, spotPairs, exTradeArea, exBusinessAreaRouter } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode"; import { ErrorCode } from "../../../constant/errorCode";
import { addOptLog } from "./userOptLog.service"; import { addOptLog } from "./userOptLog.service";
import { addCoin2Core, addPairToCore } from "../../../utils/coreSystemUtils";
import { PAIR_APPLY_STATUS } from "../../../constant/pairApplyConst"; import { PAIR_APPLY_STATUS } from "../../../constant/pairApplyConst";
......
...@@ -102,7 +102,7 @@ export async function withdrawList(pageVO: QueryVO) { ...@@ -102,7 +102,7 @@ export async function withdrawList(pageVO: QueryVO) {
return resList; return resList;
} }
async function dealReturnData(resList: any) { export async function dealReturnData(resList: any) {
if (resList.rows.length) { if (resList.rows.length) {
let usdtTickerMap = {}; let usdtTickerMap = {};
for (let item of resList.rows) { for (let item of resList.rows) {
......
import { ormDB, mainUserAsset } from "@madex/ex-ts-dao"; import { ormDB, mainUserAsset, coinTx, coinWithdraw } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode"; import { ErrorCode } from "../../../constant/errorCode";
import BigNumber from "bignumber.js"; import BigNumber from "bignumber.js";
import { any } from "async"; import { any } from "async";
import { getUserAccountFromCore } from "../../../utils/coreSystemUtils"; import { getUserAccountFromCore } from "../../../utils/coreSystemUtils";
import { dealReturnData } from "./depositAndWithdraw.service";
let _ = require('lodash'); let _ = require('lodash');
...@@ -288,6 +289,42 @@ export async function tradeAssetByUids(uids: number[]) { ...@@ -288,6 +289,42 @@ export async function tradeAssetByUids(uids: number[]) {
} }
export async function depositList(user_id: number, page: number, size: number) {
let where = {
user_id: user_id
};
let resList = await coinTx.prototype.findAndCount({
where: where,
limit: size,
offset: (Number(page) - 1) * Number(size),
order: [["createdAt", "desc"]],
raw: true
});
await dealReturnData(resList);
return resList;
}
export async function withdrawList(user_id: number, page: number, size: number) {
let where = {
user_id: user_id
};
let resList = await coinWithdraw.prototype.findAndCount({
where: where,
limit: size,
offset: (Number(page) - 1) * Number(size),
order: [["createdAt", "desc"]],
raw: true
});
await dealReturnData(resList);
return resList;
}
......
...@@ -4,6 +4,7 @@ import { NUMBER } from "sequelize"; ...@@ -4,6 +4,7 @@ import { NUMBER } from "sequelize";
import { addPairToCore } from "../../../utils/coreSystemUtils"; import { addPairToCore } from "../../../utils/coreSystemUtils";
import { ErrorCode } from "../../../constant/errorCode"; import { ErrorCode } from "../../../constant/errorCode";
import { addOptLog } from "./userOptLog.service"; import { addOptLog } from "./userOptLog.service";
import { checkPairInCoinType } from "../../../utils/coinTypeUtils";
let { logger, datetimeUtils } = require('@madex/ex-js-public'); let { logger, datetimeUtils } = require('@madex/ex-js-public');
...@@ -86,6 +87,10 @@ export async function list(param: ListParam) { ...@@ -86,6 +87,10 @@ export async function list(param: ListParam) {
} }
export const save = async (param: AddParam, currentUserId: any, ip: any) => { export const save = async (param: AddParam, currentUserId: any, ip: any) => {
//检查交易对中的币种是否存在于coin_type 中
await checkPairInCoinType(String(param.symbol));
param.updatedAt = new Date(); param.updatedAt = new Date();
param.createdAt = new Date(); param.createdAt = new Date();
let dbInfo = await spotPairs.prototype.findOne({ let dbInfo = await spotPairs.prototype.findOne({
......
...@@ -149,6 +149,8 @@ const postFunc = { ...@@ -149,6 +149,8 @@ const postFunc = {
'mUser/manage/walletAsset/detail': mUserAssetsCtrl.walletAssetDetail,//Madex 用户管理 ->钱包账户资产详情 'mUser/manage/walletAsset/detail': mUserAssetsCtrl.walletAssetDetail,//Madex 用户管理 ->钱包账户资产详情
'mUser/manage/asset/distribution': mUserAssetsCtrl.assetDistribution,//Madex 用户管理 ->资产分布 'mUser/manage/asset/distribution': mUserAssetsCtrl.assetDistribution,//Madex 用户管理 ->资产分布
'mUser/manage/tradeAsset/detail': mUserAssetsCtrl.tradeAssetsDetail,//Madex 用户管理 ->交易账户资产详情 'mUser/manage/tradeAsset/detail': mUserAssetsCtrl.tradeAssetsDetail,//Madex 用户管理 ->交易账户资产详情
'mUser/manage/deposit/list': mUserAssetsCtrl.depositList,//Madex 用户管理 -> 充值记录
'mUser/manage/withdraw/list': mUserAssetsCtrl.withdrawList,//Madex 用户管理 -> 提现记录
'mUser/manage/order/pending/list': orderPendingAndHistoryCtrl.pendingList,//Madex 用户管理 ->当前委托 'mUser/manage/order/pending/list': orderPendingAndHistoryCtrl.pendingList,//Madex 用户管理 ->当前委托
'mUser/manage/order/history/list': orderPendingAndHistoryCtrl.historyList,//Madex 用户管理 ->历史委托 'mUser/manage/order/history/list': orderPendingAndHistoryCtrl.historyList,//Madex 用户管理 ->历史委托
'mUser/manage/order/detail/list': orderPendingAndHistoryCtrl.detailList,//Madex 用户管理 ->成交记录 'mUser/manage/order/detail/list': orderPendingAndHistoryCtrl.detailList,//Madex 用户管理 ->成交记录
...@@ -251,8 +253,8 @@ const postFunc = { ...@@ -251,8 +253,8 @@ const postFunc = {
'tech/apply/new/pair/apply/review': pairApplyCtrl.review,//审核申请上新交易对 'tech/apply/new/pair/apply/review': pairApplyCtrl.review,//审核申请上新交易对
'tech/apply/new/pair/apply/rewrite': pairApplyCtrl.rewrite,//驳回申请上新交易对 'tech/apply/new/pair/apply/rewrite': pairApplyCtrl.rewrite,//驳回申请上新交易对
'tech/apply/new/pair/apply/cancel': pairApplyCtrl.cancel,//管理员取消申请上新交易对 'tech/apply/new/pair/apply/cancel': pairApplyCtrl.cancel,//管理员取消申请上新交易对
'tech/apply/new/pair/trade/area/list': pairApplyCtrl.tradeAreaList,//已有交易区列表 //'tech/apply/new/pair/trade/area/list': pairApplyCtrl.tradeAreaList,//已有交易区列表
'tech/apply/new/pair/listed': pairApplyCtrl.listed,//已有交易对列表 //'tech/apply/new/pair/listed': pairApplyCtrl.listed,//已有交易对列表
//技术部-交易上下线管理-申请审核定时器 //技术部-交易上下线管理-申请审核定时器
'tech/apply/new/cron/list': cronApplyCtrl.list,//审核上币定时器信息列表 'tech/apply/new/cron/list': cronApplyCtrl.list,//审核上币定时器信息列表
'tech/apply/new/cron/delete': cronApplyCtrl.del,//删除审核上币定时器 'tech/apply/new/cron/delete': cronApplyCtrl.del,//删除审核上币定时器
......
...@@ -100,6 +100,8 @@ let cmdWhiteList = { ...@@ -100,6 +100,8 @@ let cmdWhiteList = {
'mUser/manage/walletAsset/detail': 1, 'mUser/manage/walletAsset/detail': 1,
'mUser/manage/asset/distribution': 1, 'mUser/manage/asset/distribution': 1,
'mUser/manage/tradeAsset/detail': 1, 'mUser/manage/tradeAsset/detail': 1,
'mUser/manage/deposit/list': 1,
'mUser/manage/withdraw/list': 1,
'mUser/manage/order/pending/list': 1, 'mUser/manage/order/pending/list': 1,
'mUser/manage/order/history/list': 1, 'mUser/manage/order/history/list': 1,
'mUser/manage/order/detail/list': 1, 'mUser/manage/order/detail/list': 1,
...@@ -196,8 +198,8 @@ let cmdWhiteList = { ...@@ -196,8 +198,8 @@ let cmdWhiteList = {
'tech/apply/new/pair/apply/review': 1, 'tech/apply/new/pair/apply/review': 1,
'tech/apply/new/pair/apply/rewrite': 1, 'tech/apply/new/pair/apply/rewrite': 1,
'tech/apply/new/pair/apply/cancel': 1, 'tech/apply/new/pair/apply/cancel': 1,
'tech/apply/new/pair/trade/area/list': 1, //'tech/apply/new/pair/trade/area/list': 1,
'tech/apply/new/pair/listed': 1, //'tech/apply/new/pair/listed': 1,
//技术部-交易上下线管理-申请审核定时器 //技术部-交易上下线管理-申请审核定时器
'tech/apply/new/cron/list': 1, 'tech/apply/new/cron/list': 1,
'tech/apply/new/cron/delete': 1, 'tech/apply/new/cron/delete': 1,
......
import { ErrorCode } from "../constant/errorCode";
import { coinType } from "@madex/ex-ts-dao";
/**
* 检查交易对中的币种是否存在于coin_type 中
* @param pair
*/
export const checkPairInCoinType = async function (pair: string) {
if (!pair) {
throw ErrorCode.PARAM_MISS;
}
let coin_symbol = pair.split('_')[0];
let currency_symbol = pair.split('_')[1];
if (!coin_symbol || !currency_symbol) {
throw ErrorCode.PAIR_FORMAT_ERR;
}
let dbSymbolTask = coinType.prototype.findOne({
where: { symbol: coin_symbol },
raw: true
});
let dbCurrencyTask = coinType.prototype.findOne({
where: { symbol: currency_symbol },
raw: true
});
let [dbSymbol, dbCurrency] = await Promise.all([dbSymbolTask, dbCurrencyTask]);
if (!dbSymbol) {
throw ErrorCode.COIN_DATA_NOT_EXIST;
}
if (!dbCurrency) {
throw ErrorCode.CURRENT_COIN_DATA_NOT_EXIST;
}
}
\ No newline at end of file
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