Commit e4a5d77f authored by ml's avatar ml

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

parent b66ba41a
......@@ -121,10 +121,10 @@ export const changeUserSpotFee = async function (user_id, symbol, fee_model, mak
let product_type = symbol == 'all' ? 'spot' : 'single';
let opt_market = product_type;
//生效的费率 与要设置的费率 比对做校验 现在分不开 现货 合约 先不校验 之后分开了 再校验
let feeExist = await cancelIfFeeExist(user_id, product_type, symbol, maker_fee, taker_fee);
if (feeExist) {
return is_success;
}
let feeExist = await cancelIfFeeExist(user_id, product_type, symbol, maker_fee, taker_fee);
if (feeExist) {
return is_success;
}
let asset = await mainUserAsset.prototype.findOne({
where: {
user_id
......@@ -148,9 +148,10 @@ export const changeUserSpotFee = async function (user_id, symbol, fee_model, mak
await checkUser(user_id);
await sleep(1000);
//请求撮合 修改费率
let res = await changeTradingFee(pair, user_id, maker_fee, taker_fee, "spot",opt_market);
//请求撮合 修改费率 maker_fee 和 taker_fee 同时为1 代表初始化费率
let tmp_maker_fee = Number(maker_fee) == 0.001 ? 1 : maker_fee;
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;
};
......@@ -194,8 +195,10 @@ export const changeUserContractFee = async function (user_id, symbol, fee_model,
await checkUser(user_id);
await sleep(1000);
//请求撮合 修改费率
let res = await changeTradingFee(pair, user_id, maker_fee, taker_fee, "lpc",opt_market);
//请求撮合 修改费率 maker_fee 和 taker_fee 同时为1 代表初始化费率
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;
};
......
......@@ -208,7 +208,7 @@ async function setExpiredDefault() {
},
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 beginAt = new Date();
......
......@@ -206,7 +206,7 @@ async function setExpiredDefault() {
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 beginAt = new Date();
......
......@@ -231,7 +231,7 @@ async function setExpiredDefault() {
},
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'];
for (let i = 0; i < defaultPairFee.length; 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 logger = require('@madex/ex-js-public').logger;
......@@ -14,7 +14,7 @@ let setFeeRateJob = schedule.scheduleJob('0 10 0 * * *', async function () {
}
inJob = true;
try {
await statisProjectMakerDeals();
await statisticsProjectMakerDeals();
inJob = false;
} catch (error) {
inJob = false;
......
......@@ -65,7 +65,7 @@ export const update = async (req: any, commonUserFeeVO: CommonUserFeeVO) => {
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if (!commonUserFeeVO.id){
if (!commonUserFeeVO.id) {
throw ErrorCode.PARAM_MISS;
}
await addParamValid(commonUserFeeVO);
......@@ -103,7 +103,6 @@ export const del = async (req: any, commonUserFeeVO: CommonUserFeeVO) => {
};
/**
* 用户等级费率列表
* @param req
......@@ -141,12 +140,13 @@ async function addParamValid(commonUserFeeVO: CommonUserFeeVO) {
throw ErrorCode.PAIR_NOT_SUPPORT;
}*/
//校验费率范围
if (type == FEE_TYPE.FEE_TYPE_SPOT){
if (Number(makerFee) < 0.0002 || Number(takerFee) < 0.0005){
if (type == FEE_TYPE.FEE_TYPE_SPOT) {
if (Number(makerFee) < 0.0002 || Number(takerFee) < 0.0005) {
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;
}
}
......@@ -232,6 +232,10 @@ async function checkMaker(commonUserFeeVO: CommonUserFeeVO) {
}
//项目方
if (userChannel == 2) {
//项目方只允许现货并且单个交易对
if (Number(commonUserFeeVO.type) != 1 || commonUserFeeVO.pair == 'all') {
throw ErrorCode.PARAM_MISS;
}
let statisPeriod = commonUserFeeVO.statis_period;
let amount_require_usdt = commonUserFeeVO.amount_require_usdt;
if (!statisPeriod || Number(statisPeriod) < 0 || Number(statisPeriod) > 30) {
......
......@@ -98,6 +98,15 @@ export async function list(pageVO: CommonUserFeePageVO) {
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) {
let resList = await commonUserFeeSetting.prototype.findAll({
......@@ -107,12 +116,7 @@ export async function list(pageVO: CommonUserFeePageVO) {
});
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({
......@@ -131,8 +135,6 @@ export async function list(pageVO: CommonUserFeePageVO) {
if (userChannel == 2) {
cacheData = await getProjectMakerTradeStat(userId, pair);
}
item.avg7 = cacheData ? cacheData.avg7 : 0;
item.avg15 = cacheData ? cacheData.avg15 : 0;
item.avgUsdt = cacheData ? cacheData.avgUsdt : 0;
}
}
......@@ -524,16 +526,12 @@ async function checkContractPair(pair: string) {
async function getProjectMakerTradeStat(user_id: number, pair: string) {
let res = {
avg7: 0,
avg15: 0,
avgUsdt: 0,
};
let key = user_id + "_" + pair + "_projectMaker_FeeRate";
let redisData = await RedisClient.getSync(key);
if (redisData) {
let obj = JSON.parse(redisData);
res.avg7 = obj.avg7;
res.avg15 = obj.avg15;
res.avgUsdt = obj.avgUsdt;
}
return res;
......
......@@ -143,7 +143,7 @@ export async function kycList(queryVO: QueryVO) {
}
let resList = await userRealName.prototype.findAndCount({
attributes: ['id', 'user_id', 'status', 'createdAt'],
attributes: ['id', 'user_id', 'status', 'createdAt','auditor'],
where: where,
limit: 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