Commit 3130f337 authored by 李尚科's avatar 李尚科

fix

parent c0bf6716
Pipeline #13889 passed with stage
in 34 seconds
......@@ -12,6 +12,7 @@ class InstitutionController extends Controller {
const { ctx } = this;
const input_params = ctx.request.body;
const results = await ctx.service.course.institution.getInstitutions(input_params);
ctx.success({ results });
}
......@@ -23,6 +24,7 @@ class InstitutionController extends Controller {
const { ctx } = this;
const input_params = ctx.params;
const result = await ctx.service.course.institution.getInstitution(input_params);
ctx.success({ result });
}
......@@ -33,8 +35,9 @@ class InstitutionController extends Controller {
const { ctx } = this;
const input_params = ctx.request.body;
let ret = await ctx.service.course.institution.getInstitutions(input_params);
ctx.success(ret);
const results = await ctx.service.course.institution.getClasses(input_params);
ctx.success({ results });
}
/**
......@@ -43,8 +46,9 @@ class InstitutionController extends Controller {
async classInfo() {
const { ctx } = this;
const input_params = ctx.request.body;
let ret = await ctx.service.course.institution.getInstitutions(input_params);
const class_id = ctx.params.class_id;
let ret = await ctx.service.course.institution.getClass(class_id);
ctx.success(ret);
}
......@@ -55,7 +59,8 @@ class InstitutionController extends Controller {
const { ctx } = this;
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);
}
......@@ -65,8 +70,9 @@ class InstitutionController extends Controller {
async teacherInfo() {
const { ctx } = this;
const input_params = ctx.request.body;
let ret = await ctx.service.course.institution.getInstitutions(input_params);
const teacher_id = ctx.params.teacher_id;
let ret = await ctx.service.course.institution.getTeacher(teacher_id);
ctx.success(ret);
}
......
......@@ -5,8 +5,14 @@ module.exports = app => {
const loginAuth = app.middleware.loginAuth({ type: 'new' });//登录中间件
router.get('/options', 'course.option.getOptions');
router.post('/institutions', 'course.institution.institutionList');
router.get('/institutions', 'course.institution.institutionList');
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');
};
......@@ -13,8 +13,8 @@ class InstitutionService extends Service {
const { ctx } = this;
const institution = await ctx.prometheusModel.CourseInstitution.one({ where: { id: institution_id } });
const teachers = await this.getInstitutionTeachers({ institution_id, limit: 6 });
const classes = await this.getInstitutionClasses({ institution_id, limit: 4 });
const teachers = await this.getTeachers({ institution_id, limit: 6 });
const classes = await this.getClasses({ institution_id, limit: 4 });
const areas = await this.getInstitutionAreas({ institution_id, limit: 1000 });
const current_area = await ctx.prometheusModel.CourseArea.one({ id: area_id });
let institution_detail = await this.formatInstitutions([institution]);
......@@ -29,9 +29,9 @@ class InstitutionService extends Service {
const { ctx } = this;
const where = { id: teacher_id };
const teacher = await ctx.prometheusModel.CourseTeacher.one({ where });
teacher.point_tags = teacher.point.split(';');
teacher.work_experience_tags = teacher.work_experience.split(';');
let teacher = await ctx.prometheusModel.CourseTeacher.one({ where });
teacher.dataValues.point_tags = teacher.point.split(';');
teacher.dataValues.work_experience_tags = teacher.work_experience.split(';');
return teacher;
}
......@@ -40,14 +40,14 @@ class InstitutionService extends Service {
const { ctx } = this;
const where = { id: class_id };
const classs = await ctx.prometheusModel.CourseClass.one({ where });
classs.age_text = `${classs.min_age}-${classs.max_age}岁`;
classs.point_tags = classs.point.split(';');
classs.photo_album = classs.image.split(';');
let classs = await ctx.prometheusModel.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(';');
return classs;
}
async getInstitutionTeachers(input) {
async getTeachers(input) {
const { ctx } = this;
const attributes = ['id', 'institution_id', 'name', 'avatar', 'teacher_experience', 'lesson', 'educational_background', 'certificate'];
......@@ -59,21 +59,21 @@ class InstitutionService extends Service {
}
async getInstitutionClasses(input) {
async getClasses(input) {
const { ctx } = this;
const attributes = ['id', 'institution_id', 'name', 'image', 'type', 'price'];
const { institution_id, page, limit } = input;
const where = { institution_id };
const classes = await ctx.prometheusModel.CourseClass.list({ attributes, page, limit, where });
const ret = [];
let ret = [];
for (let i in classes.rows) {
let classs = classes.rows[i];
// classs.price_text = classs.price ? classs.price : '现场咨询';
classs.dataValues.price_text = classs.price ? classs.price : '现场咨询';
ret.push(classs);
}
return { page, count: classes.count, rows: ret };
return { page: classes.page, count: classes.count, rows: ret };
}
......
......@@ -61,19 +61,19 @@ class OrderService extends Service {
async updateOrderStateToOverdue(order) {
const { ctx } = this;
const { id, created_at, state, pay_status } = order;
if (!id || !created_at || !state || typeof (pay_status) === 'undefined') {
const { id, state_time, state, pay_status } = order;
if (!id || !state_time || !state || typeof (pay_status) === 'undefined') {
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 state_time = moment().format('YYYY-MM-DD HH:mm:ss');
const now_date = moment().format('YYYY-MM-DD HH:mm:ss');
// await this.logOrder(order);
// 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 } });
// }
if (expire_time < now_time && (state === '待支付' || state === '已取消' || state === '支付中') && pay_status === 0) {
const ret = await ctx.prometheusModel.CreditOrder.update({ state: '已失效', state_time: state_time }, { where: { id } });
const ret = await ctx.prometheusModel.CreditOrder.update({ state: '已失效', state_time: now_date }, { where: { id } });
if (ret && ret[0]) {
await this.logOrder(order);
order.state = '已失效';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment