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
a083285b
Commit
a083285b
authored
Sep 09, 2019
by
Hsinli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addd
parent
ba107535
Pipeline
#13510
passed with stage
in 28 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
141 additions
and
2 deletions
+141
-2
blacklist.js
app/controller/credit/blacklist.js
+16
-0
credit.js
app/router/credit.js
+3
-2
sms.js
app/service/common/sms.js
+46
-0
apply.js
app/service/credit/apply.js
+76
-0
No files found.
app/controller/credit/blacklist.js
View file @
a083285b
...
@@ -17,6 +17,22 @@ class BlacklistController extends Controller {
...
@@ -17,6 +17,22 @@ class BlacklistController extends Controller {
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
/**
* 获取验证码
*/
async
getBlacklistReportVerificationCode
()
{
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
request
.
body
;
const
rule
=
{
name
:
{
type
:
'string'
,
required
:
true
},
phone
:
{
type
:
'string'
,
required
:
true
},
id_card
:
{
type
:
'string'
,
required
:
true
},
}
ctx
.
validate
(
rule
,
inputParams
);
let
ret
=
await
ctx
.
service
.
credit
.
apply
.
getVerificationCode
(
inputParams
);
ctx
.
success
(
ret
);
}
/**
/**
* 获取数据报告信息
* 获取数据报告信息
...
...
app/router/credit.js
View file @
a083285b
...
@@ -7,8 +7,9 @@ module.exports = app => {
...
@@ -7,8 +7,9 @@ module.exports = app => {
router
.
get
(
'third'
,
'/history/:type'
,
'credit.order.getRecord'
);
router
.
get
(
'third'
,
'/history/:type'
,
'credit.order.getRecord'
);
//我的信用-黑名单报告
//我的信用-黑名单报告
router
.
get
(
'third'
,
'/blacklist/report/:report_id'
,
'credit.blacklist.getBlacklistReport'
);
router
.
get
(
'third'
,
'/blacklist/report/:report_id'
,
'credit.blacklist.getBlacklistReport'
);
//获取报告信息
router
.
post
(
'third'
,
'/blacklist/report'
,
'credit.blacklist.applyBlacklistReport'
);
router
.
post
(
'third'
,
'/blacklist/report'
,
'credit.blacklist.applyBlacklistReport'
);
//查询个人黑名单报告
router
.
post
(
'third'
,
'/blacklist/verification_code'
,
'credit.blacklist.getBlacklistReportVerificationCode'
);
//获取短信验证码
//我的信用-个人通话风险
//我的信用-个人通话风险
...
...
app/service/common/sms.js
0 → 100644
View file @
a083285b
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
moment
=
require
(
'moment'
);
const
_
=
require
(
'lodash'
);
class
SmsService
extends
Service
{
/**
* 短信接口
* @param {object} inputParams phone和content必须
*/
async
sendSms
(
inputParams
)
{
const
{
ctx
}
=
this
;
if
(
!
inputParams
.
hasOwnProperty
(
'phone'
)
||
!
inputParams
.
hasOwnProperty
(
'content'
))
{
ctx
.
failed
(
'手机号/短信内容不能为空'
);
}
const
url
=
'https://lan-nginx.jianbing.com/messages/index'
;
const
appId
=
'cXeKaF53GQgQk55'
;
const
appKey
=
'276BC440-B67E-44DA-ADC0-944A79F0DAB0'
;
let
params
=
{
app_id
:
appId
,
timestamp
:
new
Date
().
getTime
(),
sign
:
''
,
params
:
{
phone
:
inputParams
.
phone
,
content
:
inputParams
.
content
,
}
}
params
.
sign
=
await
ctx
.
helper
.
md5
(
params
.
timestamp
+
'&'
+
appKey
);
if
(
!
(
/【51公积金】/
.
test
(
params
.
params
.
content
)))
{
params
.
params
.
content
=
'【51公积金】'
+
params
.
params
.
content
;
}
if
(
inputParams
.
hasOwnProperty
(
'schedule'
))
{
params
.
params
.
schedule
=
inputParams
.
schedule
;
}
let
result
=
await
ctx
.
helper
.
send_request
(
url
,
params
,
{
method
:
'POST'
});
return
result
;
}
}
module
.
exports
=
SmsService
;
app/service/credit/apply.js
View file @
a083285b
...
@@ -8,6 +8,81 @@ const _ = require('lodash');
...
@@ -8,6 +8,81 @@ const _ = require('lodash');
class
ApplyService
extends
Service
{
class
ApplyService
extends
Service
{
/**
/**
* 获取短信验证码
* @param {*} inputParams
*/
async
getVerificationCode
(
inputParams
)
{
const
{
ctx
,
app
}
=
this
;
ctx
.
logger
.
info
(
inputParams
);
//姓名手机号和身份证校验
let
idVerify
=
ctx
.
helper
.
verify_id_card
(
inputParams
.
id_card
);
let
phoneVerify
=
ctx
.
helper
.
isPhoneNumber
(
inputParams
.
phone
);
let
nameVerify
=
ctx
.
helper
.
verify_real_name
(
inputParams
.
name
);
if
(
!
idVerify
)
{
ctx
.
failed
(
'身份证输入有误,请校验后输入'
);
}
if
(
!
phoneVerify
)
{
ctx
.
failed
(
'手机号输入有误,请校验后输入'
);
}
if
(
nameVerify
!==
1
)
{
ctx
.
failed
(
'姓名输入有误,请校验后输入'
);
}
//TODO 三要素校验
//生成四位验证码
/**
* redis保存
* SET KEY VALUE [EX seconds]|[PX milliseconds] [NX|XX]
* EX seconds − 设置指定的到期时间(以秒为单位)。
* PX milliseconds - 设置指定的到期时间(以毫秒为单位)。
* NX - 仅在键不存在时设置键。
* XX - 只有在键已存在时才设置。
*/
//60秒只能获取一次
let
lockKey
=
'mine:credit:black:lock'
+
inputParams
.
phone
;
let
lock
=
app
.
redis
.
get
(
lockKey
);
if
(
lock
&&
lock
!==
null
)
{
ctx
.
failed
(
'获取验证码过于频繁,请稍后再试'
);
}
await
app
.
redis
.
set
(
'lock'
,
lockKey
,
'EX'
,
60
);
//60秒锁
//每日次数限制
let
timesKey
=
'mine:credit:black:times'
+
inputParams
.
phone
;
let
times
=
app
.
redis
.
get
(
timesKey
);
if
(
!
times
)
{
times
=
0
;
}
times
++
;
if
(
times
>=
6
)
{
ctx
.
failed
(
'今日获取验证码次数过多,请明日再试'
);
}
let
pexpire
=
new
Date
(
moment
().
add
(
1
,
'days'
).
format
(
'YYYY-MM-DD'
)).
getTime
();
await
app
.
redis
.
set
(
times
,
timesKey
,
'PX'
,
pexpire
);
//今日有效
//生成
let
code
=
''
;
code
=
Math
.
round
(
Math
.
random
()
*
9999
).
toString
();
let
len
=
code
.
length
;
if
((
4
-
len
)
>
0
)
{
for
(
var
i
=
0
;
i
<
4
-
len
;
i
++
)
{
code
=
'0'
+
code
;
}
}
let
codeKey
=
'mine:credit:black:code'
+
inputParams
.
phone
;
await
app
.
redis
.
set
(
code
,
codeKey
,
'EX'
,
60
*
5
);
//5分钟有效时间
let
smsParams
=
{
phone
:
inputParams
.
phone
,
content
:
'【51公积金】您本次操作的短信验证码为'
+
code
+
',谨慎保管,切勿告诉他人。'
}
let
smsResult
=
await
ctx
.
service
.
common
.
sms
.
sendSms
(
smsParams
);
ctx
.
logger
.
info
(
smsResult
);
return
{
code
:
1
,
msg
:
'ok'
};
}
/**
* 从数据接口获取用户的黑名单报告信息
* 从数据接口获取用户的黑名单报告信息
* @param {*} inputParams
* @param {*} inputParams
*/
*/
...
@@ -123,6 +198,7 @@ class ApplyService extends Service {
...
@@ -123,6 +198,7 @@ class ApplyService extends Service {
}
}
let
reportId
=
await
ctx
.
prometheusModel
.
CreditBlacklistReport
.
create
(
reportData
);
let
reportId
=
await
ctx
.
prometheusModel
.
CreditBlacklistReport
.
create
(
reportData
);
}
}
return
true
;
}
}
...
...
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