Commit 92f02e46 authored by ml's avatar ml

VIP 管理用户费率逻辑修改

parent 8d1a7179
......@@ -38,12 +38,12 @@ export const ErrorCode = {
UID_ILLEGALITY: '30035',//UID不合法
UID_TOO_MUCH: '30036',//UID过多
SPOT_NO_ASSETS:'30037',//用户现货账户未有资产记录
U_NO_ASSETS:'30038',//用户U本位合约账户未有资产记录
COIN_NO_ASSETS:'30039',//用户币本位合约账户未有资产记录
SPOT_FEE_NEED_SET:'30040',//币币费率需要设置
SPOT_NO_ASSETS:'30037',//用户钱包账户未有资产记录
U_NO_ASSETS:'30038',//用户统一账户未有资产记录
COIN_NO_ASSETS:'30039',//用户统一账户未有资产记录
SPOT_FEE_NEED_SET:'30040',//现货费率需要设置
CONTRACT_FEE_NEED_SET:'30041',//合约费率需要设置
SON_NOT_ADD_FEE:'30042',//子账户不能添加为市商
SON_NOT_ADD_FEE:'30042',//子账户不能添加费率
LEVEL_NOT_EXIST:'30043',//指定等级不存在
ONLY_ONE_FEE:'30044',//只能有一条未提交的费率设置
ONLY_UN_SUBMIT_UPDATE:'30045',//只有未提交的记录可以修改
......@@ -76,4 +76,5 @@ export const ErrorCode = {
EXIST_ACTIVE_PAIR:'30072',//已存在生效或即将生效的该交易对费率配置
FEE_EX_OR_DEL:'30073',//费率设置已过期或已删除,不可以修改
PAIR_FORMAT_ERR:'30074',//交易对格式错误
PAIR_NOT_SUPPORT:'30075',//暂不支持此交易对
}
......@@ -136,6 +136,10 @@ async function addParamValid(commonUserFeeVO: CommonUserFeeVO) {
if (!userId || !beginTime || !expireTime || !pair || !applicant || !makerFee || !takerFee) {
throw ErrorCode.PARAM_MISS;
}
//撮合目前只支持 all 后续支持单个币对 可放开
if (pair != 'all'){
throw ErrorCode.PAIR_NOT_SUPPORT;
}
await checkMaker(commonUserFeeVO);
await paramCheck(beginTime, expireTime, Number(type), userId);
......
......@@ -153,32 +153,32 @@ export async function add(commonUserFeeVO: CommonUserFeeVO, currentUserId: any,
let pair = dbInfo.pair;
let type = dbInfo.type;
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表
if (type == FEE_TYPE.FEE_TYPE_SPOT) {
insertDbList = await feeRateSpotLog.prototype.bulkCreate(rateLogs, {
insertDbOne = await feeRateSpotLog.prototype.create(rateLog, {
transaction: tx
});
}
else if (type == FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT) {//币本位
insertDbList = await feeRateBaseCoinContractLog.prototype.bulkCreate(rateLogs, {
insertDbOne = await feeRateBaseCoinContractLog.prototype.create(rateLog, {
transaction: tx
});
}
else {//U本位
insertDbList = await feeRateContractLog.prototype.bulkCreate(rateLogs, {
insertDbOne = await feeRateContractLog.prototype.create(rateLog, {
transaction: tx
});
}
let ids = insertDbList.map(item => item.id);
let id = insertDbOne.id;
await commonUserFeeSetting.prototype.update({
fee_log_ids: ids.toString(),
fee_log_ids: id.toString(),
update_time: new Date()
}, {
where: {
......@@ -225,31 +225,31 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an
let tx;
try {
tx = await ormDB.transaction();
let feeLogIds: any;
let feeLogId: any;
//这四项修改需要 重新写入 rate_log
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) {
let insertDbList: any;
let rateLogs = await buildSubmitItems(pair, commonUserFeeVO, new Date(), Number(commonUserFeeVO.user_channel), type);
let insertDbOne: any;
let rateLog = await buildSubmitItem(pair, commonUserFeeVO, new Date(), Number(commonUserFeeVO.user_channel));
//提交到log表
if (type == FEE_TYPE.FEE_TYPE_SPOT) {
insertDbList = await feeRateSpotLog.prototype.bulkCreate(rateLogs, {
insertDbOne = await feeRateSpotLog.prototype.create(rateLog, {
transaction: tx
});
}
else if (type == FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT) {//币本位
insertDbList = await feeRateBaseCoinContractLog.prototype.bulkCreate(rateLogs, {
insertDbOne = await feeRateBaseCoinContractLog.prototype.create(rateLog, {
transaction: tx
});
}
else {//U本位
insertDbList = await feeRateContractLog.prototype.bulkCreate(rateLogs, {
insertDbOne = await feeRateContractLog.prototype.create(rateLog, {
transaction: tx
});
}
feeLogIds = insertDbList.map(item => item.id);
feeLogId = insertDbOne.id;
}
......@@ -264,7 +264,7 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an
amount_require_usdt: commonUserFeeVO.amount_require_usdt,
applicant: commonUserFeeVO.applicant,
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: {
id: Number(commonUserFeeVO.id)
......@@ -461,51 +461,32 @@ async function getDbFeeSetting(user_id: number | any, type: number | any, user_c
return dbInfo;
}
async function buildSubmitItems(pair: string, dbInfo: any, now: Date, user_channel: number, type: number) {
let pairList: any;
if (pair == 'all') {
if (type == FEE_TYPE.FEE_TYPE_SPOT) {
pairList = await getAllSpotPairs();
}
else {
//TODO:币本位和U本位的交易对怎么区分?
pairList = await getAllContractPairs();
}
async function buildSubmitItem(pair: string, dbInfo: any, now: Date, user_channel: number) {
let item = {
user_id: dbInfo.user_id,
pair: pair,
fee_model: FEE_MODEL_SPOT_DEFAULT,
maker_fee: dbInfo.maker_fee,
taker_fee: dbInfo.taker_fee,
beginAt: dbInfo.begin_time,
expireAt: dbInfo.expire_time,
is_check: FEE_RATE_LOG_STATUS.CHECK_STATUS_UNCHECK,
comment: "",
createdAt: now,
updatedAt: now
}
else {
pairList = [pair]
//项目方
if (user_channel == 2) {
item.comment = COMMENT_MAKER_FEE_SUBMIT
}
let itemList: any = [];
for (let onePair of pairList) {
let item = {
user_id: dbInfo.user_id,
pair: onePair,
fee_model: FEE_MODEL_SPOT_DEFAULT,
maker_fee: dbInfo.maker_fee,
taker_fee: dbInfo.taker_fee,
beginAt: dbInfo.begin_time,
expireAt: dbInfo.expire_time,
is_check: FEE_RATE_LOG_STATUS.CHECK_STATUS_UNCHECK,
comment: "",
createdAt: now,
updatedAt: now
}
//项目方
if (user_channel == 2) {
item.comment = COMMENT_MAKER_FEE_SUBMIT
}
else if (user_channel == 3) {
item.comment = COMMENT_KOL_FEE_SUBMIT
}
else {
item.comment = COMMENT_USER_FEE_SUBMIT
}
itemList.push(item);
else if (user_channel == 3) {
item.comment = COMMENT_KOL_FEE_SUBMIT
}
else {
item.comment = COMMENT_USER_FEE_SUBMIT
}
return itemList;
return item;
}
async function checkSpotPair(pair: string) {
......
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