Commit 8d1a7179 authored by ml's avatar ml

交易用户数据

parent 4b0a134f
...@@ -3,7 +3,10 @@ import { ...@@ -3,7 +3,10 @@ import {
userLog, userLog,
userInfo, userInfo,
userRealName, userRealName,
mainUserBills mainUserBills,
dwsUserDailyTrade,
dwsUserDailyFee,
dwsMadOrmDB
} from "@madex/ex-ts-dao"; } from "@madex/ex-ts-dao";
import BigNumber from "bignumber.js"; import BigNumber from "bignumber.js";
...@@ -61,13 +64,51 @@ export async function increaseUserList(pageVO: QueryVO) { ...@@ -61,13 +64,51 @@ export async function increaseUserList(pageVO: QueryVO) {
export async function tradeUserList(pageVO: QueryVO) { export async function tradeUserList(pageVO: QueryVO) {
//TODO:
let res = {
count: 0,
rows: []
}
return res let where:any = {
type:0,//UTC 0
category:1,//现货
[dwsMadOrmDB.Op.and]: [
{
trade_date: { [dwsMadOrmDB.Op.gte]: pageVO.from_time }
},
{
trade_date: { [dwsMadOrmDB.Op.lt]: pageVO.to_time },
}]
};
let resList: any = [];
if (!pageVO.is_export) {
resList = await dwsUserDailyTrade.prototype.findAndCount({
attributes:['user_id',dwsMadOrmDB.literal('sum(equal_usdt + equal_usdt_free) as trade_amount')],
where: where,
limit: pageVO.size,
offset: (Number(pageVO.page) - 1) * Number(pageVO.size),
order: [[dwsMadOrmDB.literal('trade_amount'), "desc"]],
group: ['user_id'],
raw: true
});
resList.count = resList.count.length;
let uids = resList.rows.map(item => item.user_id);
if (uids){
where["user_id"] = uids
await dealFeeData(where,resList.rows);
}
}
else {//导出不分页
resList = await dwsUserDailyTrade.prototype.findAll({
attributes:['user_id',dwsMadOrmDB.literal('sum(equal_usdt + equal_usdt_free) as trade_amount')],
where: where,
order: [["trade_amount", "desc"]],
group: ['user_id'],
raw: true
});
let uids = resList.map(item => item.user_id);
if (uids){
where["user_id"] = uids
await dealFeeData(where,resList);
}
}
return resList;
} }
export async function activeUserList(pageVO: QueryVO) { export async function activeUserList(pageVO: QueryVO) {
...@@ -278,8 +319,24 @@ async function increaseUserCount(pageVO: QueryVO) { ...@@ -278,8 +319,24 @@ async function increaseUserCount(pageVO: QueryVO) {
} }
async function tradeUserCount(pageVO: QueryVO) { async function tradeUserCount(pageVO: QueryVO) {
//TODO:查询交易数据
return 0; let where:any = {
type:0,//UTC 0
category:1,//现货
[dwsMadOrmDB.Op.and]: [
{
trade_date: { [dwsMadOrmDB.Op.gte]: pageVO.from_time }
},
{
trade_date: { [dwsMadOrmDB.Op.lt]: pageVO.to_time },
}]
};
let dbList = await dwsUserDailyTrade.prototype.findAll({
attributes:[dwsMadOrmDB.literal('distinct(user_id) as user_id')],
where:where,
raw:true
});
return dbList.length;
} }
...@@ -417,6 +474,21 @@ async function dealDepositAndWithdrawReturnData(resList: any) { ...@@ -417,6 +474,21 @@ async function dealDepositAndWithdrawReturnData(resList: any) {
} }
} }
async function dealFeeData(where:any,dbList:any){
let dbFeeList = await dwsUserDailyFee.prototype.findAll({
attributes:['user_id',dwsMadOrmDB.literal('sum(equalusdt_amount) as fee_amount')],
where: where,
group:['user_id'],
raw: true
});
let fee_map:any = {};
for (let item of dbFeeList) {
fee_map[item.user_id] = item.fee_amount;
}
for (let item of dbList) {
item.fee_amount = fee_map[item.user_id] ? fee_map[item.user_id] : 0
}
}
......
...@@ -266,7 +266,7 @@ const postFunc = { ...@@ -266,7 +266,7 @@ const postFunc = {
'tech/apply/new/cron/coin/add/withdraw': cronApplyCtrl.addWithdraw,//增加新币提现定时器 'tech/apply/new/cron/coin/add/withdraw': cronApplyCtrl.addWithdraw,//增加新币提现定时器
//运营部-现货-现货数据 //运营部-现货-现货数据
'operate/spot/data/increase/user/list': spotDataCtrl.increaseUserList, 'operate/spot/data/increase/user/list': spotDataCtrl.increaseUserList,
'operate/spot/data/trade/user/list': spotDataCtrl.tradeUserList,//TODO 'operate/spot/data/trade/user/list': spotDataCtrl.tradeUserList,
'operate/spot/data/active/user/list': spotDataCtrl.activeUserList, 'operate/spot/data/active/user/list': spotDataCtrl.activeUserList,
'operate/spot/data/user/deposit/list': spotDataCtrl.userDepositList, 'operate/spot/data/user/deposit/list': spotDataCtrl.userDepositList,
'operate/spot/data/user/withdraw/list': spotDataCtrl.userWithdrawList, 'operate/spot/data/user/withdraw/list': spotDataCtrl.userWithdrawList,
......
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