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

classList add sub_title&pay_count

parent 5c853f1a
Pipeline #26910 passed with stage
in 4 seconds
......@@ -14,7 +14,7 @@ class InstitutionSubService extends Service {
const page = Number(input.page) || 1;
const page_size = Number(input.page_size) || 10;
const offset = (page - 1) * page_size;
const attributes = [ 'id', 'institution_id', 'name', 'logo', 'age', 'price', 'price_type', 'mode', 'time', 'class_amount', 'multi_classes', 'cycle', 'description', 'sort' ];
const attributes = [ 'id', 'institution_id', 'name', 'logo', 'age', 'price', 'price_type', 'mode', 'time', 'class_amount', 'multi_classes', 'cycle', 'description', 'sort', 'sub_title', 'pay_count' ];
const filter = { where: { status: 1, is_deleted: 0 }, order: [[ 'sort', 'asc' ], [ 'id', 'desc' ]], limit: page_size, offset, attributes, raw: true };
let filterIds = [];
let flag = false;
......@@ -74,6 +74,10 @@ class InstitutionSubService extends Service {
let institutionList = await ctx.classModel.V5.CourseV5Institution.findAll({ where: { id: { $in: R.pluck('institution_id', classList.rows) } }, attributes: [ 'id', 'name', 'logo' ] });
institutionList = _.groupBy(institutionList, 'id');
// 订单总数
const orderCount = await ctx.classModel.V5.CourseUserOrder.findAll({ where: { class_id: { $in: _.uniq(R.pluck('id', classList.rows)) }, status: 1, is_deleted: 0 } });
const classOrder = _.groupBy(orderCount, 'class_id');
for (const i in classList.rows) {
const classCategoryList = [];
if (!ctx.isEmpty(classToCategory[classList.rows[i].id])) {
......@@ -91,6 +95,7 @@ class InstitutionSubService extends Service {
classList.rows[i].category = classCategoryList;
classList.rows[i].institution_name = ctx.isEmpty(institutionList[classList.rows[i].institution_id]) ? '' : institutionList[classList.rows[i].institution_id][0].name;
classList.rows[i].institution_logo = ctx.isEmpty(institutionList[classList.rows[i].institution_id]) ? '' : institutionList[classList.rows[i].institution_id][0].logo;
classList.rows[i].pay_count = ctx.isEmpty(classOrder[classList.rows[i].id]) ? classList.rows[i].pay_count : classList.rows[i].pay_count + classOrder[classList.rows[i].id].length;
}
const ret = {
......
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