Commit 92f02e46 authored by ml's avatar ml

VIP 管理用户费率逻辑修改

parent 8d1a7179
...@@ -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);
......
...@@ -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,51 +461,32 @@ async function getDbFeeSetting(user_id: number | any, type: number | any, user_c ...@@ -461,51 +461,32 @@ 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 item = {
let pairList: any; user_id: dbInfo.user_id,
if (pair == 'all') { pair: pair,
if (type == FEE_TYPE.FEE_TYPE_SPOT) { fee_model: FEE_MODEL_SPOT_DEFAULT,
pairList = await getAllSpotPairs(); maker_fee: dbInfo.maker_fee,
} taker_fee: dbInfo.taker_fee,
else { beginAt: dbInfo.begin_time,
//TODO:币本位和U本位的交易对怎么区分? expireAt: dbInfo.expire_time,
pairList = await getAllContractPairs(); 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 = []; else if (user_channel == 3) {
for (let onePair of pairList) { item.comment = COMMENT_KOL_FEE_SUBMIT
let item = { }
user_id: dbInfo.user_id, else {
pair: onePair, item.comment = COMMENT_USER_FEE_SUBMIT
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);
} }
return item;
return itemList;
} }
async function checkSpotPair(pair: string) { 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