|
@@ -32,17 +32,16 @@ class StatisticsService extends CrudService {
|
|
|
});
|
|
|
query.$and = [{ 'meta.createdAt': { $gte: `${year}-01-01 00:00:00` } }, { 'meta.createdAt': { $lte: `${year}-12-31 23:59:59` } }];
|
|
|
const lcList = await this.lessonCoachModel.find(query).populate('lesson_id');
|
|
|
- const lessonList = lcList.filter(f => f.lesson_id);
|
|
|
+ const lessonList = lcList.map(f => f.lesson_id);
|
|
|
const arr = [];
|
|
|
for (const months of monthList) {
|
|
|
const s = _.head(months);
|
|
|
const l = _.last(months);
|
|
|
const m = moment(s).month() + 1;
|
|
|
const list = lessonList.filter(f => moment(_.get(f, 'meta.createdAt')).isBetween(s, l, null, '[]'));
|
|
|
- console.log(list);
|
|
|
const lesson_ids = list.map(i => i._id);
|
|
|
const studentNumber = await this.lessonStudentModel.count({ lesson_id: lesson_ids, is_pay: '1' });
|
|
|
- arr.push(studentNumber);
|
|
|
+ arr.push({ name: `${m}月`, value: studentNumber });
|
|
|
}
|
|
|
return arr;
|
|
|
}
|