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
3130f337
Commit
3130f337
authored
Sep 18, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
c0bf6716
Pipeline
#13889
passed with stage
in 34 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
27 deletions
+39
-27
institution.js
app/controller/course/institution.js
+13
-7
course.js
app/router/course.js
+7
-1
institution.js
app/service/course/institution.js
+14
-14
order.js
app/service/credit/order.js
+5
-5
No files found.
app/controller/course/institution.js
View file @
3130f337
...
@@ -12,6 +12,7 @@ class InstitutionController extends Controller {
...
@@ -12,6 +12,7 @@ class InstitutionController extends Controller {
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
request
.
body
;
const
input_params
=
ctx
.
request
.
body
;
const
results
=
await
ctx
.
service
.
course
.
institution
.
getInstitutions
(
input_params
);
const
results
=
await
ctx
.
service
.
course
.
institution
.
getInstitutions
(
input_params
);
ctx
.
success
({
results
});
ctx
.
success
({
results
});
}
}
...
@@ -23,6 +24,7 @@ class InstitutionController extends Controller {
...
@@ -23,6 +24,7 @@ class InstitutionController extends Controller {
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
params
;
const
input_params
=
ctx
.
params
;
const
result
=
await
ctx
.
service
.
course
.
institution
.
getInstitution
(
input_params
);
const
result
=
await
ctx
.
service
.
course
.
institution
.
getInstitution
(
input_params
);
ctx
.
success
({
result
});
ctx
.
success
({
result
});
}
}
...
@@ -33,8 +35,9 @@ class InstitutionController extends Controller {
...
@@ -33,8 +35,9 @@ class InstitutionController extends Controller {
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
request
.
body
;
const
input_params
=
ctx
.
request
.
body
;
let
ret
=
await
ctx
.
service
.
course
.
institution
.
getInstitutions
(
input_params
);
const
results
=
await
ctx
.
service
.
course
.
institution
.
getClasses
(
input_params
);
ctx
.
success
(
ret
);
ctx
.
success
({
results
});
}
}
/**
/**
...
@@ -43,8 +46,9 @@ class InstitutionController extends Controller {
...
@@ -43,8 +46,9 @@ class InstitutionController extends Controller {
async
classInfo
()
{
async
classInfo
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
request
.
body
;
const
class_id
=
ctx
.
params
.
class_id
;
let
ret
=
await
ctx
.
service
.
course
.
institution
.
getInstitutions
(
input_params
);
let
ret
=
await
ctx
.
service
.
course
.
institution
.
getClass
(
class_id
);
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
...
@@ -55,7 +59,8 @@ class InstitutionController extends Controller {
...
@@ -55,7 +59,8 @@ class InstitutionController extends Controller {
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
request
.
body
;
const
input_params
=
ctx
.
request
.
body
;
let
ret
=
await
ctx
.
service
.
course
.
institution
.
getInstitutions
(
input_params
);
let
ret
=
await
ctx
.
service
.
course
.
institution
.
getTeachers
(
input_params
);
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
...
@@ -65,8 +70,9 @@ class InstitutionController extends Controller {
...
@@ -65,8 +70,9 @@ class InstitutionController extends Controller {
async
teacherInfo
()
{
async
teacherInfo
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
request
.
body
;
const
teacher_id
=
ctx
.
params
.
teacher_id
;
let
ret
=
await
ctx
.
service
.
course
.
institution
.
getInstitutions
(
input_params
);
let
ret
=
await
ctx
.
service
.
course
.
institution
.
getTeacher
(
teacher_id
);
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
...
...
app/router/course.js
View file @
3130f337
...
@@ -5,8 +5,14 @@ module.exports = app => {
...
@@ -5,8 +5,14 @@ module.exports = app => {
const
loginAuth
=
app
.
middleware
.
loginAuth
({
type
:
'new'
});
//登录中间件
const
loginAuth
=
app
.
middleware
.
loginAuth
({
type
:
'new'
});
//登录中间件
router
.
get
(
'/options'
,
'course.option.getOptions'
);
router
.
get
(
'/options'
,
'course.option.getOptions'
);
router
.
post
(
'/institutions'
,
'course.institution.institutionList'
);
router
.
get
(
'/institutions'
,
'course.institution.institutionList'
);
router
.
get
(
'/institutions'
,
'course.institution.institutionList'
);
router
.
get
(
'/institution/:institution_id/:area_id'
,
'course.institution.institutionInfo'
);
router
.
get
(
'/institution/:institution_id/:area_id'
,
'course.institution.institutionInfo'
);
router
.
post
(
'/classes'
,
'course.institution.classList'
);
router
.
get
(
'/classes'
,
'course.institution.classList'
);
router
.
get
(
'/class/:class_id'
,
'course.institution.classInfo'
);
router
.
post
(
'/teachers'
,
'course.institution.teacherList'
);
router
.
get
(
'/teachers'
,
'course.institution.teacherList'
);
router
.
get
(
'/teacher/:teacher_id'
,
'course.institution.teacherInfo'
);
};
};
app/service/course/institution.js
View file @
3130f337
...
@@ -13,8 +13,8 @@ class InstitutionService extends Service {
...
@@ -13,8 +13,8 @@ class InstitutionService extends Service {
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
institution
=
await
ctx
.
prometheusModel
.
CourseInstitution
.
one
({
where
:
{
id
:
institution_id
}
});
const
institution
=
await
ctx
.
prometheusModel
.
CourseInstitution
.
one
({
where
:
{
id
:
institution_id
}
});
const
teachers
=
await
this
.
get
Institution
Teachers
({
institution_id
,
limit
:
6
});
const
teachers
=
await
this
.
getTeachers
({
institution_id
,
limit
:
6
});
const
classes
=
await
this
.
get
Institution
Classes
({
institution_id
,
limit
:
4
});
const
classes
=
await
this
.
getClasses
({
institution_id
,
limit
:
4
});
const
areas
=
await
this
.
getInstitutionAreas
({
institution_id
,
limit
:
1000
});
const
areas
=
await
this
.
getInstitutionAreas
({
institution_id
,
limit
:
1000
});
const
current_area
=
await
ctx
.
prometheusModel
.
CourseArea
.
one
({
id
:
area_id
});
const
current_area
=
await
ctx
.
prometheusModel
.
CourseArea
.
one
({
id
:
area_id
});
let
institution_detail
=
await
this
.
formatInstitutions
([
institution
]);
let
institution_detail
=
await
this
.
formatInstitutions
([
institution
]);
...
@@ -29,9 +29,9 @@ class InstitutionService extends Service {
...
@@ -29,9 +29,9 @@ class InstitutionService extends Service {
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
where
=
{
id
:
teacher_id
};
const
where
=
{
id
:
teacher_id
};
cons
t
teacher
=
await
ctx
.
prometheusModel
.
CourseTeacher
.
one
({
where
});
le
t
teacher
=
await
ctx
.
prometheusModel
.
CourseTeacher
.
one
({
where
});
teacher
.
point_tags
=
teacher
.
point
.
split
(
';'
);
teacher
.
dataValues
.
point_tags
=
teacher
.
point
.
split
(
';'
);
teacher
.
work_experience_tags
=
teacher
.
work_experience
.
split
(
';'
);
teacher
.
dataValues
.
work_experience_tags
=
teacher
.
work_experience
.
split
(
';'
);
return
teacher
;
return
teacher
;
}
}
...
@@ -40,14 +40,14 @@ class InstitutionService extends Service {
...
@@ -40,14 +40,14 @@ class InstitutionService extends Service {
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
where
=
{
id
:
class_id
};
const
where
=
{
id
:
class_id
};
cons
t
classs
=
await
ctx
.
prometheusModel
.
CourseClass
.
one
({
where
});
le
t
classs
=
await
ctx
.
prometheusModel
.
CourseClass
.
one
({
where
});
classs
.
age_text
=
`
${
classs
.
min_age
}
-
${
classs
.
max_age
}
岁`
;
classs
.
dataValues
.
age_text
=
`
${
classs
.
min_age
}
-
${
classs
.
max_age
}
岁`
;
classs
.
point_tags
=
classs
.
point
.
split
(
';'
);
classs
.
dataValues
.
point_tags
=
classs
.
point
.
split
(
';'
);
classs
.
photo_album
=
classs
.
image
.
split
(
';'
);
classs
.
dataValues
.
photo_album
=
classs
.
image
.
split
(
';'
);
return
classs
;
return
classs
;
}
}
async
get
Institution
Teachers
(
input
)
{
async
getTeachers
(
input
)
{
const
{
ctx
}
=
this
;
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'
];
...
@@ -59,21 +59,21 @@ class InstitutionService extends Service {
...
@@ -59,21 +59,21 @@ class InstitutionService extends Service {
}
}
async
get
Institution
Classes
(
input
)
{
async
getClasses
(
input
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'image'
,
'type'
,
'price'
];
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'image'
,
'type'
,
'price'
];
const
{
institution_id
,
page
,
limit
}
=
input
;
const
{
institution_id
,
page
,
limit
}
=
input
;
const
where
=
{
institution_id
};
const
where
=
{
institution_id
};
const
classes
=
await
ctx
.
prometheusModel
.
CourseClass
.
list
({
attributes
,
page
,
limit
,
where
});
const
classes
=
await
ctx
.
prometheusModel
.
CourseClass
.
list
({
attributes
,
page
,
limit
,
where
});
cons
t
ret
=
[];
le
t
ret
=
[];
for
(
let
i
in
classes
.
rows
)
{
for
(
let
i
in
classes
.
rows
)
{
let
classs
=
classes
.
rows
[
i
];
let
classs
=
classes
.
rows
[
i
];
// class
s.price_text = classs.price ? classs.price : '现场咨询';
classs
.
dataValue
s
.
price_text
=
classs
.
price
?
classs
.
price
:
'现场咨询'
;
ret
.
push
(
classs
);
ret
.
push
(
classs
);
}
}
return
{
page
,
count
:
classes
.
count
,
rows
:
ret
};
return
{
page
:
classes
.
page
,
count
:
classes
.
count
,
rows
:
ret
};
}
}
...
...
app/service/credit/order.js
View file @
3130f337
...
@@ -61,19 +61,19 @@ class OrderService extends Service {
...
@@ -61,19 +61,19 @@ class OrderService extends Service {
async
updateOrderStateToOverdue
(
order
)
{
async
updateOrderStateToOverdue
(
order
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
{
id
,
created_at
,
state
,
pay_status
}
=
order
;
const
{
id
,
state_time
,
state
,
pay_status
}
=
order
;
if
(
!
id
||
!
created_at
||
!
state
||
typeof
(
pay_status
)
===
'undefined'
)
{
if
(
!
id
||
!
state_time
||
!
state
||
typeof
(
pay_status
)
===
'undefined'
)
{
return
order
;
return
order
;
}
}
const
expire_time
=
moment
(
created_at
).
valueOf
()
+
24
*
3600
*
1000
;
const
expire_time
=
moment
(
state_time
).
valueOf
()
+
24
*
3600
*
1000
;
const
now_time
=
moment
().
valueOf
();
const
now_time
=
moment
().
valueOf
();
const
state_tim
e
=
moment
().
format
(
'YYYY-MM-DD HH:mm:ss'
);
const
now_dat
e
=
moment
().
format
(
'YYYY-MM-DD HH:mm:ss'
);
// await this.logOrder(order);
// await this.logOrder(order);
// if (state === '支付中' && pay_status === 0 && moment(order.state_time).valueOf() * 300 < now_time) {
// if (state === '支付中' && pay_status === 0 && moment(order.state_time).valueOf() * 300 < now_time) {
// await ctx.prometheusModel.CreditOrder.update({ state: '待支付', state_time: state_time }, { where: { id } });
// await ctx.prometheusModel.CreditOrder.update({ state: '待支付', state_time: state_time }, { where: { id } });
// }
// }
if
(
expire_time
<
now_time
&&
(
state
===
'待支付'
||
state
===
'已取消'
||
state
===
'支付中'
)
&&
pay_status
===
0
)
{
if
(
expire_time
<
now_time
&&
(
state
===
'待支付'
||
state
===
'已取消'
||
state
===
'支付中'
)
&&
pay_status
===
0
)
{
const
ret
=
await
ctx
.
prometheusModel
.
CreditOrder
.
update
({
state
:
'已失效'
,
state_time
:
state_tim
e
},
{
where
:
{
id
}
});
const
ret
=
await
ctx
.
prometheusModel
.
CreditOrder
.
update
({
state
:
'已失效'
,
state_time
:
now_dat
e
},
{
where
:
{
id
}
});
if
(
ret
&&
ret
[
0
])
{
if
(
ret
&&
ret
[
0
])
{
await
this
.
logOrder
(
order
);
await
this
.
logOrder
(
order
);
order
.
state
=
'已失效'
;
order
.
state
=
'已失效'
;
...
...
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