Commit e4a5d77f authored by ml's avatar ml

新管理后台-部分接口逻辑调整、项目方交易量统计定时任务

parent b66ba41a
...@@ -148,9 +148,10 @@ export const changeUserSpotFee = async function (user_id, symbol, fee_model, mak ...@@ -148,9 +148,10 @@ export const changeUserSpotFee = async function (user_id, symbol, fee_model, mak
await checkUser(user_id); await checkUser(user_id);
await sleep(1000); await sleep(1000);
//请求撮合 修改费率 //请求撮合 修改费率 maker_fee 和 taker_fee 同时为1 代表初始化费率
let tmp_maker_fee = Number(maker_fee) == 0.001 ? 1 : maker_fee;
let res = await changeTradingFee(pair, user_id, maker_fee, taker_fee, "spot",opt_market); let tmp_taker_fee = Number(taker_fee) == 0.002 ? 1 : taker_fee;
let res = await changeTradingFee(pair, user_id, tmp_maker_fee, tmp_taker_fee, "spot", opt_market);
return res.is_success; return res.is_success;
}; };
...@@ -194,8 +195,10 @@ export const changeUserContractFee = async function (user_id, symbol, fee_model, ...@@ -194,8 +195,10 @@ export const changeUserContractFee = async function (user_id, symbol, fee_model,
await checkUser(user_id); await checkUser(user_id);
await sleep(1000); await sleep(1000);
//请求撮合 修改费率 //请求撮合 修改费率 maker_fee 和 taker_fee 同时为1 代表初始化费率
let res = await changeTradingFee(pair, user_id, maker_fee, taker_fee, "lpc",opt_market); let tmp_maker_fee = Number(maker_fee) == 0.0004 ? 1 : maker_fee;
let tmp_taker_fee = Number(taker_fee) == 0.0006 ? 1 : taker_fee;
let res = await changeTradingFee(pair, user_id, tmp_maker_fee, tmp_taker_fee, "lpc", opt_market);
return res.is_success; return res.is_success;
}; };
......
...@@ -208,7 +208,7 @@ async function setExpiredDefault() { ...@@ -208,7 +208,7 @@ async function setExpiredDefault() {
}, },
raw: true, raw: true,
}); });
let init_maker_rate = 1, init_taker_rate = 1; // maker_fee 和 taker_fee 同时为1 代表初始化用户费率 let init_maker_rate = 0.0004, init_taker_rate = 0.0006; // 初始用户费率
let newFeeArr: any = []; let newFeeArr: any = [];
let beginAt = new Date(); let beginAt = new Date();
......
...@@ -206,7 +206,7 @@ async function setExpiredDefault() { ...@@ -206,7 +206,7 @@ async function setExpiredDefault() {
unCheckCountObj[user_id] = amount; unCheckCountObj[user_id] = amount;
} }
let init_maker_rate = 1, init_taker_rate = 1; // maker_fee 和 taker_fee 同时为1 代表初始化用户费率 let init_maker_rate = 0.0004, init_taker_rate = 0.0006; // 初始用户费率
let newFeeArr: any = []; let newFeeArr: any = [];
let beginAt = new Date(); let beginAt = new Date();
......
...@@ -231,7 +231,7 @@ async function setExpiredDefault() { ...@@ -231,7 +231,7 @@ async function setExpiredDefault() {
}, },
raw: true, raw: true,
}); });
let init_maker_rate = 1, init_taker_rate = 1; // maker_fee 和 taker_fee 同时为1 代表初始化用户费率 let init_maker_rate = 0.001, init_taker_rate = 0.002; // 初始用户费率
let activePairs: any = ['all']; let activePairs: any = ['all'];
for (let i = 0; i < defaultPairFee.length; i++) { for (let i = 0; i < defaultPairFee.length; i++) {
let { symbol} = defaultPairFee[i]; let { symbol} = defaultPairFee[i];
......
import { statisProjectMakerDeals } from "../service/task.market.maker.statis.service"; import { statisticsProjectMakerDeals } from "../service/task.market.maker.statis.service";
const schedule = require('node-schedule'); const schedule = require('node-schedule');
const logger = require('@madex/ex-js-public').logger; const logger = require('@madex/ex-js-public').logger;
...@@ -14,7 +14,7 @@ let setFeeRateJob = schedule.scheduleJob('0 10 0 * * *', async function () { ...@@ -14,7 +14,7 @@ let setFeeRateJob = schedule.scheduleJob('0 10 0 * * *', async function () {
} }
inJob = true; inJob = true;
try { try {
await statisProjectMakerDeals(); await statisticsProjectMakerDeals();
inJob = false; inJob = false;
} catch (error) { } catch (error) {
inJob = false; inJob = false;
......
...@@ -65,7 +65,7 @@ export const update = async (req: any, commonUserFeeVO: CommonUserFeeVO) => { ...@@ -65,7 +65,7 @@ export const update = async (req: any, commonUserFeeVO: CommonUserFeeVO) => {
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 (!commonUserFeeVO.id){ if (!commonUserFeeVO.id) {
throw ErrorCode.PARAM_MISS; throw ErrorCode.PARAM_MISS;
} }
await addParamValid(commonUserFeeVO); await addParamValid(commonUserFeeVO);
...@@ -103,7 +103,6 @@ export const del = async (req: any, commonUserFeeVO: CommonUserFeeVO) => { ...@@ -103,7 +103,6 @@ export const del = async (req: any, commonUserFeeVO: CommonUserFeeVO) => {
}; };
/** /**
* 用户等级费率列表 * 用户等级费率列表
* @param req * @param req
...@@ -141,12 +140,13 @@ async function addParamValid(commonUserFeeVO: CommonUserFeeVO) { ...@@ -141,12 +140,13 @@ async function addParamValid(commonUserFeeVO: CommonUserFeeVO) {
throw ErrorCode.PAIR_NOT_SUPPORT; throw ErrorCode.PAIR_NOT_SUPPORT;
}*/ }*/
//校验费率范围 //校验费率范围
if (type == FEE_TYPE.FEE_TYPE_SPOT){ if (type == FEE_TYPE.FEE_TYPE_SPOT) {
if (Number(makerFee) < 0.0002 || Number(takerFee) < 0.0005){ if (Number(makerFee) < 0.0002 || Number(takerFee) < 0.0005) {
throw ErrorCode.FEE_TOO_LOW_OR_HIGH; throw ErrorCode.FEE_TOO_LOW_OR_HIGH;
} }
}else { }
if (Number(makerFee) < -0.00015 || Number(takerFee) < 0.00035){ else {
if (Number(makerFee) < -0.00015 || Number(takerFee) < 0.00035) {
throw ErrorCode.FEE_TOO_LOW_OR_HIGH; throw ErrorCode.FEE_TOO_LOW_OR_HIGH;
} }
} }
...@@ -232,6 +232,10 @@ async function checkMaker(commonUserFeeVO: CommonUserFeeVO) { ...@@ -232,6 +232,10 @@ async function checkMaker(commonUserFeeVO: CommonUserFeeVO) {
} }
//项目方 //项目方
if (userChannel == 2) { if (userChannel == 2) {
//项目方只允许现货并且单个交易对
if (Number(commonUserFeeVO.type) != 1 || commonUserFeeVO.pair == 'all') {
throw ErrorCode.PARAM_MISS;
}
let statisPeriod = commonUserFeeVO.statis_period; let statisPeriod = commonUserFeeVO.statis_period;
let amount_require_usdt = commonUserFeeVO.amount_require_usdt; let amount_require_usdt = commonUserFeeVO.amount_require_usdt;
if (!statisPeriod || Number(statisPeriod) < 0 || Number(statisPeriod) > 30) { if (!statisPeriod || Number(statisPeriod) < 0 || Number(statisPeriod) > 30) {
......
...@@ -98,6 +98,15 @@ export async function list(pageVO: CommonUserFeePageVO) { ...@@ -98,6 +98,15 @@ export async function list(pageVO: CommonUserFeePageVO) {
where['status'] = pageVO.status; where['status'] = pageVO.status;
} }
} }
if (pageVO.user_id) {
where['user_id'] = pageVO.user_id;
}
if (pageVO.type) {
where['type'] = pageVO.type;
}
if (pageVO.user_channel) {
where['user_channel'] = pageVO.user_channel;
}
if (pageVO.export) { if (pageVO.export) {
let resList = await commonUserFeeSetting.prototype.findAll({ let resList = await commonUserFeeSetting.prototype.findAll({
...@@ -107,12 +116,7 @@ export async function list(pageVO: CommonUserFeePageVO) { ...@@ -107,12 +116,7 @@ export async function list(pageVO: CommonUserFeePageVO) {
}); });
return resList; return resList;
} }
if (pageVO.user_id) {
where['user_id'] = pageVO.user_id;
}
if (pageVO.type) {
where['type'] = pageVO.type;
}
let resList = await commonUserFeeSetting.prototype.findAndCount({ let resList = await commonUserFeeSetting.prototype.findAndCount({
...@@ -131,8 +135,6 @@ export async function list(pageVO: CommonUserFeePageVO) { ...@@ -131,8 +135,6 @@ export async function list(pageVO: CommonUserFeePageVO) {
if (userChannel == 2) { if (userChannel == 2) {
cacheData = await getProjectMakerTradeStat(userId, pair); cacheData = await getProjectMakerTradeStat(userId, pair);
} }
item.avg7 = cacheData ? cacheData.avg7 : 0;
item.avg15 = cacheData ? cacheData.avg15 : 0;
item.avgUsdt = cacheData ? cacheData.avgUsdt : 0; item.avgUsdt = cacheData ? cacheData.avgUsdt : 0;
} }
} }
...@@ -524,16 +526,12 @@ async function checkContractPair(pair: string) { ...@@ -524,16 +526,12 @@ async function checkContractPair(pair: string) {
async function getProjectMakerTradeStat(user_id: number, pair: string) { async function getProjectMakerTradeStat(user_id: number, pair: string) {
let res = { let res = {
avg7: 0,
avg15: 0,
avgUsdt: 0, avgUsdt: 0,
}; };
let key = user_id + "_" + pair + "_projectMaker_FeeRate"; let key = user_id + "_" + pair + "_projectMaker_FeeRate";
let redisData = await RedisClient.getSync(key); let redisData = await RedisClient.getSync(key);
if (redisData) { if (redisData) {
let obj = JSON.parse(redisData); let obj = JSON.parse(redisData);
res.avg7 = obj.avg7;
res.avg15 = obj.avg15;
res.avgUsdt = obj.avgUsdt; res.avgUsdt = obj.avgUsdt;
} }
return res; return res;
......
...@@ -143,7 +143,7 @@ export async function kycList(queryVO: QueryVO) { ...@@ -143,7 +143,7 @@ export async function kycList(queryVO: QueryVO) {
} }
let resList = await userRealName.prototype.findAndCount({ let resList = await userRealName.prototype.findAndCount({
attributes: ['id', 'user_id', 'status', 'createdAt'], attributes: ['id', 'user_id', 'status', 'createdAt','auditor'],
where: where, where: where,
limit: queryVO.size, limit: queryVO.size,
offset: (Number(queryVO.page) - 1) * Number(queryVO.size), offset: (Number(queryVO.page) - 1) * Number(queryVO.size),
......
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