Commit 0e5fee07 authored by 1486327116's avatar 1486327116

Merge remote-tracking branch 'origin/master'

parents 5f24a20e 92f02e46
...@@ -38,12 +38,12 @@ export const ErrorCode = { ...@@ -38,12 +38,12 @@ export const ErrorCode = {
UID_ILLEGALITY: '30035',//UID不合法 UID_ILLEGALITY: '30035',//UID不合法
UID_TOO_MUCH: '30036',//UID过多 UID_TOO_MUCH: '30036',//UID过多
SPOT_NO_ASSETS:'30037',//用户现货账户未有资产记录 SPOT_NO_ASSETS:'30037',//用户钱包账户未有资产记录
U_NO_ASSETS:'30038',//用户U本位合约账户未有资产记录 U_NO_ASSETS:'30038',//用户统一账户未有资产记录
COIN_NO_ASSETS:'30039',//用户币本位合约账户未有资产记录 COIN_NO_ASSETS:'30039',//用户统一账户未有资产记录
SPOT_FEE_NEED_SET:'30040',//币币费率需要设置 SPOT_FEE_NEED_SET:'30040',//现货费率需要设置
CONTRACT_FEE_NEED_SET:'30041',//合约费率需要设置 CONTRACT_FEE_NEED_SET:'30041',//合约费率需要设置
SON_NOT_ADD_FEE:'30042',//子账户不能添加为市商 SON_NOT_ADD_FEE:'30042',//子账户不能添加费率
LEVEL_NOT_EXIST:'30043',//指定等级不存在 LEVEL_NOT_EXIST:'30043',//指定等级不存在
ONLY_ONE_FEE:'30044',//只能有一条未提交的费率设置 ONLY_ONE_FEE:'30044',//只能有一条未提交的费率设置
ONLY_UN_SUBMIT_UPDATE:'30045',//只有未提交的记录可以修改 ONLY_UN_SUBMIT_UPDATE:'30045',//只有未提交的记录可以修改
...@@ -76,4 +76,5 @@ export const ErrorCode = { ...@@ -76,4 +76,5 @@ export const ErrorCode = {
EXIST_ACTIVE_PAIR:'30072',//已存在生效或即将生效的该交易对费率配置 EXIST_ACTIVE_PAIR:'30072',//已存在生效或即将生效的该交易对费率配置
FEE_EX_OR_DEL:'30073',//费率设置已过期或已删除,不可以修改 FEE_EX_OR_DEL:'30073',//费率设置已过期或已删除,不可以修改
PAIR_FORMAT_ERR:'30074',//交易对格式错误 PAIR_FORMAT_ERR:'30074',//交易对格式错误
PAIR_NOT_SUPPORT:'30075',//暂不支持此交易对
} }
...@@ -136,6 +136,10 @@ async function addParamValid(commonUserFeeVO: CommonUserFeeVO) { ...@@ -136,6 +136,10 @@ async function addParamValid(commonUserFeeVO: CommonUserFeeVO) {
if (!userId || !beginTime || !expireTime || !pair || !applicant || !makerFee || !takerFee) { if (!userId || !beginTime || !expireTime || !pair || !applicant || !makerFee || !takerFee) {
throw ErrorCode.PARAM_MISS; throw ErrorCode.PARAM_MISS;
} }
//撮合目前只支持 all 后续支持单个币对 可放开
if (pair != 'all'){
throw ErrorCode.PAIR_NOT_SUPPORT;
}
await checkMaker(commonUserFeeVO); await checkMaker(commonUserFeeVO);
await paramCheck(beginTime, expireTime, Number(type), userId); await paramCheck(beginTime, expireTime, Number(type), userId);
......
...@@ -30,7 +30,6 @@ export const list = async (req: any, queryVO: QueryVO) => { ...@@ -30,7 +30,6 @@ export const list = async (req: any, queryVO: QueryVO) => {
/** /**
* 删除订阅 * 删除订阅
* TODO: 关于status 字段 从老管理后台来看 0 代表无效 1 代表有效 但是数据库备注 0 有效 1 无效 以哪个为准?
* @param req * @param req
* @param authConfigVO * @param authConfigVO
*/ */
...@@ -52,7 +51,6 @@ export const del = async (req: any, queryVO: QueryVO) => { ...@@ -52,7 +51,6 @@ export const del = async (req: any, queryVO: QueryVO) => {
/** /**
* 订阅统计 * 订阅统计
* TODO: 关于status 字段 从老管理后台来看 0 代表无效 1 代表有效 但是数据库备注 0 有效 1 无效 以哪个为准?
* @param req * @param req
* @param authConfigVO * @param authConfigVO
*/ */
...@@ -111,7 +109,6 @@ export const mailDetail = async (req: any, userMailLogVO: UserMailLogVO) => { ...@@ -111,7 +109,6 @@ export const mailDetail = async (req: any, userMailLogVO: UserMailLogVO) => {
/** /**
* 邮件发送 * 邮件发送
* TODO: 关于status 字段 从老管理后台来看 0 代表无效 1 代表有效 但是数据库备注 0 有效 1 无效 service里面又查询 status = 0 的 ???
* @param req * @param req
* @param userMailLogVO * @param userMailLogVO
*/ */
......
...@@ -153,32 +153,32 @@ export async function add(commonUserFeeVO: CommonUserFeeVO, currentUserId: any, ...@@ -153,32 +153,32 @@ export async function add(commonUserFeeVO: CommonUserFeeVO, currentUserId: any,
let pair = dbInfo.pair; let pair = dbInfo.pair;
let type = dbInfo.type; let type = dbInfo.type;
let now = new Date(); let now = new Date();
let insertDbList: any = []; let insertDbOne: any;
let rateLogs = await buildSubmitItems(pair, dbInfo, now, dbInfo.user_channel, type); let rateLog = await buildSubmitItem(pair, dbInfo, now, dbInfo.user_channel);
//提交到log表 //提交到log表
if (type == FEE_TYPE.FEE_TYPE_SPOT) { if (type == FEE_TYPE.FEE_TYPE_SPOT) {
insertDbList = await feeRateSpotLog.prototype.bulkCreate(rateLogs, { insertDbOne = await feeRateSpotLog.prototype.create(rateLog, {
transaction: tx transaction: tx
}); });
} }
else if (type == FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT) {//币本位 else if (type == FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT) {//币本位
insertDbList = await feeRateBaseCoinContractLog.prototype.bulkCreate(rateLogs, { insertDbOne = await feeRateBaseCoinContractLog.prototype.create(rateLog, {
transaction: tx transaction: tx
}); });
} }
else {//U本位 else {//U本位
insertDbList = await feeRateContractLog.prototype.bulkCreate(rateLogs, { insertDbOne = await feeRateContractLog.prototype.create(rateLog, {
transaction: tx transaction: tx
}); });
} }
let ids = insertDbList.map(item => item.id); let id = insertDbOne.id;
await commonUserFeeSetting.prototype.update({ await commonUserFeeSetting.prototype.update({
fee_log_ids: ids.toString(), fee_log_ids: id.toString(),
update_time: new Date() update_time: new Date()
}, { }, {
where: { where: {
...@@ -225,31 +225,31 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an ...@@ -225,31 +225,31 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an
let tx; let tx;
try { try {
tx = await ormDB.transaction(); tx = await ormDB.transaction();
let feeLogIds: any; let feeLogId: any;
//这四项修改需要 重新写入 rate_log //这四项修改需要 重新写入 rate_log
if (commonUserFeeVO.maker_fee != dbInfo.maker_fee || commonUserFeeVO.taker_fee != dbInfo.taker_fee if (commonUserFeeVO.maker_fee != dbInfo.maker_fee || commonUserFeeVO.taker_fee != dbInfo.taker_fee
|| commonUserFeeVO.begin_time != dbInfo.begin_time || commonUserFeeVO.expire_time != dbInfo.expire_time) { || commonUserFeeVO.begin_time != dbInfo.begin_time || commonUserFeeVO.expire_time != dbInfo.expire_time) {
let insertDbList: any; let insertDbOne: any;
let rateLogs = await buildSubmitItems(pair, commonUserFeeVO, new Date(), Number(commonUserFeeVO.user_channel), type); let rateLog = await buildSubmitItem(pair, commonUserFeeVO, new Date(), Number(commonUserFeeVO.user_channel));
//提交到log表 //提交到log表
if (type == FEE_TYPE.FEE_TYPE_SPOT) { if (type == FEE_TYPE.FEE_TYPE_SPOT) {
insertDbList = await feeRateSpotLog.prototype.bulkCreate(rateLogs, { insertDbOne = await feeRateSpotLog.prototype.create(rateLog, {
transaction: tx transaction: tx
}); });
} }
else if (type == FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT) {//币本位 else if (type == FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT) {//币本位
insertDbList = await feeRateBaseCoinContractLog.prototype.bulkCreate(rateLogs, { insertDbOne = await feeRateBaseCoinContractLog.prototype.create(rateLog, {
transaction: tx transaction: tx
}); });
} }
else {//U本位 else {//U本位
insertDbList = await feeRateContractLog.prototype.bulkCreate(rateLogs, { insertDbOne = await feeRateContractLog.prototype.create(rateLog, {
transaction: tx transaction: tx
}); });
} }
feeLogIds = insertDbList.map(item => item.id); feeLogId = insertDbOne.id;
} }
...@@ -264,7 +264,7 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an ...@@ -264,7 +264,7 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an
amount_require_usdt: commonUserFeeVO.amount_require_usdt, amount_require_usdt: commonUserFeeVO.amount_require_usdt,
applicant: commonUserFeeVO.applicant, applicant: commonUserFeeVO.applicant,
update_time: new Date(), update_time: new Date(),
fee_log_ids: feeLogIds ? feeLogIds.toString() : dbInfo.fee_log_ids, fee_log_ids: feeLogId ? feeLogId.toString() : dbInfo.fee_log_ids,
}, { }, {
where: { where: {
id: Number(commonUserFeeVO.id) id: Number(commonUserFeeVO.id)
...@@ -461,26 +461,10 @@ async function getDbFeeSetting(user_id: number | any, type: number | any, user_c ...@@ -461,26 +461,10 @@ async function getDbFeeSetting(user_id: number | any, type: number | any, user_c
return dbInfo; return dbInfo;
} }
async function buildSubmitItems(pair: string, dbInfo: any, now: Date, user_channel: number, type: number) { async function buildSubmitItem(pair: string, dbInfo: any, now: Date, user_channel: number) {
let pairList: any;
if (pair == 'all') {
if (type == FEE_TYPE.FEE_TYPE_SPOT) {
pairList = await getAllSpotPairs();
}
else {
//TODO:币本位和U本位的交易对怎么区分?
pairList = await getAllContractPairs();
}
}
else {
pairList = [pair]
}
let itemList: any = [];
for (let onePair of pairList) {
let item = { let item = {
user_id: dbInfo.user_id, user_id: dbInfo.user_id,
pair: onePair, pair: pair,
fee_model: FEE_MODEL_SPOT_DEFAULT, fee_model: FEE_MODEL_SPOT_DEFAULT,
maker_fee: dbInfo.maker_fee, maker_fee: dbInfo.maker_fee,
taker_fee: dbInfo.taker_fee, taker_fee: dbInfo.taker_fee,
...@@ -501,11 +485,8 @@ async function buildSubmitItems(pair: string, dbInfo: any, now: Date, user_chann ...@@ -501,11 +485,8 @@ async function buildSubmitItems(pair: string, dbInfo: any, now: Date, user_chann
else { else {
item.comment = COMMENT_USER_FEE_SUBMIT item.comment = COMMENT_USER_FEE_SUBMIT
} }
itemList.push(item);
}
return itemList; return item;
} }
async function checkSpotPair(pair: string) { async function checkSpotPair(pair: string) {
......
...@@ -62,7 +62,6 @@ export async function mailDetail(id: number | undefined) { ...@@ -62,7 +62,6 @@ export async function mailDetail(id: number | undefined) {
export async function mailSend(userMailLogVO: UserMailLogVO, currentUserId: any, ip: string | undefined) { export async function mailSend(userMailLogVO: UserMailLogVO, currentUserId: any, ip: string | undefined) {
let where = { let where = {
//TODO:0 ? 1 ???
status: 0 status: 0
}; };
if (userMailLogVO.user_id) { if (userMailLogVO.user_id) {
...@@ -95,7 +94,6 @@ export async function mailSend(userMailLogVO: UserMailLogVO, currentUserId: any, ...@@ -95,7 +94,6 @@ export async function mailSend(userMailLogVO: UserMailLogVO, currentUserId: any,
} }
for (let sub of toAddrRes) { for (let sub of toAddrRes) {
//TODO:老管理后台就没有模版 ???
sendEmail(sub.sub, sub.user_id, "", params, userMailLogVO.lang); sendEmail(sub.sub, sub.user_id, "", params, userMailLogVO.lang);
} }
......
...@@ -428,8 +428,8 @@ async function buildReturnData(pageData: any, fill_user_info: boolean, fill_coin ...@@ -428,8 +428,8 @@ async function buildReturnData(pageData: any, fill_user_info: boolean, fill_coin
real_name: item.real_name ? item.real_name : "", real_name: item.real_name ? item.real_name : "",
email: item.email ? item.email : "", email: item.email ? item.email : "",
register_date: item.createdAt ? item.createdAt : "", register_date: item.createdAt ? item.createdAt : "",
spot_balance: 0,//TODO:现货余额 spot_balance: 0,
contract_balance: 0,//TODO:永续合约余额 contract_balance: 0,
assets_total: assets_total,//总资产 assets_total: assets_total,//总资产
wallet_account_balance: wallet_account_balance,//钱包账户余额 wallet_account_balance: wallet_account_balance,//钱包账户余额
trade_account_balance: trade_account_balance,//交易账户余额 trade_account_balance: trade_account_balance,//交易账户余额
......
...@@ -62,7 +62,7 @@ export async function del(id: number, currentUserId: any, ip: string | undefined ...@@ -62,7 +62,7 @@ export async function del(id: number, currentUserId: any, ip: string | undefined
} }
await userSub.prototype.update({ await userSub.prototype.update({
status: 0, status: 1,//0 有效 1 无效
}, { }, {
where: { where: {
id: Number(id) id: Number(id)
...@@ -84,7 +84,7 @@ export async function count() { ...@@ -84,7 +84,7 @@ export async function count() {
let dbInfoList = await userSub.prototype.findAll({ let dbInfoList = await userSub.prototype.findAll({
where: { where: {
status: 1 status: 0
}, },
raw: true raw: true
}); });
......
...@@ -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,
......
let { let {
debug, debug,
logger logger
} = require('@madex/ex-js-public'); } = require('@madex/ex-js-public');
const {
larkRobotUtils: LarkRobotUtils,
} = require("@madex/ex-js-common")
let config = require('../../config'); let config = require('../../config');
let axios = require('axios');
debug = config.env === "development"; debug = config.env === "development";
let COMMON_KEY = "9e06e260-6c2f-49d4-98b4-e08ef096f6f5"; /**
//测试 * Lark 地址
*/
let LARK_URL_PRE = "https://open.larksuite.com/open-apis/bot/v2/hook/";
/**
* 生产:pro
*/
let COMMON_KEY = "d9f2dc6e-52cf-4933-92f1-dab9c249aa28";
/**
* 测试:dev
*/
if (debug) { if (debug) {
COMMON_KEY = "9e06e260-6c2f-49d4-98b4-e08ef096f6f5"; COMMON_KEY = "d98c9942-ff6f-4e71-a77f-41647ff19ff0";
} }
export const ROBOT_KEYS = { export const ROBOT_KEYS = {
COMMON_KEY: COMMON_KEY COMMON_KEY: COMMON_KEY
} }
...@@ -27,7 +38,9 @@ export const ROBOT_KEYS = { ...@@ -27,7 +38,9 @@ export const ROBOT_KEYS = {
* @param _func_name_ 报错方法(可选) * @param _func_name_ 报错方法(可选)
*/ */
export const sendRobotMessage = async function (url: string, content: any, _func_name_?: string) { export const sendRobotMessage = async function (url: string, content: any, _func_name_?: string) {
if (!_func_name_) {
_func_name_ = '';
}
if (typeof content != 'string') { if (typeof content != 'string') {
if (content && content.sql) { if (content && content.sql) {
content = `backend._func_name_ ${_func_name_}, ${content.sql}`; content = `backend._func_name_ ${_func_name_}, ${content.sql}`;
...@@ -55,5 +68,17 @@ export const sendRobotMessage = async function (url: string, content: any, _func ...@@ -55,5 +68,17 @@ export const sendRobotMessage = async function (url: string, content: any, _func
async function doSend(url: string, content: any) { async function doSend(url: string, content: any) {
logger.info('robot message', url, content); logger.info('robot message', url, content);
await LarkRobotUtils.sendTextSimple(url, content).catch() let URL = LARK_URL_PRE + url;
try {
let response = await axios.post(URL, {
msg_type: "text",
content: { text: content }
});
if (response && response.data) {
return response.data
}
}
catch (e) {
logger.error('robot send error', URL, content);
}
} }
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