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
aa531f54
Commit
aa531f54
authored
Sep 26, 2019
by
Hsinli
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of t-git.51gjj.com:fangbin/51business
parents
b15105a3
5181e47b
Pipeline
#14316
passed with stage
in 14 seconds
Changes
9
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
150 additions
and
113 deletions
+150
-113
callrisk.js
app/controller/credit/callrisk.js
+29
-13
credit_apply.js
app/model/prometheus/credit_apply.js
+16
-0
credit_callrisk_call_behavior.js
app/model/prometheus/credit_callrisk_call_behavior.js
+6
-6
credit_log_yys.js
app/model/prometheus/credit_log_yys.js
+7
-10
credit.js
app/router/credit.js
+4
-1
apply.js
app/service/credit/apply.js
+44
-70
callrisk.js
app/service/credit/callrisk.js
+0
-0
yys.js
app/service/credit/yys.js
+38
-13
config.local.js
config/config.local.js
+6
-0
No files found.
app/controller/credit/callrisk.js
View file @
aa531f54
...
...
@@ -5,7 +5,7 @@ const Controller = require('egg').Controller;
class
CallriskController
extends
Controller
{
/**
*
获取黑名单
报告
*
通话记录风险检测
报告
*/
async
getReport
()
{
...
...
@@ -14,8 +14,8 @@ class CallriskController extends Controller {
if
(
!
report_id
)
{
ctx
.
failed
(
'error report id'
);
}
const
ret
=
await
ctx
.
service
.
credit
.
callrisk
.
getReport
(
report_id
);
ctx
.
success
(
ret
);
const
re
sul
t
=
await
ctx
.
service
.
credit
.
callrisk
.
getReport
(
report_id
);
ctx
.
success
(
{
result
}
);
}
...
...
@@ -24,12 +24,12 @@ class CallriskController extends Controller {
*/
async
callriskInit
()
{
const
{
ctx
}
=
this
;
const
ret
=
await
ctx
.
service
.
credit
.
apply
.
callriskInit
();
ctx
.
success
(
ret
);
const
re
sul
t
=
await
ctx
.
service
.
credit
.
apply
.
callriskInit
();
ctx
.
success
(
{
result
}
);
}
/**
*
获取数据报告信息
*
立即检测
*/
async
applyCallriskReport
()
{
...
...
@@ -42,20 +42,36 @@ class CallriskController extends Controller {
password
:
{
type
:
'string'
,
required
:
true
}
}
ctx
.
validate
(
rule
,
input_params
);
await
ctx
.
service
.
credit
.
callrisk
.
checkThreeElements
(
input_params
);
const
ret
=
await
ctx
.
service
.
credit
.
apply
.
applyCallrisk
(
input_params
);
ctx
.
success
(
ret
);
const
result
=
await
ctx
.
service
.
credit
.
apply
.
applyCallrisk
(
input_params
);
ctx
.
success
({
result
});
}
async
getCode
()
{
const
{
ctx
}
=
this
;
const
order_id
=
ctx
.
request
.
body
.
order_id
;
const
result
=
await
ctx
.
service
.
credit
.
callrisk
.
getCode
(
order_id
);
ctx
.
success
({
result
});
}
async
co
nfirmCaptcha
()
{
async
co
mmitTask
()
{
const
{
ctx
}
=
this
;
const
code
=
ctx
.
request
.
body
.
code
;
const
result
=
await
ctx
.
service
.
credit
.
callrisk
.
verifyCode
(
code
);
// const result = true;
const
{
order_id
,
code
}
=
ctx
.
request
.
body
;
const
result
=
await
ctx
.
service
.
credit
.
callrisk
.
commitTask
({
order_id
,
code
}
);
ctx
.
success
({
result
});
}
async
queryTaskStatus
()
{
const
{
ctx
}
=
this
;
const
order_id
=
ctx
.
params
.
order_id
;
const
result
=
await
ctx
.
service
.
credit
.
callrisk
.
queryTaskStatus
(
order_id
);
ctx
.
success
({
result
});
}
...
...
app/model/prometheus/credit_apply.js
View file @
aa531f54
...
...
@@ -25,6 +25,22 @@ module.exports = app => {
r_code
:
STRING
,
r_msg
:
STRING
,
r_order_id
:
STRING
,
operator
:
{
type
:
STRING
,
allowNull
:
true
,
field
:
'operator'
,
get
()
{
const
operator
=
this
.
getDataValue
(
'operator'
);
if
(
operator
)
{
try
{
return
JSON
.
parse
(
operator
);
}
catch
(
error
)
{
return
[];
}
}
return
[];
},
},
valid
:
INTEGER
,
created_at
:
{
type
:
DATE
,
...
...
app/model/prometheus/credit_callrisk_call_behavior.js
View file @
aa531f54
...
...
@@ -18,15 +18,15 @@ module.exports = app => {
},
active_call_count
:
{
type
:
INTEGER
,
allowNull
:
fals
e
,
allowNull
:
tru
e
,
},
passive_call_count
:
{
type
:
INTEGER
,
allowNull
:
fals
e
,
allowNull
:
tru
e
,
},
each_call_count
:
{
type
:
INTEGER
,
allowNull
:
fals
e
,
allowNull
:
tru
e
,
},
silence_count_3day
:
{
type
:
INTEGER
,
...
...
@@ -50,7 +50,7 @@ module.exports = app => {
},
maximum_active_call_city
:
{
type
:
STRING
,
allowNull
:
fals
e
,
allowNull
:
tru
e
,
},
maximum_passive_call_count
:
{
type
:
INTEGER
,
...
...
@@ -62,7 +62,7 @@ module.exports = app => {
},
maximum_passive_call_city
:
{
type
:
STRING
,
allowNull
:
fals
e
,
allowNull
:
tru
e
,
},
maximum_call_time
:
{
type
:
INTEGER
,
...
...
@@ -74,7 +74,7 @@ module.exports = app => {
},
maximum_call_time_city
:
{
type
:
STRING
,
allowNull
:
fals
e
,
allowNull
:
tru
e
,
},
// is_deleted: {
// type: INTEGER,
...
...
app/model/prometheus/credit_
yys_order
.js
→
app/model/prometheus/credit_
log_yys
.js
View file @
aa531f54
...
...
@@ -4,23 +4,20 @@ const moment = require('moment');
module
.
exports
=
app
=>
{
const
{
INTEGER
,
STRING
,
DATE
,
TEXT
}
=
app
.
Sequelize
;
const
Credit
YysOrder
=
app
.
prometheusModel
.
define
(
'credit_yys_order
'
,
{
const
Credit
LogYys
=
app
.
prometheusModel
.
define
(
'credit_log_yys
'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
},
tyorder_idpe
:
INTEGER
,
r_order_sn
:
STRING
,
user_id
:
STRING
,
app_user_id
:
STRING
,
app_id
:
STRING
,
app_type_id
:
STRING
,
name
:
STRING
,
phone
:
STRING
,
id_card
:
STRING
,
password
:
STRING
,
r_order_sn
:
STRING
,
operator
:
TEXT
,
request_url
:
STRING
,
params
:
STRING
,
resp
:
TEXT
,
valid
:
INTEGER
,
created_at
:
{
type
:
DATE
,
...
...
@@ -38,9 +35,9 @@ module.exports = app => {
}
},
{
timestamps
:
false
,
tableName
:
'credit_
yys_order
'
,
tableName
:
'credit_
log_yys
'
,
});
return
Credit
YysOrder
;
return
Credit
LogYys
;
};
app/router/credit.js
View file @
aa531f54
...
...
@@ -26,7 +26,10 @@ module.exports = app => {
router
.
get
(
'/callrisk/report/:report_id'
,
'credit.callrisk.getReport'
);
//获取报告信息
router
.
post
(
'/callrisk/report'
,
'credit.callrisk.applyCallriskReport'
);
//查询个人通话信息
router
.
get
(
'/callrisk/init'
,
'credit.callrisk.callriskInit'
);
//进入个人通话风险检测页面
router
.
post
(
'/callrisk/confirm_captcha'
,
'credit.callrisk.confirmCaptcha'
);
//获取短信验证码
// router.post('/callrisk/confirm_captcha', 'credit.callrisk.confirmCaptcha');//获取短信验证码
router
.
post
(
'/callrisk/get_code'
,
'credit.callrisk.getCode'
);
//获取短信验证码
router
.
post
(
'/callrisk/commit'
,
'credit.callrisk.commitTask'
);
//提交任务
router
.
get
(
'/callrisk/query/:order_id'
,
'credit.callrisk.queryTaskStatus'
);
//检查任务状态
};
app/service/credit/apply.js
View file @
aa531f54
...
...
@@ -336,102 +336,76 @@ class ApplyService extends Service {
const
app_type_id
=
ctx
.
appTypeId
;
const
app_user_id
=
ctx
.
appUserId
;
const
app_id
=
ctx
.
appId
;
const
type
=
TypeConfig
p
[
'callrisk'
];
//个人通话类型
const
type
=
TypeConfig
[
'callrisk'
];
//个人通话类型
let
report_id
=
null
;
//数盒魔方三要素校验
await
ctx
.
service
.
credit
.
common
.
shuhemofangCheck
(
'callrisk'
,
input
);
// await ctx.service.credit.callrisk.checkThreeElements(input);
// await ctx.service.credit.common.shuhemofangCheck('callrisk', input);
//判断用户当前三要素是否是二次查询未支付订单
const
check_second_ret
=
await
this
.
checkSecond
();
if
(
!
check_second_ret
.
order_id
)
{
const
check_second_ret
=
await
this
.
checkSecond
(
{
name
,
phone
,
id_card
}
);
if
(
check_second_ret
.
order_id
)
{
return
check_second_ret
;
}
// let ret = {
// order_id,
// report_id: null,
// first: check_second_ret.first,
// second: check_second_ret.second,
// order_sn: null
// }
//生成订单
const
order_data
=
{
type
,
name
,
phone
,
id_card
};
const
order
=
await
ctx
.
service
.
credit
.
order
.
createOrder
(
order_data
);
const
order_id
=
order
.
id
;
//运营商API.创建订单号
const
order_sn_info
=
await
ctx
.
service
.
credit
.
yys
.
getOrderSn
(
phone
);
if
(
orderSnInfo
.
code
!==
0
)
{
ctx
.
failed
(
'getOrderSn error msg:'
+
orderSnInfo
.
msg
);
}
const
order_sn
=
order_sn_info
.
data
.
orderSn
;
const
addYysOrder
=
{
order_id
,
user_id
,
app_type_id
,
app_user_id
,
app_id
,
name
,
phone
,
id_card
,
password
,
r_order_sn
:
order_sn
,
order_sn_operator
:
orderSnInfo
.
data
.
operator
}
const
yys_order_info
=
await
ctx
.
prometheusModel
.
CreditYysOrder
.
create
(
addYysOrder
);
// ret.order_sn = yys_order_info.data.orderSn;
//调用运营商获取验证码接口
const
yys_get_code
=
await
ctx
.
service
.
credit
.
yys
.
getCode
({
password
,
order_sn
});
//创建yys-order apply 记录
const
apply
=
await
this
.
createYysApply
({
name
,
phone
,
id_card
,
password
,
order_id
});
const
order_sn
=
apply
.
r_order_id
;
//第一次调用运营商获取验证码接口
const
operator_params
=
apply
.
operator
.
params
;
let
get_code_params
=
{
orderSn
:
order_sn
,
data
:
{}
};
for
(
let
k
in
operator_params
)
{
const
operator_params_val
=
operator_params
[
k
];
if
(
operator_params_val
.
name
===
'phone'
)
{
continue
;
}
get_code_params
.
data
[
operator_params_val
.
name
]
=
input
[
operator_params_val
.
name
];
}
// get_code_params.data.phoneCode = '';
const
yys_get_code
=
await
ctx
.
service
.
credit
.
yys
.
getCode
(
get_code_params
);
if
(
yys_get_code
.
code
!==
0
)
{
ctx
.
failed
(
'getCode error msg:'
+
yys_get_code
.
msg
);
}
// //提交任务
// const yys_commit = await this.commitYys(orderSnInfo.data.orderSn, { phone, name, ID: id_card, password, phoneCode });
// if (yys_commit.code !== 0) {
// ctx.failed('getCode error msg:' + yys_commit.msg);
// }
const
order_no
=
await
ctx
.
service
.
credit
.
common
.
getOrdertNo
(
'callrisk'
,
order_id
);
await
ctx
.
prometheusModel
.
CreditOrder
.
update
({
order_no
,
apply_id
:
apply
.
id
},
{
where
:
{
id
:
order_id
}
});
return
{
order_id
,
report_id
,
first
:
check_second_ret
.
first
,
second
:
check_second_ret
.
second
,
order_sn
};
}
async
createApply
()
{
async
createYysApply
(
input
)
{
const
{
ctx
}
=
this
;
const
user_id
=
ctx
.
userId
;
const
app_type_id
=
ctx
.
appTypeId
;
const
app_user_id
=
ctx
.
appUserId
;
const
app_id
=
ctx
.
appId
;
//获取签名
const
timestamp
=
String
(
new
Date
().
getTime
());
const
appKey
=
''
;
const
sign_params
=
{
appKey
,
timestamp
,
}
;
const
sign
=
await
ctx
.
service
.
credit
.
common
.
sign
(
sign_params
,
this
.
config
.
BLACKLIST_APPLY_APPSECRET
);
//调用数据接口获取个人通话风险数据 TODO
const
params
=
{
sign
,
phone
,
name
,
idcard
,
}
const
url
=
''
;
const
result
=
await
ctx
.
helper
.
send_request
(
url
,
params
,
{
method
:
'POST'
});
const
{
name
,
phone
,
id_card
,
password
,
order_id
}
=
input
;
//运营商API.创建订单号
const
order_sn_info
=
await
ctx
.
service
.
credit
.
yys
.
getOrderSn
(
phone
)
;
if
(
order_sn_info
.
code
!==
0
)
{
ctx
.
failed
(
'getOrderSn error msg:'
+
order_sn_info
.
msg
);
}
//创建申请订单
const
apply_data
=
{
type
,
user_id
,
app_user_id
,
app_id
,
app_type_id
,
timestamp
,
appkey
:
''
,
sign
,
r_code
:
result
.
data
.
code
,
r_msg
:
result
.
data
.
msg
,
r_order_id
:
result
.
data
.
data
.
order_id
,
type
:
2
,
user_id
,
app_user_id
,
app_id
,
app_type_id
,
name
,
phone
,
id_card
,
appkey
:
this
.
config
.
YYS_APP_KEY
,
service_code
:
password
,
r_code
:
order_sn_info
.
code
,
r_msg
:
order_sn_info
.
msg
,
r_order_id
:
order_sn_info
.
data
.
orderSn
,
operator
:
JSON
.
stringify
(
order_sn_info
.
data
.
operator
)
}
const
apply
=
await
ctx
.
prometheusModel
.
CreditApply
.
create
(
apply_data
);
if
(
result
.
data
.
code
!==
0
)
{
ctx
.
failed
(
'数据获取异常'
);
}
return
apply
;
}
...
...
@@ -441,7 +415,7 @@ class ApplyService extends Service {
const
{
ctx
}
=
this
;
const
{
name
,
phone
,
id_card
}
=
input
;
const
{
user_id
}
=
this
;
const
type
=
TypeConfig
p
[
'callrisk'
];
//个人通话类型
const
type
=
TypeConfig
[
'callrisk'
];
//个人通话类型
let
first
=
false
;
//首次通过三要素验证后弹框提示:报告生成后,将无法查询其他人的报告
let
second
=
false
;
//再次查询的是待支付中的订单
let
order_id
=
null
;
...
...
app/service/credit/callrisk.js
View file @
aa531f54
This diff is collapsed.
Click to expand it.
app/service/credit/yys.js
View file @
aa531f54
...
...
@@ -19,7 +19,14 @@ class YysService extends Service {
}
let
url
=
this
.
config
.
NODE_BASE_URL
+
'/yys_api/getorderSn'
+
'?appKey='
+
this
.
config
.
YYS_APP_KEY
;
let
resp
=
await
ctx
.
helper
.
send_request
(
url
,
params
,
{
method
:
'POST'
});
ctx
.
logger
.
info
({
url
:
JSON
.
stringify
(
resp
)
});
ctx
.
logger
.
info
(
JSON
.
stringify
({
yys_getorderSn_params
:
params
,
yys_getorderSn_result
:
resp
}));
if
(
resp
.
data
.
code
===
undefined
||
resp
.
data
.
code
!==
0
)
{
ctx
.
failed
(
'getorderSn error:'
+
resp
.
data
.
msg
);
}
let
order_sn
=
resp
.
data
.
data
.
orderSn
;
await
this
.
addCreditLogYys
(
order_sn
,
'/yys_api/getorderSn'
,
params
,
resp
.
data
);
// ctx.logger.info(JSON.stringify(resp));
// ctx.logger.info(JSON.stringify({ yys_getorderSn_params: params, yys_getorderSn_result: resp }));
return
resp
.
data
;
}
...
...
@@ -29,15 +36,17 @@ class YysService extends Service {
*/
async
getCode
(
params
)
{
const
{
ctx
}
=
this
;
let
params
=
{
orderSn
:
params
.
order_sn
,
data
:
{
password
:
params
.
password
}
}
// let params_data
= {
//
orderSn: params.order_sn,
//
data: {
//
password: params.password
//
}
//
}
let
url
=
this
.
config
.
NODE_BASE_URL
+
'/yys_api/getCode'
+
'?appKey='
+
this
.
config
.
YYS_APP_KEY
;
let
resp
=
await
ctx
.
helper
.
send_request
(
url
,
params
,
{
method
:
'POST'
});
ctx
.
logger
.
info
({
url
:
JSON
.
stringify
(
resp
)
});
ctx
.
logger
.
info
(
JSON
.
stringify
({
yys_getCode_params
:
params
,
yys_getCode_result
:
resp
}));
await
this
.
addCreditLogYys
(
params
.
orderSn
,
'/yys_api/getCode'
,
params
,
resp
.
data
);
// console.info(resp);
return
resp
.
data
;
}
...
...
@@ -57,7 +66,8 @@ class YysService extends Service {
// }
const
url
=
this
.
config
.
NODE_BASE_URL
+
'/yys_api/commit'
+
'?appKey='
+
this
.
config
.
YYS_APP_KEY
;
const
resp
=
await
ctx
.
helper
.
send_request
(
url
,
params
,
{
method
:
'POST'
});
ctx
.
logger
.
info
({
url
:
JSON
.
stringify
(
resp
)
});
ctx
.
logger
.
info
(
JSON
.
stringify
({
yys_commit_params
:
params
,
yys_commit_result
:
resp
}));
await
this
.
addCreditLogYys
(
params
.
orderSn
,
'/yys_api/commit'
,
params
,
resp
.
data
);
return
resp
.
data
;
}
...
...
@@ -72,7 +82,8 @@ class YysService extends Service {
}
let
url
=
this
.
config
.
NODE_BASE_URL
+
'/yys_api/query'
+
'?appKey='
+
this
.
config
.
YYS_APP_KEY
;
let
resp
=
await
ctx
.
helper
.
send_request
(
url
,
params
,
{
method
:
'POST'
});
ctx
.
logger
.
info
({
url
:
JSON
.
stringify
(
resp
)
});
ctx
.
logger
.
info
(
JSON
.
stringify
({
yys_query_params
:
params
,
yys_query_result
:
resp
}));
await
this
.
addCreditLogYys
(
orderSn
,
'/yys_api/query'
,
params
,
resp
.
data
);
return
resp
.
data
;
}
...
...
@@ -88,19 +99,33 @@ class YysService extends Service {
let
params
=
{
sign
:
""
,
signParams
:
{
appKey
:
this
.
config
.
YYS_
APP
_KEY
,
appKey
:
this
.
config
.
YYS_
REPORT
_KEY
,
timestamp
:
String
(
new
Date
().
getTime
()),
},
orderSn
,
}
params
.
sign
=
await
ctx
.
service
.
credit
.
common
.
sign
(
params
.
signParams
,
this
.
config
.
YYS_
APPLY
_APPSECRET
);
const
url
=
this
.
config
.
YYS_
APPLY
_URL
;
params
.
sign
=
await
ctx
.
service
.
credit
.
common
.
sign
(
params
.
signParams
,
this
.
config
.
YYS_
REPORT
_APPSECRET
);
const
url
=
this
.
config
.
YYS_
REPORT
_URL
;
const
result
=
await
ctx
.
helper
.
send_request
(
url
,
params
,
{
method
:
'POST'
});
ctx
.
logger
.
info
(
JSON
.
stringify
({
thxdReport_parmas
:
params
,
thxdReport_result
:
result
}));
return
result
.
data
;
}
async
addCreditLogYys
(
order_sn
,
request_url
,
params
,
resp
)
{
const
{
ctx
}
=
this
;
const
user_id
=
ctx
.
userId
;
const
app_type_id
=
ctx
.
appTypeId
;
const
app_user_id
=
ctx
.
appUserId
;
const
app_id
=
ctx
.
appId
;
const
log_data
=
{
user_id
,
app_type_id
,
app_user_id
,
app_id
,
r_order_sn
:
order_sn
,
request_url
,
params
:
JSON
.
stringify
(
params
),
resp
:
JSON
.
stringify
(
resp
)
}
const
ret
=
await
ctx
.
prometheusModel
.
CreditLogYys
.
create
(
log_data
);
return
ret
;
}
}
...
...
config/config.local.js
View file @
aa531f54
...
...
@@ -172,6 +172,12 @@ module.exports = appInfo => {
//我的信用-通化检测
config
.
YYS_APP_KEY
=
'A86BB96F55B64DCE87A46E919A347993'
;
config
.
YYS_APPLY_APPSECRET
=
'a695e9b3c0f1e3f15fb0b958fd3a4b67'
;
//运营商报告
config
.
YYS_REPORT_KEY
=
'F4E0CA710F484CFFB1756741696E29A3'
;
config
.
YYS_REPORT_APPSECRET
=
'233B8E10E31B4C899EE6FEB3AEC22F140B6528BF'
;
config
.
YYS_REPORT_URL
=
'http://47.96.253.64:8049/mycredit/thxdReport'
;
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