Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
ts-api-demo
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wmvm
ts-api-demo
Commits
1e2908b8
Commit
1e2908b8
authored
Sep 06, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
d321f554
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
346 additions
and
198 deletions
+346
-198
package-lock.json
package-lock.json
+9
-9
mUserManage.control.ts
src/functional/mvc/control/mUserManage.control.ts
+8
-2
mUserRealName.control.ts
src/functional/mvc/control/mUserRealName.control.ts
+1
-4
aclDepartment.service.ts
src/functional/mvc/service/aclDepartment.service.ts
+67
-7
aclUser.service.ts
src/functional/mvc/service/aclUser.service.ts
+0
-37
coinAddress.service.ts
src/functional/mvc/service/coinAddress.service.ts
+21
-0
coinWithdraw.service.ts
src/functional/mvc/service/coinWithdraw.service.ts
+21
-0
mUserManage.service.ts
src/functional/mvc/service/mUserManage.service.ts
+153
-78
mUserRealName.service.ts
src/functional/mvc/service/mUserRealName.service.ts
+47
-14
userAuthConfig.service.ts
src/functional/mvc/service/userAuthConfig.service.ts
+0
-2
aclUserUtils.ts
src/utils/aclUserUtils.ts
+0
-44
mUserUtils.ts
src/utils/mUserUtils.ts
+19
-1
No files found.
package-lock.json
View file @
1e2908b8
...
@@ -1069,9 +1069,9 @@
...
@@ -1069,9 +1069,9 @@
}
}
},
},
"node_modules/@madex/ex-ts-dao"
:
{
"node_modules/@madex/ex-ts-dao"
:
{
"version"
:
"0.0.2
7
"
,
"version"
:
"0.0.2
8
"
,
"resolved"
:
"https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/@madex/ex-ts-dao/-/@madex/ex-ts-dao-0.0.2
7
.tgz"
,
"resolved"
:
"https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/@madex/ex-ts-dao/-/@madex/ex-ts-dao-0.0.2
8
.tgz"
,
"integrity"
:
"sha512-
+wt6GSr/Gs+KBjNL1U7xsSUaYGhWNiPhIAjXvlb/Klmx7lzf/95MDbKmD2+bC1ydbTknsiG1XyNE/0Iu/tDS4Q
=="
,
"integrity"
:
"sha512-
DWAieApyLqFuKYxpMjHhQbodx9qKqbBOaaSEuhhfD/lZrjFDQ81M5tpl7nbFApIantQ361d+E7TpWJC/oUdAcg
=="
,
"license"
:
"ISC"
,
"license"
:
"ISC"
,
"dependencies"
:
{
"dependencies"
:
{
"@madex/ex-js-public"
:
"git+ssh://git@bitbucket.org/biiigle/ex-js-public.git#master"
,
"@madex/ex-js-public"
:
"git+ssh://git@bitbucket.org/biiigle/ex-js-public.git#master"
,
...
@@ -1617,9 +1617,9 @@
...
@@ -1617,9 +1617,9 @@
}
}
},
},
"node_modules/@types/node"
:
{
"node_modules/@types/node"
:
{
"version"
:
"20.16.
4
"
,
"version"
:
"20.16.
5
"
,
"resolved"
:
"https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/@types/node/-/node-20.16.
4
.tgz"
,
"resolved"
:
"https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/@types/node/-/node-20.16.
5
.tgz"
,
"integrity"
:
"sha512-
ioyQ1zK9aGEomJ45zz8S8IdzElyxhvP1RVWnPrXDf6wFaUb+kk1tEcVVJkF7RPGM0VWI7cp5U57oCPIn5iN1qg
=="
,
"integrity"
:
"sha512-
VwYCweNo3ERajwy0IUlqqcyZ8/A7Zwa9ZP3MnENWcB11AejO+tLy3pu850goUW2FC/IJMdZUfKpX/yxL1gymCA
=="
,
"license"
:
"MIT"
,
"license"
:
"MIT"
,
"dependencies"
:
{
"dependencies"
:
{
"undici-types"
:
"~6.19.2"
"undici-types"
:
"~6.19.2"
...
@@ -4456,9 +4456,9 @@
...
@@ -4456,9 +4456,9 @@
}
}
},
},
"node_modules/electron-to-chromium"
:
{
"node_modules/electron-to-chromium"
:
{
"version"
:
"1.5.1
3
"
,
"version"
:
"1.5.1
4
"
,
"resolved"
:
"https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/electron-to-chromium/-/electron-to-chromium-1.5.1
3
.tgz"
,
"resolved"
:
"https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/electron-to-chromium/-/electron-to-chromium-1.5.1
4
.tgz"
,
"integrity"
:
"sha512-
lbBcvtIJ4J6sS4tb5TLp1b4LyfCdMkwStzXPyAgVgTRAsep4bvrAGaBOP7ZJtQMNJpSQ9SqG4brWOroNaQtm7
Q=="
,
"integrity"
:
"sha512-
bEfPECb3fJ15eaDnu9LEJ2vPGD6W1vt7vZleSVyFhYuMIKm3vz/g9lt7IvEzgdwj58RjbPKUF2rXTCN/UW47t
Q=="
,
"dev"
:
true
,
"dev"
:
true
,
"license"
:
"ISC"
"license"
:
"ISC"
},
},
...
...
src/functional/mvc/control/mUserManage.control.ts
View file @
1e2908b8
...
@@ -11,7 +11,7 @@ import { isLimitUserId } from "../../../utils/mUserCommonUtils";
...
@@ -11,7 +11,7 @@ import { isLimitUserId } from "../../../utils/mUserCommonUtils";
let
isIp
=
require
(
'is-ip'
);
let
isIp
=
require
(
'is-ip'
);
/**
/**
* Madex 用户列表
* Madex 用户列表
/kyc用户列表
* @param req
* @param req
* @param infoVO
* @param infoVO
*/
*/
...
@@ -20,7 +20,13 @@ export const userList = async (req: any, queryVO: QueryVO) => {
...
@@ -20,7 +20,13 @@ export const userList = async (req: any, queryVO: QueryVO) => {
try
{
try
{
queryVO
.
page
=
Optional
.
opt
(
queryVO
,
'page'
,
1
);
queryVO
.
page
=
Optional
.
opt
(
queryVO
,
'page'
,
1
);
queryVO
.
size
=
Optional
.
opt
(
queryVO
,
'size'
,
20
);
queryVO
.
size
=
Optional
.
opt
(
queryVO
,
'size'
,
20
);
let
res
=
await
mUserManageService
.
userList
(
queryVO
);
let
condition
=
String
(
queryVO
.
condition
);
//查询类型 1:uid/姓名/邮箱/证件号 2:充币/提币地址
let
condition_type
=
1
;
if
(
condition
&&
condition
.
length
>=
32
)
{
condition_type
=
2
;
}
let
res
=
await
mUserManageService
.
userList
(
Number
(
queryVO
.
page
),
Number
(
queryVO
.
size
),
condition
,
condition_type
);
return
Res3Utils
.
result
(
res
);
return
Res3Utils
.
result
(
res
);
}
}
catch
(
e
)
{
catch
(
e
)
{
...
...
src/functional/mvc/control/mUserRealName.control.ts
View file @
1e2908b8
...
@@ -20,11 +20,8 @@ export const kycList = async (req: any, queryVO: QueryVO) => {
...
@@ -20,11 +20,8 @@ export const kycList = async (req: any, queryVO: QueryVO) => {
try
{
try
{
queryVO
.
page
=
Optional
.
opt
(
queryVO
,
'page'
,
1
);
queryVO
.
page
=
Optional
.
opt
(
queryVO
,
'page'
,
1
);
queryVO
.
size
=
Optional
.
opt
(
queryVO
,
'size'
,
20
);
queryVO
.
size
=
Optional
.
opt
(
queryVO
,
'size'
,
20
);
let
currentUserId
=
await
getCurrentUserId
(
req
.
cookies
.
session_id
);
let
dbInfo
=
await
getOneAclUserByUid
(
currentUserId
);
let
isAdmin
=
dbInfo
.
user_type
==
AclUserInfoConst
.
USER_TYPE
.
ADMIN
let
res
=
await
mUserRealNameService
.
kycList
(
queryVO
,
isAdmin
);
let
res
=
await
mUserRealNameService
.
kycList
(
queryVO
);
return
Res3Utils
.
result
(
res
);
return
Res3Utils
.
result
(
res
);
}
}
catch
(
e
)
{
catch
(
e
)
{
...
...
src/functional/mvc/service/aclDepartment.service.ts
View file @
1e2908b8
...
@@ -224,7 +224,34 @@ export const getUserList = async function (aclDepartmentPageVO: AclDepartmentPag
...
@@ -224,7 +224,34 @@ export const getUserList = async function (aclDepartmentPageVO: AclDepartmentPag
let
account
=
aclDepartmentPageVO
.
account
;
let
account
=
aclDepartmentPageVO
.
account
;
let
dIds
=
aclDepartmentPageVO
.
dIds
;
let
dIds
=
aclDepartmentPageVO
.
dIds
;
let
pageData
:
any
;
let
pageData
:
any
;
if
(
account
)
{
//部门 和 account 都作为查询条件时 先查用户
if
(
dIds
&&
account
)
{
let
userList
=
await
getAclUserData
(
account
);
//没有直接返回
if
(
!
userList
.
length
)
{
pageData
=
{
count
:
0
,
rows
:
[]
}
return
pageData
;
}
let
uids
:
number
[]
=
[];
let
userMap
=
{}
for
(
let
item
of
userList
)
{
userMap
[
item
.
user_id
]
=
item
;
uids
.
push
(
item
.
user_id
);
}
//有则分页查询部门用户
pageData
=
await
getDpUserPageData
(
dIds
,
page
,
size
,
[]);
for
(
let
oneItem
of
pageData
.
rows
)
{
oneItem
.
account
=
userMap
[
oneItem
.
user_id
]
?
userMap
[
oneItem
.
user_id
].
account
:
""
;
oneItem
.
phone
=
userMap
[
oneItem
.
user_id
]
?
userMap
[
oneItem
.
user_id
].
phone
:
""
;
oneItem
.
email
=
userMap
[
oneItem
.
user_id
]
?
userMap
[
oneItem
.
user_id
].
email
:
""
;
oneItem
.
user_status
=
userMap
[
oneItem
.
user_id
]
?
userMap
[
oneItem
.
user_id
].
user_status
:
""
;
oneItem
.
remark
=
userMap
[
oneItem
.
user_id
]
?
userMap
[
oneItem
.
user_id
].
remark
:
""
;
}
}
else
if
(
account
)
{
pageData
=
await
getAclUserPageData
(
account
,
page
,
size
);
pageData
=
await
getAclUserPageData
(
account
,
page
,
size
);
if
(
pageData
.
rows
&&
pageData
.
rows
.
length
)
{
if
(
pageData
.
rows
&&
pageData
.
rows
.
length
)
{
let
uids
=
pageData
.
rows
.
map
(
item
=>
item
.
user_id
);
let
uids
=
pageData
.
rows
.
map
(
item
=>
item
.
user_id
);
...
@@ -246,17 +273,17 @@ export const getUserList = async function (aclDepartmentPageVO: AclDepartmentPag
...
@@ -246,17 +273,17 @@ export const getUserList = async function (aclDepartmentPageVO: AclDepartmentPag
}
}
}
}
else
{
else
{
pageData
=
await
getDpUserPageData
(
dIds
,
page
,
size
);
pageData
=
await
getDpUserPageData
(
dIds
,
page
,
size
,
[]
);
if
(
pageData
.
rows
&&
pageData
.
rows
.
length
)
{
if
(
pageData
.
rows
&&
pageData
.
rows
.
length
)
{
let
uids
=
pageData
.
rows
.
map
(
item
=>
item
.
user_id
);
let
uids
=
pageData
.
rows
.
map
(
item
=>
item
.
user_id
);
let
u
dp
List
=
await
aclUserInfo
.
prototype
.
findAll
({
let
u
serInfo
List
=
await
aclUserInfo
.
prototype
.
findAll
({
where
:
{
where
:
{
user_id
:
{
[
madAdminOrmDB
.
Op
.
in
]:
uids
}
user_id
:
{
[
madAdminOrmDB
.
Op
.
in
]:
uids
}
},
},
raw
:
true
raw
:
true
});
});
let
userMap
=
{}
let
userMap
=
{}
for
(
let
item
of
u
dp
List
)
{
for
(
let
item
of
u
serInfo
List
)
{
userMap
[
item
.
user_id
]
=
item
;
userMap
[
item
.
user_id
]
=
item
;
}
}
for
(
let
oneItem
of
pageData
.
rows
)
{
for
(
let
oneItem
of
pageData
.
rows
)
{
...
@@ -264,6 +291,7 @@ export const getUserList = async function (aclDepartmentPageVO: AclDepartmentPag
...
@@ -264,6 +291,7 @@ export const getUserList = async function (aclDepartmentPageVO: AclDepartmentPag
oneItem
.
phone
=
userMap
[
oneItem
.
user_id
]
?
userMap
[
oneItem
.
user_id
].
phone
:
""
;
oneItem
.
phone
=
userMap
[
oneItem
.
user_id
]
?
userMap
[
oneItem
.
user_id
].
phone
:
""
;
oneItem
.
email
=
userMap
[
oneItem
.
user_id
]
?
userMap
[
oneItem
.
user_id
].
email
:
""
;
oneItem
.
email
=
userMap
[
oneItem
.
user_id
]
?
userMap
[
oneItem
.
user_id
].
email
:
""
;
oneItem
.
user_status
=
userMap
[
oneItem
.
user_id
]
?
userMap
[
oneItem
.
user_id
].
user_status
:
""
;
oneItem
.
user_status
=
userMap
[
oneItem
.
user_id
]
?
userMap
[
oneItem
.
user_id
].
user_status
:
""
;
oneItem
.
remark
=
userMap
[
oneItem
.
user_id
]
?
userMap
[
oneItem
.
user_id
].
remark
:
""
;
}
}
}
}
...
@@ -271,11 +299,14 @@ export const getUserList = async function (aclDepartmentPageVO: AclDepartmentPag
...
@@ -271,11 +299,14 @@ export const getUserList = async function (aclDepartmentPageVO: AclDepartmentPag
return
pageData
;
return
pageData
;
}
}
async
function
getDpUserPageData
(
dIds
:
string
,
page
:
number
,
size
:
number
)
{
async
function
getDpUserPageData
(
dIds
:
string
,
page
:
number
,
size
:
number
,
uids
:
number
[]
)
{
let
where
=
{};
let
where
=
{};
if
(
dIds
)
{
if
(
dIds
)
{
where
[
'department_id'
]
=
dIds
;
where
[
'department_id'
]
=
dIds
;
}
}
if
(
uids
.
length
)
{
where
[
'user_id'
]
=
{
[
madAdminOrmDB
.
Op
.
in
]:
uids
}
}
let
resList
=
await
aclUserDepartmentPosition
.
prototype
.
findAndCount
({
let
resList
=
await
aclUserDepartmentPosition
.
prototype
.
findAndCount
({
where
:
where
,
where
:
where
,
limit
:
size
,
limit
:
size
,
...
@@ -306,7 +337,7 @@ async function getAclUserPageData(account: string, page: number, size: number) {
...
@@ -306,7 +337,7 @@ async function getAclUserPageData(account: string, page: number, size: number) {
}
}
}
}
let
resList
=
await
aclUserInfo
.
prototype
.
findAndCount
({
let
resList
=
await
aclUserInfo
.
prototype
.
findAndCount
({
attributes
:
[
'user_id'
,
'account'
,
'phone'
,
'email'
,
'user_status'
],
attributes
:
[
'user_id'
,
'account'
,
'phone'
,
'email'
,
'user_status'
,
'remark'
],
where
:
where
,
where
:
where
,
limit
:
size
,
limit
:
size
,
offset
:
(
page
-
1
)
*
size
,
offset
:
(
page
-
1
)
*
size
,
...
@@ -335,7 +366,7 @@ async function getAllUserDepartmentPositionMap() {
...
@@ -335,7 +366,7 @@ async function getAllUserDepartmentPositionMap() {
});
});
let
userMap
=
{};
let
userMap
=
{};
for
(
let
item
of
userList
)
{
for
(
let
item
of
userList
)
{
userMap
[
item
.
user_id
]
=
item
.
account
;
userMap
[
item
.
user_id
]
=
item
.
remark
;
}
}
for
(
let
item
of
udpList
)
{
for
(
let
item
of
udpList
)
{
...
@@ -356,6 +387,35 @@ async function getAllUserDepartmentPositionMap() {
...
@@ -356,6 +387,35 @@ async function getAllUserDepartmentPositionMap() {
}
}
async
function
getAclUserData
(
account
:
string
)
{
let
where
:
{};
if
(
!
isNaN
(
Number
(
account
)))
{
where
=
{
[
madAdminOrmDB
.
Op
.
or
]:
{
user_id
:
Number
(
account
),
account
:
{
[
madAdminOrmDB
.
Op
.
like
]:
`
${
account
}
%`
},
email
:
{
[
madAdminOrmDB
.
Op
.
like
]:
`
${
account
}
%`
},
}
}
}
else
{
where
=
{
[
madAdminOrmDB
.
Op
.
or
]:
{
account
:
{
[
madAdminOrmDB
.
Op
.
like
]:
`
${
account
}
%`
},
email
:
{
[
madAdminOrmDB
.
Op
.
like
]:
`
${
account
}
%`
},
}
}
}
let
resList
=
await
aclUserInfo
.
prototype
.
findAll
({
attributes
:
[
'user_id'
,
'account'
,
'phone'
,
'email'
,
'user_status'
,
'remark'
],
where
:
where
,
order
:
[[
"user_id"
,
"asc"
]],
raw
:
true
});
return
resList
;
}
...
...
src/functional/mvc/service/aclUser.service.ts
View file @
1e2908b8
...
@@ -320,43 +320,6 @@ export async function updateUserStatus(userId: any, userStatus: number) {
...
@@ -320,43 +320,6 @@ export async function updateUserStatus(userId: any, userStatus: number) {
}
}
}
}
export
async
function
findAllForPage
(
page
:
number
,
size
:
number
,
userId
?:
number
,
typeArr
?:
any
,
statusArr
?:
any
,
fromTime
?:
any
,
toTime
?:
any
,
remark
?:
any
)
{
try
{
let
where
=
Object
.
create
(
null
);
if
(
userId
)
{
where
.
user_id
=
userId
}
if
(
typeArr
)
{
where
.
user_type
=
{
[
madAdminOrmDB
.
Op
.
in
]:
typeArr
};
}
if
(
statusArr
)
{
where
.
user_status
=
{
[
madAdminOrmDB
.
Op
.
in
]:
statusArr
};
}
if
(
fromTime
&&
toTime
)
{
where
.
createdAt
=
{
[
madAdminOrmDB
.
Op
.
between
]:
[
fromTime
,
toTime
]
};
}
if
(
remark
)
{
where
.
remark
=
{
[
madAdminOrmDB
.
Op
.
like
]:
`
${
remark
}
%`
};
}
let
resList
=
await
aclUserInfo
.
prototype
.
findAndCount
({
where
:
where
,
limit
:
size
,
offset
:
(
page
-
1
)
*
size
,
order
:
[[
"user_id"
,
"asc"
]],
raw
:
true
});
return
resList
;
}
catch
(
e
)
{
logger
.
error
(
'aclUserService.findAllForPage.error:'
+
e
)
throw
e
;
}
}
async
function
dealReturnData
(
rows
:
any
)
{
async
function
dealReturnData
(
rows
:
any
)
{
if
(
!
rows
.
length
)
{
if
(
!
rows
.
length
)
{
return
return
...
...
src/functional/mvc/service/coinAddress.service.ts
0 → 100644
View file @
1e2908b8
import
{
ormDB
,
coinAddress
}
from
"@madex/ex-ts-dao"
;
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
export
const
getCoinAddressMapByUids
=
async
function
(
uids
:
number
[]){
if
(
!
uids
.
length
){
throw
ErrorCode
.
PARAM_MISS
;
}
let
dbInfoList
=
await
coinAddress
.
prototype
.
findAll
({
where
:
{
user_id
:
{
[
ormDB
.
Op
.
in
]:
uids
}
},
raw
:
true
});
let
resMap
=
{};
for
(
let
item
of
dbInfoList
)
{
resMap
[
item
.
user_id
]
=
item
}
return
resMap
;
}
src/functional/mvc/service/coinWithdraw.service.ts
0 → 100644
View file @
1e2908b8
import
{
ormDB
,
coinWithdraw
,
}
from
"@madex/ex-ts-dao"
;
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
export
const
getCoinWithdrawMapByUids
=
async
function
(
uids
:
number
[])
{
if
(
!
uids
.
length
)
{
throw
ErrorCode
.
PARAM_MISS
;
}
let
dbInfoList
=
await
coinWithdraw
.
prototype
.
findAll
({
where
:
{
user_id
:
{
[
ormDB
.
Op
.
in
]:
uids
}
},
raw
:
true
});
let
resMap
=
{};
for
(
let
item
of
dbInfoList
)
{
resMap
[
item
.
user_id
]
=
item
}
return
resMap
;
}
\ No newline at end of file
src/functional/mvc/service/mUserManage.service.ts
View file @
1e2908b8
import
{
ormDB
,
userAccountChangeLog
,
userInfo
,
userProfile
}
from
"@madex/ex-ts-dao"
;
import
{
coinAddress
,
coinWithdraw
,
ormDB
,
userAccountChangeLog
,
userInfo
,
userProfile
}
from
"@madex/ex-ts-dao"
;
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
import
{
getProfileByUserIds
}
from
"./mUserProfile.service"
;
import
{
getProfileByUserIds
}
from
"./mUserProfile.service"
;
import
{
getRealNameByUserIds
,
getRealNameByUserId
}
from
"./mUserRealName.service"
;
import
{
getRealName
Map
ByUserIds
,
getRealNameByUserId
}
from
"./mUserRealName.service"
;
import
{
MUserRedisKey
}
from
"../../../constant/mUserRedisKey"
;
import
{
MUserRedisKey
}
from
"../../../constant/mUserRedisKey"
;
import
{
getMUserInfoByEmail
,
getMUserInfoByUid
,
sendEmail
,
updateMUserInfo
}
from
"../../../utils/mUserUtils"
;
import
{
getMUserInfoByEmail
,
getMUserInfoByUid
,
getUserInfoMapByUids
,
sendEmail
,
updateMUserInfo
}
from
"../../../utils/mUserUtils"
;
import
{
existEmail
,
getProcessingEmailListByMUserId
}
from
"./mUserAccountChangeLog.service"
;
import
{
existEmail
,
getProcessingEmailListByMUserId
}
from
"./mUserAccountChangeLog.service"
;
import
{
AFTER_MODIFIED_MAILBOX_TIP
,
EMAIL_FORBID_TEMPLATE
}
from
"../../../constant/emailTemplateType"
;
import
{
AFTER_MODIFIED_MAILBOX_TIP
,
EMAIL_FORBID_TEMPLATE
}
from
"../../../constant/emailTemplateType"
;
import
{
addLog
,
MUserLogType
}
from
"./mUserOptLog.service"
;
import
{
addLog
,
MUserLogType
}
from
"./mUserOptLog.service"
;
...
@@ -13,6 +13,8 @@ import { getFatherUserId, getUidsByFatherUid } from "./mUserInfoSon.service";
...
@@ -13,6 +13,8 @@ import { getFatherUserId, getUidsByFatherUid } from "./mUserInfoSon.service";
import
{
recordMUserOperateLog
,
TYPE
}
from
"./mUserAccountOperateLog.service"
;
import
{
recordMUserOperateLog
,
TYPE
}
from
"./mUserAccountOperateLog.service"
;
import
{
tradeAsset2USDTByUids
,
walletAsset2USDTByUids
}
from
"./mUserAssets.service"
;
import
{
tradeAsset2USDTByUids
,
walletAsset2USDTByUids
}
from
"./mUserAssets.service"
;
import
BigNumber
from
"bignumber.js"
;
import
BigNumber
from
"bignumber.js"
;
import
{
getCoinWithdrawMapByUids
}
from
"./coinWithdraw.service"
;
import
{
getCoinAddressMapByUids
}
from
"./coinAddress.service"
;
let
_
=
require
(
'lodash'
);
let
_
=
require
(
'lodash'
);
let
{
logger
,
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
let
{
logger
,
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
...
@@ -27,99 +29,91 @@ export interface QueryVO {
...
@@ -27,99 +29,91 @@ export interface QueryVO {
user_id
?:
number
|
any
;
user_id
?:
number
|
any
;
kyc_status
?:
number
|
any
;
lock_status
?:
number
|
any
;
totp_status
?:
number
|
any
;
start_date
?:
Date
|
any
;
end_date
?:
Date
|
any
;
email
?:
string
|
any
email
?:
string
|
any
totp_code
?:
string
|
any
totp_code
?:
string
|
any
lock_type
?:
number
|
any
//锁定类型 1 锁定当前账户 2 锁定当前账户及其所有子账户
lock_type
?:
number
|
any
//锁定类型 1 锁定当前账户 2 锁定当前账户及其所有子账户
condition
?:
string
}
}
export
async
function
userList
(
queryVO
:
QueryVO
)
{
export
async
function
userList
(
page
:
number
,
size
:
number
,
condition
:
string
,
condition_type
:
number
)
{
let
where
=
Object
.
create
(
null
);
if
(
queryVO
.
user_id
)
{
where
.
user_id
=
queryVO
.
user_id
;
}
if
(
!
isNaN
(
queryVO
.
lock_status
))
{
where
.
is_lock
=
queryVO
.
lock_status
;
}
if
(
!
isNaN
(
queryVO
.
totp_status
))
{
let
pageData
:
any
;
where
.
totp_encrypt
=
queryVO
.
totp_status
?
{
[
ormDB
.
Op
.
not
]:
null
}
:
{
[
ormDB
.
Op
.
is
]:
null
};
let
where
:
any
}
//uid/姓名/邮箱/证件号 查询
if
(
condition_type
==
1
)
{
//没有查询条件
if
(
condition
==
"undefined"
||
condition
==
undefined
||
condition
==
""
)
{
where
=
""
;
}
else
{
where
=
{
email
:
String
(
condition
),
real_name
:
String
(
condition
),
phone
:
String
(
condition
),
identity
:
String
(
condition
),
}
//数字类型的话 补充uid作为查询条件
if
(
!
isNaN
(
Number
(
condition
)))
{
where
[
'user_id'
]
=
Number
(
condition
)
}
}
if
(
queryVO
.
start_date
&&
queryVO
.
end_date
)
{
//
let
from
=
datetimeUtils
.
trim
(
queryVO
.
start_date
,
's'
);
pageData
=
await
userInfo
.
prototype
.
findAndCount
({
let
to
=
datetimeUtils
.
trim
(
queryVO
.
end_date
,
's'
);
attributes
:
[
'user_id'
,
'email'
,
'real_name'
,
'createdAt'
,
'totp_encrypt'
,
'is_lock'
,
'identity'
],
where
.
createdAt
=
{
[
ormDB
.
Op
.
between
]:
[
from
,
to
]
};
where
:
where
?
{
[
ormDB
.
Op
.
or
]:
where
}
:
{},
limit
:
size
,
offset
:
(
page
-
1
)
*
size
,
order
:
[[
"user_id"
,
"asc"
]],
raw
:
true
});
await
buildReturnData
(
pageData
,
false
,
true
,
true
);
return
pageData
;
}
}
else
{
let
resList
=
await
userInfo
.
prototype
.
findAndCount
({
if
(
condition
)
{
attributes
:
[
'user_id'
,
'email'
,
'real_name'
,
'createdAt'
,
'totp_encrypt'
,
'is_lock'
],
where
=
{
where
:
where
,
address
:
String
(
condition
)
limit
:
queryVO
.
size
,
offset
:
(
Number
(
queryVO
.
page
)
-
1
)
*
Number
(
queryVO
.
size
),
order
:
[[
"user_id"
,
"asc"
]],
raw
:
true
});
if
(
resList
.
rows
.
length
>
0
)
{
let
uids
=
resList
.
rows
.
map
(
item
=>
item
.
user_id
);
//个人资料
let
profileMap
=
await
getProfileByUserIds
(
uids
);
//实名信息
let
realNameMap
=
await
getRealNameByUserIds
(
uids
);
//钱包余额
let
walletAssetMap
=
await
walletAsset2USDTByUids
(
uids
);
//交易账户余额
let
tradeAssetMap
=
await
tradeAsset2USDTByUids
(
uids
);
//替换rows的集合
let
infoList
:
any
=
[];
for
(
let
item
of
resList
.
rows
)
{
let
wallet_account_balance
=
new
BigNumber
(
String
(
walletAssetMap
[
item
.
user_id
].
balance_usdt
)).
add
(
new
BigNumber
(
String
(
walletAssetMap
[
item
.
user_id
].
holds_usdt
)));
let
trade_account_balance
=
new
BigNumber
(
String
(
tradeAssetMap
[
item
.
user_id
].
balance_usdt
)).
add
(
new
BigNumber
(
String
(
tradeAssetMap
[
item
.
user_id
].
holds_usdt
)));
let
oneProfile
=
profileMap
[
item
.
user_id
];
let
oneRealName
=
realNameMap
[
item
.
user_id
];
let
one
=
{
user_id
:
item
.
user_id
,
nick_name
:
oneProfile
?
(
oneProfile
.
nick_name
?
oneProfile
.
nick_name
:
""
)
:
""
,
real_name
:
item
.
real_name
,
email
:
item
.
email
,
register_date
:
item
.
createdAt
,
spot_trade_total
:
0
,
//TODO:现货交易总量
contract_trade_total
:
0
,
//TODO:永续合约交易总量
spot_balance
:
0
,
//TODO:现货余额
contract_balance
:
0
,
//TODO:永续合约余额
assets_total
:
0
,
//TODO: 总资产
spot_order
:
0
,
//TODO: 现货订单数量
contract_order
:
0
,
//TODO: 永续合约订单数量
wallet_account_balance
:
wallet_account_balance
,
//钱包账户余额
trade_account_balance
:
trade_account_balance
,
//TODO: 交易账户余额
kyc_status
:
oneRealName
?
oneRealName
.
status
:
0
,
//0未提交,1审核中,2审核不通过,3审核通过
kyc_type
:
oneRealName
?
oneRealName
.
type
:
0
,
//1身份证,2护照,3驾驶证
kyc_identity
:
oneRealName
?
oneRealName
.
identity
:
0
,
//证件号
is_bind_totp
:
item
.
totp_encrypt
?
1
:
0
,
lock_status
:
item
.
is_lock
,
//0 否 1 是
}
}
infoList
.
push
(
one
);
}
}
resList
.
rows
=
infoList
;
pageData
=
await
coinAddress
.
prototype
.
findAndCount
({
attributes
:
[
'user_id'
,
'address'
],
where
:
where
,
limit
:
size
,
offset
:
(
page
-
1
)
*
size
,
order
:
[[
"id"
,
"asc"
]],
raw
:
true
});
if
(
!
pageData
.
rows
.
length
)
{
if
(
condition
)
{
where
=
{
to_address
:
String
(
condition
)
}
}
pageData
=
await
coinWithdraw
.
prototype
.
findAndCount
({
attributes
:
[
'user_id'
,
'to_address'
],
where
:
where
,
limit
:
size
,
offset
:
(
page
-
1
)
*
size
,
order
:
[[
"id"
,
"asc"
]],
raw
:
true
});
await
buildReturnData
(
pageData
,
true
,
true
,
false
);
return
pageData
;
}
else
{
await
buildReturnData
(
pageData
,
true
,
false
,
true
);
return
pageData
;
}
}
}
return
resList
;
}
}
...
@@ -385,6 +379,87 @@ async function modifyUserEmail(m_user_id: number, email_new: string, email_old:
...
@@ -385,6 +379,87 @@ async function modifyUserEmail(m_user_id: number, email_new: string, email_old:
}
}
/**
* 构造返回数据
* @param pageData 分页数据
* @param fill_user_info 是否需要 填充 user_info 的数据 0 否 1 是
* @param fill_coin_address 是否需要 填充 coin_address 的数据 0 否 1 是
* @param fill_coin_withdraw 是否需要 填充 coin_withdraw 的数据 0 否 1 是
*/
async
function
buildReturnData
(
pageData
:
any
,
fill_user_info
:
boolean
,
fill_coin_address
:
boolean
,
fill_coin_withdraw
:
boolean
)
{
if
(
pageData
.
rows
.
length
>
0
)
{
let
uids
=
pageData
.
rows
.
map
(
item
=>
item
.
user_id
);
//注意顺序
let
task
:
any
=
[];
//实名信息
task
.
push
(
getRealNameMapByUserIds
(
uids
));
//钱包余额
task
.
push
(
walletAsset2USDTByUids
(
uids
));
//交易账户余额
task
.
push
(
tradeAsset2USDTByUids
(
uids
));
//用户信息
task
.
push
(
fill_user_info
?
getUserInfoMapByUids
(
uids
)
:
null
);
//充值地址
task
.
push
(
fill_coin_address
?
getCoinAddressMapByUids
(
uids
)
:
null
);
//提现地址
task
.
push
(
fill_coin_withdraw
?
getCoinWithdrawMapByUids
(
uids
)
:
null
);
let
[
realNameMap
,
walletAssetMap
,
tradeAssetMap
,
userInfoMap
,
coinAddrMap
,
withdrawMap
]
=
await
Promise
.
all
(
task
);
//替换rows的集合
let
infoList
:
any
=
[];
for
(
let
item
of
pageData
.
rows
)
{
let
user_id
=
item
.
user_id
;
//初始化
let
wallet_account_balance
=
new
BigNumber
(
String
(
walletAssetMap
[
item
.
user_id
].
balance_usdt
)).
add
(
new
BigNumber
(
String
(
walletAssetMap
[
item
.
user_id
].
holds_usdt
)));
let
trade_account_balance
=
new
BigNumber
(
String
(
tradeAssetMap
[
item
.
user_id
].
balance_usdt
)).
add
(
new
BigNumber
(
String
(
tradeAssetMap
[
item
.
user_id
].
holds_usdt
)));
let
oneRealName
=
realNameMap
[
item
.
user_id
];
let
one
=
{
user_id
:
user_id
,
real_name
:
item
.
real_name
?
item
.
real_name
:
""
,
email
:
item
.
email
?
item
.
email
:
""
,
register_date
:
item
.
createdAt
?
item
.
createdAt
:
""
,
spot_trade_total
:
0
,
//TODO:现货交易总量
contract_trade_total
:
0
,
//TODO:永续合约交易总量
spot_balance
:
0
,
//TODO:现货余额
contract_balance
:
0
,
//TODO:永续合约余额
assets_total
:
0
,
//TODO: 总资产
spot_order
:
0
,
//TODO: 现货订单数量
contract_order
:
0
,
//TODO: 永续合约订单数量
wallet_account_balance
:
wallet_account_balance
,
//钱包账户余额
trade_account_balance
:
trade_account_balance
,
//TODO: 交易账户余额
kyc_status
:
oneRealName
?
oneRealName
.
status
:
0
,
//0未提交,1审核中,2审核不通过,3审核通过
kyc_type
:
oneRealName
?
oneRealName
.
type
:
0
,
//1身份证,2护照,3驾驶证
kyc_identity
:
item
.
kyc_identity
?
item
.
kyc_identity
:
""
,
is_bind_totp
:
item
.
totp_encrypt
?
1
:
0
,
lock_status
:
item
.
is_lock
?
item
.
is_lock
:
""
,
address
:
item
.
address
?
item
.
address
:
""
,
to_address
:
item
.
to_address
?
item
.
to_address
:
""
,
};
//填充用户信息
if
(
userInfoMap
)
{
one
[
'real_name'
]
=
userInfoMap
[
user_id
]
?
userInfoMap
[
user_id
].
real_name
:
""
;
one
[
'email'
]
=
userInfoMap
[
user_id
]
?
userInfoMap
[
user_id
].
email
:
""
;
one
[
'register_date'
]
=
userInfoMap
[
user_id
]
?
userInfoMap
[
user_id
].
createdAt
:
""
;
one
[
'kyc_identity'
]
=
userInfoMap
[
user_id
]
?
userInfoMap
[
user_id
].
identity
:
""
;
one
[
'is_bind_totp'
]
=
userInfoMap
[
user_id
]
&&
userInfoMap
[
user_id
].
totp_encrypt
?
1
:
0
;
one
[
'lock_status'
]
=
userInfoMap
[
user_id
]
?
userInfoMap
[
user_id
].
is_lock
:
""
;
}
//充币地址
if
(
coinAddrMap
)
{
one
[
'address'
]
=
coinAddrMap
[
user_id
]
?
coinAddrMap
[
user_id
].
address
:
""
;
}
//提币地址
if
(
withdrawMap
)
{
one
[
'to_address'
]
=
withdrawMap
[
user_id
]
?
withdrawMap
[
user_id
].
to_address
:
""
;
}
infoList
.
push
(
one
);
}
pageData
.
rows
=
infoList
;
}
}
...
...
src/functional/mvc/service/mUserRealName.service.ts
View file @
1e2908b8
...
@@ -31,6 +31,16 @@ export interface QueryVO {
...
@@ -31,6 +31,16 @@ export interface QueryVO {
audit_deny
?:
string
,
audit_deny
?:
string
,
comment
?:
string
comment
?:
string
type
?:
number
//证件类型 1身份证,2护照,3驾驶证
source
?:
number
// 认证来源 1 web 2 app
auditor
?:
number
//审核人员id
from_time
?:
Date
|
any
to_time
?:
Date
|
any
}
}
export
async
function
getRealNameByUserId
(
user_id
:
number
|
any
)
{
export
async
function
getRealNameByUserId
(
user_id
:
number
|
any
)
{
...
@@ -43,7 +53,7 @@ export async function getRealNameByUserId(user_id: number | any) {
...
@@ -43,7 +53,7 @@ export async function getRealNameByUserId(user_id: number | any) {
return
dbInfo
?
dbInfo
:
null
return
dbInfo
?
dbInfo
:
null
}
}
export
async
function
getRealNameByUserIds
(
userIds
:
number
[])
{
export
async
function
getRealName
Map
ByUserIds
(
userIds
:
number
[])
{
let
dbInfoList
=
await
userRealName
.
prototype
.
findAll
({
let
dbInfoList
=
await
userRealName
.
prototype
.
findAll
({
where
:
{
where
:
{
...
@@ -59,22 +69,17 @@ export async function getRealNameByUserIds(userIds: number[]) {
...
@@ -59,22 +69,17 @@ export async function getRealNameByUserIds(userIds: number[]) {
}
}
export
async
function
kycList
(
queryVO
:
QueryVO
,
isAdmin
:
boolean
)
{
export
async
function
kycList
(
queryVO
:
QueryVO
)
{
let
where
=
{}
let
where
=
{}
if
(
isAdmin
)
{
if
(
queryVO
.
user_id
)
{
if
(
queryVO
.
user_id
)
{
//uid 是否在受限范围内
where
[
"user_id"
]
=
queryVO
.
user_id
if
(
isLimitUserId
(
queryVO
.
user_id
))
{
throw
ErrorCode
.
UID_LIMIT
}
}
where
[
"user_id"
]
=
queryVO
.
user_id
;
}
}
else
{
else
{
if
(
queryVO
.
user_id
)
{
if
(
UID_MIN
&&
UID_LIMIT
.
length
)
{
//uid 是否在受限范围内
if
(
isLimitUserId
(
queryVO
.
user_id
))
{
throw
ErrorCode
.
UID_LIMIT
}
where
[
"user_id"
]
=
queryVO
.
user_id
}
else
{
where
[
ormDB
.
Op
.
and
]
=
[{
where
[
ormDB
.
Op
.
and
]
=
[{
user_id
:
{
[
ormDB
.
Op
.
gte
]:
UID_MIN
}
user_id
:
{
[
ormDB
.
Op
.
gte
]:
UID_MIN
}
},
},
...
@@ -82,16 +87,44 @@ export async function kycList(queryVO: QueryVO, isAdmin: boolean) {
...
@@ -82,16 +87,44 @@ export async function kycList(queryVO: QueryVO, isAdmin: boolean) {
user_id
:
{
[
ormDB
.
Op
.
notIn
]:
UID_LIMIT
},
user_id
:
{
[
ormDB
.
Op
.
notIn
]:
UID_LIMIT
},
}]
}]
}
}
else
{
where
[
"user_id"
]
=
{
[
ormDB
.
Op
.
gte
]:
UID_MIN
}
}
}
}
if
(
!
isNaN
(
Number
(
queryVO
.
status
)))
{
if
(
!
isNaN
(
Number
(
queryVO
.
status
)))
{
where
[
"status"
]
=
queryVO
.
status
where
[
"status"
]
=
queryVO
.
status
}
}
if
(
queryVO
.
source
)
{
//来源
if
(
queryVO
.
source
==
1
)
{
where
[
"delta"
]
=
""
}
else
{
where
[
ormDB
.
Op
.
and
]
=
[{
delta
:
{
[
ormDB
.
Op
.
not
]:
null
}
},
{
delta
:
{
[
ormDB
.
Op
.
ne
]:
""
},
}]
}
}
if
(
queryVO
.
type
)
{
where
[
"type"
]
=
queryVO
.
type
}
if
(
queryVO
.
auditor
)
{
where
[
"auditor"
]
=
queryVO
.
auditor
}
if
(
queryVO
.
from_time
&&
queryVO
.
to_time
)
{
where
[
'updatedAt'
]
=
{
[
ormDB
.
Op
.
between
]:
[
queryVO
.
from_time
,
queryVO
.
to_time
]
}
}
let
resList
=
await
userRealName
.
prototype
.
findAndCount
({
let
resList
=
await
userRealName
.
prototype
.
findAndCount
({
attributes
:
[
'id'
,
'user_id'
,
'status'
,
'createdAt'
],
attributes
:
[
'id'
,
'user_id'
,
'status'
,
'createdAt'
],
where
:
where
,
where
:
where
,
limit
:
queryVO
.
size
,
limit
:
queryVO
.
size
,
offset
:
(
Number
(
queryVO
.
page
)
-
1
)
*
Number
(
queryVO
.
size
),
offset
:
(
Number
(
queryVO
.
page
)
-
1
)
*
Number
(
queryVO
.
size
),
order
:
[[
"
id
"
,
"desc"
]],
order
:
[[
"
updatedAt
"
,
"desc"
]],
raw
:
true
raw
:
true
});
});
...
...
src/functional/mvc/service/userAuthConfig.service.ts
View file @
1e2908b8
...
@@ -32,8 +32,6 @@ export interface AuthConfigVO {
...
@@ -32,8 +32,6 @@ export interface AuthConfigVO {
updatedAt
?:
Date
|
any
;
updatedAt
?:
Date
|
any
;
user_type
?:
number
|
any
;
totp_code
?:
any
totp_code
?:
any
}
}
...
...
src/utils/aclUserUtils.ts
View file @
1e2908b8
...
@@ -24,51 +24,7 @@ export const getCurrentUserId = async function (sessionId: string) {
...
@@ -24,51 +24,7 @@ export const getCurrentUserId = async function (sessionId: string) {
return
currentUser
.
userId
;
return
currentUser
.
userId
;
}
}
/**
* 判断是否是管理员 通过 UID
* @param user_id
*/
export
const
isAdminUserByUid
=
async
function
(
user_id
:
number
)
{
let
dbInfo
=
await
getOneAclUserByUid
(
user_id
);
if
(
dbInfo
.
user_type
!=
AclUserInfoConst
.
USER_TYPE
.
ADMIN
)
{
throw
ErrorCode
.
NO_PERMISSION
}
}
/**
* 判断是否是超管 通过 UID
* @param user_id
*/
export
const
isSuperAdminUserByUid
=
async
function
(
user_id
:
number
)
{
let
dbInfo
=
await
getOneAclUserByUid
(
user_id
);
if
(
dbInfo
.
user_type
!=
AclUserInfoConst
.
USER_TYPE
.
SUPER_ADMIN
)
{
throw
ErrorCode
.
NO_PERMISSION
}
}
/**
* 判断是否是管理员 通过 session_id
* @param sessionId
*/
export
const
isAdminUserBySessionId
=
async
function
(
sessionId
:
string
)
{
let
currentUserId
=
await
getCurrentUserId
(
sessionId
);
let
dbInfo
=
await
getOneAclUserByUid
(
currentUserId
);
if
(
dbInfo
.
user_type
!=
AclUserInfoConst
.
USER_TYPE
.
ADMIN
)
{
throw
ErrorCode
.
NO_PERMISSION
}
}
/**
* 判断是否是超管 通过 session_id
* @param sessionId
*/
export
const
isSuperAdminUserBySessionId
=
async
function
(
sessionId
:
string
)
{
let
currentUserId
=
await
getCurrentUserId
(
sessionId
);
let
dbInfo
=
await
getOneAclUserByUid
(
currentUserId
);
if
(
dbInfo
.
user_type
!=
AclUserInfoConst
.
USER_TYPE
.
SUPER_ADMIN
)
{
throw
ErrorCode
.
NO_PERMISSION
}
}
/**
/**
* 通过 user_id 查询用户
* 通过 user_id 查询用户
* @param user_id
* @param user_id
...
...
src/utils/mUserUtils.ts
View file @
1e2908b8
import
{
userInfo
}
from
"@madex/ex-ts-dao"
;
import
{
ormDB
,
userInfo
}
from
"@madex/ex-ts-dao"
;
import
{
requestUtils
,
logger
}
from
"@madex/ex-js-public"
;
import
{
requestUtils
,
logger
}
from
"@madex/ex-js-public"
;
import
{
config
}
from
"@madex/ex-js-common"
;
import
{
config
}
from
"@madex/ex-js-common"
;
import
{
ErrorCode
}
from
"../constant/errorCode"
;
import
{
ErrorCode
}
from
"../constant/errorCode"
;
...
@@ -58,4 +58,22 @@ export const updateMUserInfo = async function (user_id: number, updateInfo: any)
...
@@ -58,4 +58,22 @@ export const updateMUserInfo = async function (user_id: number, updateInfo: any)
user_id
:
user_id
user_id
:
user_id
}
}
});
});
}
export
async
function
getUserInfoMapByUids
(
uids
:
number
[])
{
if
(
!
uids
.
length
)
{
throw
ErrorCode
.
PARAM_MISS
;
}
let
dbInfoList
=
await
userInfo
.
prototype
.
findAll
({
where
:
{
user_id
:
{
[
ormDB
.
Op
.
in
]:
uids
}
},
raw
:
true
});
let
resMap
=
{};
for
(
let
item
of
dbInfoList
)
{
resMap
[
item
.
user_id
]
=
item
}
return
resMap
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment