Commit 2c4bb343 authored by 任国军's avatar 任国军

add pay_count,sub_title,video_count

parent 78116fd6
Pipeline #24741 passed with stage
in 4 seconds
......@@ -33,6 +33,8 @@ module.exports = app => {
button_pay_text: STRING,
top_price: STRING,
pay_price: DECIMAL,
sub_title: STRING,
pay_count: INTEGER,
sort: INTEGER,
status: INTEGER,
is_deleted: INTEGER,
......
......@@ -99,7 +99,7 @@ class InstitutionSubService extends Service {
// 课程详情
async getClassInfo(id) {
const { ctx } = this;
const attributes = [ 'id', 'institution_id', 'name', 'logo', 'age', 'price', 'price_type', 'mode', 'time', 'class_amount', 'multi_classes', 'cycle', 'description', 'button_style', 'button_text', 'button_type', 'button_sub_text', 'button_url', 'button_pay_text', 'top_price', 'pay_price', 'sort' ];
const attributes = [ 'id', 'institution_id', 'name', 'logo', 'age', 'price', 'price_type', 'mode', 'time', 'class_amount', 'multi_classes', 'cycle', 'description', 'button_style', 'button_text', 'button_type', 'button_sub_text', 'button_url', 'button_pay_text', 'top_price', 'pay_price', 'sub_title', 'pay_count', 'sort' ];
const classInfo = await ctx.classModel.V5.CourseV5Class.findOne({ where: { id, status: 1, is_deleted: 0 }, attributes, raw: true });
if (ctx.isEmpty(classInfo)) {
ctx.failed('数据不存在');
......@@ -163,6 +163,12 @@ class InstitutionSubService extends Service {
const userOrder = ctx.isEmpty(ctx.userUuid) ? {} : await ctx.classModel.V5.CourseUserOrder.findOne({ where: { user_uuid: ctx.userUuid, class_id: id, status: 1, is_deleted: 0 }, attributes: [ 'id' ] });
classInfo.is_bought = ctx.isEmpty(userOrder) ? 0 : 1;
// 视频总数
const videoCount = await ctx.classModel.V5.CourseV5Video.count({ where: { class_id: id, status: 1, is_deleted: 0 } });
// 订单总数
const orderCount = await ctx.classModel.V5.CourseUserOrder.count({ where: { class_id: id, status: 1, is_deleted: 0 } });
classInfo.price_type = await this.getClassPriceType(classInfo.price_type);
classInfo.mode = await this.getClassMode(classInfo.mode);
classInfo.student_works = studentWorks;
......@@ -172,6 +178,8 @@ class InstitutionSubService extends Service {
classInfo.institution_name = ctx.isEmpty(institution) ? '' : institution.name;
classInfo.institution_logo = ctx.isEmpty(institution) ? '' : institution.logo;
classInfo.institution_description = ctx.isEmpty(institution) ? '' : institution.description;
classInfo.pay_count += orderCount;
classInfo.video_count = videoCount;
return classInfo;
}
......
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