Commit fef64a78 authored by ml's avatar ml

增加 普通用户手续费相关接口 调整用户信息接口

parent ea3f8ff2
......@@ -875,7 +875,7 @@
},
"node_modules/@madex/ex-js-common": {
"version": "1.0.0",
"resolved": "git+ssh://git@bitbucket.org/biiigle/ex-js-common.git#a074015198403c5598adea7e0fd4380936a5aa2b",
"resolved": "git+ssh://git@bitbucket.org/biiigle/ex-js-common.git#8731a80a995567cd1c6e9ecdb256ea9df1e0ff31",
"license": "ISC",
"dependencies": {
"@madex/ex-js-dao": "git+ssh://git@bitbucket.org/biiigle/ex-js-dao.git#master",
......@@ -1069,9 +1069,9 @@
}
},
"node_modules/@madex/ex-ts-dao": {
"version": "0.0.20",
"resolved": "https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/@madex/ex-ts-dao/-/@madex/ex-ts-dao-0.0.20.tgz",
"integrity": "sha512-c4TCZnRNc9LfdTh436vTg4DM+dxGeJIpcUo1BjKPijkdL0Ij42BkXOU3iyajViUks7kadVd7VLK9JAeqYDSaUQ==",
"version": "0.0.21",
"resolved": "https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/@madex/ex-ts-dao/-/@madex/ex-ts-dao-0.0.21.tgz",
"integrity": "sha512-uXdHq1OyOLxilsj9/k5lavzDvt0HqKOH/oTf3HHSHup2aF/UepUIwm62RyZoDE/MdrdRFS0DZsnddAbAcARRqw==",
"license": "ISC",
"dependencies": {
"@madex/ex-js-public": "git+ssh://git@bitbucket.org/biiigle/ex-js-public.git#master",
......@@ -1617,9 +1617,9 @@
}
},
"node_modules/@types/node": {
"version": "20.16.1",
"resolved": "https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/@types/node/-/node-20.16.1.tgz",
"integrity": "sha512-zJDo7wEadFtSyNz5QITDfRcrhqDvQI1xQNQ0VoizPjM/dVAODqqIUWbJPkvsxmTI0MYRGRikcdjMPhOssnPejQ==",
"version": "20.16.2",
"resolved": "https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/@types/node/-/node-20.16.2.tgz",
"integrity": "sha512-91s/n4qUPV/wg8eE9KHYW1kouTfDk2FPGjXbBMfRWP/2vg1rCXNQL1OCabwGs0XSdukuK+MwCDXE30QpSeMUhQ==",
"license": "MIT",
"dependencies": {
"undici-types": "~6.19.2"
......@@ -2725,9 +2725,9 @@
}
},
"node_modules/aws4": {
"version": "1.13.1",
"resolved": "https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/aws4/-/aws4-1.13.1.tgz",
"integrity": "sha512-u5w79Rd7SU4JaIlA/zFqG+gOiuq25q5VLyZ8E+ijJeILuTxVzZgp2CaGw/UTw6pXYN9XMO9yiqj/nEHmhTG5CA==",
"version": "1.13.2",
"resolved": "https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/aws4/-/aws4-1.13.2.tgz",
"integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==",
"license": "MIT"
},
"node_modules/axios": {
......
......@@ -37,4 +37,18 @@ export const ErrorCode = {
DATA_STATUS_CHANGED: '30034',//非法操作,数据状态已经变更
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',//币币费率需要设置
CONTRACT_FEE_NEED_SET:'30041',//合约费率需要设置
SON_NOT_ADD_FEE:'30042',//子账户不能添加为市商
LEVEL_NOT_EXIST:'30043',//指定等级不存在
ONLY_ONE_FEE:'30044',//只能有一条未提交的费率设置
ONLY_UN_SUBMIT_UPDATE:'30045',//只有未提交的记录可以修改
UID_TYPE_NOT_UPDATE:'30046',//用户ID和类型不能修改
DEL_UN_SUBMIT_ACTIVE:'30047',//只能删除未提交或未生效的记录
FEE_USED_NOT_DEL:'30048',//费率已生效,不能删除
ONLY_UN_SUBMIT_CAN_SUBMIT:'30049',//只有未提交的记录才能提交
}
export const FEE_RATE_LOG_STATUS = {
/**
* 状态: 未生效。
*/
CHECK_STATUS_UNCHECK: 0,
/**
* 状态: 生效中。
*/
CHECK_STATUS_ACTIVE: 1,
/**
* 状态: 已删除(未生效时用户主动删除)。
*/
CHECK_STATUS_DELETED: 2,
/**
* 状态: 已经生效过,已失效(生效后被新的费率覆盖而失效)。
*/
CHECK_STATUS_ACTIVE_OVER: 3,
}
/**
* 币币、合约手续费feeModel字段默认值。
*/
export const FEE_MODEL_SPOT_DEFAULT = "fixedingain"
\ No newline at end of file
export const FEE_TYPE = {
/**
* 费率类型: 全部。
*/
FEE_TYPE_ALL: 0,
/**
* 费率类型: 币币。
*/
FEE_TYPE_SPOT: 1,
/**
* 费率类型: U本位合约。
*/
FEE_TYPE_CONTRACT: 2,
/**
* 费率类型: 币本位合约。
*/
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_STATUS = {
/**
* 费率设置纪录状态: 未提交。
*/
STATUS_FEE_SETTING_NEW: 0,
/**
* 费率设置纪录状态: 已提交。
*/
STATUS_FEE_SETTING_SUBMIT: 1,
/**
* 费率设置纪录状态: 已生效。
*/
STATUS_FEE_SETTING_EFFECTED: 2,
/**
* 费率设置纪录状态: 已过期。
*/
STATUS_FEE_SETTING_EXPIRE: 3,
/**
* 费率设置纪录状态: 已删除。
*/
STATUS_FEE_SETTING_DELETED: 4,
}
/**
* 普通用户手续费提交备注。
*/
export const COMMENT_USER_FEE_SUBMIT = "提交普通用户手续费";
\ No newline at end of file
export const SYMBOL_ALL = "all";
\ No newline at end of file
import * as commonUserFeeSettingService from "../service/commonUserFeeSetting.service";
import { CommonUserFeeVO, CommonUserFeePageVO } from "../service/commonUserFeeSetting.service";
import { vipLevelFeeSetting } from "@madex/ex-ts-dao";
let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert, datetimeUtils } = require('@madex/ex-js-public');
import { ErrorCode } from "../../../constant/errorCode";
import { IS_ACTIVE, IS_ACTIVE_ARR, LINK_TYPE_ARR } from "../../../constant/usefulLinkConst";
import { getCurrentUserId } from "../../../utils/aclUserUtils";
import { FEE_TYPE, FEE_TYPE_LIST } from "../../../constant/marketMakerConst";
import { baseCoinCheck, baseUCheck, spotCheck } from "../../../utils/feeRateCheckValidUtils";
import { getMUserInfoByUid } from "../../../utils/mUserUtils";
import { getFatherUserId } from "../service/mUserInfoSon.service";
let isIp = require('is-ip');
/**
* 手续费列表
* @param req
* @param infoVO
*/
export const list = async (req: any, pageVO: CommonUserFeePageVO) => {
let func_name = "commonUserFeeSetting.control.list";
try {
pageVO.page = Optional.opt(pageVO, 'page', 1);
pageVO.size = Optional.opt(pageVO, 'size', 20);
let res = await commonUserFeeSettingService.list(pageVO);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 添加用户费率
* @param req
* @param authConfigVO
*/
export const add = async (req: any, commonUserFeeVO: CommonUserFeeVO) => {
let func_name = "commonUserFeeSetting.control.add";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
await addParamValid(commonUserFeeVO);
let res = await commonUserFeeSettingService.add(commonUserFeeVO, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 修改用户费率
* @param req
* @param authConfigVO
*/
export const update = async (req: any, commonUserFeeVO: CommonUserFeeVO) => {
let func_name = "commonUserFeeSetting.control.update";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
await updateParamValid(commonUserFeeVO);
let res = await commonUserFeeSettingService.update(commonUserFeeVO, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 删除用户费率
* @param req
* @param authConfigVO
*/
export const del = async (req: any, commonUserFeeVO: CommonUserFeeVO) => {
let func_name = "commonUserFeeSetting.control.del";
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.del(commonUserFeeVO.id, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 提交用户费率
* @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);
}
};
async function addParamValid(commonUserFeeVO: CommonUserFeeVO) {
let userId = commonUserFeeVO.user_id;
let beginTime = commonUserFeeVO.begin_time;
let expireTime = commonUserFeeVO.expire_time;
let type = commonUserFeeVO.type;
let levelId = commonUserFeeVO.level_id;
if (!userId || !beginTime || !expireTime) {
throw ErrorCode.PARAM_MISS;
}
await paramCheck(beginTime, expireTime, Number(type), userId);
if (levelId) {
let vipLevelSetting = await vipLevelFeeSetting.prototype.findOne({
where: {
id: levelId
},
raw: true
});
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;
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) {
throw ErrorCode.USER_NOT_EXIST;
}
let fuid = await getFatherUserId(userId);
if (fuid) {
throw ErrorCode.SON_NOT_ADD_FEE;
}
}
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
* @param expireTime
* @param type
* @param userId
*/
async function paramCheck(beginTime: any, expireTime: any, type: number, userId: number) {
//结束时间最少需要是一小时后;开始时间和结束时间最少需要间隔一小时
if (!datetimeUtils.between(expireTime, new Date()) > datetimeUtils.HOUR
|| !datetimeUtils.between(expireTime, beginTime) > datetimeUtils.HOUR) {
throw ErrorCode.PARAM_MISS;
}
if (isNaN(Number(type)) || !FEE_TYPE_LIST.includes(Number(type))) {
throw ErrorCode.PARAM_MISS;
}
if (type == FEE_TYPE.FEE_TYPE_SPOT) {
if (!await spotCheck(userId)) {
throw ErrorCode.SPOT_NO_ASSETS;
}
}
else if (type == FEE_TYPE.FEE_TYPE_CONTRACT) {
if (!await baseUCheck(userId)) {
throw ErrorCode.U_NO_ASSETS;
}
}
else if (type == FEE_TYPE.FEE_TYPE_BASE_COIN_CONTRACT) {
if (!await baseCoinCheck(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;
}
if (!await baseCoinCheck(userId)) {
throw ErrorCode.COIN_NO_ASSETS;
}
}
}
This diff is collapsed.
import { ormDB, feeRateBaseCoinContractLog } from "@madex/ex-ts-dao";
import { FEE_RATE_LOG_STATUS } from "../../../constant/feeRateLogConst";
export const getByIdList = async function (ids: any) {
let list = await feeRateBaseCoinContractLog.prototype.findAll({
where: {
id: { [ormDB.Op.in]: ids }
},
raw: true
});
return list;
}
export const uncheck2Deleted = async function (ids: any, tx: any) {
await feeRateBaseCoinContractLog.prototype.update({
is_check: FEE_RATE_LOG_STATUS.CHECK_STATUS_DELETED
}, {
where: {
id: { [ormDB.Op.in]: ids },
is_check: FEE_RATE_LOG_STATUS.CHECK_STATUS_UNCHECK
},
transaction: tx
});
}
\ No newline at end of file
import { ormDB, feeRateContractLog } from "@madex/ex-ts-dao";
import { FEE_RATE_LOG_STATUS } from "../../../constant/feeRateLogConst";
export const getByIdList = async function (ids: any) {
let list = await feeRateContractLog.prototype.findAll({
where: {
id: { [ormDB.Op.in]: ids }
},
raw: true
});
return list;
}
/**
* 需要注意在上层处理事务
* @param ids
* @param tx
*/
export const uncheck2Deleted = async function (ids: any, tx: any) {
await feeRateContractLog.prototype.update({
is_check: FEE_RATE_LOG_STATUS.CHECK_STATUS_DELETED
}, {
where: {
id: { [ormDB.Op.in]: ids },
is_check: FEE_RATE_LOG_STATUS.CHECK_STATUS_UNCHECK
},
transaction: tx
});
}
\ No newline at end of file
import { ormDB, feeRateSpotLog } from "@madex/ex-ts-dao";
import { FEE_RATE_LOG_STATUS } from "../../../constant/feeRateLogConst";
export const getByIdList = async function (ids: any) {
let list = await feeRateSpotLog.prototype.findAll({
where: {
id: { [ormDB.Op.in]: ids }
},
raw: true
});
return list;
}
export const uncheck2Deleted = async function (ids: any, tx: any) {
await feeRateSpotLog.prototype.update({
is_check: FEE_RATE_LOG_STATUS.CHECK_STATUS_DELETED
}, {
where: {
id: { [ormDB.Op.in]: ids },
is_check: FEE_RATE_LOG_STATUS.CHECK_STATUS_UNCHECK
},
transaction: tx
});
}
\ No newline at end of file
......@@ -24,11 +24,12 @@ export const TYPE = {
KYC: 9
}
export const recordMUserOperateLog = async function (m_user_id: number, operate_user_id: number, operate_type: number,
comment: string, before_v: string, after_v: string) {
comment: string, before_v: string, after_v: string) {
let aclUser = await aclUserInfo.prototype.findOne({
where: {
user_id: operate_user_id
}
},
raw: true
});
let operate_user_name = aclUser.account ? aclUser.account : operate_user_id;
......
......@@ -83,7 +83,8 @@ export async function mailSend(userMailLogVO: UserMailLogVO, currentUserId: any,
}
let toAddrRes = await userSub.prototype.findAll({
where: where
where: where,
raw: true
});
if (!toAddrRes.length) {
throw ErrorCode.DATA_NOT_EXIST
......
......@@ -101,7 +101,8 @@ export async function kycList(queryVO: QueryVO, isAdmin: boolean) {
attributes: ['user_id', 'email'],
where: {
user_id: { [ormDB.Op.in]: uids }
}
},
raw: true
});
for (let dbUserInfo of dbUserInfos) {
userMap[dbUserInfo.user_id] = dbUserInfo.email;
......@@ -136,7 +137,8 @@ export async function oneDetail(id: number) {
attributes: ['user_id', 'email'],
where: {
user_id: dbOne.user_id
}
},
raw: true
});
dbOne.email = dbUserInfo ? dbUserInfo.email : "";
......
......@@ -11,6 +11,7 @@ import { getOneAclUserByAccount, getOneAclUserByUid } from "../../../utils/aclUs
import { RedisVal } from "../../../constant/redis-val";
import Config from "../../../../config";
import * as userOptLogService from "./userOptLog.service";
import { findByUserId } from "../service/userAuthConfig.service";
const Otplib = require('otplib');
......@@ -30,7 +31,8 @@ export const getInfo = async (currentUserId: number | any, sessionId: string) =>
ApiAssert.isFalse(ErrorCode.ACCOUNT_STOP, dbUserInfo.user_status === AclUserInfoConst.USER_STATUS.DEL);
let { roleSet, authSet } = await aclRoleAuthService.getUserAcl(dbUserInfo.user_id);
//安全项配置
let authConfigDbInfo = await findByUserId(currentUserId);
let data = {
remark: dbUserInfo.remark,
......@@ -40,6 +42,11 @@ export const getInfo = async (currentUserId: number | any, sessionId: string) =>
sessionId: sessionId,
roleSet: roleSet,
authSet: authSet,
force: authConfigDbInfo ? authConfigDbInfo.force : 0,
deadline: authConfigDbInfo ? authConfigDbInfo.deadline : null,
hasTotp: authConfigDbInfo && authConfigDbInfo.totp_encrypt ? 1 : 0,
isLocked: authConfigDbInfo ? authConfigDbInfo.is_locked : 0,
lockedTime: authConfigDbInfo ? authConfigDbInfo.locked_time : null,
}
return data
......
......@@ -25,6 +25,7 @@ import * as mUserManageCtrl from "../../mvc/control/mUserManage.control";
import * as mUserRealNameCtrl from "../../mvc/control/mUserRealName.control";
import * as usefulLinkCtrl from "../../mvc/control/usefulLink.control";
import * as mUserSubscribeCtrl from "../../mvc/control/mUserSubscribe.control";
import * as commonUserFeeSettingCtrl from "../../mvc/control/commonUserFeeSetting.control";
const getFunc = {
'user/info': userController.getUserInfo,
};
......@@ -123,8 +124,12 @@ const postFunc = {
'mUser/subscribe/mail/detail': mUserSubscribeCtrl.mailDetail,//发送详情
'mUser/subscribe/mail/send/group': mUserSubscribeCtrl.maiSendGroup,//群发邮件
//普通用户手续费
'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,//提交普通用户手续费
};
......
......@@ -77,6 +77,11 @@ let cmdWhiteList = {
'mUser/subscribe/mail/send': 1,
'mUser/subscribe/mail/detail': 1,
'mUser/subscribe/mail/send/group': 1,
'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,
};
......
let blockCoin = "BIX0";
export const spotCheck = async function (user_id: number) {
//TODO:后面补齐查询现货资产逻辑
let exist = {};
return exist;
}
export const baseCoinCheck = async function (user_id: number) {
//TODO:后面补齐查询币本位资产逻辑
let exist = {};
return exist;
}
export const baseUCheck = async function (user_id: number) {
//TODO:后面补齐查询U本位资产逻辑
let exist = {};
return exist;
}
\ No newline at end of file
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