Commit a037a351 authored by 1486327116's avatar 1486327116

Merge remote-tracking branch 'origin/master'

parents f6263b68 4974661c
import BigNumber from "bignumber.js";
let { authCommon: AuthCommon, redisUtilsCommon: RedisClient, financeAccountDataUtils, finAccDwDataUtils, tickerUtils } = require('@madex/ex-js-common');
import { ROBOT_KEYS, sendRobotMessage } from "../../src/utils/robotUtils";
import { siteAssetsNoPage } from "../../src/functional/mvc/service/v2/assetCheck.service";
let { logger, datetimeUtils } = require('@madex/ex-js-public');
/**
* 余额和
* 资金转入转出检查并告警
*/
export const balanceAndFundingInOutCheck = async function (start_time: number, end_time: number) {
//账户
let accountList = await financeAccountDataUtils.getAccountInfoList();
if (!accountList.length) {
return;
}
//转入转出数据
let inOutDataList = await finAccDwDataUtils.getDepositAndWithdrawDataByAccounts(accountList, start_time, end_time);
//余额、初始资金数据
let balanceDataList = await financeAccountDataUtils.getFundingDataByAccounts(accountList);
let warningValueMap: any = {};
for (let account of accountList) {
warningValueMap[account.id] = account;
}
let balanceMap: any = {};
for (let oneData of balanceDataList) {
let { category_id, account_id, balance_usdt } = oneData;
let warning_value = warningValueMap[account_id] ? warningValueMap[account_id].balance_warning : 0;
let account_name = warningValueMap[account_id] ? warningValueMap[account_id].account : "未知账户名";
let platform_name = warningValueMap[account_id] ? getPlatformName(warningValueMap[account_id].platform) : "未知平台";
if (Number(balance_usdt) <= Number(warning_value)) {
let msg = `\n做市资金余额低于预设值\n时间:${new Date().toLocaleString()}\n账户ID:${account_id}\n账户名:${account_name}\n平台:${platform_name}\n当前余额:${Number(balance_usdt)}\n预设值:${Number(warning_value)}`;
await sendRobotMessage(ROBOT_KEYS.ABK_KEY, msg);
}
balanceMap[account_id] = balance_usdt;
}
let tickerMap = {};
for (let oneData of inOutDataList) {
let { account_id, symbol, change, bill_type, time } = oneData;
let usdt_rate = tickerMap[symbol] ? tickerMap[symbol] : await tickerUtils.rateCoin2USDT(symbol);
tickerMap[symbol] = usdt_rate;
let change_usdt = new BigNumber(change).mul(new BigNumber(usdt_rate));
let account_name = warningValueMap[account_id] ? warningValueMap[account_id].account : "未知账户名";
let platform_name = warningValueMap[account_id] ? getPlatformName(warningValueMap[account_id].platform) : "未知平台";
let msg = `\n资产变动\n时间:${new Date(Number(time)).toLocaleString()}\n${bill_type == 1 ? "转入做市账户" : "从做市账户转出"}\n账户ID:${account_id}\n账户名:${account_name}\n平台:${platform_name}\n币种:${symbol}\n数量:${Number(change)}\n估值(U):${Number(change_usdt)}\n当前账户余额(U):${Number(balanceMap[account_id])}`;
await sendRobotMessage(ROBOT_KEYS.ABK_KEY, msg);
}
}
function getPlatformName(platform: any) {
let name = ""
switch (platform) {
case 1:
name = "KTX";
break;
case 2:
name = "Binance";
break;
case 3:
name = "OKEX";
break;
default:
name = "未知平台";
break;
}
return name;
}
/**
* 站内资产和钱包资产对账
*/
export const walletAssetAndSiteAssetCheck = async function () {
let dbDataList = await siteAssetsNoPage();
for (let item of dbDataList) {
let { asset_id, symbol, chain_type, site_assets, total_wallet_assets } = item;
let site_assets_number = new BigNumber(site_assets).toNumber().toFixed(4);
let total_wallet_assets_number = new BigNumber(total_wallet_assets).toNumber().toFixed(4);
//账不平 发送lark
if (site_assets_number != total_wallet_assets_number) {
let msg = `\n站内钱包对账错误\n时间:${new Date().toLocaleString()}\n链名:${chain_type}\n币名:${symbol}\n站内数量:${site_assets_number}\n钱包数量:${total_wallet_assets_number}\n差值:${Number(site_assets_number) - Number(total_wallet_assets_number)}`
await sendRobotMessage(ROBOT_KEYS.ABK_KEY, msg);
}
}
}
\ No newline at end of file
...@@ -140,7 +140,7 @@ export const doExPairTrigger = async function (trigId: any, pair: string, action ...@@ -140,7 +140,7 @@ export const doExPairTrigger = async function (trigId: any, pair: string, action
}); });
} }
else { else {
await contractPairs.prototype.update(target_value, { await spotPairs.prototype.update(target_value, {
where: { where: {
id: dbPair.id id: dbPair.id
}, },
......
'use strict';
/**
* 资产管理后台-钱包对账、程序自动对账告警
*/
const schedule = require('node-schedule');
let { logger, datetimeUtils } = require('@madex/ex-js-public');
import * as service from "../service/task.abk.asset.check.warning.service";
let running1 = false;
let running2 = false;
/**
* 程序自动对账
* 每10分钟跑一次
*/
let autoCheckJob = schedule.scheduleJob('0 */10 * * * *', async function () {
logger.info('autoCheckJob start');
if (!running1) {
try {
running1 = true;
let now = new Date();
let end_time_ts = now.getTime();
let start_time_ts = datetimeUtils.sub(now, datetimeUtils.DAY * 10).getTime();
await service.balanceAndFundingInOutCheck(start_time_ts,end_time_ts);
logger.info("autoCheckJob job finish");
}
catch (e) {
logger.info(e)
}
running1 = false;
}
});
/**
* 钱包自动对账
* 每10分钟跑一次
*/
let walletAssetCheckJob = schedule.scheduleJob('0 */10 * * * *', async function () {
logger.info('walletAssetCheckJob start');
if (!running2) {
try {
running2 = true;
await service.walletAssetAndSiteAssetCheck();
logger.info("walletAssetCheckJob job finish");
}
catch (e) {
logger.info(e)
}
running2 = false;
}
});
...@@ -85,4 +85,7 @@ export const ErrorCode = { ...@@ -85,4 +85,7 @@ export const ErrorCode = {
STATUS_PASS_NO_UP:'30081',//审核已通过,不允许修改 STATUS_PASS_NO_UP:'30081',//审核已通过,不允许修改
AFTER_AUDIT_SUBMIT:'30082',//请先审核,再提交 AFTER_AUDIT_SUBMIT:'30082',//请先审核,再提交
PWD_FORMAT_ERR:'30083',//密码格式错误 PWD_FORMAT_ERR:'30083',//密码格式错误
CATEGORY_HAVE_ACCOUNT:'30084',//该分类下有账户,不可以删除
CATEGORY_HAVE_SAME_ACCOUNT:'30085',//该分类下存在相同账户
ACCOUNT_HAVE_INIT_ASSET:'30086',//该账户下存在初始资金记录,不允许删除
} }
...@@ -145,3 +145,20 @@ export const mixinCoinList = async (req: any, param: ListParam) => { ...@@ -145,3 +145,20 @@ export const mixinCoinList = async (req: any, param: ListParam) => {
} }
}; };
export const updateIconUrl = async (req: any, param: AddParam) => {
let func_name = "coinTypeCtl.updateIconUrl";
let cmd = req.path;
try {
ApiAssert.notNull('3000', param.id);
ApiAssert.notNull('3000', param.icon_url);
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
let res = await service.updateIconUrl(param, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
}
import * as financeAccountService from "../service/fianceAccount.service";
import { FinanceAccountVO, FinanceAccountPageVO, AccountInitAssetVO } from "../service/fianceAccount.service";
let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert, datetimeUtils } = require('@madex/ex-js-public');
import { ErrorCode } from "../../../constant/errorCode";
import { getCurrentUserId } from "../../../utils/aclUserUtils";
import { coinType, contractPairs, spotPairs } from "@madex/ex-ts-dao";
let isIp = require('is-ip');
/**
* 账户列表
* @param req
* @param infoVO
*/
export const list = async (req: any, pageVO: FinanceAccountPageVO) => {
let func_name = "financeAccount.control.list";
try {
pageVO.page = Optional.opt(pageVO, 'page', 1);
pageVO.size = Optional.opt(pageVO, 'size', 20);
let res = await financeAccountService.list(pageVO);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 添加新的账户
* @param req
* @param authConfigVO
*/
export const add = async (req: any, financeAccountVO: FinanceAccountVO) => {
let func_name = "financeAccount.control.add";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
await paramValid(financeAccountVO);
let res = await financeAccountService.add(financeAccountVO, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 修改账户信息
* @param req
* @param authConfigVO
*/
export const update = async (req: any, financeAccountVO: FinanceAccountVO) => {
let func_name = "financeAccount.control.update";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if (!financeAccountVO.id) {
throw ErrorCode.PARAM_MISS
}
await paramValid(financeAccountVO);
let res = await financeAccountService.update(financeAccountVO, currentUserId, ip);
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, financeAccountVO: FinanceAccountVO) => {
let func_name = "financeAccount.control.del";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if (!financeAccountVO.id) {
throw ErrorCode.PARAM_MISS
}
let res = await financeAccountService.del(financeAccountVO.id, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 添加初始资金
* @param req
* @param authConfigVO
*/
export const addInitAsset = async (req: any, accountInitAssetVO: AccountInitAssetVO) => {
let func_name = "financeAccount.control.addInitAsset";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if (!accountInitAssetVO.account_id || !accountInitAssetVO.symbol ||
!accountInitAssetVO.amount_usdt ||
!accountInitAssetVO.amount ||
Number(accountInitAssetVO.amount_usdt) < 0 ||
Number(accountInitAssetVO.amount) < 0) {
throw ErrorCode.PARAM_MISS;
}
let res = await financeAccountService.addInitAsset(accountInitAssetVO, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 初始资金列表
* @param req
* @param authConfigVO
*/
export const initAssetList = async (req: any, pageVO: FinanceAccountPageVO) => {
let func_name = "financeAccount.control.initAssetList";
try {
pageVO.page = Optional.opt(pageVO, 'page', 1);
pageVO.size = Optional.opt(pageVO, 'size', 20);
if (!pageVO.account_id) {
throw ErrorCode.PARAM_MISS;
}
let res = await financeAccountService.initAssetList(pageVO);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
async function paramValid(financeAccountVO: FinanceAccountVO) {
if (!financeAccountVO.category_id || !financeAccountVO.account ||
!financeAccountVO.platform) {
throw ErrorCode.PARAM_MISS;
}
if (financeAccountVO.platform == 1) {//KTX
if (!financeAccountVO.uid) {
throw ErrorCode.PARAM_MISS;
}
}
else if (financeAccountVO.platform == 2) {//币安
if (!financeAccountVO.apikey || !financeAccountVO.secret) {
throw ErrorCode.PARAM_MISS;
}
}
else if (financeAccountVO.platform == 3) {
if (!financeAccountVO.apikey || !financeAccountVO.secret || !financeAccountVO.pwd) {
throw ErrorCode.PARAM_MISS;
}
}
else {
throw ErrorCode.PARAM_MISS;
}
}
import * as categoryService from "../service/fianceAccountCategory.service";
import { FinanceAccountCategoryVO, FinanceAccountCategoryPageVO } from "../service/fianceAccountCategory.service";
let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert, datetimeUtils } = require('@madex/ex-js-public');
import { ErrorCode } from "../../../constant/errorCode";
import { getCurrentUserId } from "../../../utils/aclUserUtils";
import { coinType, contractPairs, spotPairs } from "@madex/ex-ts-dao";
let isIp = require('is-ip');
/**
* 分类列表
* @param req
* @param infoVO
*/
export const list = async (req: any, pageVO: FinanceAccountCategoryPageVO) => {
let func_name = "financeAccountCategory.control.list";
try {
pageVO.page = Optional.opt(pageVO, 'page', 1);
pageVO.size = Optional.opt(pageVO, 'size', 20);
let res = await categoryService.list(pageVO);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 添加新的分类
* @param req
* @param authConfigVO
*/
export const add = async (req: any, financeAccountCategoryVO: FinanceAccountCategoryVO) => {
let func_name = "financeAccountCategory.control.add";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
await paramValid(financeAccountCategoryVO);
let res = await categoryService.add(financeAccountCategoryVO, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 修改分类
* @param req
* @param authConfigVO
*/
export const update = async (req: any, financeAccountCategoryVO: FinanceAccountCategoryVO) => {
let func_name = "financeAccountCategory.control.update";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if (!financeAccountCategoryVO.id) {
throw ErrorCode.PARAM_MISS
}
await paramValid(financeAccountCategoryVO);
let res = await categoryService.update(financeAccountCategoryVO, currentUserId, ip);
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, financeAccountCategoryVO: FinanceAccountCategoryVO) => {
let func_name = "financeAccountCategory.control.del";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if (!financeAccountCategoryVO.id) {
throw ErrorCode.PARAM_MISS
}
let res = await categoryService.del(financeAccountCategoryVO.id, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
async function paramValid(financeAccountCategoryVO: FinanceAccountCategoryVO) {
if (!financeAccountCategoryVO.name) {
throw ErrorCode.PARAM_MISS;
}
}
import * as assetCheckService from "../../service/v2/assetCheck.service"; import * as assetCheckService from "../../service/v2/assetCheck.service";
import { CommonParam, setPageAndSize } from "../../service/v2/abkCommonService"; import { CommonParam, setPageAndSize,beforeQueryCheckTime } from "../../service/v2/abkCommonService";
let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert } = require('@madex/ex-js-public'); let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert } = require('@madex/ex-js-public');
import { ErrorCode } from "../../../../constant/errorCode"; import { ErrorCode } from "../../../../constant/errorCode";
...@@ -121,5 +121,62 @@ export const withdrawList = async (req: any, commonParam: CommonParam) => { ...@@ -121,5 +121,62 @@ export const withdrawList = async (req: any, commonParam: CommonParam) => {
}; };
/**
* 资金监控-总记录
* @param req
* @param commonParam
*/
export const fundingTotalRecords = async (req: any, commonParam: CommonParam) => {
let func_name = "assetCheck.control.fundingTotalRecords";
try {
let res = await assetCheckService.fundingTotalRecords();
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 资金监控-每日记录
* @param req
* @param commonParam
*/
export const fundingDailyRecords = async (req: any, commonParam: CommonParam) => {
let func_name = "assetCheck.control.fundingDailyRecords";
try {
setPageAndSize(commonParam);
beforeQueryCheckTime(commonParam);
let res = await assetCheckService.fundingDailyRecords(commonParam);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 自动对账列表
* @param req
* @param commonParam
*/
export const autoCheckList = async (req: any, commonParam: CommonParam) => {
let func_name = "assetCheck.control.fundingDailyRecords";
try {
let res = await assetCheckService.autoCheckList();
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 分支上 // @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import { coinType, ormDB, spotPairs ,mixinCoin,mixinChain} 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"); const _ = require("lodash");
let { logger, datetimeUtils } = require('@madex/ex-js-public'); let { logger, datetimeUtils } = require('@madex/ex-js-public');
...@@ -25,6 +26,7 @@ export interface AddParam { ...@@ -25,6 +26,7 @@ export interface AddParam {
id: any, id: any,
symbol: string; symbol: string;
mixin_id: string; mixin_id: string;
asset_id: number; asset_id: number;
...@@ -133,13 +135,13 @@ export async function list(param: ListParam) { ...@@ -133,13 +135,13 @@ export async function list(param: ListParam) {
export async function chainList() { export async function chainList() {
let resList = await coinType.prototype.findAll({ let resList = await coinType.prototype.findAll({
attributes:['chain_type'], attributes: ['chain_type'],
where: { where: {
is_main:1 is_main: 1
}, },
raw: true raw: true
}); });
let chains:any[] = []; let chains: any[] = [];
for (let item of resList) { for (let item of resList) {
let chainType = item.chain_type; let chainType = item.chain_type;
if (chainType) { if (chainType) {
...@@ -168,7 +170,8 @@ export const save = async (param: AddParam, currentUserId: any, ip: any) => { ...@@ -168,7 +170,8 @@ export const save = async (param: AddParam, currentUserId: any, ip: any) => {
param.is_main = 0; param.is_main = 0;
param.asset_id = exist.asset_id; param.asset_id = exist.asset_id;
param.main_status = exist.main_status; param.main_status = exist.main_status;
}else { }
else {
param.is_main = 1; param.is_main = 1;
param.asset_id = 0; param.asset_id = 0;
param.main_status = 0; param.main_status = 0;
...@@ -270,17 +273,16 @@ export const audit = async (param: AddParam, currentUserId: any, ip: any) => { ...@@ -270,17 +273,16 @@ export const audit = async (param: AddParam, currentUserId: any, ip: any) => {
}; };
export async function mixinCoinList(param: ListParam) { export async function mixinCoinList(param: ListParam) {
let where = {}; let where = {};
if (param.symbol) { if (param.symbol) {
where["symbol"] = { [ormDB.Op.like]: `%${param.symbol}%` }; where["symbol"] = { [ormDB.Op.like]: `%${param.symbol}%` };
} }
let resList = await mixinCoin.prototype.findAndCount({ let resList = await mixinCoin.prototype.findAndCount({
attributes:['symbol','name','symbol_id',['symbol_id','mixin_id'],'display_symbol','chain_id', attributes: ['symbol', 'name', 'symbol_id', ['symbol_id', 'mixin_id'], 'display_symbol', 'chain_id',
['address','contract'],['precision','original_decimals'],['dust','deposit_min'],['dust','withdraw_min'], ['address', 'contract'], ['precision', 'original_decimals'], ['dust', 'deposit_min'], ['dust', 'withdraw_min'],
['confirm','deposit_confirm_count'],['confirm','safe_confirm_count'], ['confirm', 'deposit_confirm_count'], ['confirm', 'safe_confirm_count'],
'price_btc','price_usd','balance','comment'], 'price_btc', 'price_usd', 'balance', 'comment'],
// include:{ // include:{
// model:mixinChain.prototype, // model:mixinChain.prototype,
// required:true, //INNER JOIN // required:true, //INNER JOIN
...@@ -292,19 +294,19 @@ export async function mixinCoinList(param: ListParam) { ...@@ -292,19 +294,19 @@ export async function mixinCoinList(param: ListParam) {
order: [["symbol", "asc"]], order: [["symbol", "asc"]],
raw: true raw: true
}); });
let chainIDs =_.map(resList.rows,'chain_id') let chainIDs = _.map(resList.rows, 'chain_id')
let m = await mixinChain.prototype.findAll({ let m = await mixinChain.prototype.findAll({
attributes:['name','symbol','threshold','withdrawal_fee','is_memo','chain_id'], attributes: ['name', 'symbol', 'threshold', 'withdrawal_fee', 'is_memo', 'chain_id'],
where:{ where: {
chain_id:chainIDs chain_id: chainIDs
}, },
raw: true, raw: true,
}) })
let chainMap = _.keyBy(m,'chain_id'); let chainMap = _.keyBy(m, 'chain_id');
for (const item of resList.rows) { for (const item of resList.rows) {
let isMainToken = (item.symbol_id ==item.chain_id &&item.chain_id ==item.contract) let isMainToken = (item.symbol_id == item.chain_id && item.chain_id == item.contract)
if (chainMap[item.chain_id]) { if (chainMap[item.chain_id]) {
item.chain_type = chainMap[item.chain_id].symbol item.chain_type = chainMap[item.chain_id].symbol
item.issupport_memo = chainMap[item.chain_id].is_memo; item.issupport_memo = chainMap[item.chain_id].is_memo;
...@@ -312,10 +314,34 @@ export async function mixinCoinList(param: ListParam) { ...@@ -312,10 +314,34 @@ export async function mixinCoinList(param: ListParam) {
item.withdraw_fee = isMainToken ? chainMap[item.chain_id].withdrawal_fee : (5 / (item.price_usd > 0 ? item.price_usd : 0.001)).toFixed(4); 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) { if (item.contract) {
item.is_erc20=1; item.is_erc20 = 1;
}else { }
item.is_erc20=0; else {
item.is_erc20 = 0;
} }
} }
return resList; return resList;
} }
\ No newline at end of file
export const updateIconUrl = 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
}
let upInfo = {
icon_url: param.icon_url,
updatedAt: new Date(),
}
await coinType.prototype.update(upInfo, {
where: { id: id }
})
//管理后台操作日志
addOptLog(currentUserId, 0, '币种管理更新 icon_url', ip, JSON.stringify(param), '币种管理');
return 'ok';
};
\ No newline at end of file
import { financeAccount, ormDB, financeAccountInitAsset, financeAccountCategory } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode";
import { addOptLog } from "./userOptLog.service";
let _ = require('lodash');
let { logger } = require('@madex/ex-js-public');
export interface FinanceAccountVO {
id?: number;
category_id?: number;
uid?: number;
account?: string | any;
remark?: string | any;
apikey?: string | any;
secret?: string | any;
pwd?: string | any;
platform?: number;
status?: number;
balance_warning?: number;
createdAt?: Date | any,
updatedAt?: Date | any,
}
export interface FinanceAccountPageVO extends FinanceAccountVO, AccountInitAssetVO {
page?: number,
size?: number,
}
export interface AccountInitAssetVO {
id?: number;
account_id?: number;
symbol?: string | any;
amount?: number;
amount_usdt?: number;
remark?: string | any;
createdAt?: Date | any,
updatedAt?: Date | any,
}
export async function list(pageVO: FinanceAccountPageVO) {
let where = {
category_id: pageVO.category_id
};
let resList = await financeAccount.prototype.findAndCount({
where: where,
limit: pageVO.size,
offset: (Number(pageVO.page) - 1) * Number(pageVO.size),
order: [["id", "asc"]],
raw: true
});
if (resList.rows.length) {
let cids = resList.rows.map(item => item.category_id);
let cList = await financeAccountCategory.prototype.findAll({
where: {
id: cids
},
raw: true
});
let tmpMap: any = {};
for (let item of cList) {
tmpMap[item.id] = item.name;
}
for (let item of resList.rows) {
item.category_name = tmpMap[item.category_id] ? tmpMap[item.category_id] : ""
}
}
return resList;
}
export async function add(financeAccountVO: FinanceAccountVO, currentUserId: any, ip: any) {
let dbOne = await financeAccount.prototype.findOne({
where: {
category_id: financeAccountVO.category_id,
apikey: financeAccountVO.apikey
},
raw: true
});
if (dbOne) {
throw ErrorCode.DATA_EXIST;
}
financeAccountVO.createdAt = new Date();
financeAccountVO.updatedAt = new Date();
if (!financeAccountVO.status) {
//默认可用
financeAccountVO.status = 1;
}
if (!financeAccountVO.balance_warning) {
financeAccountVO.balance_warning = 0;
}
if (!financeAccountVO.uid) {
financeAccountVO.uid = 0;
}
await financeAccount.prototype.create(financeAccountVO);
//管理后台操作日志
addOptLog(currentUserId, 0, '新增账户', ip, JSON.stringify(financeAccountVO), '金融部-其他管理');
return 'success';
}
export async function update(financeAccountVO: FinanceAccountVO, currentUserId: any, ip: any) {
let exist = await financeAccount.prototype.findOne({
where: {
id: financeAccountVO.id
},
raw: true
});
if (!exist) {
throw ErrorCode.DATA_NOT_EXIST
}
let dbOne = await financeAccount.prototype.findOne({
where: {
category_id: financeAccountVO.category_id,
apikey: financeAccountVO.apikey,
id: { [ormDB.Op.ne]: financeAccountVO.id }
},
raw: true
});
if (dbOne) {
throw ErrorCode.CATEGORY_HAVE_SAME_ACCOUNT;
}
if (!financeAccountVO.balance_warning) {
financeAccountVO.balance_warning = 0;
}
if (!financeAccountVO.uid) {
financeAccountVO.uid = 0;
}
financeAccountVO.updatedAt = new Date();
await financeAccount.prototype.update(financeAccountVO, {
where: {
id: Number(financeAccountVO.id)
}
})
//管理后台操作日志
addOptLog(currentUserId, 0, '修改账户信息', ip, JSON.stringify(financeAccountVO), '金融部-其他管理');
return 'success';
}
export async function del(id: number, currentUserId: any, ip: string | undefined) {
let exist = await financeAccount.prototype.findOne({
where: {
id: id
},
raw: true
});
if (!exist) {
throw ErrorCode.DATA_NOT_EXIST
}
let dbInitAsset = await financeAccountInitAsset.prototype.findOne({
where: {
account_id: id
},
raw: true
});
if (dbInitAsset) {
throw ErrorCode.ACCOUNT_HAVE_INIT_ASSET
}
await financeAccount.prototype.destroy({
where: {
id: id
}
})
//管理后台操作日志
addOptLog(currentUserId, 0, '删除账户信息', ip, `id:${id}`, '金融部-其他管理');
return 'success';
}
export async function addInitAsset(accountInitAssetVO: AccountInitAssetVO, currentUserId: any, ip: any) {
accountInitAssetVO.createdAt = new Date();
accountInitAssetVO.updatedAt = new Date();
await financeAccountInitAsset.prototype.create(accountInitAssetVO);
//管理后台操作日志
addOptLog(currentUserId, 0, '新增初始资金', ip, JSON.stringify(accountInitAssetVO), '金融部-其他管理');
return 'success';
}
export async function initAssetList(pageVO: FinanceAccountPageVO) {
let where = {
account_id: pageVO.account_id
};
let resList = await financeAccountInitAsset.prototype.findAndCount({
where: where,
limit: pageVO.size,
offset: (Number(pageVO.page) - 1) * Number(pageVO.size),
order: [["createdAt", "desc"]],
raw: true
});
if (resList.rows.length) {
let aids = resList.rows.map(item => item.account_id);
let aList = await financeAccount.prototype.findAll({
where: {
id: aids
},
raw: true
});
let tmpMap: any = {};
for (let item of aList) {
tmpMap[item.id] = item.account;
}
for (let item of resList.rows) {
item.account_name = tmpMap[item.account_id] ? tmpMap[item.account_id] : ""
}
}
return resList;
}
import { financeAccountCategory, ormDB, financeAccount } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode";
import { addOptLog } from "./userOptLog.service";
let _ = require('lodash');
let { logger } = require('@madex/ex-js-public');
export interface FinanceAccountCategoryVO {
id?: number;
name?: string | any;
remark?: string | any;
createdAt?: Date | any,
updatedAt?: Date | any,
}
export interface FinanceAccountCategoryPageVO extends FinanceAccountCategoryVO {
page?: number,
size?: number,
}
export async function list(pageVO: FinanceAccountCategoryPageVO) {
let where = {};
let resList = await financeAccountCategory.prototype.findAll({
where: where,
order: [["id", "asc"]],
raw: true
});
return resList;
}
export async function add(financeAccountCategoryVO: FinanceAccountCategoryVO, currentUserId: any, ip: any) {
financeAccountCategoryVO.createdAt = new Date();
financeAccountCategoryVO.updatedAt = new Date();
await financeAccountCategory.prototype.create(financeAccountCategoryVO);
//管理后台操作日志
addOptLog(currentUserId, 0, '新增账户分类', ip, JSON.stringify(financeAccountCategoryVO), '金融部-其他管理');
return 'success';
}
export async function update(financeAccountCategoryVO: FinanceAccountCategoryVO, currentUserId: any, ip: any) {
let exist = await financeAccountCategory.prototype.findOne({
where: {
id: financeAccountCategoryVO.id
},
raw: true
});
if (!exist) {
throw ErrorCode.DATA_NOT_EXIST
}
financeAccountCategoryVO.updatedAt = new Date();
await financeAccountCategory.prototype.update(financeAccountCategoryVO, {
where: {
id: Number(financeAccountCategoryVO.id)
}
})
//管理后台操作日志
addOptLog(currentUserId, 0, '修改账户分类', ip, JSON.stringify(financeAccountCategoryVO), '金融部-其他管理');
return 'success';
}
export async function del(id: number, currentUserId: any, ip: string | undefined) {
let exist = await financeAccountCategory.prototype.findOne({
where: {
id: id
},
raw: true
});
if (!exist) {
throw ErrorCode.DATA_NOT_EXIST
}
//分类下有账户 不可以删除
let dbAccount = await financeAccount.prototype.findOne({
where: {
category_id: id
},
raw: true
});
if (dbAccount) {
throw ErrorCode.CATEGORY_HAVE_ACCOUNT;
}
await financeAccountCategory.prototype.destroy({
where: {
id: id
}
})
//管理后台操作日志
addOptLog(currentUserId, 0, '删除账户分类', ip, `id:${id}`, '金融部-其他管理');
return 'success';
}
...@@ -20,6 +20,8 @@ export interface CommonParam { ...@@ -20,6 +20,8 @@ export interface CommonParam {
user_type?: any//查询条件 用户类型:1:普通用户;2:代理用户(crm用户) user_type?: any//查询条件 用户类型:1:普通用户;2:代理用户(crm用户)
asset_id?: any asset_id?: any
category_id?: any//分类id
} }
export function setPageAndSize(commonParam: CommonParam) { export function setPageAndSize(commonParam: CommonParam) {
......
...@@ -61,11 +61,11 @@ export async function gatherData(from_time: any, to_time: any) { ...@@ -61,11 +61,11 @@ export async function gatherData(from_time: any, to_time: any) {
let lpc_data = buildOneResult(commonData.lpc_fee_usdt, commonData.lpc_back_usdt, crmData.lpc_fee_usdt, crmData.lpc_back_usdt); let lpc_data = buildOneResult(commonData.lpc_fee_usdt, commonData.lpc_back_usdt, crmData.lpc_fee_usdt, crmData.lpc_back_usdt);
let ipc_data = buildOneResult(commonData.ipc_fee_usdt, commonData.ipc_back_usdt, crmData.ipc_fee_usdt, crmData.ipc_back_usdt); let ipc_data = buildOneResult(commonData.ipc_fee_usdt, commonData.ipc_back_usdt, crmData.ipc_fee_usdt, crmData.ipc_back_usdt);
let all_common_fee = new BigNumber(commonData.spot_fee_usdt).add(new BigNumber(commonData.lpc_fee_usdt)).add(new BigNumber(commonData.ipc_fee_usdt)).add(withdraw_common_user_fee); let all_common_fee = new BigNumber(commonData.spot_fee_usdt || 0).add(new BigNumber(commonData.lpc_fee_usdt || 0)).add(new BigNumber(commonData.ipc_fee_usdt || 0)).add(withdraw_common_user_fee || 0);
let all_common_back = new BigNumber(commonData.spot_back_usdt).add(new BigNumber(commonData.lpc_back_usdt)).add(new BigNumber(commonData.ipc_back_usdt)); let all_common_back = new BigNumber(commonData.spot_back_usdt || 0).add(new BigNumber(commonData.lpc_back_usdt || 0)).add(new BigNumber(commonData.ipc_back_usdt || 0));
let all_crm_fee = new BigNumber(crmData.spot_fee_usdt).add(new BigNumber(crmData.lpc_fee_usdt)).add(new BigNumber(crmData.ipc_fee_usdt)).add(withdraw_crm_user_fee); let all_crm_fee = new BigNumber(crmData.spot_fee_usdt || 0).add(new BigNumber(crmData.lpc_fee_usdt || 0)).add(new BigNumber(crmData.ipc_fee_usdt || 0)).add(withdraw_crm_user_fee || 0);
let all_crm_back = new BigNumber(crmData.spot_back_usdt).add(new BigNumber(crmData.ipc_back_usdt)).add(new BigNumber(crmData.ipc_back_usdt)); let all_crm_back = new BigNumber(crmData.spot_back_usdt || 0).add(new BigNumber(crmData.ipc_back_usdt || 0)).add(new BigNumber(crmData.ipc_back_usdt || 0));
let all_data = buildOneResult(all_common_fee, all_common_back, all_crm_fee, all_crm_back); let all_data = buildOneResult(all_common_fee, all_common_back, all_crm_fee, all_crm_back);
//总手续费+提现手续费 //总手续费+提现手续费
......
...@@ -52,6 +52,8 @@ import * as spotDataCtrl from "../../mvc/control/spotData.control"; ...@@ -52,6 +52,8 @@ import * as spotDataCtrl from "../../mvc/control/spotData.control";
import * as exBusinessAreaCtrl from "../../mvc/control/exBusinessArea.control"; import * as exBusinessAreaCtrl from "../../mvc/control/exBusinessArea.control";
import * as rewardTimePeriodCtrl from "../../mvc/control/rewardTimePeriod.control"; import * as rewardTimePeriodCtrl from "../../mvc/control/rewardTimePeriod.control";
import * as collateralCtrl from "../../mvc/control/collateral.control"; import * as collateralCtrl from "../../mvc/control/collateral.control";
import * as fianceAccountCtrl from "../../mvc/control/fianceAccount.control";
import * as fianceAccountCategoryCtrl from "../../mvc/control/fianceAccountCategory.control";
const getFunc = { const getFunc = {
'user/info': userController.getUserInfo, 'user/info': userController.getUserInfo,
...@@ -88,6 +90,7 @@ const postFunc = { ...@@ -88,6 +90,7 @@ const postFunc = {
'coinType/audit': coinTypeCtrl.audit, 'coinType/audit': coinTypeCtrl.audit,
'coinType/mixinCoinList': coinTypeCtrl.mixinCoinList, 'coinType/mixinCoinList': coinTypeCtrl.mixinCoinList,
'coinType/chainList': coinTypeCtrl.chainList, 'coinType/chainList': coinTypeCtrl.chainList,
'coinType/updateIconUrl': coinTypeCtrl.updateIconUrl,
//权限管理 - 我的权限 //权限管理 - 我的权限
...@@ -304,6 +307,22 @@ const postFunc = { ...@@ -304,6 +307,22 @@ const postFunc = {
//技术部-其他管理-返佣时间配置 //技术部-其他管理-返佣时间配置
'tech/other/reward/time/period/set': rewardTimePeriodCtrl.set, 'tech/other/reward/time/period/set': rewardTimePeriodCtrl.set,
'tech/other/reward/time/period/get': rewardTimePeriodCtrl.get, 'tech/other/reward/time/period/get': rewardTimePeriodCtrl.get,
//金融部-其他管理-账户管理
'fiance/other/account/category/list': fianceAccountCategoryCtrl.list,
'fiance/other/account/category/add': fianceAccountCategoryCtrl.add,
'fiance/other/account/category/update': fianceAccountCategoryCtrl.update,
'fiance/other/account/category/del': fianceAccountCategoryCtrl.del,
'fiance/other/account/list': fianceAccountCtrl.list,
'fiance/other/account/add': fianceAccountCtrl.add,
'fiance/other/account/update': fianceAccountCtrl.update,
'fiance/other/account/del': fianceAccountCtrl.del,
'fiance/other/account/addInitAsset': fianceAccountCtrl.addInitAsset,
'fiance/other/account/initAssetList': fianceAccountCtrl.initAssetList,
}; };
......
...@@ -34,6 +34,10 @@ const postFunc = { ...@@ -34,6 +34,10 @@ const postFunc = {
'assetCheck/siteAssetsDetails': assetCheckCtrl.siteAssetsDetails,//站内资产-详情 'assetCheck/siteAssetsDetails': assetCheckCtrl.siteAssetsDetails,//站内资产-详情
'assetCheck/depositList': assetCheckCtrl.depositList,//实时充值 'assetCheck/depositList': assetCheckCtrl.depositList,//实时充值
'assetCheck/withdrawList': assetCheckCtrl.withdrawList,//实时提现 'assetCheck/withdrawList': assetCheckCtrl.withdrawList,//实时提现
'assetCheck/funding/monitor/totalRecords': assetCheckCtrl.fundingTotalRecords,//资金监控-总记录
'assetCheck/funding/monitor/dailyRecords': assetCheckCtrl.fundingDailyRecords,//资金监控-每日记录
'assetCheck/auto/checkList': assetCheckCtrl.autoCheckList,//自动对账列表
//收入分析 //收入分析
'abkFeeStatistics/home/gatherData': feeStatisticsCtrl.gatherData,//首页数据概览 'abkFeeStatistics/home/gatherData': feeStatisticsCtrl.gatherData,//首页数据概览
'abkFeeStatistics/getFeeData': feeStatisticsCtrl.getFeeData,//平台、现货、合约 手续费查询 'abkFeeStatistics/getFeeData': feeStatisticsCtrl.getFeeData,//平台、现货、合约 手续费查询
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import * as ReqUtils from "../utils/req-utils"; import * as ReqUtils from "../utils/req-utils";
import Config from "../../config"; import Config from "../../config";
import * as collateralCtrl from "../functional/mvc/control/collateral.control"; import * as collateralCtrl from "../functional/mvc/control/collateral.control";
const { const {
Res3Utils, Res3Utils,
logger: Logger, logger: Logger,
...@@ -38,6 +39,7 @@ let cmdWhiteList = { ...@@ -38,6 +39,7 @@ let cmdWhiteList = {
'coinType/getAllSubmitSuccess': 1, 'coinType/getAllSubmitSuccess': 1,
'coinType/audit': 1, 'coinType/audit': 1,
'coinType/mixinCoinList': 1, 'coinType/mixinCoinList': 1,
'coinType/updateIconUrl': 1,
//权限管理 - 我的权限 //权限管理 - 我的权限
'user/getInfo': 1, 'user/getInfo': 1,
...@@ -238,10 +240,20 @@ let cmdWhiteList = { ...@@ -238,10 +240,20 @@ let cmdWhiteList = {
//技术部-其他管理-返佣时间配置 //技术部-其他管理-返佣时间配置
'tech/other/reward/time/period/set': 1, 'tech/other/reward/time/period/set': 1,
'tech/other/reward/time/period/get': 1, 'tech/other/reward/time/period/get': 1,
//金融部-其他管理-账户管理
'fiance/other/account/category/list': 1,
'fiance/other/account/category/add': 1,
'fiance/other/account/category/update': 1,
'fiance/other/account/category/del': 1,
'fiance/other/account/list': 1,
'fiance/other/account/add': 1,
'fiance/other/account/update': 1,
'fiance/other/account/del': 1,
'fiance/other/account/addInitAsset': 1,
'fiance/other/account/initAssetList': 1,
}; };
let filter = function (app: any) { let filter = function (app: any) {
app.use(function (req, res, next) { app.use(function (req, res, next) {
let path = ReqUtils.parsePath(req.originalUrl); let path = ReqUtils.parsePath(req.originalUrl);
......
...@@ -3,12 +3,12 @@ let { ...@@ -3,12 +3,12 @@ let {
logger logger
} = require('@madex/ex-js-public'); } = require('@madex/ex-js-public');
let config = require('../../config'); import Config from "../../config";
let axios = require('axios'); let axios = require('axios');
debug = config.env === "development"; debug = Config.node_env == "development";
/** /**
* Lark 地址 * Lark 地址
...@@ -20,16 +20,24 @@ let LARK_URL_PRE = "https://open.larksuite.com/open-apis/bot/v2/hook/"; ...@@ -20,16 +20,24 @@ let LARK_URL_PRE = "https://open.larksuite.com/open-apis/bot/v2/hook/";
*/ */
let COMMON_KEY = "d9f2dc6e-52cf-4933-92f1-dab9c249aa28"; let COMMON_KEY = "d9f2dc6e-52cf-4933-92f1-dab9c249aa28";
/**
* 资产管理后台通知
*/
let ABK_KEY = "d0edce37-1798-4648-bd87-45b7a5ae5c64";
/** /**
* 测试:dev * 测试:dev
*/ */
if (debug) { if (debug) {
COMMON_KEY = "d98c9942-ff6f-4e71-a77f-41647ff19ff0"; COMMON_KEY = "d98c9942-ff6f-4e71-a77f-41647ff19ff0";
ABK_KEY = "d98c9942-ff6f-4e71-a77f-41647ff19ff0";
} }
export const ROBOT_KEYS = { export const ROBOT_KEYS = {
COMMON_KEY: COMMON_KEY COMMON_KEY: COMMON_KEY,
ABK_KEY: ABK_KEY,
} }
/** /**
* *
......
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