Commit 2f6992f9 authored by ml's avatar ml

Merge branch 'master' of ssh://gitlab.mytoken.org:10022/zhuangke/ts-api-demo into asset_backend

# Conflicts:
#	src/constant/errorCode.ts
parents c60b827e 245eb6ec
...@@ -49,10 +49,10 @@ const syncPair = async () => { ...@@ -49,10 +49,10 @@ const syncPair = async () => {
await pairModel.prototype.update({ await pairModel.prototype.update({
status: 2, status: 2,
product_id: cfg.productId, product_id: cfg.productId,
price_scale: cfg["priceScale"], // price_scale: cfg["priceScale"],
price_increment: cfg["priceIncrement"], // price_increment: cfg["priceIncrement"],
quantity_scale: cfg["quantityScale"], // quantity_scale: cfg["quantityScale"],
quantity_increment: cfg["quantityIncrement"], // quantity_increment: cfg["quantityIncrement"],
taker_fee:cfg["takerFee"], taker_fee:cfg["takerFee"],
maker_fee:cfg["makerFee"] maker_fee:cfg["makerFee"]
}, { }, {
...@@ -87,31 +87,15 @@ const syncCoin = async () => { ...@@ -87,31 +87,15 @@ const syncCoin = async () => {
main_status: 2, main_status: 2,
asset_id: cfg["id"], asset_id: cfg["id"],
}, { }, {
where: { id, main_status: 1 } where: { general_name:symbol } // 同名币的一块更新了
}); });
logger.info(symbol, "sync config success") logger.info(symbol, "sync config success")
} }
} }
// 更新is_main等于0的状态
let dbsyncres = await coinType.prototype.findAll({
attributes: ['general_name','asset_id'],
where: {
is_main: 1,
main_status: 2,
},
raw: true
})
for (const coin of dbsyncres) {
await coinType.prototype.update({ main_status: 2,asset_id:coin.asset_id }, {
where: {
general_name: coin.general_name, is_main: 0, main_status: 0
}
})
}
} }
// job.invoke(); job.invoke();
...@@ -82,5 +82,7 @@ export const ErrorCode = { ...@@ -82,5 +82,7 @@ export const ErrorCode = {
PAIR_IS_NOT_ACTIVE:'30078',//交易对已是未激活状态 PAIR_IS_NOT_ACTIVE:'30078',//交易对已是未激活状态
PAIR_IS_HIDE:'30079',//交易对已是隐藏状态 PAIR_IS_HIDE:'30079',//交易对已是隐藏状态
PAIR_IS_NOT_HIDE:'30080',//交易对已是未隐藏状态 PAIR_IS_NOT_HIDE:'30080',//交易对已是未隐藏状态
STATUS_PASS_NO_UP:'30081',//审核已通过,不允许修改
AFTER_AUDIT_SUBMIT:'30082',//请先审核,再提交
PWD_FORMAT_ERR:'30083',//密码格式错误 PWD_FORMAT_ERR:'30083',//密码格式错误
} }
...@@ -21,6 +21,20 @@ export const list = async (req: any, param: ListParam) => { ...@@ -21,6 +21,20 @@ export const list = async (req: any, param: ListParam) => {
} }
}; };
export const chainList = async (req: any, param: ListParam) => {
let func_name = "coinTypeCtl.chainList";
let cmd = req.path;
try {
let res = await service.chainList();
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
export const save = async (req: any, param: AddParam) => { export const save = async (req: any, param: AddParam) => {
let func_name = "coinTypeCtl.save"; let func_name = "coinTypeCtl.save";
let cmd = req.path; let cmd = req.path;
...@@ -100,3 +114,34 @@ export const getAllSubmitSuccess = async (req: any, param: ListParam) => { ...@@ -100,3 +114,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);
}
};
...@@ -17,6 +17,9 @@ export const list = async (req: any, infoPageVO: I18nInfoPageVO) => { ...@@ -17,6 +17,9 @@ export const list = async (req: any, infoPageVO: I18nInfoPageVO) => {
try { try {
infoPageVO.page = Optional.opt(infoPageVO, 'page', 1); infoPageVO.page = Optional.opt(infoPageVO, 'page', 1);
infoPageVO.size = Optional.opt(infoPageVO, 'size', 20); infoPageVO.size = Optional.opt(infoPageVO, 'size', 20);
if (!infoPageVO.site){
throw ErrorCode.PARAM_MISS;
}
let res = await i18nService.list(infoPageVO); let res = await i18nService.list(infoPageVO);
return Res3Utils.result(res); return Res3Utils.result(res);
...@@ -37,6 +40,9 @@ export const add = async (req: any, infoVO: I18nInfoVO) => { ...@@ -37,6 +40,9 @@ export const add = async (req: any, infoVO: I18nInfoVO) => {
try { try {
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);
if (!infoVO.site){
throw ErrorCode.PARAM_MISS;
}
let res = await i18nService.add(infoVO,currentUserId,ip); let res = await i18nService.add(infoVO,currentUserId,ip);
return Res3Utils.result(res); return Res3Utils.result(res);
} }
...@@ -56,6 +62,9 @@ export const preview = async (req: any, infoVO: I18nInfoVO) => { ...@@ -56,6 +62,9 @@ export const preview = async (req: any, infoVO: I18nInfoVO) => {
let cmd = req.path; let cmd = req.path;
try { try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*'; let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
if (!infoVO.site){
throw ErrorCode.PARAM_MISS;
}
let currentUserId = await getCurrentUserId(req.cookies.session_id); let currentUserId = await getCurrentUserId(req.cookies.session_id);
let res = await i18nService.preview(infoVO,currentUserId,ip); let res = await i18nService.preview(infoVO,currentUserId,ip);
return Res3Utils.result(res); return Res3Utils.result(res);
...@@ -74,7 +83,10 @@ export const versionList = async (req: any, infoVO: I18nInfoVO) => { ...@@ -74,7 +83,10 @@ export const versionList = async (req: any, infoVO: I18nInfoVO) => {
let func_name = "i18nCtrl.versionList"; let func_name = "i18nCtrl.versionList";
let cmd = req.path; let cmd = req.path;
try { try {
let res = await i18nService.versionList(); if (!infoVO.site){
throw ErrorCode.PARAM_MISS;
}
let res = await i18nService.versionList(infoVO.site);
return Res3Utils.result(res); return Res3Utils.result(res);
} }
catch (e) { catch (e) {
......
...@@ -20,6 +20,9 @@ export const list = async (req: any, i18nInfoLogVO: I18nInfoLogVO) => { ...@@ -20,6 +20,9 @@ export const list = async (req: any, i18nInfoLogVO: I18nInfoLogVO) => {
if (!i18nInfoLogVO.version){ if (!i18nInfoLogVO.version){
throw ErrorCode.PARAM_MISS; throw ErrorCode.PARAM_MISS;
} }
if (!i18nInfoLogVO.site){
throw ErrorCode.PARAM_MISS;
}
let res = await i18nLogService.list(i18nInfoLogVO); let res = await i18nLogService.list(i18nInfoLogVO);
return Res3Utils.result(res); return Res3Utils.result(res);
} }
...@@ -40,6 +43,7 @@ export const revert = async (req: any, i18nInfoLogVO: I18nInfoLogVO) => { ...@@ -40,6 +43,7 @@ export const revert = async (req: any, i18nInfoLogVO: I18nInfoLogVO) => {
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);
ApiAssert.notNull(ErrorCode.PARAM_MISS, i18nInfoLogVO.version); ApiAssert.notNull(ErrorCode.PARAM_MISS, i18nInfoLogVO.version);
ApiAssert.notNull(ErrorCode.PARAM_MISS, i18nInfoLogVO.site);
let res = await i18nLogService.revert(i18nInfoLogVO,currentUserId,ip); let res = await i18nLogService.revert(i18nInfoLogVO,currentUserId,ip);
return Res3Utils.result(res); return Res3Utils.result(res);
} }
......
// @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 ,mixinCoin,mixinChain} from "@madex/ex-ts-dao";
import { addCoin2Core } 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";
const _ = require("lodash");
let { logger, datetimeUtils } = require('@madex/ex-js-public'); let { logger, datetimeUtils } = require('@madex/ex-js-public');
...@@ -24,6 +25,9 @@ export interface AddParam { ...@@ -24,6 +25,9 @@ export interface AddParam {
id: any, id: any,
symbol: string; symbol: string;
mixin_id: string;
asset_id: number;
is_active: number; is_active: number;
...@@ -127,12 +131,48 @@ export async function list(param: ListParam) { ...@@ -127,12 +131,48 @@ export async function list(param: ListParam) {
return resList; return resList;
} }
export async function chainList() {
let resList = await coinType.prototype.findAll({
attributes:['chain_type'],
where: {
is_main:1
},
raw: true
});
let chains:any[] = [];
for (let item of resList) {
let chainType = item.chain_type;
if (chainType) {
chains.push(chainType);
}
}
return chains;
}
export const save = async (param: AddParam, currentUserId: any, ip: any) => { export const save = async (param: AddParam, currentUserId: any, ip: any) => {
if (!param.weight) { if (!param.weight) {
param.weight = 0; param.weight = 0;
} }
param.updatedAt = new Date(); param.updatedAt = new Date();
param.createdAt = new Date(); param.createdAt = new Date();
let general_name = param.general_name;
let exist = await coinType.prototype.findOne({ // 同名币判断
where: {
is_main: 1,
general_name: general_name,
},
raw: true
});
if (exist) {
param.is_main = 0;
param.asset_id = exist.asset_id;
param.main_status = exist.main_status;
}else {
param.is_main = 1;
param.asset_id = 0;
param.main_status = 0;
}
await coinType.prototype.create(param); await coinType.prototype.create(param);
//管理后台操作日志 //管理后台操作日志
addOptLog(currentUserId, 0, '币种管理新增', ip, JSON.stringify(param), '币种管理'); addOptLog(currentUserId, 0, '币种管理新增', ip, JSON.stringify(param), '币种管理');
...@@ -150,6 +190,9 @@ export const update = async (param: AddParam, currentUserId: any, ip: any) => { ...@@ -150,6 +190,9 @@ export const update = async (param: AddParam, currentUserId: any, ip: any) => {
if (!dbInfo) { if (!dbInfo) {
throw ErrorCode.DATA_NOT_EXIST throw ErrorCode.DATA_NOT_EXIST
} }
if (dbInfo.audit_status) {//审核通过后不可修改
throw ErrorCode.STATUS_PASS_NO_UP
}
param.updatedAt = new Date(); param.updatedAt = new Date();
await coinType.prototype.update(param, { await coinType.prototype.update(param, {
where: { id: id } where: { id: id }
...@@ -169,6 +212,9 @@ export const pushToCoreSystem = async (id: any, currentUserId: any, ip: any) => ...@@ -169,6 +212,9 @@ export const pushToCoreSystem = async (id: any, currentUserId: any, ip: any) =>
if (!cfg) { if (!cfg) {
throw ErrorCode.SUBMIT_STATUS_OR_MAIN_ERR; throw ErrorCode.SUBMIT_STATUS_OR_MAIN_ERR;
} }
if (!cfg.audit_status) {
throw ErrorCode.AFTER_AUDIT_SUBMIT;
}
let symbol = cfg.general_name; let symbol = cfg.general_name;
let optResult = await addCoin2Core(symbol, cfg.id); let optResult = await addCoin2Core(symbol, cfg.id);
...@@ -196,3 +242,80 @@ export async function getAllSubmitSuccess() { ...@@ -196,3 +242,80 @@ export async function getAllSubmitSuccess() {
}); });
return resList; 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',['symbol_id','mixin_id'],'display_symbol','chain_id',
['address','contract'],['precision','original_decimals'],['dust','deposit_min'],['dust','withdraw_min'],
['confirm','deposit_confirm_count'],['confirm','safe_confirm_count'],
'price_btc','price_usd','balance','comment'],
// include:{
// model:mixinChain.prototype,
// required:true, //INNER JOIN
// attributes:['name','symbol','threshold','withdrawal_fee','is_memo'],
// },
where: where,
limit: param.size,
offset: (param.page - 1) * param.size,
order: [["symbol", "asc"]],
raw: true
});
let chainIDs =_.map(resList.rows,'chain_id')
let m = await mixinChain.prototype.findAll({
attributes:['name','symbol','threshold','withdrawal_fee','is_memo','chain_id'],
where:{
chain_id:chainIDs
},
raw: true,
})
let chainMap = _.keyBy(m,'chain_id');
for (const item of resList.rows) {
let isMainToken = (item.symbol_id ==item.chain_id &&item.chain_id ==item.contract)
if (chainMap[item.chain_id]) {
item.chain_type = chainMap[item.chain_id].symbol
item.issupport_memo = chainMap[item.chain_id].is_memo;
item.valid_decimals = 8;
item.withdraw_fee = isMainToken ? chainMap[item.chain_id].withdrawal_fee : (5 / (item.price_usd > 0 ? item.price_usd : 0.001)).toFixed(4);
}
if (item.contract) {
item.is_erc20=1;
}else {
item.is_erc20=0;
}
}
return resList;
}
\ No newline at end of file
...@@ -15,8 +15,16 @@ export interface CoinTypeApplyVO { ...@@ -15,8 +15,16 @@ export interface CoinTypeApplyVO {
symbol?: string; symbol?: string;
mixin_id?: string;
name?: string; name?: string;
general_name?: string;
chain_type?: string;
issupport_memo?: number;
forbid_info?: string; forbid_info?: string;
explor_url?: string; explor_url?: string;
...@@ -43,6 +51,8 @@ export interface CoinTypeApplyVO { ...@@ -43,6 +51,8 @@ export interface CoinTypeApplyVO {
withdraw_min?: string; withdraw_min?: string;
deposit_min?: string;
tm_enable_deposit?: Date | any, tm_enable_deposit?: Date | any,
tm_enable_withdraw?: Date | any, tm_enable_withdraw?: Date | any,
...@@ -267,12 +277,38 @@ export async function review(id: any, currentUser: any, ip: string | undefined) ...@@ -267,12 +277,38 @@ export async function review(id: any, currentUser: any, ip: string | undefined)
if (dbSymbol) { if (dbSymbol) {
throw ErrorCode.COIN_DATA_EXIST; throw ErrorCode.COIN_DATA_EXIST;
} }
let exist = await coinType.prototype.findOne({
where: {
is_main:1,
general_name:dbApply.general_name,
},
raw: true
});
let is_main = 0;
let asset_id = 0;
let main_status = 0;
if (exist) {
is_main = 0; // 同名币
asset_id = exist.asset_id;
main_status = exist.main_status;
}else {
is_main = 1;
asset_id = 0;
main_status = 0;
}
let insertInfo = { let insertInfo = {
symbol: dbApply.symbol, symbol: dbApply.symbol,
is_active: 1, is_active: 1,
is_main: 1, asset_id:asset_id,
is_main: is_main,
main_status:main_status,
name: dbApply.name, name: dbApply.name,
general_name: dbApply.name, mixin_id:dbApply.mixin_id,
issupport_memo:dbApply.issupport_memo,
deposit_min:dbApply.deposit_min,
general_name: dbApply.general_name,
chain_type:dbApply.chain_type,
original_decimals: dbApply.original_decimals, original_decimals: dbApply.original_decimals,
valid_decimals: dbApply.valid_decimals, valid_decimals: dbApply.valid_decimals,
is_erc20: dbApply.is_erc20, is_erc20: dbApply.is_erc20,
...@@ -288,10 +324,9 @@ export async function review(id: any, currentUser: any, ip: string | undefined) ...@@ -288,10 +324,9 @@ export async function review(id: any, currentUser: any, ip: string | undefined)
forbid_info: dbApply.forbid_info, forbid_info: dbApply.forbid_info,
enable_deposit: 0, enable_deposit: 0,
enable_withdraw: 0, enable_withdraw: 0,
main_status: 0,
createdAt: new Date(), createdAt: new Date(),
updatedAt: new Date(), updatedAt: new Date(),
} };
await coinType.prototype.create(insertInfo); await coinType.prototype.create(insertInfo);
reason = "币种创建完成"; reason = "币种创建完成";
await updateApply(Number(id), APPLY_STATUS.CREATE_SYMBOL, currentUser.account, reason, dbApply.symbol); await updateApply(Number(id), APPLY_STATUS.CREATE_SYMBOL, currentUser.account, reason, dbApply.symbol);
...@@ -360,6 +395,7 @@ export async function review(id: any, currentUser: any, ip: string | undefined) ...@@ -360,6 +395,7 @@ export async function review(id: any, currentUser: any, ip: string | undefined)
} }
let res = await addCoin2Core(dbSymbol.symbol, dbSymbol.id); let res = await addCoin2Core(dbSymbol.symbol, dbSymbol.id);
if (!res.is_success) { if (!res.is_success) {
RobotUtil.sendRobotMessage(RobotUtil.ROBOT_KEYS.COMMON_KEY, res.err_msg);
throw ErrorCode.ADD_PAIR_TO_CORE_ERR; throw ErrorCode.ADD_PAIR_TO_CORE_ERR;
} }
await coinType.prototype.update({ main_status: 1 }, { await coinType.prototype.update({ main_status: 1 }, {
......
...@@ -77,7 +77,7 @@ export async function list(pageVO: BusinessAreaPageVO) { ...@@ -77,7 +77,7 @@ export async function list(pageVO: BusinessAreaPageVO) {
} }
let resList = await exBusinessArea.prototype.findAll({ let resList = await exBusinessArea.prototype.findAll({
order: [["id", "asc"]], order: [["level","asc"],["id", "asc"]],
raw: true raw: true
}); });
return resList; return resList;
......
...@@ -10,6 +10,8 @@ let _ = require('lodash'); ...@@ -10,6 +10,8 @@ let _ = require('lodash');
export interface I18nInfoVO { export interface I18nInfoVO {
info_json: string; info_json: string;
site: string;
} }
export interface I18nInfoPageVO extends I18nInfoVO { export interface I18nInfoPageVO extends I18nInfoVO {
...@@ -27,7 +29,9 @@ export interface I18nInfoPageVO extends I18nInfoVO { ...@@ -27,7 +29,9 @@ export interface I18nInfoPageVO extends I18nInfoVO {
} }
export const list = async (infoPageVO: I18nInfoPageVO) => { export const list = async (infoPageVO: I18nInfoPageVO) => {
let condition = {}; let condition = {
site: infoPageVO.site
};
if (infoPageVO.platform) { if (infoPageVO.platform) {
condition['platform'] = Number(infoPageVO.platform); condition['platform'] = Number(infoPageVO.platform);
} }
...@@ -59,7 +63,8 @@ export const add = async (infoVO: I18nInfoVO, currentUserId: any, ip: any) => { ...@@ -59,7 +63,8 @@ export const add = async (infoVO: I18nInfoVO, currentUserId: any, ip: any) => {
throw ErrorCode.PARAM_MISS; throw ErrorCode.PARAM_MISS;
} }
let infoList = JSON.parse(infoJson); let infoList = JSON.parse(infoJson);
let lastVersionList = await getLastVersionList();
let lastVersionList = await getLastVersionList(infoVO.site);
let timestamp = new Date(); let timestamp = new Date();
let insertHistoryList: any = []; let insertHistoryList: any = [];
...@@ -86,25 +91,26 @@ export const add = async (infoVO: I18nInfoVO, currentUserId: any, ip: any) => { ...@@ -86,25 +91,26 @@ export const add = async (infoVO: I18nInfoVO, currentUserId: any, ip: any) => {
let key = insertOne['platform'] + '_' + insertOne['module'] + '_' + insertOne['code']; let key = insertOne['platform'] + '_' + insertOne['module'] + '_' + insertOne['code'];
insertOne.version = version; insertOne.version = version;
insertOne.sub_code = insertOne.sub_code ? insertOne.sub_code : insertOne.site = infoVO.site;
insertOne.sub_code = insertOne.sub_code !== null ? insertOne.sub_code :
(lastVersionMap[key] ? lastVersionMap[key].sub_code : ''); (lastVersionMap[key] ? lastVersionMap[key].sub_code : '');
insertOne.zh_cn = insertOne.zh_cn ? insertOne.zh_cn : insertOne.zh_cn = insertOne.zh_cn !== null ? insertOne.zh_cn :
(lastVersionMap[key] ? lastVersionMap[key].zh_cn : ''); (lastVersionMap[key] ? lastVersionMap[key].zh_cn : '');
insertOne.en_us = insertOne.en_us ? insertOne.en_us : insertOne.en_us = insertOne.en_us !== null ? insertOne.en_us :
(lastVersionMap[key] ? lastVersionMap[key].en_us : ''); (lastVersionMap[key] ? lastVersionMap[key].en_us : '');
insertOne.ja_jp = insertOne.ja_jp ? insertOne.ja_jp : insertOne.ja_jp = insertOne.ja_jp !== null ? insertOne.ja_jp :
(lastVersionMap[key] ? lastVersionMap[key].ja_jp : ''); (lastVersionMap[key] ? lastVersionMap[key].ja_jp : '');
insertOne.ko_kr = insertOne.ko_kr ? insertOne.ko_kr : insertOne.ko_kr = insertOne.ko_kr !== null ? insertOne.ko_kr :
(lastVersionMap[key] ? lastVersionMap[key].ko_kr : ''); (lastVersionMap[key] ? lastVersionMap[key].ko_kr : '');
insertOne.vi_vn = insertOne.vi_vn ? insertOne.vi_vn : insertOne.vi_vn = insertOne.vi_vn !== null ? insertOne.vi_vn :
(lastVersionMap[key] ? lastVersionMap[key].vi_vn : ''); (lastVersionMap[key] ? lastVersionMap[key].vi_vn : '');
insertOne.ar_ae = insertOne.ar_ae ? insertOne.ar_ae : insertOne.ar_ae = insertOne.ar_ae !== null ? insertOne.ar_ae :
(lastVersionMap[key] ? lastVersionMap[key].ar_ae : ''); (lastVersionMap[key] ? lastVersionMap[key].ar_ae : '');
insertOne.createdAt = timestamp; insertOne.createdAt = timestamp;
...@@ -163,7 +169,7 @@ export const preview = async (infoVO: I18nInfoVO, currentUserId: any, ip: any) = ...@@ -163,7 +169,7 @@ export const preview = async (infoVO: I18nInfoVO, currentUserId: any, ip: any) =
throw ErrorCode.PARAM_MISS; throw ErrorCode.PARAM_MISS;
} }
let infoList = JSON.parse(infoJson); let infoList = JSON.parse(infoJson);
let lastVersionList = await getLastVersionList(); let lastVersionList = await getLastVersionList(infoVO.site);
let timestamp = new Date().getTime(); let timestamp = new Date().getTime();
let lastVersionMap: any = {}; let lastVersionMap: any = {};
...@@ -186,25 +192,25 @@ export const preview = async (infoVO: I18nInfoVO, currentUserId: any, ip: any) = ...@@ -186,25 +192,25 @@ export const preview = async (infoVO: I18nInfoVO, currentUserId: any, ip: any) =
} }
let key = insertOne['platform'] + '_' + insertOne['module'] + '_' + insertOne['code']; let key = insertOne['platform'] + '_' + insertOne['module'] + '_' + insertOne['code'];
insertOne.sub_code = insertOne.sub_code ? insertOne.sub_code : insertOne.sub_code = insertOne.sub_code !== null ? insertOne.sub_code :
(lastVersionMap[key] ? lastVersionMap[key].sub_code : ''); (lastVersionMap[key] ? lastVersionMap[key].sub_code : '');
insertOne.zh_cn = insertOne.zh_cn ? insertOne.zh_cn : insertOne.zh_cn = insertOne.zh_cn !== null ? insertOne.zh_cn :
(lastVersionMap[key] ? lastVersionMap[key].zh_cn : ''); (lastVersionMap[key] ? lastVersionMap[key].zh_cn : '');
insertOne.en_us = insertOne.en_us ? insertOne.en_us : insertOne.en_us = insertOne.en_us !== null ? insertOne.en_us :
(lastVersionMap[key] ? lastVersionMap[key].en_us : ''); (lastVersionMap[key] ? lastVersionMap[key].en_us : '');
insertOne.ja_jp = insertOne.ja_jp ? insertOne.ja_jp : insertOne.ja_jp = insertOne.ja_jp !== null ? insertOne.ja_jp :
(lastVersionMap[key] ? lastVersionMap[key].ja_jp : ''); (lastVersionMap[key] ? lastVersionMap[key].ja_jp : '');
insertOne.ko_kr = insertOne.ko_kr ? insertOne.ko_kr : insertOne.ko_kr = insertOne.ko_kr !== null ? insertOne.ko_kr :
(lastVersionMap[key] ? lastVersionMap[key].ko_kr : ''); (lastVersionMap[key] ? lastVersionMap[key].ko_kr : '');
insertOne.vi_vn = insertOne.vi_vn ? insertOne.vi_vn : insertOne.vi_vn = insertOne.vi_vn !== null ? insertOne.vi_vn :
(lastVersionMap[key] ? lastVersionMap[key].vi_vn : ''); (lastVersionMap[key] ? lastVersionMap[key].vi_vn : '');
insertOne.ar_ae = insertOne.ar_ae ? insertOne.ar_ae : insertOne.ar_ae = insertOne.ar_ae !== null ? insertOne.ar_ae :
(lastVersionMap[key] ? lastVersionMap[key].ar_ae : ''); (lastVersionMap[key] ? lastVersionMap[key].ar_ae : '');
insertOne.updatedAt = timestamp; insertOne.updatedAt = timestamp;
...@@ -218,10 +224,12 @@ export const preview = async (infoVO: I18nInfoVO, currentUserId: any, ip: any) = ...@@ -218,10 +224,12 @@ export const preview = async (infoVO: I18nInfoVO, currentUserId: any, ip: any) =
return resList; return resList;
}; };
export const versionList = async () => { export const versionList = async (site:any) => {
let options = { let options = {
attributes: ['version', 'createdAt', 'updatedAt'], attributes: ['version', 'createdAt', 'updatedAt'],
where: {}, where: {
site:Number(site)
},
order: [['version', 'desc']], order: [['version', 'desc']],
group: ['version', 'createdAt', 'updatedAt'], group: ['version', 'createdAt', 'updatedAt'],
raw: true raw: true
...@@ -240,11 +248,13 @@ export const versionList = async () => { ...@@ -240,11 +248,13 @@ export const versionList = async () => {
/** /**
* 查询版本记录 * 查询站点版本记录
*/ */
export async function getLastVersionList() { export async function getLastVersionList(site: any) {
return await i18nInfo.prototype.findAll({ return await i18nInfo.prototype.findAll({
where: {}, where: {
site: Number(site)
},
order: [['id', 'asc']], order: [['id', 'asc']],
raw: true raw: true
}); });
......
...@@ -17,7 +17,8 @@ export interface I18nInfoLogVO extends I18nInfoPageVO { ...@@ -17,7 +17,8 @@ export interface I18nInfoLogVO extends I18nInfoPageVO {
export async function list(i18nInfoLogVO: I18nInfoLogVO) { export async function list(i18nInfoLogVO: I18nInfoLogVO) {
let condition = { let condition = {
version:i18nInfoLogVO.version version: i18nInfoLogVO.version,
site: Number(i18nInfoLogVO.site)
}; };
if (i18nInfoLogVO.platform) { if (i18nInfoLogVO.platform) {
condition['platform'] = Number(i18nInfoLogVO.platform); condition['platform'] = Number(i18nInfoLogVO.platform);
...@@ -48,7 +49,8 @@ export async function list(i18nInfoLogVO: I18nInfoLogVO) { ...@@ -48,7 +49,8 @@ export async function list(i18nInfoLogVO: I18nInfoLogVO) {
export async function revert(i18nInfoLogVO: I18nInfoLogVO, currentUserId: any, ip: any) { export async function revert(i18nInfoLogVO: I18nInfoLogVO, currentUserId: any, ip: any) {
let dbHistoryList = await i18nInfoHistory.prototype.findAll({ let dbHistoryList = await i18nInfoHistory.prototype.findAll({
where: { where: {
version: i18nInfoLogVO.version version: i18nInfoLogVO.version,
site: Number(i18nInfoLogVO.site)
}, },
order: [['info_id', 'asc']], order: [['info_id', 'asc']],
raw: true, raw: true,
...@@ -63,7 +65,7 @@ export async function revert(i18nInfoLogVO: I18nInfoLogVO, currentUserId: any, i ...@@ -63,7 +65,7 @@ export async function revert(i18nInfoLogVO: I18nInfoLogVO, currentUserId: any, i
insertInfoList.push(item); insertInfoList.push(item);
} }
let currentVersionList = await getLastVersionList(); let currentVersionList = await getLastVersionList(i18nInfoLogVO.site);
let current_version = ""; let current_version = "";
for (let item of currentVersionList) { for (let item of currentVersionList) {
...@@ -83,13 +85,16 @@ export async function revert(i18nInfoLogVO: I18nInfoLogVO, currentUserId: any, i ...@@ -83,13 +85,16 @@ export async function revert(i18nInfoLogVO: I18nInfoLogVO, currentUserId: any, i
//删除历史版本 //删除历史版本
await i18nInfoHistory.prototype.destroy({ await i18nInfoHistory.prototype.destroy({
where: { where: {
version: i18nInfoLogVO.version version: i18nInfoLogVO.version,
site: Number(i18nInfoLogVO.site)
}, },
transaction: tx transaction: tx
}); });
//删除当前版本 //删除当前版本
await i18nInfo.prototype.destroy({ await i18nInfo.prototype.destroy({
where: {}, where: {
site: Number(i18nInfoLogVO.site)
},
transaction: tx transaction: tx
}); });
//当前版本存入历史 //当前版本存入历史
......
...@@ -135,6 +135,8 @@ export async function apply(pairApplyVO: PairApplyVO, currentUser: any, ip: stri ...@@ -135,6 +135,8 @@ export async function apply(pairApplyVO: PairApplyVO, currentUser: any, ip: stri
pairApplyVO.status = PAIR_APPLY_STATUS.WAIT_VIEW; pairApplyVO.status = PAIR_APPLY_STATUS.WAIT_VIEW;
pairApplyVO.createdAt = new Date(); pairApplyVO.createdAt = new Date();
pairApplyVO.updatedAt = new Date(); pairApplyVO.updatedAt = new Date();
pairApplyVO.is_active = 0;
pairApplyVO.is_hide = 0;
if (Number(pairApplyVO.id) > 0) {//update if (Number(pairApplyVO.id) > 0) {//update
let dbApply = await exPairApply.prototype.findOne({ let dbApply = await exPairApply.prototype.findOne({
where: { id: pairApplyVO.id }, where: { id: pairApplyVO.id },
...@@ -269,7 +271,7 @@ export async function review(id: any, currentUser: any, ip: string | undefined) ...@@ -269,7 +271,7 @@ export async function review(id: any, currentUser: any, ip: string | undefined)
//检查交易对中的币种是否存在于coin_type 中 //检查交易对中的币种是否存在于coin_type 中
await checkPairInCoinType(pair); await checkPairInCoinType(pair);
//检查交易对是否存在 //检查交易对是否存在
await checkPairExist(pair, type); await checkPairExistBeforeCreate(pair, type);
let insertInfo = { let insertInfo = {
symbol: pair, symbol: pair,
...@@ -366,7 +368,9 @@ export async function review(id: any, currentUser: any, ip: string | undefined) ...@@ -366,7 +368,9 @@ export async function review(id: any, currentUser: any, ip: string | undefined)
param["max_order_value"] = dbPair.max_order_value; param["max_order_value"] = dbPair.max_order_value;
} }
let optResult = await addPairToCore(param); let optResult = await addPairToCore(param);
addOptLog(currentUser.userId, 0, '上新交易对申请审核-提交到撮合', ip, `param:${JSON.stringify(param)}`, '交易上下线管理');
if (!optResult.is_success) { if (!optResult.is_success) {
RobotUtil.sendRobotMessage(RobotUtil.ROBOT_KEYS.COMMON_KEY, optResult.err_msg);
throw ErrorCode.ADD_PAIR_TO_CORE_ERR; throw ErrorCode.ADD_PAIR_TO_CORE_ERR;
} }
//现货 //现货
...@@ -428,7 +432,7 @@ export async function review(id: any, currentUser: any, ip: string | undefined) ...@@ -428,7 +432,7 @@ export async function review(id: any, currentUser: any, ip: string | undefined)
} }
//管理后台操作日志 //管理后台操作日志
addOptLog(currentUser.userId, 0, '上新交易对申请审核', ip, `msg:${reason},dbInfo:${JSON.stringify(dbApply)}`, '交易上下线管理'); addOptLog(currentUser.userId, 0, '上新交易对申请审核', ip, `msg:${reason},dbInfo:${dbApply.id}`, '交易上下线管理');
return 'success'; return 'success';
} }
...@@ -508,3 +512,24 @@ async function checkPairExist(pair: string, type: number) { ...@@ -508,3 +512,24 @@ async function checkPairExist(pair: string, type: number) {
return dbPair; return dbPair;
} }
async function checkPairExistBeforeCreate(pair: string, type: number) {
let dbPair: any;
//现货
if (type == 1) {
dbPair = await spotPairs.prototype.findOne({
where: { symbol: pair },
raw: true
});
}
else {//合约
dbPair = await contractPairs.prototype.findOne({
where: { symbol: pair },
raw: true
});
}
if (dbPair) {
throw ErrorCode.PAIR_EXIST;
}
return dbPair;
}
...@@ -140,6 +140,12 @@ export const update = async (param: AddParam, currentUserId: any, ip: any) => { ...@@ -140,6 +140,12 @@ export const update = async (param: AddParam, currentUserId: any, ip: any) => {
if (param.quantity_increment) { if (param.quantity_increment) {
updateInfo['quantity_increment'] = param.quantity_increment updateInfo['quantity_increment'] = param.quantity_increment
} }
if (param.maker_fee) {
updateInfo['maker_fee'] = param.maker_fee
}
if (param.taker_fee) {
updateInfo['taker_fee'] = param.taker_fee
}
updateInfo['is_active'] = param.is_active ? param.is_active : 0; updateInfo['is_active'] = param.is_active ? param.is_active : 0;
updateInfo['is_hide'] = param.is_hide ? param.is_hide : 0; updateInfo['is_hide'] = param.is_hide ? param.is_hide : 0;
......
...@@ -83,6 +83,10 @@ const postFunc = { ...@@ -83,6 +83,10 @@ const postFunc = {
'coinType/list': coinTypeCtrl.list, 'coinType/list': coinTypeCtrl.list,
'coinType/pushToCoreSystem': coinTypeCtrl.pushToCoreSystem, 'coinType/pushToCoreSystem': coinTypeCtrl.pushToCoreSystem,
'coinType/getAllSubmitSuccess': coinTypeCtrl.getAllSubmitSuccess, 'coinType/getAllSubmitSuccess': coinTypeCtrl.getAllSubmitSuccess,
'coinType/audit': coinTypeCtrl.audit,
'coinType/mixinCoinList': coinTypeCtrl.mixinCoinList,
'coinType/chainList': coinTypeCtrl.chainList,
//权限管理 - 我的权限 //权限管理 - 我的权限
'user/getInfo': userOptCtrl.getInfo, 'user/getInfo': userOptCtrl.getInfo,
......
...@@ -31,8 +31,11 @@ let cmdWhiteList = { ...@@ -31,8 +31,11 @@ let cmdWhiteList = {
'coinType/save': 1, 'coinType/save': 1,
'coinType/update': 1, 'coinType/update': 1,
'coinType/list': 1, 'coinType/list': 1,
'coinType/chainList': 1,
'coinType/pushToCoreSystem': 1, 'coinType/pushToCoreSystem': 1,
'coinType/getAllSubmitSuccess': 1, 'coinType/getAllSubmitSuccess': 1,
'coinType/audit': 1,
'coinType/mixinCoinList': 1,
//权限管理 - 我的权限 //权限管理 - 我的权限
'user/getInfo': 1, 'user/getInfo': 1,
......
...@@ -16,11 +16,15 @@ const ExcludeApi = { ...@@ -16,11 +16,15 @@ const ExcludeApi = {
"user/login/confirm": 1, "user/login/confirm": 1,
"mUser/fee/vip/level/list": 1, "mUser/fee/vip/level/list": 1,
"spotPair/getAllSubmitSuccess": 1, "spotPair/getAllSubmitSuccess": 1,
"contractPair/getAllSubmitSuccess": 1,
"coinType/getAllSubmitSuccess": 1, "coinType/getAllSubmitSuccess": 1,
'acl/role/getAll': 1, 'acl/role/getAll': 1,
'position/allList': 1, 'position/allList': 1,
'department/allList': 1, 'department/allList': 1,
'operate/other/business/area/list': 1, 'operate/other/business/area/list': 1,
'coinType/mixinCoinList': 1,
'coinType/chainList': 1,
}; };
//管理员需要强制绑定,该位置做特殊处理 //管理员需要强制绑定,该位置做特殊处理
const AdminExcludeApi = { const AdminExcludeApi = {
......
import WebSocket from 'ws';
const client = new WebSocket('ws://127.0.0.1:8443?sid=12312',[],{"headers":{"api-key":111}});
// 心跳
let heartbeatInterval: any;
const heartbeatConfig = {
interval: 30000, // 心跳间隔
};
function heartBeat (){
console.log(new Date() +" send ping...")
client.ping()
}
client.on('error', console.error);
client.on('open', function open() {
console.log("success open!")
if (heartbeatInterval) {
clearInterval(heartbeatInterval);
}
heartbeatInterval = setInterval(heartBeat, heartbeatConfig.interval); // 设置心跳
});
client.on('message', function message(data) {
console.log('received: %s', data);
});
client.on('onclose', function message(data) {
if (heartbeatInterval) {
clearInterval(heartbeatInterval); // 清除心跳定时器
}
console.log('Connection closed');
});
client.on('pong',function (){
console.log("rec pong")
})
\ 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