Commit b85ea206 authored by ml's avatar ml

实名列表逻辑调整

parent 3d6790b2
...@@ -41,6 +41,8 @@ export interface QueryVO { ...@@ -41,6 +41,8 @@ export interface QueryVO {
from_time?: Date | any from_time?: Date | any
to_time?: Date | any to_time?: Date | any
condition?: string
} }
export async function getRealNameByUserId(user_id: number | any) { export async function getRealNameByUserId(user_id: number | any) {
...@@ -70,28 +72,49 @@ export async function getRealNameMapByUserIds(userIds: number[]) { ...@@ -70,28 +72,49 @@ export async function getRealNameMapByUserIds(userIds: number[]) {
export async function kycList(queryVO: QueryVO) { export async function kycList(queryVO: QueryVO) {
let where = {} let condition = queryVO.condition;
if (queryVO.user_id) { let uids: any = [];
//uid 是否在受限范围内 let userMap = {};
if (isLimitUserId(queryVO.user_id)) { if (condition) {
throw ErrorCode.UID_LIMIT let orCondition = {
email: String(condition),
real_name: String(condition),
phone: String(condition),
identity: String(condition),
};
if (!isNaN(Number(condition))) {
orCondition['user_id'] = Number(condition)
} }
where["user_id"] = queryVO.user_id;
let dbUserList = await userInfo.prototype.findAll({
attributes: ['user_id', 'email', 'phone'],
where: { [ormDB.Op.or]: orCondition },
raw: true
});
if (!dbUserList.length) {
return {
count: 0,
rows: []
} }
else {
if (UID_MIN && UID_LIMIT.length) {
where[ormDB.Op.and] = [{
user_id: { [ormDB.Op.gte]: UID_MIN }
},
{
user_id: { [ormDB.Op.notIn]: UID_LIMIT },
}]
} }
else { for (let one of dbUserList) {
where["user_id"] = { [ormDB.Op.gte]: UID_MIN } uids.push(one.user_id)
userMap[one.user_id] = one.email;
} }
} }
if (!isNaN(Number(queryVO.status))) {
let where = {}
if (uids.length) {
where['user_id'] = { [ormDB.Op.in]: uids }
}
if (condition && !isNaN(Number(condition))) {
where[ormDB.Op.or] = {
user_id: Number(condition),
identity: condition
}
}
if (queryVO.status || queryVO.status === 0) {
where["status"] = queryVO.status where["status"] = queryVO.status
} }
if (queryVO.source) { if (queryVO.source) {
...@@ -129,8 +152,8 @@ export async function kycList(queryVO: QueryVO) { ...@@ -129,8 +152,8 @@ export async function kycList(queryVO: QueryVO) {
}); });
if (resList.rows.length) { if (resList.rows.length) {
let uids = resList.rows.map(item => item.user_id); if (!uids.length) {
let userMap = {}; uids = resList.rows.map(item => item.user_id);
let dbUserInfos = await userInfo.prototype.findAll({ let dbUserInfos = await userInfo.prototype.findAll({
attributes: ['user_id', 'email'], attributes: ['user_id', 'email'],
where: { where: {
...@@ -141,6 +164,7 @@ export async function kycList(queryVO: QueryVO) { ...@@ -141,6 +164,7 @@ export async function kycList(queryVO: QueryVO) {
for (let dbUserInfo of dbUserInfos) { for (let dbUserInfo of dbUserInfos) {
userMap[dbUserInfo.user_id] = dbUserInfo.email; userMap[dbUserInfo.user_id] = dbUserInfo.email;
} }
}
for (let item of resList.rows) { for (let item of resList.rows) {
item.email = userMap[item.user_id] ? userMap[item.user_id] : "" item.email = userMap[item.user_id] ? userMap[item.user_id] : ""
} }
......
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