Commit b66ba41a authored by ml's avatar ml

新管理后台-部分接口逻辑调整、增加新接口

parent 465c4989
......@@ -88,4 +88,5 @@ export const ErrorCode = {
CATEGORY_HAVE_ACCOUNT:'30084',//该分类下有账户,不可以删除
CATEGORY_HAVE_SAME_ACCOUNT:'30085',//该分类下存在相同账户
ACCOUNT_HAVE_INIT_ASSET:'30086',//该账户下存在初始资金记录,不允许删除
NOT_COMMON_USER_NOT_OPT:'30087',//非普通用户,不允许操作
}
......@@ -6,5 +6,6 @@ export const KYC_STATUS = {
}
export const SETTING_FLAG = {
FLAG_REAL_NAME_AUTH: 1 << 4
FLAG_REAL_NAME_AUTH: 1 << 4,
FLAG_LOGIN_GOOGLE_CONFIRM: 1 << 0,
}
\ No newline at end of file
import * as mUserBillsService from "../service/mUserBills.service";
import { QueryVO } from "../service/mUserBills.service";
let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert } = require('@madex/ex-js-public');
import { ErrorCode } from "../../../constant/errorCode";
/**
* 账单类型列表
* @param req
* @param infoVO
*/
export const billTypeList = async (req: any, queryVO: QueryVO) => {
let func_name = "mUserBillsCtrl.billTypeList";
try {
if (!queryVO.account_type) {
throw ErrorCode.PARAM_MISS
}
let res = await mUserBillsService.billTypeList(queryVO.account_type);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 账单详情
* @param req
* @param infoVO
*/
export const billDetailList = async (req: any, queryVO: QueryVO) => {
let func_name = "mUserAssetsCtrl.billDetailList";
try {
queryVO.page = Optional.opt(queryVO, 'page', 1);
queryVO.size = Optional.opt(queryVO, 'size', 20);
if (!queryVO.account_type) {
throw ErrorCode.PARAM_MISS
}
if (!queryVO.user_id) {
throw ErrorCode.PARAM_MISS
}
if (!queryVO.from_time) {
throw ErrorCode.PARAM_MISS
}
if (!queryVO.to_time) {
throw ErrorCode.PARAM_MISS
}
let res = await mUserBillsService.billDetailList(queryVO);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
......@@ -197,3 +197,72 @@ export const clear24WithdrawLimit = async (req: any, queryVO: QueryVO) => {
};
/**
* Madex 锁定提现
* @param req
* @param queryVO
*/
export const withdrawLock = async (req: any, queryVO: QueryVO) => {
let func_name = "mUserManageCtrl.withdrawLock";
try {
if (!queryVO.user_id || !queryVO.totp_code) {
throw ErrorCode.PARAM_MISS
}
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
let res = await mUserManageService.withdrawLock(currentUserId, queryVO.user_id, ip, queryVO.totp_code);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 解锁提现
* @param req
* @param queryVO
*/
export const withdrawUnlock = async (req: any, queryVO: QueryVO) => {
let func_name = "mUserManageCtrl.withdrawUnlock";
try {
if (!queryVO.user_id || !queryVO.totp_code) {
throw ErrorCode.PARAM_MISS
}
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
let res = await mUserManageService.withdrawUnlock(currentUserId, queryVO.user_id, ip, queryVO.totp_code);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* Madex 清除谷歌
* @param req
* @param queryVO
*/
export const clearTotp = async (req: any, queryVO: QueryVO) => {
let func_name = "mUserManageCtrl.clearTotp";
try {
if (!queryVO.user_id || !queryVO.totp_code) {
throw ErrorCode.PARAM_MISS
}
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
let res = await mUserManageService.clearTotp(currentUserId, queryVO.user_id, ip, queryVO.totp_code);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
import { ormDB, dwdMadOrmDB, mainUserAsset, dwdExLedger, coinTx, coinWithdraw, mainUserBills } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode";
import BigNumber from "bignumber.js";
import { any } from "async";
import { getUserAccountFromCore } from "../../../utils/coreSystemUtils";
import { dealReturnData } from "./depositAndWithdraw.service";
let _ = require('lodash');
let { logger, BigNumberUtils } = require('@madex/ex-js-public');
let { tickerUtils, billsDefineTreeNewUtils } = require('@madex/ex-js-common');
export interface QueryVO {
user_id?: number,
symbol?: string | any;
account_type: number,//1 钱包账户 2 交易账户
page?: number,
size?: number
from_time?: any
to_time?: any
type?: string
}
export async function billTypeList(account_type: number) {
let body: any = {
type: []
};
//pid 对应 bills_define_tree_new 的根节点id
let pid: any;
if (account_type == 1) {
pid = 1;//钱包账户
}
else {
pid = 224;//交易账户
}
//billsTreeDealWithBody() 会处理 body.type
let [tmp, typesMap] = await Promise.all([billsDefineTreeNewUtils.billsTreeDealWithBody(pid, body), getBillTypesMap()]);
let bill_type_arr = body.type;
bill_type_arr = bill_type_arr.filter(item => item >= 0);
let res: any = {};
for (let oneType of bill_type_arr) {
res[oneType] = typesMap[oneType] ? typesMap[oneType] : "";
}
return res;
}
export async function billDetailList(queryVO: QueryVO) {
let res: any;
let page = Number(queryVO.page);
let size = Number(queryVO.size);
let account_type = Number(queryVO.account_type);
let user_id = Number(queryVO.user_id);
let symbol = queryVO.symbol;
let from_time = queryVO.from_time;
let to_time = queryVO.to_time;
let type = queryVO.type;
let bill_type_arr: any = [];
if (type) {
let split = type.split(',');
for (let oneType of split) {
bill_type_arr.push(Number(oneType));
}
}
if (account_type == 1) {//钱包账户
res = await getMainBills(user_id, symbol, from_time, to_time, bill_type_arr, page, size);
}
else {
res = await getTradeBills(user_id, symbol, from_time, to_time, bill_type_arr, page, size);
}
return res;
}
async function getBillTypesMap() {
//用的地方少 这里就不生成dao 文件了
let sql = `SELECT bill_type, bill_info_alias
FROM bills_define_tree_new
WHERE bill_type > -1`;
let typeList = await ormDB.query(sql, { raw: true, type: ormDB.QueryTypes.SELECT });
let map: any = {};
for (let item of typeList) {
map[item.bill_type] = item.bill_info_alias;
}
return map;
}
async function getMainBills(user_id: number, symbol: string, from_time: any, to_time: any, bill_type_arr: any, page: number, size: number) {
let condition = {
user_id,
createdAt: {
[ormDB.Op.and]: [
{ [ormDB.Op.gte]: from_time },
{ [ormDB.Op.lt]: to_time }
]
}
}
if (bill_type_arr.length) {
condition['type'] = bill_type_arr;
}
if (symbol) {
condition['symbol'] = symbol
}
let resList = await mainUserBills.prototype.findAndCount({
attributes: ['user_id', 'symbol', ormDB.literal('type as bill_type'), ormDB.literal(' `change` as change_amount'), 'result', 'comment', 'createdAt'],
where: condition,
order: [['id', 'desc']],
limit: size,
offset: page * size - size,
raw: true
});
return resList;
}
async function getTradeBills(user_id: number, symbol: string, from_time: any, to_time: any, bill_type_arr: any, page: number, size: number) {
let condition = {
user_id,
time: {
[dwdMadOrmDB.Op.and]: [
{ [dwdMadOrmDB.Op.gte]: new Date(from_time).getTime() },
{ [dwdMadOrmDB.Op.lt]: new Date(to_time).getTime() }
]
}
}
if (bill_type_arr.length) {
condition['type'] = bill_type_arr;
}
if (symbol) {
condition['asset'] = symbol
}
let resList = await dwdExLedger.prototype.findAndCount({
attributes: ['user_id', dwdMadOrmDB.literal('asset as symbol'), dwdMadOrmDB.literal('type as bill_type'), dwdMadOrmDB.literal('amount as change_amount'), dwdMadOrmDB.literal('balance as result'), 'comment', 'createdAt'],
where: condition,
order: [['ledger_id', 'desc']],
limit: size,
offset: page * size - size,
raw: true
});
return resList;
}
......@@ -15,6 +15,7 @@ import BigNumber from "bignumber.js";
import { getCoinWithdrawMapByUids } from "./coinWithdraw.service";
import { getCoinAddressMapByUids } from "./coinAddress.service";
import { M_SESSION_ID_PREFIX } from "../../../constant/redis-val";
import { SETTING_FLAG } from "../../../constant/mUserInfoConst";
let _ = require('lodash');
let { logger, datetimeUtils } = require('@madex/ex-js-public');
......@@ -147,6 +148,7 @@ export async function oneUserDetail(m_user_id: number) {
lock_status: oneUser.is_lock, //0 否 1 是
login_lock: isLoginLock.is_limit ? 1 : 0,//登陆锁定 0 否 1 是
withdraw_limit_24: is_withdraw > 0 ? 0 : 1,//24小时提现限制
withdraw_lock: oneUser.user_type == 6 ? 1 : 0//提现锁定
}
return res;
......@@ -543,7 +545,7 @@ function getLoginLimitKeys(user_id: number) {
async function killAllLogin(user_id: number) {
let key = M_SESSION_ID_PREFIX + user_id;
let sessionList = await redisUtilsCommon.getSync(key);
if (sessionList && sessionList.length){
if (sessionList && sessionList.length) {
sessionList.push(key);
for (let item of sessionList) {
await redisUtilsCommon.delSync(item);
......@@ -551,6 +553,81 @@ async function killAllLogin(user_id: number) {
}
}
export async function withdrawLock(currentUserId: number, m_user_id: any, ip: any, totp_code: any) {
//校验谷歌
await checkTotp(currentUserId, totp_code);
let dnUidUserInfo = await getMUserInfoByUid(m_user_id);
if (!dnUidUserInfo) {
throw ErrorCode.USER_NOT_EXIST;
}
//除普通用户外 不允许操作
if (dnUidUserInfo.user_type != 0) {
throw ErrorCode.NOT_COMMON_USER_NOT_OPT;
}
await updateMUserInfo(m_user_id, { user_type: 6 });//6 定义为 提现锁定
let comment = `ip:${ip},提现锁定用户:${m_user_id}`;
//管理后台操作日志
addOptLog(currentUserId, Number(m_user_id), '提现锁定用户', ip, comment, '用户管理');
//管理后台操作Madex 用户的日志
recordMUserOperateLog(m_user_id, currentUserId, TYPE.ACCOUNT_STATUS, comment, "0", "6");
return 'success';
}
export async function withdrawUnlock(currentUserId: number, m_user_id: any, ip: any, totp_code: any) {
//校验谷歌
await checkTotp(currentUserId, totp_code);
let dnUidUserInfo = await getMUserInfoByUid(m_user_id);
if (!dnUidUserInfo) {
throw ErrorCode.USER_NOT_EXIST;
}
if (Number(dnUidUserInfo.deleted_flag) > 0) {
throw ErrorCode.DEL_USER_NO_UNLOCK;
}
if (dnUidUserInfo.user_type != 6) {
throw ErrorCode.USER_NOT_LOCK;
}
await updateMUserInfo(m_user_id, { user_type: 0 });//解除提现锁定
let comment = `ip:${ip},解除用户提现锁定:${m_user_id}`;
//管理后台操作日志
addOptLog(currentUserId, Number(m_user_id), '解除用户提现锁定', ip, comment, '用户管理');
//管理后台操作Madex 用户的日志
recordMUserOperateLog(m_user_id, currentUserId, TYPE.ACCOUNT_STATUS, comment, "6", "0");
return 'success';
}
export async function clearTotp(currentUserId: number, m_user_id: any, ip: any, totp_code: any) {
//校验谷歌
await checkTotp(currentUserId, totp_code);
let dnUidUserInfo = await getMUserInfoByUid(m_user_id);
if (!dnUidUserInfo) {
throw ErrorCode.USER_NOT_EXIST;
}
let updateInfo = { totp_encrypt: "" };
let oldFlag = dnUidUserInfo.setting_flag;
// 如果没有手机号,则清除用户认证位。
if (!dnUidUserInfo.phone) {
let newFlag = oldFlag & (~SETTING_FLAG.FLAG_LOGIN_GOOGLE_CONFIRM);
updateInfo["setting_flag"] = newFlag;
}
await updateMUserInfo(m_user_id, updateInfo);//清除谷歌
//踢出登陆
killAllLogin(m_user_id);
let comment = `ip:${ip},清除用户谷歌:${m_user_id}`;
//管理后台操作日志
addOptLog(currentUserId, Number(m_user_id), '清除用户谷歌', ip, comment, '用户管理');
//管理后台操作Madex 用户的日志
recordMUserOperateLog(m_user_id, currentUserId, TYPE.GOOGLE_KEY, comment, "", "");
return 'success';
}
......
......@@ -7,32 +7,68 @@ import { getUserFillsFromCore, getUserOrdersFromCore } from "../../../utils/core
let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert } = require('@madex/ex-js-public');
export interface QueryVo {
market?: string
market?: string// spot 现货 lpc 合约
user_id?: number
before?: string
before?: string//上一页传 这个
after?: string
after?: string//下一页传 这个
limit?: number
limit?: number//条数
symbol?: string//交易对
start_time?: any//时间
end_time?: any//时间
order_id?: string//订单ID
}
export const pendingList = async (queryVo: QueryVo) => {
let param = {
market: queryVo.market ? queryVo.market : "spot",
user_id: queryVo.user_id,
status: "unsettled",//当前委托
market:queryVo.market
}
if (queryVo.symbol) {
param['symbol'] = queryVo.symbol
}
if (queryVo.start_time) {
param['start_time'] = new Date(queryVo.start_time).getTime();
}
if (queryVo.end_time) {
param['end_time'] = new Date(queryVo.end_time).getTime();
}
if (queryVo.before) {
param['before'] = queryVo.before
}
if (queryVo.after) {
param['after'] = queryVo.after
}
if (queryVo.limit) {
param['limit'] = queryVo.limit
}
let res = await getUserOrdersFromCore(param);
return res;
};
export const historyList = async (queryVo: QueryVo) => {
let param = {
market: queryVo.market ? queryVo.market : "spot",
user_id: queryVo.user_id,
status: "settled",//历史委托
market:queryVo.market
};
if (queryVo.symbol) {
param['symbol'] = queryVo.symbol
}
if (queryVo.start_time) {
param['start_time'] = new Date(queryVo.start_time).getTime();
}
if (queryVo.end_time) {
param['end_time'] = new Date(queryVo.end_time).getTime();
}
if (queryVo.before) {
param['before'] = queryVo.before
......@@ -50,6 +86,16 @@ export const historyList = async (queryVo: QueryVo) => {
export const detailList = async (queryVo: QueryVo) => {
let param = {
user_id: queryVo.user_id,
market: queryVo.market ? queryVo.market : "spot",
};
if (queryVo.symbol) {
param['symbol'] = queryVo.symbol
}
if (queryVo.start_time) {
param['start_time'] = new Date(queryVo.start_time).getTime();
}
if (queryVo.end_time) {
param['end_time'] = new Date(queryVo.end_time).getTime();
}
if (queryVo.before) {
param['before'] = queryVo.before
......@@ -60,6 +106,9 @@ export const detailList = async (queryVo: QueryVo) => {
if (queryVo.limit) {
param['limit'] = queryVo.limit
}
if (queryVo.order_id) {
param['order_id'] = queryVo.order_id
}
let res = await getUserFillsFromCore(param);
return res;
};
......
......@@ -54,6 +54,7 @@ import * as rewardTimePeriodCtrl from "../../mvc/control/rewardTimePeriod.contro
import * as collateralCtrl from "../../mvc/control/collateral.control";
import * as fianceAccountCtrl from "../../mvc/control/fianceAccount.control";
import * as fianceAccountCategoryCtrl from "../../mvc/control/fianceAccountCategory.control";
import * as billsCtrl from "../../mvc/control/mUserBills.control";
const getFunc = {
'user/info': userController.getUserInfo,
......@@ -168,6 +169,11 @@ const postFunc = {
'mUser/manage/order/pending/list': orderPendingAndHistoryCtrl.pendingList,//Madex 用户管理 ->当前委托
'mUser/manage/order/history/list': orderPendingAndHistoryCtrl.historyList,//Madex 用户管理 ->历史委托
'mUser/manage/order/detail/list': orderPendingAndHistoryCtrl.detailList,//Madex 用户管理 ->成交记录
'mUser/manage/withdrawLock': mUserManageCtrl.withdrawLock,//Madex 用户管理 -> 锁定提现
'mUser/manage/withdrawUnlock': mUserManageCtrl.withdrawUnlock,//Madex 用户管理 -> 解除锁定提现
'mUser/manage/clearTotp': mUserManageCtrl.clearTotp,//Madex 用户管理 -> 清除谷歌
'mUser/manage/billTypeList': billsCtrl.billTypeList,//账单类型列表
'mUser/manage/billDetailList': billsCtrl.billDetailList,//账单详情
//运营部-现货-资源位管理
'link/useful/list': usefulLinkCtrl.list,//链接记录列表
......
......@@ -111,6 +111,11 @@ let cmdWhiteList = {
'mUser/manage/order/pending/list': 1,
'mUser/manage/order/history/list': 1,
'mUser/manage/order/detail/list': 1,
'mUser/manage/withdrawLock': 1,
'mUser/manage/withdrawUnlock': 1,
'mUser/manage/clearTotp': 1,
'mUser/manage/billTypeList': 1,
'mUser/manage/billDetailList': 1,
//运营部-现货-资源位管理
'link/useful/list': 1,
'link/useful/add': 1,
......
......@@ -24,6 +24,7 @@ const ExcludeApi = {
'operate/other/business/area/list': 1,
'coinType/mixinCoinList': 1,
'coinType/chainList': 1,
'mUser/manage/billTypeList': 1,
};
//管理员需要强制绑定,该位置做特殊处理
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment