Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
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
方斌
51business
Commits
bfbd0267
Commit
bfbd0267
authored
Feb 10, 2020
by
Hsinli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addd
parent
b6f746d6
Pipeline
#19277
passed with stage
in 57 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
153 additions
and
1 deletion
+153
-1
check.js
app/controller/duxiaoman/check.js
+26
-0
duxiaoman.js
app/router/duxiaoman.js
+9
-0
check.js
app/service/duxiaoman/check.js
+111
-0
config.prod.js
config/config.prod.js
+7
-1
No files found.
app/controller/duxiaoman/check.js
0 → 100644
View file @
bfbd0267
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
CheckController
extends
Controller
{
/**
* 获取用户手机
*/
async
getUserHidePhone
()
{
const
{
ctx
}
=
this
;
ret
=
await
ctx
.
service
.
duxiaoman
.
check
.
getUserHidePhone
();
ctx
.
success
(
ret
);
}
/**
* 获取度小满查询结果
*/
async
getCheck
()
{
const
{
ctx
}
=
this
;
const
ret
=
await
ctx
.
service
.
duxiaoman
.
check
.
check
();
ctx
.
success
(
ret
);
}
}
module
.
exports
=
CheckController
;
app/router/duxiaoman.js
0 → 100644
View file @
bfbd0267
'use strict'
;
module
.
exports
=
app
=>
{
const
router
=
app
.
router
.
namespace
(
app
.
config
.
projectRootPath
+
'/duxiaoman/check'
);
router
.
get
(
'/phone'
,
'duxiaoman.check.getUserHidePhone'
);
router
.
get
(
'/result'
,
'duxiaoman.check.getCheck'
);
};
app/service/duxiaoman/check.js
0 → 100644
View file @
bfbd0267
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
moment
=
require
(
'moment'
);
class
CheckService
extends
Service
{
/**
* 获取用户的手机号(打码)
*/
async
getUserHidePhone
()
{
const
{
ctx
}
=
this
;
let
ret
=
{
isLogin
:
false
,
hidePhone
:
''
};
if
(
!
ctx
.
appUserId
||
!
ctx
.
deviceId
||
!
ctx
.
deviceLoginId
||
!
ctx
.
userId
)
{
//如果没有登录就不做处理
return
ret
;
}
let
filter
=
{
attributes
:
[
'passport'
],
where
:
{
sid
:
ctx
.
oldUserId
,
yys_cid
:
10
}
}
let
userInfo
=
await
ctx
.
gjjModel
.
SysUser
.
findOne
(
filter
);
if
(
!
userInfo
)
{
ctx
.
failed
(
'没有找到对应的手机号'
);
}
ret
.
hidePhone
=
userInfo
.
passport
.
replace
(
/
(\d{3})\d{4}(\d{4})
/
,
'$1****$2'
);
return
ret
;
}
/**
* 签名,加密
* @param {object} params 需要加密的参数对象
*/
async
sign
(
params
)
{
const
{
ctx
}
=
this
;
let
signKey
=
this
.
config
.
DXM_SECRET
;
let
sign
=
''
;
if
(
!
params
)
{
ctx
.
failed
(
'params is empty'
);
}
//键名排序
const
sortParamsKey
=
Object
.
keys
(
params
).
sort
();
//键值拼接-升序
let
sortValues
=
''
;
for
(
let
i
in
sortParamsKey
)
{
if
([
'sign'
,
'Sign'
].
includes
(
sortParamsKey
[
i
]))
{
continue
;
}
sortValues
+=
sortParamsKey
[
i
]
+
'='
+
params
[
sortParamsKey
[
i
]]
+
'&'
;
}
sortValues
=
sortValues
.
substring
(
0
,
sortValues
.
length
-
1
)
+
signKey
;
sign
=
ctx
.
helper
.
md5
(
sortValues
);
ctx
.
logger
.
info
({
sign
:
sign
});
return
sign
;
}
async
check
()
{
const
{
ctx
}
=
this
;
if
(
!
ctx
.
appUserId
||
!
ctx
.
oldUserId
||
!
ctx
.
userId
)
{
//如果没有登录就不做处理
ctx
.
failed
(
'登录异常'
);
}
//获取用户手机号
let
filter
=
{
attributes
:
[
'passport'
],
where
:
{
sid
:
ctx
.
oldUserId
,
yys_cid
:
10
}
}
let
userInfo
=
await
ctx
.
gjjModel
.
SysUser
.
findOne
(
filter
);
if
(
!
userInfo
)
{
ctx
.
failed
(
'没有找到对应的手机号'
);
}
let
params
=
{
app_id
:
this
.
config
.
DXM_APP_ID
,
datetime
:
new
Date
.
getTime
(),
phone
:
ctx
.
helper
.
md5
(
userInfo
.
passport
),
fr
:
'gjj_test'
,
//TODO,线下测试随意,不为空即可
sign
:
''
,
}
params
.
sign
=
await
this
.
sign
(
params
);
let
dxmUrl
=
this
.
config
.
DXM_URL
+
'?'
;
for
(
let
i
in
params
)
{
dxmUrl
+=
i
+
'='
+
params
[
i
]
+
'&'
;
}
dxmUrl
=
dxmUrl
.
substring
(
0
,
dxmUrl
.
length
-
1
);
ctx
.
logger
.
info
(
'dxmUrl:'
+
dxmUrl
);
let
result
=
await
ctx
.
helper
.
send_request
(
dxmUrl
,
{},
{
method
:
'GET'
});
ctx
.
logger
.
info
(
'result:'
+
JSON
.
stringify
(
result
));
return
result
;
}
}
module
.
exports
=
CheckService
;
config/config.prod.js
View file @
bfbd0267
...
...
@@ -14,7 +14,7 @@ module.exports = appInfo => {
dir
:
'/jianbing/logs/51business'
,
};
// add your config here
config
.
middleware
=
[
'errorHandler'
,
'deviceLogin'
,
'deviceInit'
,
'responseSet'
];
config
.
middleware
=
[
'errorHandler'
,
'deviceLogin'
,
'deviceInit'
,
'responseSet'
];
// 是否启用csrf安全
config
.
security
=
{
...
...
@@ -159,5 +159,11 @@ module.exports = appInfo => {
config
.
YYS_REPORT_APPSECRET
=
process
.
env
.
YYS_REPORT_APPSECRET
;
config
.
YYS_REPORT_URL
=
process
.
env
.
YYS_REPORT_URL
;
//度小满金融查询
config
.
DXM_APP_ID
=
process
.
env
.
DXM_APP_ID
;
config
.
DXM_SECRET
=
process
.
env
.
DXM_SECRET
;
config
.
DXM_URL
=
process
.
env
.
DXM_URL
;
return
config
;
};
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