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
730aa56a
Commit
730aa56a
authored
Oct 10, 2019
by
Hsinli
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of t-git.51gjj.com:fangbin/51business
parents
66492aec
838d8d50
Pipeline
#14659
passed with stage
in 34 seconds
Changes
9
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
167 additions
and
107 deletions
+167
-107
test.js
app/controller/common/test.js
+1
-1
callrisk.js
app/controller/credit/callrisk.js
+2
-1
order.js
app/controller/credit/order.js
+1
-1
institution.js
app/service/course/institution.js
+96
-76
option.js
app/service/course/option.js
+2
-2
apply.js
app/service/credit/apply.js
+17
-8
callrisk.js
app/service/credit/callrisk.js
+39
-10
yys.js
app/service/credit/yys.js
+8
-7
config.local.js
config/config.local.js
+1
-1
No files found.
app/controller/common/test.js
View file @
730aa56a
...
...
@@ -6,7 +6,7 @@ class TestController extends Controller {
const
{
service
,
ctx
}
=
this
;
const
from
=
{
lng
:
120.069206
,
lat
:
30.291121
};
const
to
=
{
lng
:
120.212997
,
lat
:
30.29133
};
const
ret
=
await
service
.
course
.
lbs
.
getLBSDistance
(
'
driving'
,
from
,
[
to
]);
const
ret
=
await
service
.
course
.
lbs
.
getLBSDistance
(
'
walking'
,
from
,
[
to
,
to
]);
ctx
.
success
(
ret
);
}
}
...
...
app/controller/credit/callrisk.js
View file @
730aa56a
...
...
@@ -39,7 +39,8 @@ class CallriskController extends Controller {
name
:
{
type
:
'string'
,
required
:
true
},
phone
:
{
type
:
'string'
,
required
:
true
},
id_card
:
{
type
:
'string'
,
required
:
true
},
password
:
{
type
:
'string'
,
required
:
true
}
password
:
{
type
:
'string'
,
required
:
true
},
net
:
{
type
:
'string'
,
required
:
true
},
}
ctx
.
validate
(
rule
,
input_params
);
const
result
=
await
ctx
.
service
.
credit
.
apply
.
applyCallrisk
(
input_params
);
...
...
app/controller/credit/order.js
View file @
730aa56a
...
...
@@ -34,7 +34,7 @@ class OrderController extends Controller {
const
{
method
,
order_id
,
reject_url
}
=
input_params
;
let
result
=
await
ctx
.
service
.
credit
.
order
.
unifiedOrder
(
method
,
order_id
);
// result.reject_url = reject_url;
result
.
url
=
`
${
result
.
url
}
&
py=#shanp.com&
redirect_url=
${
reject_url
}
`
;
result
.
url
=
`
${
result
.
url
}
&redirect_url=
${
reject_url
}
`
;
ctx
.
success
({
result
});
}
...
...
app/service/course/institution.js
View file @
730aa56a
...
...
@@ -8,20 +8,20 @@ const moment = require('moment');
class
InstitutionService
extends
Service
{
//
机构列表页
//
机构列表页
async
getInstitutions
(
input
)
{
const
{
ctx
}
=
this
;
const
user_uuid
=
ctx
.
userUuid
;
const
{
cats
,
ages
,
lat
,
lng
,
address
}
=
input
;
const
where_institutions
=
input
.
institutions
;
//
保存定位记录
//
保存定位记录
if
(
address
&&
lat
&&
lng
)
{
ctx
.
classModel
.
CourseLogUserGps
.
add
({
user_uuid
,
address
,
lat
,
lng
});
}
//
处理条件过滤条件
le
t
where
=
{
status
:
1
,
is_deleted
:
0
};
//
处理条件过滤条件
cons
t
where
=
{
status
:
1
,
is_deleted
:
0
};
if
(
Number
(
cats
))
{
const
cat_ret
=
await
ctx
.
classModel
.
CourseCat
.
one
({
where
:
{
id
:
cats
}
});
const
cat_id
=
cat_ret
.
id
;
...
...
@@ -30,7 +30,7 @@ class InstitutionService extends Service {
const
next_next_level
=
cat_level
+
2
;
const
next_cat
=
await
ctx
.
classModel
.
CourseCat
.
all
({
where
:
{
level
:
next_level
,
parent_id
:
cat_id
}
});
const
next_next_cat
=
await
ctx
.
classModel
.
CourseCat
.
all
({
where
:
{
level
:
next_next_level
,
first_id
:
cat_id
}
});
let
cat_ids
=
[
cat_id
,
];
let
cat_ids
=
[
cat_id
];
cat_ids
=
cat_ids
.
concat
(
R
.
pluck
(
'id'
,
next_cat
)).
concat
(
R
.
pluck
(
'id'
,
next_next_cat
));
const
institutions
=
await
ctx
.
classModel
.
CourseInstitutionToCat
.
all
({
where
:
{
cat_id
:
{
$in
:
cat_ids
}
}
});
where
.
id
=
{
$in
:
R
.
pluck
(
'institution_id'
,
institutions
)
};
...
...
@@ -43,15 +43,15 @@ class InstitutionService extends Service {
where
.
corner
=
{
$ne
:
''
};
}
//
关联校区表查找信息
const
include
=
[{
model
:
ctx
.
classModel
.
CourseArea
,
where
:
{
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'institution_id'
,
'name'
,
'address'
,
'lat'
,
'lng'
]
}];
const
attributes
=
[
'id'
,
'name'
,
'type'
,
'establishment_time'
,
'class_type'
,
'teacher_count'
,
'teacher_experience'
,
'corner'
,
'min_age'
,
'max_age'
,
'price'
,
'characteristic'
,
];
//
关联校区表查找信息
const
include
=
[{
model
:
ctx
.
classModel
.
CourseArea
,
where
:
{
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'institution_id'
,
'name'
,
'address'
,
'lat'
,
'lng'
]
}];
const
attributes
=
[
'id'
,
'name'
,
'type'
,
'establishment_time'
,
'class_type'
,
'teacher_count'
,
'teacher_experience'
,
'corner'
,
'min_age'
,
'max_age'
,
'price'
,
'characteristic'
];
const
institutions
=
await
ctx
.
classModel
.
CourseInstitution
.
findAll
({
attributes
,
include
,
where
});
const
institution_area_list
=
await
this
.
getInstitutionAreaList
(
institutions
);
//
将校区表处理成数组
const
institution_area_list
=
await
this
.
getInstitutionAreaList
(
institutions
);
//
将校区表处理成数组
// const from = { lat, lng };
const
area_lbs
=
await
this
.
computeDistance
(
institution_area_list
,
{
lat
,
lng
});
//
计算距离信息
const
institution_areas
=
await
this
.
findShortestDistanceAreas
(
institution_area_list
,
area_lbs
);
//
查找最短距离并输出
const
area_lbs
=
await
this
.
computeDistance
(
institution_area_list
,
{
lat
,
lng
});
//
计算距离信息
const
institution_areas
=
await
this
.
findShortestDistanceAreas
(
institution_area_list
,
area_lbs
);
//
查找最短距离并输出
const
ret
=
await
this
.
formatInstitutions
(
institution_areas
);
return
ret
;
...
...
@@ -71,11 +71,11 @@ class InstitutionService extends Service {
const
teachers
=
await
this
.
getTeachers
({
institution_id
,
limit
:
6
});
const
classes
=
await
this
.
getClasses
({
institution_id
,
limit
:
4
});
const
institution_images
=
await
ctx
.
classModel
.
CourseImages
.
all
({
where
:
{
type
:
1
,
type_id
:
institution_id
}
});
//
图片
const
institution_images
=
await
ctx
.
classModel
.
CourseImages
.
all
({
where
:
{
type
:
1
,
type_id
:
institution_id
}
});
//
图片
//
处理详情页信息
const
current_area
=
await
ctx
.
classModel
.
CourseArea
.
one
({
id
:
area_id
});
let
institution_detail
=
await
this
.
formatInstitutions
([
institution
]);
//
处理详情页信息
const
current_area
=
await
ctx
.
classModel
.
CourseArea
.
one
({
where
:
{
id
:
area_id
}
});
let
institution_detail
=
await
this
.
formatInstitutions
([
institution
]);
institution_detail
=
institution_detail
[
0
];
institution_detail
.
address
=
current_area
.
address
;
institution_detail
.
phone
=
current_area
.
phone
;
...
...
@@ -84,13 +84,13 @@ class InstitutionService extends Service {
institution_detail
.
honor
=
institution
.
honor
;
institution_detail
.
is_collect
=
0
;
//
计算校区距离
const
areas_ret
=
await
this
.
getInstitutionAreas
({
institution_id
,
limit
:
1000
});
//
校区
//
计算校区距离
const
areas_ret
=
await
this
.
getInstitutionAreas
({
institution_id
,
limit
:
1000
});
//
校区
const
area_rows
=
areas_ret
.
rows
;
const
area_lbs
=
(
lat
>
0
||
lng
>
0
)
?
await
this
.
computeDistance
(
area_rows
,
{
lat
,
lng
})
:
[];
//
计算距离信息
cons
t
areas
=
[];
const
area_lbs
=
(
lat
>
0
||
lng
>
0
)
?
await
this
.
computeDistance
(
area_rows
,
{
lat
,
lng
})
:
[];
//
计算距离信息
le
t
areas
=
[];
for
(
le
t
i
in
area_rows
)
{
for
(
cons
t
i
in
area_rows
)
{
const
area
=
area_rows
[
i
];
const
lbs
=
i
<
area_lbs
.
length
?
area_lbs
[
i
]
:
{
distance
:
0
,
duration
:
0
,
travel_method
:
''
};
...
...
@@ -102,7 +102,7 @@ class InstitutionService extends Service {
if
(
lbs
.
travel_method
===
'walking'
)
{
travel_tips
=
`距我
${
distance
}
km,步行
${
duration
}
分钟`
;
}
if
(
distance
===
0
&&
duration
===
0
)
{
if
(
Number
(
distance
)
===
0
&&
duration
===
0
)
{
travel_tips
=
'暂无法计算出距离'
;
}
if
(
area
.
id
==
area_id
&&
area
.
institution_id
==
institution_id
)
{
...
...
@@ -119,20 +119,36 @@ class InstitutionService extends Service {
travel_tips
,
lat
:
area
.
lat
,
lng
:
area
.
lng
,
distance
:
Number
(
distance
)
===
0
?
999999999.0
:
parseFloat
(
distance
),
});
}
areas
=
_
.
orderBy
(
areas
,
[
'distance'
],
[
'asc'
]);
//
是否收藏过
//
是否收藏过
const
collection_ret
=
await
ctx
.
classModel
.
CourseUserCollection
.
one
({
where
:
{
user_uuid
,
institution_id
,
is_deleted
:
0
}
});
if
(
collection_ret
&&
collection_ret
.
id
)
{
institution_detail
.
is_collect
=
1
;
}
//
处理图片
//
处理图片
const
photo_album
=
[];
for
(
let
i
in
institution_images
)
{
const
photo_check
=
[];
// 去重
for
(
const
i
in
institution_images
)
{
const
institution_image
=
institution_images
[
i
];
if
(
institution_image
.
is_video
>
0
)
{
if
(
photo_check
.
includes
(
institution_image
.
video_url
))
{
continue
;
}
else
{
photo_check
.
push
(
institution_image
.
video_url
);
}
}
else
{
if
(
photo_check
.
includes
(
institution_image
.
image_url
))
{
continue
;
}
else
{
photo_check
.
push
(
institution_image
.
image_url
);
}
}
photo_album
.
push
({
image
:
institution_image
.
image_url
,
is_video
:
institution_image
.
is_video
,
...
...
@@ -141,15 +157,15 @@ class InstitutionService extends Service {
}
institution_detail
.
photo_album
=
photo_album
;
return
{
institution_detail
,
teachers
:
teachers
.
rows
,
classes
:
classes
.
rows
,
areas
:
areas
};
return
{
institution_detail
,
teachers
:
teachers
.
rows
,
classes
:
classes
.
rows
,
areas
};
}
async
getTeacher
(
teacher_id
)
{
const
{
ctx
}
=
this
;
const
where
=
{
id
:
teacher_id
};
le
t
teacher
=
await
ctx
.
classModel
.
CourseTeacher
.
one
({
where
});
teacher
.
dataValues
.
point_tags
=
teacher
.
point
?
teacher
.
point
.
split
(
';
'
)
:
[];
cons
t
teacher
=
await
ctx
.
classModel
.
CourseTeacher
.
one
({
where
});
teacher
.
dataValues
.
point_tags
=
teacher
.
point
?
teacher
.
point
.
split
(
',
'
)
:
[];
teacher
.
dataValues
.
work_experience_tags
=
teacher
.
work_experience
?
teacher
.
work_experience
.
split
(
';'
)
:
[];
const
institution
=
await
ctx
.
classModel
.
CourseInstitution
.
find
({
where
:
{
id
:
teacher
.
institution_id
}
});
...
...
@@ -162,10 +178,11 @@ class InstitutionService extends Service {
const
{
ctx
}
=
this
;
const
where
=
{
id
:
class_id
};
le
t
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
(
';
'
)
:
[];
cons
t
classs
=
await
ctx
.
classModel
.
CourseClass
.
one
({
where
});
classs
.
dataValues
.
age_text
=
Number
(
classs
.
max_age
)
>
0
?
`
${
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
.
class_period
=
classs
.
class_period
>
0
?
classs
.
class_period
:
''
;
return
classs
;
}
...
...
@@ -173,14 +190,14 @@ class InstitutionService extends Service {
async
getTeachers
(
input
)
{
const
{
ctx
}
=
this
;
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'avatar'
,
'teacher_experience'
,
'lesson'
,
'educational_background'
,
'certificate'
];
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'avatar'
,
'teacher_experience'
,
'lesson'
,
'educational_background'
,
'certificate'
];
const
{
institution_id
,
page
,
limit
}
=
input
;
const
where
=
{
institution_id
};
const
teachers
=
await
ctx
.
classModel
.
CourseTeacher
.
list
({
attributes
,
page
,
limit
,
where
});
const
ret
=
[];
for
(
let
i
in
teacher
s
)
{
const
teacher
=
teacher
s
[
i
];
for
(
const
i
in
teachers
.
row
s
)
{
const
teacher
=
teachers
.
row
s
[
i
];
ret
.
push
({
id
:
teacher
.
id
,
institution_id
:
teacher
.
institution_id
,
...
...
@@ -193,36 +210,37 @@ class InstitutionService extends Service {
});
}
return
ret
;
return
{
page
,
count
:
ret
.
length
,
rows
:
ret
}
;
}
async
getClasses
(
input
)
{
const
{
ctx
}
=
this
;
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'type'
,
'price'
];
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'type'
,
'price'
];
const
{
institution_id
,
page
,
limit
}
=
input
;
const
where
=
{
institution_id
};
const
classes
=
await
ctx
.
classModel
.
CourseClass
.
list
({
attributes
,
page
,
limit
,
where
});
const
p_class_images
=
[];
//
获取图片信息
for
(
le
t
j
in
classes
.
rows
)
{
//
获取图片信息
for
(
cons
t
j
in
classes
.
rows
)
{
const
classs
=
classes
.
rows
[
j
];
p_class_images
[
j
]
=
ctx
.
classModel
.
CourseImages
.
one
({
where
:
{
type
:
2
,
type_id
:
classs
.
id
,
is_cover
:
1
,
is_video
:
0
}
});
p_class_images
[
j
]
=
ctx
.
classModel
.
CourseImages
.
one
({
where
:
{
type
:
2
,
type_id
:
classs
.
id
,
is_video
:
0
}
});
}
const
class_images
=
await
Promise
.
all
(
p_class_images
).
then
(
result
=>
{
//
等待所有异步内容获取完成
const
class_images
=
await
Promise
.
all
(
p_class_images
).
then
(
result
=>
{
//
等待所有异步内容获取完成
return
result
;
}).
catch
(
error
=>
{
ctx
.
failed
(
error
);
});
//
格式化课程信息
le
t
ret
=
[];
for
(
le
t
i
in
classes
.
rows
)
{
le
t
classs
=
classes
.
rows
[
i
];
classs
.
dataValues
.
image
=
class_images
[
i
]
?
class_images
[
i
].
image_url
:
''
;
;
//
格式化课程信息
cons
t
ret
=
[];
for
(
cons
t
i
in
classes
.
rows
)
{
cons
t
classs
=
classes
.
rows
[
i
];
classs
.
dataValues
.
image
=
class_images
[
i
]
?
class_images
[
i
].
image_url
:
''
;
classs
.
dataValues
.
price_text
=
classs
.
price
?
classs
.
price
:
'现场咨询'
;
classs
.
dataValues
.
class_period
=
classs
.
class_period
>
0
?
classs
.
class_period
:
''
;
ret
.
push
(
classs
);
}
...
...
@@ -233,7 +251,7 @@ class InstitutionService extends Service {
async
getInstitutionAreas
(
input
)
{
const
{
ctx
}
=
this
;
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'address'
,
'phone'
,
'lat'
,
'lng'
];
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'address'
,
'phone'
,
'lat'
,
'lng'
];
const
{
institution_id
,
page
,
limit
}
=
input
;
const
where
=
{
institution_id
};
const
areas
=
await
ctx
.
classModel
.
CourseArea
.
list
({
attributes
,
page
,
limit
,
where
});
...
...
@@ -242,7 +260,7 @@ class InstitutionService extends Service {
}
//
机构列表 并有多校区 {id:1,..., course_areas:[{},{}]
//
机构列表 并有多校区 {id:1,..., course_areas:[{},{}]
async
getInstitutionAreaList
(
institutions
)
{
const
{
ctx
}
=
this
;
...
...
@@ -252,11 +270,11 @@ class InstitutionService extends Service {
}
const
ret
=
[];
for
(
le
t
i
in
institutions
)
{
le
t
institution
=
institutions
[
i
];
for
(
cons
t
i
in
institutions
)
{
cons
t
institution
=
institutions
[
i
];
if
(
!
institution
.
course_areas
||
institution
.
course_areas
.
length
===
0
)
continue
;
const
course_areas
=
institution
.
course_areas
;
for
(
le
t
j
in
course_areas
)
{
for
(
cons
t
j
in
course_areas
)
{
const
course_area
=
course_areas
[
j
];
ret
.
push
({
id
:
institution
.
id
,
...
...
@@ -302,29 +320,29 @@ class InstitutionService extends Service {
const
lat
=
from
.
lat
;
const
lng
=
from
.
lng
;
// console.info({ lat, lng });
//
计算距离
//
计算距离
const
driving_results
=
await
ctx
.
service
.
course
.
lbs
.
getLBSDistance
(
'driving'
,
{
lat
,
lng
},
lbs_array
);
const
walking_results
=
await
ctx
.
service
.
course
.
lbs
.
getLBSDistance
(
'walking'
,
{
lat
,
lng
},
lbs_array
);
if
(
!
walking_results
.
results
&&
!
driving_results
.
results
)
{
return
[];
}
//
处理距离结果
//
处理距离结果
const
drivings
=
driving_results
.
results
.
map
(
item
=>
{
const
distance
=
(
item
.
distance
/
1000
).
toFixed
(
1
);
const
duration
=
Math
.
ceil
(
item
.
duration
/
60
);
return
{
distance
:
distance
,
duration
:
duration
}
return
{
distance
,
duration
};
});
const
walkings
=
walking_results
.
results
.
map
(
item
=>
{
const
distance
=
(
item
.
distance
/
1000
).
toFixed
(
2
);
const
duration
=
Math
.
ceil
(
item
.
distance
/
80
);
return
{
distance
:
distance
,
duration
:
duration
}
return
{
distance
,
duration
};
});
//
格式化 判断步行或驾车
//
格式化 判断步行或驾车
const
results
=
[];
for
(
le
t
i
in
lbs_array
)
{
le
t
lbs
=
lbs_array
[
i
];
for
(
cons
t
i
in
lbs_array
)
{
cons
t
lbs
=
lbs_array
[
i
];
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
;
...
...
@@ -355,10 +373,10 @@ class InstitutionService extends Service {
// const institution_lbs = await this.computeDistance(areas_list);
const
institution_lbs
=
areas_list
;
for
(
le
t
i
in
institution_areas
)
{
for
(
cons
t
i
in
institution_areas
)
{
le
t
institution_area
=
institution_areas
[
i
];
//
TODO 校验经纬度
cons
t
institution_area
=
institution_areas
[
i
];
//
TODO 校验经纬度
const
lbs
=
i
<
institution_lbs
.
length
?
institution_lbs
[
i
]
:
{
distance
:
0
,
duration
:
0
,
travel_method
:
''
};
const
area_name
=
institution_area
.
area_name
;
...
...
@@ -368,14 +386,14 @@ class InstitutionService extends Service {
if
(
lbs
.
travel_method
===
'walking'
)
{
travel_tips
=
`
${
area_name
}
,距我
${
distance
}
km,步行
${
duration
}
分钟`
;
}
if
(
distance
===
0
&&
duration
===
0
)
{
if
(
Number
(
distance
)
===
0
&&
Number
(
duration
)
===
0
)
{
travel_tips
=
'暂无法计算出距离'
;
}
// area.distance = distance;
// area.duration = duration;
// area.travel_tips = travel_tips;
institution_area
.
distance
=
distance
;
institution_area
.
distance
=
Number
(
distance
)
===
0
?
999999999.0
:
parseFloat
(
distance
)
;
institution_area
.
duration
=
duration
;
institution_area
.
travel_tips
=
travel_tips
;
...
...
@@ -383,8 +401,8 @@ class InstitutionService extends Service {
}
const
results
=
[];
ret
=
_
.
orderBy
(
ret
,
[
'distance'
],
[
'asc'
]);
for
(
le
t
j
in
ret
)
{
ret
=
_
.
orderBy
(
ret
,
[
'distance'
],
[
'asc'
]);
for
(
cons
t
j
in
ret
)
{
const
val
=
ret
[
j
];
if
(
!
results
[
val
.
id
])
{
results
[
val
.
id
]
=
val
;
...
...
@@ -401,20 +419,20 @@ class InstitutionService extends Service {
return
[];
}
//
处理机构图片
//
处理机构图片
const
p_institution_images
=
[];
for
(
le
t
j
in
institutions
)
{
for
(
cons
t
j
in
institutions
)
{
const
institution
=
institutions
[
j
];
p_institution_images
[
j
]
=
ctx
.
classModel
.
CourseImages
.
one
({
where
:
{
type
:
1
,
type_id
:
institution
.
id
,
is_cover
:
1
,
is_video
:
0
}
});
}
const
institution_images
=
await
Promise
.
all
(
p_institution_images
).
then
(
result
=>
{
//
等待所有异步内容获取完成
const
institution_images
=
await
Promise
.
all
(
p_institution_images
).
then
(
result
=>
{
//
等待所有异步内容获取完成
return
result
;
}).
catch
(
error
=>
{
ctx
.
failed
(
error
);
});
cons
t
ret
=
[];
for
(
le
t
i
in
institutions
)
{
le
t
ret
=
[];
for
(
cons
t
i
in
institutions
)
{
const
institution
=
institutions
[
i
];
// const course_areas = institution.course_areas;
// if (!course_areas || course_areas.length === 0) continue;
...
...
@@ -430,7 +448,12 @@ class InstitutionService extends Service {
if
(
Number
(
institution
.
establishment_time
))
{
tags
.
push
(
'成立'
+
build_time
+
'年'
);
}
const
image
=
institution_images
[
i
]
?
institution_images
[
i
].
image_url
:
''
;
let
image
=
institution_images
[
i
]
?
institution_images
[
i
].
image_url
:
''
;
// 取不到封面图就从详情图列表里选一张
if
(
ctx
.
isEmpty
(
image
))
{
const
tmpImage
=
await
ctx
.
classModel
.
CourseImages
.
one
({
where
:
{
type
:
1
,
type_id
:
institution
.
id
,
is_cover
:
0
,
is_video
:
0
}
});
image
=
ctx
.
isEmpty
(
tmpImage
)
?
''
:
tmpImage
.
image_url
;
}
ret
.
push
({
id
:
institution
.
id
,
...
...
@@ -445,21 +468,18 @@ class InstitutionService extends Service {
max_age
:
institution
.
max_age
,
price
:
institution
.
price
?
institution
.
price
:
0
,
tags
,
area_id
:
institution
.
area_id
,
//
校区id TODO
travel_tips
:
institution
.
travel_tips
,
//
TODO
area_id
:
institution
.
area_id
,
//
校区id TODO
travel_tips
:
institution
.
travel_tips
,
//
TODO
characteristic
:
institution
.
characteristic
?
institution
.
characteristic
:
''
,
distance
:
institution
.
distance
,
});
}
ret
=
_
.
orderBy
(
ret
,
[
'distance'
],
[
'asc'
]);
return
ret
;
}
}
module
.
exports
=
InstitutionService
;
app/service/course/option.js
View file @
730aa56a
...
...
@@ -39,7 +39,7 @@ class OptionService extends Service {
cats
:
tree_cats
,
ages
:
AGE_CATS
,
institutions
:
INSTITUTION_TYPE
,
}
};
return
options
;
}
...
...
@@ -58,7 +58,7 @@ class OptionService extends Service {
newNode
.
level
=
node
.
level
;
newNode
.
value
=
node
.
id
;
newNode
.
_child
=
this
.
getTrees
(
data
,
node
.
id
);
if
(
newNode
.
_child
.
length
!==
0
)
newNode
.
_child
.
unshift
({
id
:
0
,
name
:
'全部'
,
value
:
0
});
if
(
newNode
.
_child
.
length
!==
0
)
newNode
.
_child
.
unshift
({
id
:
0
,
name
:
'全部'
,
value
:
node
.
id
});
ret
.
push
(
newNode
);
}
}
...
...
app/service/credit/apply.js
View file @
730aa56a
...
...
@@ -58,20 +58,29 @@ class ApplyService extends Service {
return
ret
;
}
/**
* 进入个人通话查询页面
*/
async
callriskInit
()
{
const
{
ctx
}
=
this
;
if
(
!
ctx
.
userId
)
{
ctx
.
failed
(
'登录异常'
);
}
let
ret
=
{
have_be_pay_order
:
false
,
order_id
:
null
,
phone
:
''
,
placeholder
:
{
name
:
''
,
id_card
:
''
id_card
:
''
,
}
}
let
bePayOrder
=
await
ctx
.
service
.
credit
.
order
.
getBePayOrder
(
'callrisk'
);
if
(
bePayOrder
.
length
!==
0
)
{
ret
.
have_be_pay_order
=
true
;
ret
.
order_id
=
bePayOrder
[
0
].
id
;
ret
.
phone
=
bePayOrder
[
0
].
phone
.
substring
(
0
,
3
)
+
'****'
+
bePayOrder
[
0
].
phone
.
substring
(
7
,
11
)
}
//第一次查询成功的订单,反显姓名和身份证
...
...
@@ -330,7 +339,7 @@ class ApplyService extends Service {
async
applyCallrisk
(
input
)
{
const
{
ctx
}
=
this
;
const
{
name
,
phone
,
id_card
,
password
}
=
input
;
const
{
name
,
phone
,
id_card
,
password
,
net
}
=
input
;
const
user_id
=
ctx
.
userId
;
const
app_type_id
=
ctx
.
appTypeId
;
const
app_user_id
=
ctx
.
appUserId
;
...
...
@@ -353,7 +362,7 @@ class ApplyService extends Service {
const
order_id
=
order
.
id
;
//创建yys-order apply 记录
const
apply
=
await
this
.
createYysApply
({
name
,
phone
,
id_card
,
password
,
order_id
});
const
apply
=
await
this
.
createYysApply
({
name
,
phone
,
id_card
,
password
,
net
,
order_id
});
const
order_sn
=
apply
.
r_order_id
;
//第一次调用运营商获取验证码接口
...
...
@@ -392,10 +401,10 @@ class ApplyService extends Service {
const
app_type_id
=
ctx
.
appTypeId
;
const
app_user_id
=
ctx
.
appUserId
;
const
app_id
=
ctx
.
appId
;
const
{
name
,
phone
,
id_card
,
password
,
order_id
}
=
input
;
const
{
name
,
phone
,
id_card
,
password
,
net
,
order_id
}
=
input
;
//运营商API.创建订单号
const
order_sn_info
=
await
ctx
.
service
.
credit
.
yys
.
getOrderSn
(
phone
);
const
order_sn_info
=
await
ctx
.
service
.
credit
.
yys
.
getOrderSn
(
{
phone
,
net
}
);
if
(
order_sn_info
.
code
!==
0
)
{
ctx
.
failed
(
'getOrderSn error msg:'
+
order_sn_info
.
msg
);
}
...
...
@@ -430,14 +439,14 @@ class ApplyService extends Service {
let
orderFilter
=
{
arrtibutes
:
[
'id'
,
'name'
,
'id_card'
],
where
:
{
user_id
:
ctx
.
userI
d
,
user_id
:
user_i
d
,
state
:
'已支付'
,
type
:
2
,
type
:
type
,
valid
:
1
}
}
let
orderInfo
=
await
ctx
.
prometheusModel
.
CreditOrder
.
findOne
(
orderFilter
);
if
(
orderInfo
!==
null
&&
(
inputParams
.
name
!==
orderInfo
.
name
||
inputParams
.
id_card
!==
orderInfo
.
id_card
))
{
if
(
orderInfo
!==
null
&&
(
name
!==
orderInfo
.
name
||
id_card
!==
orderInfo
.
id_card
))
{
ctx
.
failed
(
'仅供本人查询使用,无法查询其他人信息'
);
}
...
...
app/service/credit/callrisk.js
View file @
730aa56a
...
...
@@ -82,7 +82,7 @@ class CallriskService extends Service {
//订单是否在有效期内
const
report_valid
=
await
ctx
.
service
.
credit
.
order
.
getReportValid
(
'callrisk'
,
report_id
);
cons
t
report
=
{
le
t
report
=
{
basics
:
{
data
:
basics
},
call_overview
:
{
data
:
call_overview
},
call_type
:
{
data
:
call_type
},
...
...
@@ -90,6 +90,7 @@ class CallriskService extends Service {
call_behavior
:
{
data
:
call_behavior
},
report_valid
,
};
report
.
basics
.
data
.
call_result_assessment
=
await
this
.
getEvaluationLevel
(
report
);
const
ret
=
this
.
formatHeadExplainMsg
(
report
);
...
...
@@ -138,9 +139,30 @@ class CallriskService extends Service {
const
{
ctx
}
=
this
;
const
call_behavior
=
await
ctx
.
prometheusModel
.
CreditCallriskCallBehavior
.
one
({
where
:
{
report_id
}
});
const
call_behavior_silence_cycles
=
await
ctx
.
prometheusModel
.
CreditCallriskSilenceCycle
.
all
({
where
:
{
report_id
}
});
call_behavior
.
silence_cycle
=
call_behavior
?
[]
:
call_behavior_silence_cycles
;
const
ret
=
{
silence_count_3day
:
call_behavior
.
silence_count_3day
,
silence_time_3day
:
call_behavior
.
silence_time_3day
,
silence_time_rate_3day
:
call_behavior
.
silence_time_rate_3day
,
silence_cycle
:
call_behavior_silence_cycles
,
call_each_other
:
{
active_call_count
:
call_behavior
.
active_call_count
,
passive_call_count
:
call_behavior
.
passive_call_count
,
each_call_count
:
call_behavior
.
each_call_count
,
},
call_rank
:
{
maximum_active_call_count
:
call_behavior
.
maximum_active_call_count
,
maximum_active_call_number
:
call_behavior
.
maximum_active_call_number
,
maximum_active_call_city
:
call_behavior
.
maximum_active_call_city
,
maximum_passive_call_count
:
call_behavior
.
maximum_passive_call_count
,
maximum_passive_call_number
:
call_behavior
.
maximum_passive_call_number
,
maximum_passive_call_city
:
call_behavior
.
maximum_passive_call_city
,
maximum_call_time
:
call_behavior
.
maximum_call_time
,
maximum_call_time_number
:
call_behavior
.
maximum_call_time_number
,
maximum_call_time_city
:
call_behavior
.
maximum_call_time_city
,
},
};
return
call_behavior
;
return
ret
;
}
async
formatReport
()
{
...
...
@@ -338,8 +360,8 @@ class CallriskService extends Service {
const
{
ctx
}
=
this
;
const
basics
=
report
.
basics
.
data
;
const
call_overview
=
report
.
call_overview
.
data
;
//
const call_type = report.call_type.data;
//
const call_active = report.call_active.data;
const
call_type
=
report
.
call_type
.
data
;
const
call_active
=
report
.
call_active
.
data
;
const
call_behavior
=
report
.
call_behavior
.
data
;
//入网时长分数计算
...
...
@@ -357,11 +379,11 @@ class CallriskService extends Service {
//话费分数计算
let
month_fee_sum
=
0
;
for
(
let
i
in
call_overview
.
data
)
{
const
month_call_overview
=
call_overview
.
data
[
i
];
for
(
let
i
in
call_overview
)
{
const
month_call_overview
=
call_overview
[
i
];
month_fee_sum
+=
month_call_overview
.
call_fee_month
;
}
const
fee_avg
=
month_fee_sum
/
call_overview
.
data
.
length
;
//平均月话费
const
fee_avg
=
month_fee_sum
/
call_overview
.
length
;
//平均月话费
let
fee_avg_score
=
0
;
if
(
fee_avg
<
20
)
{
fee_avg_score
=
20
;
...
...
@@ -370,6 +392,12 @@ class CallriskService extends Service {
}
//通话类型分数计算
const
loan_call_count
=
call_type
.
loan_call_count
;
const
bank_call_count
=
call_type
.
bank_call_count
;
const
court_call_count
=
call_type
.
court_call_count
;
const
collection_call_count
=
call_type
.
collection_call_count
;
const
laywer_call_count
=
call_type
.
laywer_call_count
;
const
macao_call_count
=
call_type
.
macao_call_count
;
let
call_type_score
=
0
;
if
(
loan_call_count
>=
1
)
{
call_type_score
+=
7
;
...
...
@@ -391,8 +419,8 @@ class CallriskService extends Service {
}
//通话活跃分数计算
const
call_time_percent
=
night_call_time
/
routine_call_time
;
const
call_count_percent
=
night_call_count
/
routine_call_count
;
const
call_time_percent
=
call_active
.
night_call_time
/
call_active
.
routine_call_time
;
const
call_count_percent
=
call_active
.
night_call_count
/
call_active
.
routine_call_count
;
let
call_time_score
=
0
;
let
call_count_score
=
0
;
if
(
call_time_percent
>=
0.2
)
{
...
...
@@ -426,6 +454,7 @@ class CallriskService extends Service {
call_behavior_socre
=
10
;
}
console
.
info
(
net_time_score
,
fee_avg_score
,
call_type_score
,
call_active_score
,
call_behavior_socre
);
const
sum_score
=
net_time_score
+
fee_avg_score
+
call_type_score
+
call_active_score
+
call_behavior_socre
;
let
call_result_assessment
=
'优质'
;
...
...
app/service/credit/yys.js
View file @
730aa56a
...
...
@@ -12,13 +12,14 @@ class YysService extends Service {
* 创建订单号
* @param {*}
*/
async
getOrderSn
(
phone
)
{
async
getOrderSn
(
{
phone
,
net
}
)
{
const
{
ctx
}
=
this
;
let
params
=
{
phone
:
phone
phone
:
phone
,
net
:
Number
(
net
),
}
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'
});
let
resp
=
await
ctx
.
helper
.
send_request
(
url
,
params
,
{
method
:
'POST'
,
timeout
:
30000
});
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
);
...
...
@@ -43,7 +44,7 @@ class YysService extends Service {
// }
// }
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'
});
let
resp
=
await
ctx
.
helper
.
send_request
(
url
,
params
,
{
method
:
'POST'
,
timeout
:
30000
});
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);
...
...
@@ -65,7 +66,7 @@ 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'
});
const
resp
=
await
ctx
.
helper
.
send_request
(
url
,
params
,
{
method
:
'POST'
,
timeout
:
30000
});
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
;
...
...
@@ -81,7 +82,7 @@ class YysService extends Service {
orderSn
:
orderSn
,
}
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'
});
let
resp
=
await
ctx
.
helper
.
send_request
(
url
,
params
,
{
method
:
'POST'
,
timeout
:
30000
});
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
;
...
...
@@ -106,7 +107,7 @@ class YysService extends Service {
}
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'
});
const
result
=
await
ctx
.
helper
.
send_request
(
url
,
params
,
{
method
:
'POST'
,
timeout
:
30000
});
ctx
.
logger
.
info
(
JSON
.
stringify
({
thxdReport_parmas
:
params
,
thxdReport_result
:
result
}));
return
result
.
data
;
...
...
config/config.local.js
View file @
730aa56a
...
...
@@ -103,7 +103,7 @@ module.exports = appInfo => {
// other sequelize configurations
dialect
:
'mysql'
,
host
:
'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com'
,
database
:
'class_
dev
'
,
database
:
'class_
uat
'
,
username
:
'class_testing'
,
password
:
'WV862L32451I6KD58tU9K'
,
port
:
3306
,
...
...
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