Commit 9e3c753b authored by ml's avatar ml

mixin 相关

parent 517e8b33
......@@ -82,4 +82,6 @@ export const ErrorCode = {
PAIR_IS_NOT_ACTIVE:'30078',//交易对已是未激活状态
PAIR_IS_HIDE:'30079',//交易对已是隐藏状态
PAIR_IS_NOT_HIDE:'30080',//交易对已是未隐藏状态
STATUS_PASS_NO_UP:'30081',//审核已通过,不允许修改
AFTER_AUDIT_SUBMIT:'30082',//请先审核,再提交
}
......@@ -100,3 +100,34 @@ export const getAllSubmitSuccess = async (req: any, param: ListParam) => {
}
};
export const audit = async (req: any, param: AddParam) => {
let func_name = "coinTypeCtl.audit";
let cmd = req.path;
try {
ApiAssert.notNull('3000', param.id);
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
let res = await service.audit(param, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
export const mixinCoinList = async (req: any, param: ListParam) => {
let func_name = "coinTypeCtl.list";
let cmd = req.path;
try {
param.page = Optional.opt(param, 'page', 1);
param.size = Optional.opt(param, 'size', 50);
let res = await service.mixinCoinList(param);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import { coinType, ormDB, spotPairs } from "@madex/ex-ts-dao";
import { coinType, ormDB, spotPairs ,mixinCoin} from "@madex/ex-ts-dao";
import { addCoin2Core } from "../../../utils/coreSystemUtils";
import { ErrorCode } from "../../../constant/errorCode";
import { addOptLog } from "./userOptLog.service";
......@@ -150,6 +150,9 @@ export const update = async (param: AddParam, currentUserId: any, ip: any) => {
if (!dbInfo) {
throw ErrorCode.DATA_NOT_EXIST
}
if (dbInfo.audit_status) {//审核通过后不可修改
throw ErrorCode.STATUS_PASS_NO_UP
}
param.updatedAt = new Date();
await coinType.prototype.update(param, {
where: { id: id }
......@@ -169,6 +172,9 @@ export const pushToCoreSystem = async (id: any, currentUserId: any, ip: any) =>
if (!cfg) {
throw ErrorCode.SUBMIT_STATUS_OR_MAIN_ERR;
}
if (!cfg.audit_status) {
throw ErrorCode.AFTER_AUDIT_SUBMIT;
}
let symbol = cfg.general_name;
let optResult = await addCoin2Core(symbol, cfg.id);
......@@ -195,4 +201,48 @@ export async function getAllSubmitSuccess() {
raw: true
});
return resList;
}
export const audit = async (param: AddParam, currentUserId: any, ip: any) => {
let id = param.id;
let dbInfo = await coinType.prototype.findOne({
where: {
id: id
},
raw: true
});
if (!dbInfo) {
throw ErrorCode.DATA_NOT_EXIST
}
param.updatedAt = new Date();
if (!dbInfo.audit_status) {
await coinType.prototype.update({
audit_status: 1,
}, {
where: { id: id }
})
//管理后台操作日志
addOptLog(currentUserId, 0, '币种管理审核', ip, JSON.stringify(param), '币种管理');
}
return 'ok';
};
export async function mixinCoinList(param: ListParam) {
let where = {};
if (param.symbol) {
where["symbol"] = { [ormDB.Op.like]: `%${param.symbol}%` };
}
let resList = await mixinCoin.prototype.findAndCount({
attributes:['symbol','name','symbol_id','display_symbol','chain_id','address','precision','dust','confirm','price_btc','price_usd','balance','comment'],
where: where,
limit: param.size,
offset: (param.page - 1) * param.size,
order: [["symbol", "asc"]],
raw: true
});
return resList;
}
\ No newline at end of file
......@@ -80,6 +80,8 @@ const postFunc = {
'coinType/list': coinTypeCtrl.list,
'coinType/pushToCoreSystem': coinTypeCtrl.pushToCoreSystem,
'coinType/getAllSubmitSuccess': coinTypeCtrl.getAllSubmitSuccess,
'coinType/audit': coinTypeCtrl.audit,
'coinType/mixinCoinList': coinTypeCtrl.mixinCoinList,
//权限管理 - 我的权限
'user/getInfo': userOptCtrl.getInfo,
......
......@@ -34,6 +34,8 @@ let cmdWhiteList = {
'coinType/list': 1,
'coinType/pushToCoreSystem': 1,
'coinType/getAllSubmitSuccess': 1,
'coinType/audit': 1,
'coinType/mixinCoinList': 1,
//权限管理 - 我的权限
'user/getInfo': 1,
......
......@@ -21,6 +21,7 @@ const ExcludeApi = {
'position/allList': 1,
'department/allList': 1,
'operate/other/business/area/list': 1,
'coinType/mixinCoinList': 1,
};
//管理员需要强制绑定,该位置做特殊处理
const AdminExcludeApi = {
......
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