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
565694e3
Commit
565694e3
authored
Sep 11, 2019
by
Hsinli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addd
parent
29cc4525
Pipeline
#13656
passed with stage
in 7 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
229 additions
and
65 deletions
+229
-65
credit_shuhemofang.js
app/model/prometheus/credit_shuhemofang.js
+37
-0
apply.js
app/service/credit/apply.js
+64
-61
common.js
app/service/credit/common.js
+115
-1
config.local.js
config/config.local.js
+5
-0
config.prod.js
config/config.prod.js
+8
-3
No files found.
app/model/prometheus/credit_shuhemofang.js
0 → 100644
View file @
565694e3
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
INTEGER
,
STRING
,
DATE
}
=
app
.
Sequelize
;
const
CreditShuhemofang
=
app
.
prometheusModel
.
define
(
'credit_shuhemofang'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
},
type
:
INTEGER
,
user_id
:
STRING
,
app_user_id
:
STRING
,
app_id
:
STRING
,
app_type_id
:
STRING
,
name
:
STRING
,
phone
:
STRING
,
id_card
:
STRING
,
status
:
STRING
,
response
:
STRING
,
created_at
:
{
type
:
DATE
,
get
()
{
const
date
=
this
.
getDataValue
(
'created_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
}
},
{
timestamps
:
false
,
tableName
:
'credit_shuhemofang'
,
});
return
CreditShuhemofang
;
};
app/service/credit/apply.js
View file @
565694e3
...
...
@@ -7,6 +7,55 @@ const _ = require('lodash');
class
ApplyService
extends
Service
{
/**
* 进入黑名单查询页面
*/
async
blacklistInit
()
{
const
{
ctx
}
=
this
;
let
ret
=
{
have_be_pay_order
:
false
,
order_id
:
null
,
placeholder
:
{
name
:
''
,
id_card
:
''
}
}
if
(
!
ctx
.
userId
)
{
ctx
.
failed
(
'登录异常'
);
}
let
bePayOrder
=
await
ctx
.
service
.
credit
.
order
.
getBePayOrder
(
1
);
if
(
bePayOrder
.
length
!==
0
)
{
ret
.
have_be_pay_order
=
true
;
ret
.
order_id
=
bePayOrder
[
0
].
id
;
}
//第一次查询成功的订单,反显姓名和身份证
let
filter
=
{
where
:
{
user_id
:
ctx
.
userId
,
type
:
1
,
valid
:
1
,
},
order
:
[[
'id'
,
'asc'
]]
}
let
orderInfo
=
await
ctx
.
prometheusModel
.
CreditOrder
.
findOne
(
filter
);
if
(
orderInfo
!=
null
)
{
let
applyFilter
=
{
where
:
{
id
:
orderInfo
.
apply_id
}
}
let
applyInfo
=
await
ctx
.
prometheusModel
.
CreditApply
.
findOne
(
applyFilter
);
if
(
applyInfo
!=
null
)
{
ret
.
placeholder
.
name
=
applyInfo
.
name
;
ret
.
placeholder
.
id_card
=
applyInfo
.
id_card
;
}
}
return
ret
;
}
/**
* 获取短信验证码
* @param {*} inputParams
...
...
@@ -35,17 +84,10 @@ class ApplyService extends Service {
ctx
.
failed
(
'姓名输入有误,请校验后输入'
);
}
//TODO 三要素校验
//生成四位验证码
/**
* redis保存
* SET KEY VALUE [EX seconds]|[PX milliseconds] [NX|XX]
* EX seconds − 设置指定的到期时间(以秒为单位)。
* PX milliseconds - 设置指定的到期时间(以毫秒为单位)。
* NX - 仅在键不存在时设置键。
* XX - 只有在键已存在时才设置。
*/
//数盒魔方三要素校验
await
ctx
.
service
.
credit
.
common
.
shuhemofangCheck
(
'blacklist'
,
inputParams
);
//验证码
//60秒只能获取一次
let
lockKey
=
'mine:credit:black:lock'
+
inputParams
.
phone
;
let
lock
=
await
app
.
redis
.
get
(
lockKey
);
...
...
@@ -79,7 +121,12 @@ class ApplyService extends Service {
}
}
let
codeKey
=
'mine:credit:black:code'
+
inputParams
.
phone
;
await
app
.
redis
.
set
(
codeKey
,
code
,
'EX'
,
60
*
5
);
//5分钟有效时间
let
codeData
=
{
//用于避免用户获取验证码之后修改姓名/身份证等
code
:
code
,
name
:
inputParams
.
name
,
id_card
:
inputParams
.
id_card
}
await
app
.
redis
.
set
(
codeKey
,
codeData
,
'EX'
,
60
*
5
);
//5分钟有效时间
let
smsParams
=
{
...
...
@@ -95,53 +142,6 @@ class ApplyService extends Service {
}
/**
* 进入黑名单查询页面
*/
async
blacklistInit
()
{
const
{
ctx
}
=
this
;
let
ret
=
{
have_be_pay_order
:
false
,
order_id
:
null
,
placeholder
:
{
name
:
''
,
id_card
:
''
}
}
if
(
!
ctx
.
userId
)
{
ctx
.
failed
(
'登录异常'
);
}
let
bePayOrder
=
await
ctx
.
service
.
credit
.
order
.
getBePayOrder
(
1
);
if
(
bePayOrder
.
length
!=
0
)
{
ret
.
have_be_pay_order
=
true
;
ret
.
order_id
=
bePayOrder
[
0
].
id
;
}
//第一次查询成功的订单,反显姓名和身份证
let
filter
=
{
where
:
{
user_id
:
ctx
.
userId
,
type
:
1
,
valid
:
1
,
},
order
:
[[
'id'
,
'asc'
]]
}
let
orderInfo
=
await
ctx
.
prometheusModel
.
CreditOrder
.
findOne
(
filter
);
if
(
orderInfo
!=
null
)
{
let
applyFilter
=
{
where
:
{
id
:
orderInfo
.
apply_id
}
}
let
applyInfo
=
await
ctx
.
prometheusModel
.
CreditApply
.
findOne
(
applyFilter
);
if
(
applyInfo
!=
null
)
{
ret
.
placeholder
.
name
=
applyInfo
.
name
;
ret
.
placeholder
.
id_card
=
applyInfo
.
id_card
;
}
}
return
ret
;
}
/**
* 从数据接口获取用户的黑名单报告信息
...
...
@@ -160,10 +160,13 @@ class ApplyService extends Service {
}
//验证码校验
let
codeKey
=
'mine:credit:black:code'
+
inputParams
.
phone
;
let
code
=
await
app
.
redis
.
get
(
codeKey
);
if
(
code
!==
inputParams
.
code
)
{
let
code
Data
=
await
app
.
redis
.
get
(
codeKey
);
if
(
code
Data
.
code
!==
inputParams
.
code
)
{
ctx
.
failed
(
'验证码错误,请重试'
);
}
if
(
codeData
.
name
!==
inputParams
.
name
||
codeData
.
id_card
!==
inputParams
.
id_card
)
{
ctx
.
failed
(
'获取验证码后请不要修改姓名、身份证等信息'
);
}
//判断用户是否第一次三要素核验成功
let
applyFilter
=
{
...
...
app/service/credit/common.js
View file @
565694e3
...
...
@@ -164,7 +164,7 @@ class CommonService extends Service {
error_msg
=
ret_data
.
return_msg
?
ret_data
.
return_msg
:
error_msg
;
ctx
.
failed
(
error_msg
);
}
if
(
ret_data
.
trade_state
===
'SUCCESS'
)
{
return
false
;
}
...
...
@@ -244,6 +244,120 @@ class CommonService extends Service {
return
sign
;
}
/**
* 数盒魔方三要素认证和存贮
* @param {*} data
* @param {*} type 黑名单blacklist通话callrisk
*/
async
queryShuhemofang
(
type
,
data
)
{
const
{
ctx
}
=
this
;
if
([
'blacklist'
,
'callrisk'
].
includes
(
type
))
{
ctx
.
failed
(
'未知类型的数据检测'
);
}
let
need
=
[
'name'
,
'id_card'
,
'phone'
];
for
(
let
i
in
need
)
{
if
(
!
data
.
hasOwnProperty
(
need
[
i
]
||
!
data
[
need
[
i
]]))
{
ctx
.
failed
(
need
[
i
]
+
'参数缺失'
);
}
}
let
ret
=
await
this
.
requestShuhemofang
(
data
);
let
shuhemofangData
=
{
type
:
type
===
'blacklist'
?
1
:
2
,
user_id
:
ctx
.
userId
,
app_user_id
:
ctx
.
appUserId
,
app_id
:
ctx
.
appId
,
app_type_id
:
ctx
.
appTypeId
,
name
:
data
.
name
,
phone
:
data
.
phone
,
id_card
:
data
.
id_card
,
status
:
(
ret
.
hasOwnProperty
(
'result'
)
&&
ret
.
result
.
hasOwnProperty
(
'data'
))
?
ret
.
result
.
data
:
ret
.
code
,
response
:
ret
,
}
let
shuhemofang
=
await
ctx
.
prometheusModel
.
CreditShuhemofang
.
create
(
shuhemofangData
);
return
shuhemofang
;
}
/**
* 请求数盒魔方
* @param {*} data name,phone,id_card三要素
*/
async
requestShuhemofang
(
data
)
{
let
timestamp
=
new
Date
().
getTime
().
toString
();
let
params
=
{
mobile
:
data
.
phone
,
idNo
:
data
.
id_card
,
name
:
data
.
name
,
appkey
:
this
.
config
.
SHUHEMOFANG_APP_KEY
,
timestamp
:
timestamp
,
sign
:
md5
(
this
.
config
.
SHUHEMOFANG_APP_KEY
+
this
.
config
.
SHUHEMOFANG_APP_SECRET
+
timestamp
),
}
let
resp
=
await
this
.
helper
.
send_request
(
this
.
config
.
SHUHEMOFANG_URL
,
params
,
{
method
:
'POST'
});
return
resp
.
data
;
}
/**
* 根据数盒魔方结果提示
* @param {*} status 数盒魔方返回状态码
*/
async
noticeShuhemofang
(
status
)
{
//异常情况
if
(
status
===
'2'
)
{
ctx
.
failed
(
'手机号已实名,身份证姓名均不匹配,请重新输入'
);
}
if
(
status
===
'3'
)
{
ctx
.
failed
(
'手机号已实名,姓名不匹配,请重新输入'
);
}
if
(
status
===
'4'
)
{
ctx
.
failed
(
'手机号已实名,身份证不匹配,请重新输入'
);
}
//未知情况
if
(
status
!=
'1'
)
{
ctx
.
failed
(
'认证过程中出现了一些问题,请稍后重试'
);
}
}
/**
* 数盒魔方校验
* @param {*} type 黑名单(blacklist)通话(callrisk)
* @param {object} inputParams name,phone,id_card
*/
async
shuhemofangCheck
(
type
,
inputParams
)
{
const
{
ctx
}
=
this
;
if
([
'blacklist'
,
'callrisk'
].
includes
(
type
))
{
ctx
.
failed
(
'未知类型的数据检测'
);
}
//1:判断用户当前三要素是否已经校验过
//2:有记录根据记录弹框,没记录判断该用户是否已经校验满5次
let
shmfFilter
=
{
user_id
:
ctx
.
userId
}
let
shmfList
=
await
ctx
.
prometheusModel
.
CreditShuhemofang
.
findAll
(
shmfFilter
);
if
(
shmfList
!==
undefined
&&
shmfList
.
length
>
0
)
{
let
history
=
{
in
:
false
,
detail
:
{}
};
for
(
let
i
in
shmfList
)
{
if
(
shmfList
[
i
].
name
===
inputParams
.
name
&&
shmfList
[
i
].
phone
===
inputParams
.
phone
&&
shmfList
[
i
].
id_card
===
inputParams
.
id_card
)
{
history
.
in
=
true
;
history
.
detail
=
shmfList
[
i
];
break
;
}
}
if
(
history
.
in
)
{
await
this
.
noticeShuhemofang
(
Number
(
history
.
detail
.
status
));
}
else
{
if
(
shmfList
.
length
>=
5
)
{
ctx
.
failed
(
'您输入的想要检测人数已超过最大限制,仅可检测输入过的检测信息'
);
}
else
{
let
resp
=
this
.
queryShuhemofang
(
type
,
inputParams
);
await
this
.
noticeShuhemofang
(
resp
.
status
);
}
}
}
}
}
module
.
exports
=
CommonService
;
config/config.local.js
View file @
565694e3
...
...
@@ -131,6 +131,11 @@ module.exports = appInfo => {
config
.
BLACKLIST_APPLY_APPSECRET
=
'233B8E10E31B4C899EE6FEB3AEC22F140B6528BF'
;
config
.
BLACKLIST_APPLY_URL
=
'http://47.96.253.64:8049/mycredit/blackList'
;
//数盒魔方
config
.
SHUHEMOFANG_APP_KEY
=
'BdNFbog6'
;
config
.
SHUHEMOFANG_APP_SECRET
=
'a695e9b3c0f1e3f15fb0b958fd3a4b67'
;
config
.
SHUHEMOFANG_URL
=
'https://api.soohaid.com:8211/api/mobile/factor3s'
;
return
config
;
};
config/config.prod.js
View file @
565694e3
...
...
@@ -118,9 +118,14 @@ module.exports = appInfo => {
config
.
BLACKLIST_APPLY_URL
=
process
.
env
.
BLACKLIST_APPLY_URL
;
//微信支付相关内容
config
.
MCH_APPID
=
process
.
env
.
MCH_APPID
;;
//商户关联的APPID
config
.
MCH_ID
=
process
.
env
.
MCH_ID
;;
//商户id
config
.
MCH_KEY
=
process
.
env
.
MCH_KEY
;;
//商户秘钥
config
.
MCH_APPID
=
process
.
env
.
MCH_APPID
;
//商户关联的APPID
config
.
MCH_ID
=
process
.
env
.
MCH_ID
;
//商户id
config
.
MCH_KEY
=
process
.
env
.
MCH_KEY
;
//商户秘钥
//数盒魔方
SHUHEMOFANG_APP_KEY
=
process
.
env
.
SHUHEMOFANG_APP_KEY
;
SHUHEMOFANG_APP_SECRET
=
process
.
env
.
SHUHEMOFANG_APP_SECRET
;
SHUHEMOFANG_URL
=
process
.
env
.
SHUHEMOFANG_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