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
7161837c
Commit
7161837c
authored
Sep 26, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
f038c111
Pipeline
#14249
passed with stage
in 5 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
173 additions
and
34 deletions
+173
-34
mini_auth.js
app/middleware/mini_auth.js
+2
-0
institution.js
app/service/course/institution.js
+18
-6
apply.js
app/service/credit/apply.js
+31
-15
callrisk.js
app/service/credit/callrisk.js
+88
-2
yys.js
app/service/credit/yys.js
+34
-11
No files found.
app/middleware/mini_auth.js
View file @
7161837c
...
...
@@ -18,6 +18,8 @@ module.exports = (options, app) => {
if
(
ctx
.
helper
.
md5
(
openid
+
uuid
+
'jbwl'
)
!=
auth_token
)
{
ctx
.
failed
(
'login auth error'
);
}
// console.info('11111111111111111111111111111111');
// console.info(auth_info);
ctx
.
setUserUuid
(
user_uuid
);
await
next
();
...
...
app/service/course/institution.js
View file @
7161837c
...
...
@@ -3,6 +3,7 @@
const
Service
=
require
(
'egg'
).
Service
;
const
R
=
require
(
'ramda'
);
const
_
=
require
(
'lodash'
);
const
moment
=
require
(
'moment'
);
class
InstitutionService
extends
Service
{
...
...
@@ -156,7 +157,7 @@ class InstitutionService extends Service {
let
classs
=
await
ctx
.
classModel
.
CourseClass
.
one
({
where
});
classs
.
dataValues
.
age_text
=
`
${
classs
.
min_age
}
-
${
classs
.
max_age
}
岁`
;
classs
.
dataValues
.
point_tags
=
classs
.
point
?
classs
.
point
.
split
(
';'
)
:
[];
classs
.
dataValues
.
photo_album
=
classs
.
image
?
classs
.
image
.
split
(
';'
)
:
[]
;
classs
.
dataValues
.
photo_album
=
classs
.
image
?
classs
.
image
.
split
(
';'
)
:
[];
return
classs
;
}
...
...
@@ -301,8 +302,8 @@ class InstitutionService extends Service {
const
results
=
[];
for
(
let
i
in
lbs_array
)
{
let
lbs
=
lbs_array
[
i
];
const
driving
=
drivings
[
i
]
?
drivings
[
i
]
:
{
distance
:
0
,
duration
:
0
};
const
walking
=
walkings
[
i
]
?
walkings
[
i
]
:
{
distance
:
0
,
duration
:
0
};
const
driving
=
(
drivings
[
i
]
&&
drivings
[
i
].
distance
!==
-
1
)
?
drivings
[
i
]
:
{
distance
:
0
,
duration
:
0
};
const
walking
=
(
walkings
[
i
]
&&
walkings
[
i
].
distance
!==
-
1
)
?
walkings
[
i
]
:
{
distance
:
0
,
duration
:
0
};
const
lbs_distance
=
driving
.
distance
>
distance
?
driving
:
walking
;
const
travel_method
=
driving
.
distance
>
distance
?
'driving'
:
'walking'
;
results
.
push
({
...
...
@@ -327,12 +328,14 @@ class InstitutionService extends Service {
const
{
ctx
}
=
this
;
cons
t
ret
=
[];
le
t
ret
=
[];
// const institution_lbs = await this.computeDistance(areas_list);
const
institution_lbs
=
areas_list
;
for
(
let
i
in
institution_areas
)
{
let
institution_area
=
institution_areas
[
i
];
//TODO 校验经纬度
const
lbs
=
institution_lbs
[
i
];
const
area_name
=
institution_area
.
area_name
;
...
...
@@ -353,10 +356,19 @@ class InstitutionService extends Service {
institution_area
.
duration
=
duration
;
institution_area
.
travel_tips
=
travel_tips
;
ret
.
push
(
institution_area
)
;
ret
[
i
]
=
institution_area
;
}
return
ret
;
const
results
=
[];
ret
=
_
.
orderBy
(
ret
,
[
'distance'
],
[
'asc'
]);
for
(
let
j
in
ret
)
{
const
val
=
ret
[
j
];
if
(
!
results
[
val
.
id
]
&&
val
.
distance
!==
0
)
{
results
[
val
.
id
]
=
val
;
}
}
return
results
;
}
async
formatInstitutions
(
institutions
)
{
...
...
app/service/credit/apply.js
View file @
7161837c
...
...
@@ -313,6 +313,7 @@ class ApplyService extends Service {
* @param {*} inputParams
*/
async
applyCallrisk
(
input
)
{
const
{
ctx
}
=
this
;
const
{
name
,
phone
,
id_card
,
password
}
=
input
;
const
user_id
=
ctx
.
userId
;
...
...
@@ -329,26 +330,26 @@ class ApplyService extends Service {
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
}
// 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
);
le
t
order_id
=
order
.
id
;
cons
t
order_id
=
order
.
id
;
//运营商API.创建订单号
let
orderSnI
nfo
=
await
ctx
.
service
.
credit
.
yys
.
getOrderSn
(
phone
);
const
order_sn_i
nfo
=
await
ctx
.
service
.
credit
.
yys
.
getOrderSn
(
phone
);
if
(
orderSnInfo
.
code
!==
0
)
{
ctx
.
failed
(
'getOrderSn error msg:'
+
orderSnInfo
.
msg
);
}
le
t
addYysOrder
=
{
const
order_sn
=
order_sn_info
.
data
.
orderSn
;
cons
t
addYysOrder
=
{
order_id
,
user_id
,
app_type_id
,
...
...
@@ -358,15 +359,30 @@ class ApplyService extends Service {
phone
,
id_card
,
password
,
r_order_sn
:
order
SnInfo
.
data
.
orderS
n
,
r_order_sn
:
order
_s
n
,
order_sn_operator
:
orderSnInfo
.
data
.
operator
}
let
YysOrderI
nfo
=
await
ctx
.
prometheusModel
.
CreditYysOrder
.
create
(
addYysOrder
);
ret
.
order_sn
=
orderSnI
nfo
.
data
.
orderSn
;
const
yys_order_i
nfo
=
await
ctx
.
prometheusModel
.
CreditYysOrder
.
create
(
addYysOrder
);
// ret.order_sn = yys_order_i
nfo.data.orderSn;
return
ret
;
//调用运营商获取验证码接口
const
yys_get_code
=
await
ctx
.
service
.
credit
.
yys
.
getCode
({
password
,
order_sn
});
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);
// }
return
{
order_id
,
report_id
,
first
:
check_second_ret
.
first
,
second
:
check_second_ret
.
second
,
order_sn
};
}
async
createApply
()
{
const
{
ctx
}
=
this
;
...
...
app/service/credit/callrisk.js
View file @
7161837c
...
...
@@ -490,8 +490,23 @@ class CallriskService extends Service {
call_count_array
=
[
'较高'
,
'不符合'
,
'不利于'
];
}
//TODO 计算近6个月每个月通话的城市有几个。
const
call_active_msg
=
`您的夜间通话次数占【
${
call_count_array
[
0
]}
】,【
${
call_count_array
[
1
]}
】日常社交时间,【
${
call_count_array
[
2
]}
】贷款机构对您的放贷评估。您的通话活跃地区【变动较大/变化不大】,您当前个人的社交/社会状态稳定度【较好/一般】,【有利于/不利于】贷款机构对您的放贷评估。`
;
const
call_most_city
=
call_active
.
city_active
.
slice
(
0
,
3
);
let
total_time
=
0
;
let
top_three_city_total_time
=
0
;
for
(
let
i
in
call_most_city
)
{
const
call_city
=
call_most_city
[
i
];
top_three_city_total_time
+=
call_city
.
call_time
;
}
for
(
let
j
in
call_active
.
city_active
)
{
const
call
=
call_active
.
city_active
[
j
];
total_time
+=
call
.
call_time
;
}
const
percent
=
(
top_three_city_total_time
/
total_time
).
toFixed
(
2
);
let
call_active_text
=
[
'变化不大'
,
'较好'
,
'有利于'
];
if
(
percent
<=
0.6
)
{
call_active_text
=
[
'变动较大'
,
'一般'
,
'不利于'
];
}
const
call_active_msg
=
`您的夜间通话次数占【
${
call_count_array
[
0
]}
】,【
${
call_count_array
[
1
]}
】日常社交时间,【
${
call_count_array
[
2
]}
】贷款机构对您的放贷评估。您的通话活跃地区【
${
call_active_text
[
0
]}
】,您当前个人的社交/社会状态稳定度【
${
call_active_text
[
1
]}
】,【
${
call_active_text
[
2
]}
】贷款机构对您的放贷评估。`
;
//通话行为解析
let
call_behavior_array
=
[
'较少'
,
'稳定'
,
'有利于'
,];
...
...
@@ -510,6 +525,77 @@ class CallriskService extends Service {
}
//获取验证码
async
getCode
(
order_id
)
{
const
{
ctx
}
=
this
;
const
user_id
=
ctx
.
userId
;
// const { order_id } = input;
const
yys_order_info
=
await
ctx
.
prometheusModel
.
CreditYysOrder
.
one
({
where
:
{
order_id
,
user_id
}
});
if
(
!
yys_order_info
||
!
yys_order_info
.
id
)
{
ctx
.
failed
(
'error order_sn'
);
}
const
password
=
yys_order_info
.
password
;
const
params
=
{
order_sn
,
password
};
const
ret
=
await
ctx
.
service
.
credit
.
yys
.
getCode
(
params
);
if
(
ret
.
code
!==
0
)
{
ctx
.
failed
(
'getCode error msg:'
+
ret
.
msg
);
}
return
{
order_id
};
}
//提交任务给运营商
async
commitYys
(
input
)
{
const
{
ctx
}
=
this
;
const
user_id
=
ctx
.
userId
;
const
{
order_id
,
code
}
=
input
;
const
yys_order
=
await
ctx
.
prometheusModel
.
CreditYysOrder
.
one
({
where
:
{
order_id
,
user_id
}
});
// const order_id = yys_order.order_id;
const
order_info
=
await
ctx
.
prometheusModel
.
CreditOrder
.
one
({
where
:
{
id
:
order_id
,
user_id
}
});
const
input
=
{
phone
:
order_info
.
phone
,
name
:
order_info
.
name
,
ID
:
order_info
.
id_card
,
password
:
yys_order
.
password
,
phoneCode
:
code
,
};
const
operator
=
yys_order
.
operator
;
const
params
=
operator
.
params
;
let
request_params
=
{};
for
(
let
i
in
params
)
{
const
column
=
params
[
i
].
name
;
request_params
[
column
]
=
input
[
column
];
}
const
request_data
=
{
orderSn
,
params
:
request_params
};
const
yys_commit
=
await
ctx
.
service
.
credit
.
yys
.
commit
(
request_data
);
if
(
yys_commit
.
code
!==
0
)
{
ctx
.
failed
(
'commit error msg:'
+
yys_commit
.
msg
);
}
return
{
order_id
};
}
//查询任务状态
async
queryTaskStatus
(
order_id
)
{
const
{
ctx
}
=
this
;
const
code_array
=
[];
const
yys_order
=
await
ctx
.
prometheusModel
.
CreditYysOrder
({
where
:
{
order_id
}
});
const
order_sn
=
yys_order
.
r_order_sn
;
const
query_resp
=
await
ctx
.
service
.
credit
.
yys
.
query
(
order_sn
);
const
r_code
=
query_resp
.
code
;
if
(
r_code
===
0
)
{
const
yys_report_data
=
await
ctx
.
service
.
credit
.
yys
.
getData
(
order_sn
);
}
return
query_resp
;
}
...
...
app/service/credit/yys.js
View file @
7161837c
...
...
@@ -17,7 +17,7 @@ class YysService extends Service {
let
params
=
{
phone
:
phone
}
let
url
=
this
.
config
.
NODE_BASE_URL
+
'/getorderSn'
+
'?appKey='
+
this
.
config
.
YYS_APP_KEY
;
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
)
});
return
resp
.
data
;
...
...
@@ -35,7 +35,7 @@ class YysService extends Service {
password
:
params
.
password
}
}
let
url
=
this
.
config
.
NODE_BASE_URL
+
'/getCode'
+
'?appKey='
+
this
.
config
.
YYS_APP_KEY
;
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
)
});
return
resp
.
data
;
...
...
@@ -47,15 +47,16 @@ class YysService extends Service {
* @param {*} params 需要提交的参数,根据getOrderSn的operator来确定需要的参数
*/
async
commit
(
params
)
{
const
{
ctx
}
=
this
;
let
params
=
{
orderSn
:
params
.
order_sn
,
params
:
{
password
:
params
.
password
}
}
let
url
=
this
.
config
.
NODE_BASE_URL
+
'
/commit'
+
'?appKey='
+
this
.
config
.
YYS_APP_KEY
;
le
t
resp
=
await
ctx
.
helper
.
send_request
(
url
,
params
,
{
method
:
'POST'
});
//
let params = {
//
orderSn: params.order_sn,
//
params: {
//
password: params.password
//
}
//
}
const
url
=
this
.
config
.
NODE_BASE_URL
+
'/yys_api
/commit'
+
'?appKey='
+
this
.
config
.
YYS_APP_KEY
;
cons
t
resp
=
await
ctx
.
helper
.
send_request
(
url
,
params
,
{
method
:
'POST'
});
ctx
.
logger
.
info
({
url
:
JSON
.
stringify
(
resp
)
});
return
resp
.
data
;
}
...
...
@@ -69,12 +70,34 @@ class YysService extends Service {
let
params
=
{
orderSn
:
orderSn
,
}
let
url
=
this
.
config
.
NODE_BASE_URL
+
'/query'
+
'?appKey='
+
this
.
config
.
YYS_APP_KEY
;
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
)
});
return
resp
.
data
;
}
/**
* 获取报告
* @param {*} orderSn 创建订单时生成的订单号
*/
async
getData
(
orderSn
)
{
const
{
ctx
}
=
this
;
const
data
=
{
sign
:
''
,
params
:
{
appKey
:
this
.
config
.
YYS_APP_KEY
,
timestamp
:
new
Date
().
getTime
(),
token
:
''
,
orderSn
,
}
};
let
url
=
this
.
config
.
NODE_BASE_URL
+
'/yys_api/getData'
+
'?appKey='
+
this
.
config
.
YYS_APP_KEY
;
let
resp
=
await
ctx
.
helper
.
send_request
(
url
,
data
,
{
method
:
'POST'
});
ctx
.
logger
.
info
({
url
:
JSON
.
stringify
(
resp
)
});
return
resp
.
data
;
}
}
...
...
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