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
3d340875
Commit
3d340875
authored
Sep 25, 2019
by
Hsinli
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of t-git.51gjj.com:fangbin/51business
parents
2c27dfc4
3115c115
Pipeline
#14211
passed with stage
in 20 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
18 deletions
+21
-18
response.js
app/controller/response.js
+13
-8
institution.js
app/service/course/institution.js
+6
-8
user.js
app/service/course/user.js
+2
-2
No files found.
app/controller/response.js
View file @
3d340875
...
...
@@ -16,7 +16,7 @@ class ResponseController extends Controller {
channel_id
:
{
type
:
'string'
,
required
:
true
},
}
ctx
.
validate
(
rule
,
input_params
);
const
channel_alias
=
input_params
.
channel_id
;
if
(
target_url
.
indexOf
(
'?'
)
!==
-
1
)
{
target_url
+=
`&channel_id=
${
channel_alias
}
`
;
...
...
@@ -30,6 +30,7 @@ class ResponseController extends Controller {
const
app_user_id
=
ctx
.
cookies
.
get
(
'app_user_id'
,
{
signed
:
false
});
const
device_id
=
ctx
.
cookies
.
get
(
'device_id'
,
{
signed
:
false
});
const
device_login_id
=
ctx
.
cookies
.
get
(
'device_login_id'
,
{
signed
:
false
});
ctx
.
logger
.
info
(
'target_user--'
+
JSON
.
stringify
({
target_cookies_user
:
{
token
,
user_id
,
app_user_id
,
device_id
,
device_login_id
}
}));
if
(
token
&&
user_id
&&
app_user_id
&&
device_id
&&
device_login_id
)
{
ctx
.
redirect
(
target_url
);
return
;
...
...
@@ -37,6 +38,7 @@ class ResponseController extends Controller {
const
user_sid
=
ctx
.
cookies
.
get
(
'jianbing_customer_id'
,
{
signed
:
false
});
const
auth_token
=
ctx
.
cookies
.
get
(
'auth_token'
,
{
signed
:
false
});
ctx
.
logger
.
info
(
'target_user--'
+
new
Date
().
getTime
()
+
JSON
.
stringify
({
target_old_user
:
{
auth_token
,
user_sid
}
}));
const
phone_info
=
await
ctx
.
service
.
user
.
get_phone_by_user_sid
({
user_sid
:
user_sid
,
token
:
auth_token
});
//获取用户手机号码
ctx
.
logger
.
info
(
'phone_info: '
+
JSON
.
stringify
(
phone_info
));
const
phone
=
phone_info
.
phone
;
...
...
@@ -53,17 +55,19 @@ class ResponseController extends Controller {
app_id
:
app_id
,
channel_id
:
channel_id
,
}
ctx
.
logger
.
info
(
'go_register_params: '
+
JSON
.
stringify
(
go_register_params
));
console
.
info
(
this
.
config
.
NODE_URL
+
'/login/go_register'
);
//
ctx.logger.info('go_register_params: ' + JSON.stringify(go_register_params));
//
console.info(this.config.NODE_URL + '/login/go_register');
const
result_go_register
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
NODE_URL
+
'/login/go_register'
,
go_register_params
,
{
method
:
'POST'
});
//通过手机号直接注册新用户中心
node_user_center_login_ret
=
result_go_register
.
data
;
ctx
.
logger
.
info
(
'go_register_result: '
+
JSON
.
stringify
(
node_user_center_login_ret
));
ctx
.
logger
.
info
(
'target_user--'
+
new
Date
().
getTime
()
+
JSON
.
stringify
({
target_old_user
:
{
go_register_params
,
node_user_center_login_ret
}
}));
// ctx.logger.info('go_register_result: ' + JSON.stringify(node_user_center_login_ret));
node_user_center_login_ret
.
user_id
=
node_user_center_login_ret
.
uid
;
node_user_center_login_ret
.
device_login_id
=
node_user_center_login_ret
.
device_login_logs_id
;
delete
(
node_user_center_login_ret
.
uid
);
delete
(
node_user_center_login_ret
.
device_login_logs_id
);
}
ctx
.
logger
.
info
(
'target_user--'
+
new
Date
().
getTime
()
+
JSON
.
stringify
({
target_old_user
:
{
channel_id
,
app_id
}
}));
if
(
!
phone
||
!
channel_id
||
!
app_id
||
!
node_user_center_login_ret
.
token
)
{
// 或渠道错误 或直接注册新用户中心失败时 使用设备登录
const
user_agent
=
header
.
user_agent
?
header
.
user_agent
:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36'
;
const
ip
=
ctx
.
helper
.
getClientIP
();
...
...
@@ -75,10 +79,11 @@ class ResponseController extends Controller {
app_id
:
app_id
,
device_info
:
{},
}
ctx
.
logger
.
info
(
'device_login_params: '
+
JSON
.
stringify
(
device_login_params
));
//设备登录参数
//
ctx.logger.info('device_login_params: ' + JSON.stringify(device_login_params));//设备登录参数
const
result_device_login
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
NODE_URL
+
'/login/device'
,
device_login_params
,
{
method
:
'POST'
});
//设备登录
const
device_login_data
=
result_device_login
.
data
;
//设备登录返回结果
ctx
.
logger
.
info
(
'device_login_result: '
+
JSON
.
stringify
(
device_login_data
));
// ctx.logger.info('device_login_result: ' + JSON.stringify(device_login_data));
ctx
.
logger
.
info
(
'target_user--'
+
new
Date
().
getTime
()
+
JSON
.
stringify
({
target_old_user
:
{
device_login_params
,
result_device_login
}
}));
if
(
!
device_login_data
||
Object
.
keys
(
device_login_data
).
length
===
0
)
{
ctx
.
failed
(
'device login error, device_login_data empty'
);
}
...
...
@@ -94,13 +99,13 @@ class ResponseController extends Controller {
node_user_center_login_ret
.
device_id
=
device_login_data
.
device_id
;
node_user_center_login_ret
.
device_login_id
=
device_login_data
.
device_login_logs_id
;
}
const
expire
=
7200
*
1000
;
const
date
=
new
Date
();
for
(
let
key
in
node_user_center_login_ret
)
{
const
value
=
node_user_center_login_ret
[
key
];
const
exist_value
=
ctx
.
cookies
.
get
(
key
,
{
signed
:
false
});
if
(
!
exist_value
)
{
if
(
!
exist_value
)
{
ctx
.
cookies
.
set
(
key
,
value
,
{
httpOnly
:
false
,
signed
:
false
,
path
:
'/'
,
overwrite
:
true
});
}
}
...
...
app/service/course/institution.js
View file @
3d340875
...
...
@@ -143,8 +143,8 @@ class InstitutionService extends Service {
const
{
ctx
}
=
this
;
const
where
=
{
id
:
teacher_id
};
let
teacher
=
await
ctx
.
classModel
.
CourseTeacher
.
one
({
where
});
teacher
.
dataValues
.
point_tags
=
teacher
.
point
.
split
(
';'
)
;
teacher
.
dataValues
.
work_experience_tags
=
teacher
.
work_experience
.
split
(
';'
)
;
teacher
.
dataValues
.
point_tags
=
teacher
.
point
?
teacher
.
point
.
split
(
';'
)
:
[]
;
teacher
.
dataValues
.
work_experience_tags
=
teacher
.
work_experience
?
teacher
.
work_experience
.
split
(
';'
)
:
[]
;
return
teacher
;
}
...
...
@@ -155,8 +155,8 @@ class InstitutionService extends Service {
const
where
=
{
id
:
class_id
};
let
classs
=
await
ctx
.
classModel
.
CourseClass
.
one
({
where
});
classs
.
dataValues
.
age_text
=
`
${
classs
.
min_age
}
-
${
classs
.
max_age
}
岁`
;
classs
.
dataValues
.
point_tags
=
classs
.
point
.
split
(
';'
)
;
classs
.
dataValues
.
photo_album
=
classs
.
image
.
split
(
';'
)
;
classs
.
dataValues
.
point_tags
=
classs
.
point
?
classs
.
point
.
split
(
';'
)
:
[]
;
classs
.
dataValues
.
photo_album
=
classs
.
image
?
classs
.
image
.
split
(
';'
)
:
[]
;
return
classs
;
}
...
...
@@ -275,10 +275,8 @@ class InstitutionService extends Service {
}
const
from
=
from_gps
;
console
.
info
(
'11111111111111111111111111'
);
console
.
info
(
from_gps
);
const
lat
=
from_gps
.
lat
;
const
lng
=
from_gps
.
lng
;
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
);
...
...
app/service/course/user.js
View file @
3d340875
...
...
@@ -96,7 +96,7 @@ class UserService extends Service {
const
{
ctx
}
=
this
;
const
user_uuid
=
ctx
.
userUuid
;
const
{
page
,
limit
}
=
input
;
const
{
page
,
limit
,
lat
,
lng
}
=
input
;
const
where
=
{
user_uuid
,
is_deleted
:
0
};
const
collect_institution_rows
=
await
ctx
.
classModel
.
CourseUserCollection
.
list
({
page
,
limit
,
where
});
const
institution_ids
=
R
.
pluck
(
'institution_id'
,
collect_institution_rows
.
rows
);
...
...
@@ -107,7 +107,7 @@ class UserService extends Service {
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
:
{
id
:
{
$in
:
institution_ids
},
status
:
1
,
is_deleted
:
0
}
});
const
institution_area_list
=
await
ctx
.
service
.
course
.
institution
.
getInstitutionAreaList
(
institutions
);
const
area_lbs
=
await
ctx
.
service
.
course
.
institution
.
computeDistance
(
institution_area_list
);
//计算距离
const
area_lbs
=
await
ctx
.
service
.
course
.
institution
.
computeDistance
(
institution_area_list
,
{
lat
,
lng
}
);
//计算距离
const
institution_areas
=
await
ctx
.
service
.
course
.
institution
.
findShortestDistanceAreas
(
institution_area_list
,
area_lbs
);
const
ret
=
await
ctx
.
service
.
course
.
institution
.
formatInstitutions
(
institution_areas
);
...
...
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