Commit f98662c1 authored by ml's avatar ml

资产管理后台-特殊费率修改

parent 373aa973
...@@ -153,32 +153,36 @@ export async function add(commonUserFeeVO: CommonUserFeeVO, currentUserId: any, ...@@ -153,32 +153,36 @@ 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 insertDbOne: any; let insertDbList: any;
let rateLog = await buildSubmitItem(pair, dbInfo, now, dbInfo.user_channel); let rateLogs = await buildSubmitItems(pair, dbInfo, now, dbInfo.user_channel);
//提交到log表 //提交到log表
if (type == FEE_TYPE.FEE_TYPE_SPOT) { if (type == FEE_TYPE.FEE_TYPE_SPOT) {
insertDbOne = await feeRateSpotLog.prototype.create(rateLog, { insertDbList = await feeRateSpotLog.prototype.bulkCreate(rateLogs, {
transaction: tx transaction: tx,
returning: true
}); });
} }
else if (type == FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT) {//币本位 else if (type == FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT) {//币本位
insertDbOne = await feeRateBaseCoinContractLog.prototype.create(rateLog, { insertDbList = await feeRateBaseCoinContractLog.prototype.bulkCreate(rateLogs, {
transaction: tx transaction: tx,
returning: true
}); });
} }
else {//U本位 else {//U本位
insertDbOne = await feeRateContractLog.prototype.create(rateLog, { insertDbList = await feeRateContractLog.prototype.bulkCreate(rateLogs, {
transaction: tx transaction: tx,
returning: true
}); });
} }
let id = insertDbOne.id; let idsList = insertDbList.map(item => item.id);
let ids = idsList.length ? idsList.join(",") : "";
await commonUserFeeSetting.prototype.update({ await commonUserFeeSetting.prototype.update({
fee_log_ids: id.toString(), fee_log_ids: ids,
update_time: new Date() update_time: new Date()
}, { }, {
where: { where: {
...@@ -225,31 +229,35 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an ...@@ -225,31 +229,35 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an
let tx; let tx;
try { try {
tx = await ormDB.transaction(); tx = await ormDB.transaction();
let feeLogId: any; let feeLogIds: any;
//这四项修改需要 重新写入 rate_log //这四项修改需要 重新写入 rate_log
if (commonUserFeeVO.maker_fee != dbInfo.maker_fee || commonUserFeeVO.taker_fee != dbInfo.taker_fee if (Number(commonUserFeeVO.maker_fee) != Number(dbInfo.maker_fee) || Number(commonUserFeeVO.taker_fee) != Number(dbInfo.taker_fee)
|| commonUserFeeVO.begin_time != dbInfo.begin_time || commonUserFeeVO.expire_time != dbInfo.expire_time) { || datetimeUtils.trim(commonUserFeeVO.begin_time, 's').getTime() != datetimeUtils.trim(dbInfo.begin_time, 's').getTime()
let insertDbOne: any; || datetimeUtils.trim(commonUserFeeVO.expire_time, 's').getTime() != datetimeUtils.trim(dbInfo.expire_time, 's').getTime()) {
let rateLog = await buildSubmitItem(pair, commonUserFeeVO, new Date(), Number(commonUserFeeVO.user_channel)); let insertDbList: any;
let rateLogs = await buildSubmitItems(pair, commonUserFeeVO, new Date(), Number(commonUserFeeVO.user_channel));
//提交到log表 //提交到log表
if (type == FEE_TYPE.FEE_TYPE_SPOT) { if (type == FEE_TYPE.FEE_TYPE_SPOT) {
insertDbOne = await feeRateSpotLog.prototype.create(rateLog, { insertDbList = await feeRateSpotLog.prototype.bulkCreate(rateLogs, {
transaction: tx transaction: tx,
returning: true
}); });
} }
else if (type == FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT) {//币本位 else if (type == FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT) {//币本位
insertDbOne = await feeRateBaseCoinContractLog.prototype.create(rateLog, { insertDbList = await feeRateBaseCoinContractLog.prototype.bulkCreate(rateLogs, {
transaction: tx transaction: tx,
returning: true
}); });
} }
else {//U本位 else {//U本位
insertDbOne = await feeRateContractLog.prototype.create(rateLog, { insertDbList = await feeRateContractLog.prototype.bulkCreate(rateLogs, {
transaction: tx transaction: tx,
returning: true
}); });
} }
let idsList = insertDbList.map(item => item.id);
feeLogId = insertDbOne.id; feeLogIds = idsList.length ? idsList.join(",") : dbInfo.fee_log_ids;
} }
...@@ -264,7 +272,7 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an ...@@ -264,7 +272,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: feeLogId ? feeLogId.toString() : dbInfo.fee_log_ids, fee_log_ids: feeLogIds,
}, { }, {
where: { where: {
id: Number(commonUserFeeVO.id) id: Number(commonUserFeeVO.id)
...@@ -461,32 +469,51 @@ async function getDbFeeSetting(user_id: number | any, type: number | any, user_c ...@@ -461,32 +469,51 @@ async function getDbFeeSetting(user_id: number | any, type: number | any, user_c
return dbInfo; return dbInfo;
} }
async function buildSubmitItem(pair: string, dbInfo: any, now: Date, user_channel: number) { async function buildSubmitItems(pair: string, dbInfo: any, now: Date, user_channel: number) {
let item = { let type = Number(dbInfo.type);
user_id: dbInfo.user_id, let submitItems: any = [];
pair: pair, let pairs: any = [];
fee_model: FEE_MODEL_SPOT_DEFAULT, //全部交易对时需要查询交易对表
maker_fee: dbInfo.maker_fee, if (pair == 'all') {
taker_fee: dbInfo.taker_fee, //现货
beginAt: dbInfo.begin_time, if (type == FEE_TYPE.FEE_TYPE_SPOT) {
expireAt: dbInfo.expire_time, pairs = await getAllSpotPairs();
is_check: FEE_RATE_LOG_STATUS.CHECK_STATUS_UNCHECK, }
comment: "", else {//合约 这里目前查询的是 contract_pairs 如果之后 币本位的交易对有单独的表 需要修改此处代码
createdAt: now, pairs = await getAllContractPairs();
updatedAt: now }
}
//项目方
if (user_channel == 2) {
item.comment = COMMENT_MAKER_FEE_SUBMIT
}
else if (user_channel == 3) {
item.comment = COMMENT_KOL_FEE_SUBMIT
} }
else { else {
item.comment = COMMENT_USER_FEE_SUBMIT pairs.push(pair);
} }
for (let onePair of pairs) {
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
}
return item; submitItems.push(item);
}
return submitItems;
} }
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