Commit 94108a6a authored by ml's avatar ml

费率管理调整为VIP管理、相关逻辑调整、增加市商费率逻辑

parent 72108c1a
......@@ -47,7 +47,7 @@ export const ErrorCode = {
LEVEL_NOT_EXIST:'30043',//指定等级不存在
ONLY_ONE_FEE:'30044',//只能有一条未提交的费率设置
ONLY_UN_SUBMIT_UPDATE:'30045',//只有未提交的记录可以修改
UID_TYPE_NOT_UPDATE:'30046',//用户ID和类型不能修改
UID_TYPE_NOT_UPDATE:'30046',//用户ID、费率类型、交易对不能修改
DEL_UN_SUBMIT_ACTIVE:'30047',//只能删除未提交或未生效的记录
FEE_USED_NOT_DEL:'30048',//费率已生效,不能删除
ONLY_UN_SUBMIT_CAN_SUBMIT:'30049',//只有未提交的记录才能提交
......@@ -57,8 +57,8 @@ export const ErrorCode = {
PWD_ILLEGAL:'30053',//密码过短或过长
FIXED_AND_DEFAULT:'30054',//固定和默认不能同时为是
NOT_HIDDEN_TWO:'30055',//每种语言非隐藏并且固定的至少要有2个
COIN_TYPE_NOT_EXIST:'30056',//指定币种不存在
PAIR_NOT_EXIST:'30057',//指定币对不存在
COIN_TYPE_NOT_EXIST:'30056',//币种不存在
PAIR_NOT_EXIST:'30057',//币对不存在
LIMIT_ERROR:'30058',//limit参数必须在10-2000之间
ADD_PAIR_TO_CORE_ERR:'30059',//币种/交易对提交到撮合失败
SUBMIT_STATUS_ERR:'30060',//请确认提交状态
......@@ -70,7 +70,9 @@ export const ErrorCode = {
DEPOSIT_WITHDRAW_TM_EXPIRE:'30066',//开放充值时间/开放提现时间过短
CURRENT_STATUS_NOT_APPLY:'30067',//当前状态不可以审核
CURRENT_COIN_DATA_NOT_EXIST:'30068',//币种管理中计价币种不存在
PAIR_EXIST:'30069',//交易对已存在
PAIR_EXIST:'30069',//交易对已存在
ACTIVE_TM_EXPIRE:'30070',//交易时间过短
NO_TRIGGER_DEL:'30071',//只有未触发的任务可以删除
EXIST_ACTIVE_PAIR:'30072',//已存在生效或即将生效的该交易对费率配置
FEE_EX_OR_DEL:'30073',//费率设置已过期或已删除,不可以修改
}
export const FEE_TYPE = {
/**
* 费率类型: 全部。
*/
FEE_TYPE_ALL: 0,
/**
* 费率类型: 币币。
......@@ -17,20 +13,11 @@ export const FEE_TYPE = {
* 费率类型: 币本位合约。
*/
FEE_TYPE_BASE_COIN_CONTRACT: 3,
/**
* 费率类型: 合约(U本位+币本位)
*/
FEE_TYPE_CONTRACT_ALL: 5,
}
export const FEE_TYPE_LIST = [FEE_TYPE.FEE_TYPE_ALL, FEE_TYPE.FEE_TYPE_SPOT, FEE_TYPE.FEE_TYPE_CONTRACT, FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT, FEE_TYPE.FEE_TYPE_CONTRACT_ALL,]
export const FEE_TYPE_LIST = [FEE_TYPE.FEE_TYPE_SPOT, FEE_TYPE.FEE_TYPE_CONTRACT, FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT]
export const FEE_STATUS = {
/**
* 费率设置纪录状态: 未提交。
*/
STATUS_FEE_SETTING_NEW: 0,
/**
* 费率设置纪录状态: 已提交。
*/
......@@ -52,4 +39,16 @@ export const FEE_STATUS = {
/**
* 普通用户手续费提交备注。
*/
export const COMMENT_USER_FEE_SUBMIT = "提交普通用户手续费";
\ No newline at end of file
export const COMMENT_USER_FEE_SUBMIT = "提交普通用户手续费";
/**
* 市商手续费提交备注。
*/
export const COMMENT_MAKER_FEE_SUBMIT = "提交市商手续费";
/**
* KOL手续费提交备注。
*/
export const COMMENT_KOL_FEE_SUBMIT = "提交KOL手续费";
\ No newline at end of file
......@@ -65,7 +65,11 @@ export const update = async (req: any, commonUserFeeVO: CommonUserFeeVO) => {
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
await updateParamValid(commonUserFeeVO);
if (!commonUserFeeVO.id){
throw ErrorCode.PARAM_MISS;
}
await addParamValid(commonUserFeeVO);
let res = await commonUserFeeSettingService.update(commonUserFeeVO, currentUserId, ip);
return Res3Utils.result(res);
......@@ -99,27 +103,6 @@ export const del = async (req: any, commonUserFeeVO: CommonUserFeeVO) => {
};
/**
* 提交用户费率
* @param req
* @param authConfigVO
*/
export const submit = async (req: any, commonUserFeeVO: CommonUserFeeVO) => {
let func_name = "commonUserFeeSetting.control.submit";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if (!commonUserFeeVO.id) {
throw ErrorCode.PARAM_MISS
}
let res = await commonUserFeeSettingService.submit(commonUserFeeVO.id, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 用户等级费率列表
......@@ -145,11 +128,15 @@ async function addParamValid(commonUserFeeVO: CommonUserFeeVO) {
let expireTime = commonUserFeeVO.expire_time;
let type = commonUserFeeVO.type;
let levelId = commonUserFeeVO.level_id;
let pair = commonUserFeeVO.pair;
let applicant = commonUserFeeVO.applicant;
let makerFee = commonUserFeeVO.maker_fee;
let takerFee = commonUserFeeVO.taker_fee;
if (!userId || !beginTime || !expireTime) {
if (!userId || !beginTime || !expireTime || !pair || !applicant || !makerFee || !takerFee) {
throw ErrorCode.PARAM_MISS;
}
await checkMaker(commonUserFeeVO);
await paramCheck(beginTime, expireTime, Number(type), userId);
if (levelId) {
......@@ -162,24 +149,17 @@ async function addParamValid(commonUserFeeVO: CommonUserFeeVO) {
if (!vipLevelSetting) {
throw ErrorCode.LEVEL_NOT_EXIST;
}
commonUserFeeVO.spot_maker_fee = vipLevelSetting.spot_maker;
commonUserFeeVO.spot_taker_fee = vipLevelSetting.spot_taker;
commonUserFeeVO.contract_maker_fee = vipLevelSetting.contract_maker;
commonUserFeeVO.contract_taker_fee = vipLevelSetting.contract_taker;
if (type == FEE_TYPE.FEE_TYPE_SPOT) {
commonUserFeeVO.maker_fee = vipLevelSetting.spot_maker;
commonUserFeeVO.taker_fee = vipLevelSetting.spot_taker;
}
else {
commonUserFeeVO.maker_fee = vipLevelSetting.contract_maker;
commonUserFeeVO.taker_fee = vipLevelSetting.contract_taker;
}
return;
}
if ((type == FEE_TYPE.FEE_TYPE_ALL || type == FEE_TYPE.FEE_TYPE_SPOT)
&& (!commonUserFeeVO.spot_maker_fee || !commonUserFeeVO.spot_taker_fee)) {
throw ErrorCode.SPOT_FEE_NEED_SET;
}
if ((type == FEE_TYPE.FEE_TYPE_ALL || type == FEE_TYPE.FEE_TYPE_CONTRACT_ALL
|| type == FEE_TYPE.FEE_TYPE_CONTRACT || type == FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT)
&& (!commonUserFeeVO.contract_maker_fee || !commonUserFeeVO.contract_taker_fee)) {
throw ErrorCode.CONTRACT_FEE_NEED_SET;
}
let user = await getMUserInfoByUid(userId);
if (!user || user.deleted_flag == 1) {
......@@ -194,22 +174,6 @@ async function addParamValid(commonUserFeeVO: CommonUserFeeVO) {
}
async function updateParamValid(commonUserFeeVO: CommonUserFeeVO) {
let id = commonUserFeeVO.id;
let userId = commonUserFeeVO.user_id;
let beginTime = commonUserFeeVO.begin_time;
let expireTime = commonUserFeeVO.expire_time;
let type = commonUserFeeVO.type;
let makerFee = commonUserFeeVO.maker_fee;
let takerFee = commonUserFeeVO.taker_fee;
if (!id || !userId || !beginTime || !expireTime || !makerFee || !takerFee) {
throw ErrorCode.PARAM_MISS;
}
await paramCheck(beginTime, expireTime, Number(type), userId);
}
/**
* 添加和更新校验入参
* @param beginTime
......@@ -242,23 +206,24 @@ async function paramCheck(beginTime: any, expireTime: any, type: number, userId:
throw ErrorCode.COIN_NO_ASSETS;
}
}
else if (type == FEE_TYPE.FEE_TYPE_CONTRACT_ALL) {
if (!await baseUCheck(userId)) {
throw ErrorCode.U_NO_ASSETS;
}
if (!await baseCoinCheck(userId)) {
throw ErrorCode.COIN_NO_ASSETS;
}
}
else if (type == FEE_TYPE.FEE_TYPE_ALL) {
if (!await spotCheck(userId)) {
throw ErrorCode.SPOT_NO_ASSETS;
}
if (!await baseUCheck(userId)) {
throw ErrorCode.U_NO_ASSETS;
}
async function checkMaker(commonUserFeeVO: CommonUserFeeVO) {
let userChannel = commonUserFeeVO.user_channel;
if (!userChannel) {
throw ErrorCode.PARAM_MISS
}
//项目方
if (userChannel == 2) {
//TODO:校验该用户是不是市商
let statisPeriod = commonUserFeeVO.statis_period;
let amount_require_usdt = commonUserFeeVO.amount_require_usdt;
if (!statisPeriod || Number(statisPeriod) < 0 || Number(statisPeriod) > 30) {
throw ErrorCode.PARAM_MISS;
}
if (!await baseCoinCheck(userId)) {
throw ErrorCode.COIN_NO_ASSETS;
if (!amount_require_usdt) {
throw ErrorCode.PARAM_MISS;
}
}
}
}
\ No newline at end of file
......@@ -169,12 +169,12 @@ const postFunc = {
'mUser/subscribe/mail/detail': mUserSubscribeCtrl.mailDetail,//发送详情
'mUser/subscribe/mail/send/group': mUserSubscribeCtrl.maiSendGroup,//群发邮件
//运营部-现货-费率管理-普通用户手续费
//运营部-现货-VIP管理(普通用户手续费、市商手续费)
'mUser/fee/setting/list': commonUserFeeSettingCtrl.list,//普通用户手续费列表
'mUser/fee/setting/add': commonUserFeeSettingCtrl.add,//新增普通用户手续费
'mUser/fee/setting/update': commonUserFeeSettingCtrl.update,//修改普通用户手续费
'mUser/fee/setting/delete': commonUserFeeSettingCtrl.del,//删除普通用户手续费
'mUser/fee/setting/submit': commonUserFeeSettingCtrl.submit,//提交普通用户手续费
//'mUser/fee/setting/submit': commonUserFeeSettingCtrl.submit,//提交普通用户手续费
'mUser/fee/vip/level/list': commonUserFeeSettingCtrl.vipLevelList,//用户等级费率列表
//技术部-App管理-App版本管理
......
......@@ -111,12 +111,12 @@ let cmdWhiteList = {
'mUser/subscribe/mail/send': 1,
'mUser/subscribe/mail/detail': 1,
'mUser/subscribe/mail/send/group': 1,
//运营部-现货-费率管理-普通用户手续费
//运营部-现货-VIP管理(普通用户手续费、市商手续费)
'mUser/fee/setting/list': 1,
'mUser/fee/setting/add': 1,
'mUser/fee/setting/update': 1,
'mUser/fee/setting/delete': 1,
'mUser/fee/setting/submit': 1,
//'mUser/fee/setting/submit': 1,
'mUser/fee/vip/level/list': 1,
//技术部-App管理-App版本管理
'tech/app/version/list': 1,
......
import { mainUserAsset } from "@madex/ex-ts-dao";
let blockCoin = "BIX0";
export const spotCheck = async function (user_id: number) {
//TODO:后面补齐查询现货资产逻辑
let exist = {};
let exist = await mainUserAsset.prototype.findOne({
where: {
user_id: user_id
},
raw: true
})
return exist;
}
......
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