Commit ec4a3a38 authored by 任国军's avatar 任国军

recommendClass add age & category filter

parent 0f0d3864
Pipeline #22923 passed with stage
in 3 seconds
...@@ -21,6 +21,7 @@ module.exports = app => { ...@@ -21,6 +21,7 @@ module.exports = app => {
is_open: INTEGER, is_open: INTEGER,
url: STRING, url: STRING,
color: STRING, color: STRING,
bind: INTEGER,
status: INTEGER, status: INTEGER,
is_deleted: INTEGER, is_deleted: INTEGER,
sort: INTEGER, sort: INTEGER,
......
...@@ -241,7 +241,6 @@ class ReportService extends Service { ...@@ -241,7 +241,6 @@ class ReportService extends Service {
answerIds = _.concat(answerIds, v.answers); answerIds = _.concat(answerIds, v.answers);
} }
const tagList = await ctx.classModel.V5.CourseV5Answer.findAll({ where: { id: { $in: answerIds } }, attributes: [ 'tag' ] }); const tagList = await ctx.classModel.V5.CourseV5Answer.findAll({ where: { id: { $in: answerIds } }, attributes: [ 'tag' ] });
console.log(tagList);
for (const v of tagList) { for (const v of tagList) {
if (!ctx.isEmpty(v.tag)) { if (!ctx.isEmpty(v.tag)) {
tags.push(v.tag); tags.push(v.tag);
...@@ -272,7 +271,7 @@ class ReportService extends Service { ...@@ -272,7 +271,7 @@ class ReportService extends Service {
answerFilterList = _.concat(answerFilterList, ageFilterList); answerFilterList = _.concat(answerFilterList, ageFilterList);
// 先做筛选 // 先做筛选
const where = await this.classFilter(answerFilterList); const where = await this.classFilter(answerFilterList, catId, babyAge);
let classList = await ctx.classModel.V5.CourseV5Class.findAll({ where, attributes: [ 'id', 'institution_id', 'name', 'logo', 'age', 'price', 'price_type', 'mode', 'time', 'class_amount', 'multi_classes', 'cycle', 'sort' ], raw: true }); let classList = await ctx.classModel.V5.CourseV5Class.findAll({ where, attributes: [ 'id', 'institution_id', 'name', 'logo', 'age', 'price', 'price_type', 'mode', 'time', 'class_amount', 'multi_classes', 'cycle', 'sort' ], raw: true });
// 格式化课程 // 格式化课程
classList = await this.formatClassList(classList); classList = await this.formatClassList(classList);
...@@ -293,7 +292,7 @@ class ReportService extends Service { ...@@ -293,7 +292,7 @@ class ReportService extends Service {
// 筛选课程 // 筛选课程
async classFilter(answerFilterList) { async classFilter(answerFilterList, catId, babyAge) {
const { ctx } = this; const { ctx } = this;
const where = { status: 1, is_deleted: 0 }; const where = { status: 1, is_deleted: 0 };
...@@ -350,9 +349,13 @@ class ReportService extends Service { ...@@ -350,9 +349,13 @@ class ReportService extends Service {
} }
} }
} }
if (classFlag) { // 分类筛选
tmpClassList = await ctx.classModel.V5.CourseV5ClassToCat.findAll({ where: { cat_id: catId, status: 1, is_deleted: 0 }, attributes: [ 'class_id' ] });
classIds = classFlag ? _.union(classIds, R.pluck('class_id', tmpClassList)) : R.pluck('class_id', tmpClassList);
// 年级筛选
tmpClassList = await ctx.classModel.V5.CourseV5ClassToAge.findAll({ where: { age_id: babyAge, status: 1, is_deleted: 0 }, attributes: [ 'class_id' ] });
classIds = _.union(classIds, R.pluck('class_id', tmpClassList));
where.id = { $in: classIds }; where.id = { $in: classIds };
}
return where; return where;
} }
......
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