statistics.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. 'use strict';
  2. const { CrudService } = require('naf-framework-mongoose-free/lib/service');
  3. const { BusinessError, ErrorCode } = require('naf-core').Error;
  4. const _ = require('lodash');
  5. const assert = require('assert');
  6. const moment = require('moment');
  7. const { ObjectId } = require('mongoose').Types;
  8. //
  9. class StatisticsService extends CrudService {
  10. constructor(ctx) {
  11. super(ctx, 'statistics');
  12. this.billModel = this.ctx.model.Business.Bill;
  13. this.rssModel = this.ctx.model.Relation.RelationStudentSchool;
  14. this.rcsModel = this.ctx.model.Relation.RelationCoachSchool;
  15. this.lessonCoachModel = this.ctx.model.Business.LessonCoach;
  16. this.lessonStudentModel = this.ctx.model.Business.LessonStudent;
  17. this.lessonModel = this.ctx.model.Business.Lesson;
  18. }
  19. // 教练统计,学员情况
  20. async coachStudentLesson({ school_id, coach_id }) {
  21. assert(school_id, '缺少学校信息');
  22. assert(coach_id, '缺少教练信息');
  23. const query = { school_id, coach_id };
  24. const { year } = this.getPartsOfNow();
  25. const yearEnd = `${year}-12-01`;
  26. let monthList = this.getMonthList(12, yearEnd);
  27. monthList = monthList.map(i => {
  28. const start = moment(i).startOf('month').format('YYYY-MM-DD HH:mm:ss');
  29. const end = moment(i).endOf('month').format('YYYY-MM-DD HH:mm:ss');
  30. return [ start, end ];
  31. });
  32. query.$and = [{ 'meta.createdAt': { $gte: `${year}-01-01 00:00:00` } }, { 'meta.createdAt': { $lte: `${year}-12-31 23:59:59` } }];
  33. const lcList = await this.lessonCoachModel.find(query).populate('lesson_id');
  34. const lessonList = lcList.map(f => f.lesson_id);
  35. const arr = [];
  36. for (const months of monthList) {
  37. const s = _.head(months);
  38. const l = _.last(months);
  39. const m = moment(s).month() + 1;
  40. const list = lessonList.filter(f => moment(_.get(f, 'meta.createdAt')).isBetween(s, l, null, '[]'));
  41. const lesson_ids = list.map(i => i._id);
  42. const studentNumber = await this.lessonStudentModel.count({ lesson_id: lesson_ids, is_pay: '1' });
  43. arr.push({ name: `${m}月`, value: studentNumber });
  44. }
  45. return arr;
  46. }
  47. // 教练统计, 授课情况
  48. async coachLesson({ coach_id, school_id }) {
  49. assert(school_id, '缺少学校信息');
  50. assert(coach_id, '缺少教练信息');
  51. const query = { school_id, coach_id };
  52. const { year } = this.getPartsOfNow();
  53. const yearEnd = `${year}-12-01`;
  54. let monthList = this.getMonthList(12, yearEnd);
  55. monthList = monthList.map(i => {
  56. const start = moment(i).startOf('month').format('YYYY-MM-DD HH:mm:ss');
  57. const end = moment(i).endOf('month').format('YYYY-MM-DD HH:mm:ss');
  58. return [ start, end ];
  59. });
  60. query.$and = [{ 'meta.createdAt': { $gte: `${year}-01-01 00:00:00` } }, { 'meta.createdAt': { $lte: `${year}-12-31 23:59:59` } }];
  61. const lcList = await this.lessonCoachModel.find(query).populate('lesson_id');
  62. const lessonList = lcList.filter(f => f.lesson_id && f.lesson_id.status === '4');
  63. const arr = [];
  64. for (const months of monthList) {
  65. const s = _.head(months);
  66. const l = _.last(months);
  67. const m = moment(s).month() + 1;
  68. const list = lessonList.filter(f => moment(_.get(f, 'meta.createdAt')).isBetween(s, l, null, '[]'));
  69. arr.push({ name: `${m}月`, value: list.length });
  70. }
  71. return arr;
  72. }
  73. // 学员统计,付费情况
  74. async studentPay({ school_id, student_id }) {
  75. assert(school_id, '缺少学校信息');
  76. assert(student_id, '缺少学生信息');
  77. const query = { school_id, payer_id: student_id, is_pay: '1', type: [ '-1', '-2', '2' ] };
  78. const { year } = this.getPartsOfNow();
  79. const yearEnd = `${year}-12-01`;
  80. let monthList = this.getMonthList(12, yearEnd);
  81. monthList = monthList.map(i => {
  82. const start = moment(i).startOf('month').format('YYYY-MM-DD HH:mm:ss');
  83. const end = moment(i).endOf('month').format('YYYY-MM-DD HH:mm:ss');
  84. return [ start, end ];
  85. });
  86. query.$and = [{ 'meta.createdAt': { $gte: `${year}-01-01 00:00:00` } }, { 'meta.createdAt': { $lte: `${year}-12-31 23:59:59` } }];
  87. const billList = await this.billModel.find(query);
  88. const arr = [];
  89. for (const months of monthList) {
  90. const s = _.head(months);
  91. const l = _.last(months);
  92. const m = moment(s).month() + 1;
  93. const list = billList.filter(f => moment(_.get(f, 'meta.createdAt')).isBetween(s, l, null, '[]'));
  94. const payList = list.filter(f => f.type !== '2');
  95. const returnList = list.filter(f => f.type === '2');
  96. const pay = payList.reduce((p, n) => p + (n.money || 0), 0);
  97. const ret = returnList.reduce((p, n) => p + (n.money || 0), 0);
  98. const total = pay - ret;
  99. arr.push({ name: `${m}月`, value: total });
  100. }
  101. return arr;
  102. }
  103. // 学员统计,学员上课时长及签到
  104. async studentLearning({ school_id, student_id }) {
  105. assert(school_id, '缺少学校信息');
  106. assert(student_id, '缺少学生信息');
  107. const query = { school_id, student_id, is_pay: '1' };
  108. const { year } = this.getPartsOfNow();
  109. const yearEnd = `${year}-12-01`;
  110. let monthList = this.getMonthList(12, yearEnd);
  111. monthList = monthList.map(i => {
  112. const start = moment(i).startOf('month').format('YYYY-MM-DD HH:mm:ss');
  113. const end = moment(i).endOf('month').format('YYYY-MM-DD HH:mm:ss');
  114. return [ start, end ];
  115. });
  116. query.$and = [{ 'meta.createdAt': { $gte: `${year}-01-01 00:00:00` } }, { 'meta.createdAt': { $lte: `${year}-12-31 23:59:59` } }];
  117. const lsList = await this.lessonStudentModel.find(query).populate('lesson_id');
  118. const lessonList = lsList.map(i => i.lesson_id).map(i => _.pick(i, [ '_id', 'type', 'title', 'meta', 'status', 'time_start', 'time_end' ]));
  119. const minutes = [];
  120. const signs = [];
  121. for (const months of monthList) {
  122. const s = _.head(months);
  123. const l = _.last(months);
  124. const m = moment(s).month() + 1;
  125. const list = lessonList.filter(f => moment(_.get(f, 'meta.createdAt')).isBetween(s, l, null, '[]') && f.status === '4');
  126. let minute = 0;
  127. let sign = 0;
  128. for (const lesson of list) {
  129. const { time_start, time_end, _id: lesson_id } = lesson;
  130. minute += moment(time_end).diff(time_start, 'minutes');
  131. const r = lsList.find(f => ObjectId(f.lesson_id._id).equals(lesson_id));
  132. if (r && _.get(r, 'is_sign') === '1') sign++;
  133. }
  134. minutes.push(minute);
  135. signs.push(sign);
  136. }
  137. return { minutes, signs };
  138. }
  139. // 学校统计,教练收入
  140. async schoolCoachIn({ school_id, coach_id }) {
  141. assert(school_id, '缺少学校信息');
  142. assert(coach_id, '缺少教练信息');
  143. // 教练收入分为私教课和公开课,公开课是根据给教练设置的钱计算,
  144. const query = { school_id, coach_id };
  145. const { year } = this.getPartsOfNow();
  146. const yearEnd = `${year}-12-01`;
  147. let monthList = this.getMonthList(12, yearEnd);
  148. monthList = monthList.map(i => {
  149. const start = moment(i).startOf('month').format('YYYY-MM-DD HH:mm:ss');
  150. const end = moment(i).endOf('month').format('YYYY-MM-DD HH:mm:ss');
  151. return [ start, end ];
  152. });
  153. query.$and = [{ 'meta.createdAt': { $gte: `${year}-01-01 00:00:00` } }, { 'meta.createdAt': { $lte: `${year}-12-31 23:59:59` } }];
  154. const lcList = await this.lessonCoachModel.find(query).populate('lesson_id');
  155. const lessonList = lcList.map(i => i.lesson_id).map(i => _.pick(i, [ '_id', 'type', 'title', 'meta' ]));
  156. const arr = [];
  157. for (const months of monthList) {
  158. const s = _.head(months);
  159. const l = _.last(months);
  160. const m = moment(s).month() + 1;
  161. const obj = { m, total: 0 };
  162. const list = lessonList.filter(f => moment(_.get(f, 'meta.createdAt')).isBetween(s, l, null, '[]'));
  163. // console.log(m);
  164. const privateLesson = list.filter(f => f.type === '1');
  165. const publicLesson = list.filter(f => f.type === '0');
  166. // 先算公开课
  167. for (const pl of publicLesson) {
  168. // 找到该教练的价格,这节公开课的人头数 算出教练应得金额
  169. const { _id: lesson_id } = pl;
  170. const lessonCoach = lcList.find(f => ObjectId(f.lesson_id._id).equals(lesson_id));
  171. if (!lessonCoach) continue;
  172. const studentNumber = await this.lessonStudentModel.count({ lesson_id, is_pay: '1' });
  173. const { money = 0 } = lessonCoach;
  174. const total = money * studentNumber;
  175. obj.total += total;
  176. }
  177. for (const pl of privateLesson) {
  178. // 私教课,lessonStudent中这个课学生交的钱
  179. const { _id: lesson_id } = pl;
  180. const studentList = await this.lessonStudentModel.find({ lesson_id, is_pay: '1' });
  181. const total = studentList.reduce((p, n) => p + (n.money || 0), 0);
  182. obj.total += total;
  183. }
  184. arr.push(obj);
  185. }
  186. return arr;
  187. }
  188. // 学校统计 每月上课次数
  189. async schoolSignCoach({ school_id, coach_id }) {
  190. assert(school_id, '缺少学校信息');
  191. assert(coach_id, '缺少教练信息');
  192. // 查出这个学校下面的教练
  193. const query = { school_id, coach_id };
  194. const { year } = this.getPartsOfNow();
  195. const yearEnd = `${year}-12-01`;
  196. query.$and = [{ 'meta.createdAt': { $gte: `${year}-01-01 00:00:00` } }, { 'meta.createdAt': { $lte: `${year}-12-31 23:59:59` } }];
  197. let monthList = this.getMonthList(12, yearEnd);
  198. monthList = monthList.map(i => {
  199. const start = moment(i).startOf('month').format('YYYY-MM-DD HH:mm:ss');
  200. const end = moment(i).endOf('month').format('YYYY-MM-DD HH:mm:ss');
  201. return [ start, end ];
  202. });
  203. let lcList = await this.lessonCoachModel.find(query, { coach_id: 1, meta: 1 });
  204. if (lcList.length > 0) lcList = JSON.parse(JSON.stringify(lcList));
  205. const arr = [];
  206. for (const months of monthList) {
  207. const s = _.head(months);
  208. const l = _.last(months);
  209. const m = moment(s).month() + 1;
  210. const obj = { m };
  211. const list = lcList.filter(f => moment(_.get(f, 'meta.createdAt')).isBetween(s, l, null, '[]'));
  212. obj.value = list.length;
  213. arr.push(obj);
  214. }
  215. return arr;
  216. }
  217. // 学校统计:学员按岁数区间
  218. async schoolStudentAge({ school_id }) {
  219. assert(school_id, '缺少学校信息');
  220. // 年龄组
  221. const ageList = [
  222. [ null, 6 ],
  223. [ 7, 9 ],
  224. [ 10, 12 ],
  225. [ 12, 18 ],
  226. [ 19, 30 ],
  227. [ 31, null ],
  228. ];
  229. const data = [];
  230. let list = await this.rssModel.find({ school_id }).populate('student_id', 'birth');
  231. if (list.length > 0) list = JSON.parse(JSON.stringify(list));
  232. for (const a of ageList) {
  233. const start = _.head(a);
  234. const end = _.last(a);
  235. const obj = {};
  236. if (start && end) obj.name = `${start}-${end}岁`;
  237. else if (!start) obj.name = `${end}岁以下`;
  238. else if (!end) obj.name = `${start}岁以上`;
  239. const l = list.filter(f => {
  240. const birth = _.get(f, 'student_id.birth');
  241. const age = moment().diff(birth, 'years');
  242. if (start && end) return age >= start && age <= end;
  243. else if (!start) return age <= end;
  244. else if (!end) return age >= start;
  245. return false;
  246. });
  247. obj.value = l.length;
  248. data.push(obj);
  249. }
  250. return data;
  251. }
  252. /**
  253. * 羽校总收入
  254. * 统计账单的 收入(类型为-1/-2) 且 is_pay 不为 0
  255. * m:当前这个月; 3m: 往前推3个月; 6m:往前推6个月; 1y:当前年
  256. * @param {Object} query 查询条件
  257. * @property {String} school_id 学校id
  258. * @property {String} skip 分页
  259. * @property {String} limit 分页
  260. */
  261. async schoolTotalIn({ school_id }) {
  262. assert(school_id, '缺少羽校信息');
  263. const query = { is_pay: { $ne: '0' }, school_id, type: [ '-1', '-2' ] };
  264. const projection = { pay_for: 1, from_id: 1, type: 1, money: 1, time: 1, payer_id: 1 };
  265. const qm = this.resetQuery('m');
  266. const bm = await this.billModel.find({ ...qm, ...query }, projection);
  267. const mm = bm.reduce((p, n) => this.ctx.plus(p, n.money), 0);
  268. const q3m = this.resetQuery('3m');
  269. const b3m = await this.billModel.find({ ...q3m, ...query }, projection);
  270. const m3m = b3m.reduce((p, n) => this.ctx.plus(p, n.money), 0);
  271. const q6m = this.resetQuery('6m');
  272. const b6m = await this.billModel.find({ ...q6m, ...query }, projection);
  273. const m6m = b6m.reduce((p, n) => this.ctx.plus(p, n.money), 0);
  274. const qy = this.resetQuery('1y');
  275. const by = await this.billModel.find({ ...qy, ...query }, projection);
  276. const my = by.reduce((p, n) => this.ctx.plus(p, n.money), 0);
  277. return { mm, m3m, m6m, my };
  278. }
  279. async studentSign({ school_id, lesson_id, student_id, range, skip, limit }) {
  280. const pipeline = [];
  281. const baseCol = { time_start: 1, title: 1 };
  282. const studentQuery = {};
  283. // 返回数据:课程,上课时间,学生,是否签到,是否缴费
  284. let $match = { school_id, lesson_id };
  285. if (_.isArray(range)) {
  286. const start = _.head(range);
  287. const end = _.last(range);
  288. const timeQuery = (start, end) => ({ $and: [{ time_start: { $gte: start } }, { time_start: { $lte: end } }] });
  289. const tq = timeQuery(start, end);
  290. $match = { ...$match, ...tq };
  291. }
  292. pipeline.push({ $match });
  293. pipeline.push({ $addFields: { lesson_id: { $toString: '$_id' } } });
  294. if (student_id) {
  295. studentQuery.student_id = student_id;
  296. }
  297. // #region 正式学生
  298. pipeline.push({
  299. $lookup: {
  300. from: 'lessonStudent',
  301. localField: 'lesson_id',
  302. foreignField: 'lesson_id',
  303. pipeline: [
  304. { $match: studentQuery },
  305. { $project: { is_sign: 1, is_pay: 1, soid: { $toObjectId: '$student_id' } } },
  306. {
  307. $lookup: {
  308. from: 'student',
  309. localField: 'soid',
  310. foreignField: '_id',
  311. as: 'si',
  312. },
  313. },
  314. { $project: { is_sign: 1, is_pay: 1, name: { $first: '$si.name' }, icon: { $first: '$si.icon' } } },
  315. ],
  316. as: 'zStudent',
  317. },
  318. });
  319. // #endregion
  320. // #region 临时学生
  321. pipeline.push({
  322. $lookup: {
  323. from: 'tempLessonApply',
  324. localField: 'lesson_id',
  325. foreignField: 'lesson_id',
  326. pipeline: [
  327. { $match: studentQuery },
  328. { $addFields: { soid: { $toObjectId: '$student_id' } } },
  329. {
  330. $lookup: {
  331. from: 'student',
  332. localField: 'soid',
  333. foreignField: '_id',
  334. as: 'si',
  335. },
  336. },
  337. { $project: { name: 1, is_sign: 1, is_pay: 1, icon: { $ifNull: [{ $first: '$si.icon' }, []] } } },
  338. ],
  339. as: 'lStudent',
  340. },
  341. });
  342. // #endregion
  343. pipeline.push({ $project: { ...baseCol, studentList: { $concatArrays: [ '$zStudent', '$lStudent' ] } } });
  344. pipeline.push({ $unwind: '$studentList' });
  345. pipeline.push({ $project: { ...baseCol, name: '$studentList.name', is_pay: '$studentList.is_pay', is_sign: '$studentList.is_sign', icon: '$studentList.icon' } });
  346. const qp = _.cloneDeep(pipeline);
  347. if (parseInt(skip)) qp.push({ $skip: parseInt(skip) });
  348. if (parseInt(limit)) qp.push({ $limit: parseInt(limit) });
  349. const data = await this.lessonModel.aggregate(qp);
  350. const tp = _.cloneDeep(pipeline);
  351. tp.push(this.totalPip());
  352. const tr = await this.lessonModel.aggregate(tp);
  353. const total = this.getTotal(tr);
  354. return { data, total };
  355. }
  356. async schoolInByLesson({ school_id, time = 'm', skip = 0, limit }) {
  357. const tq = this.resetQuery(time, 'time_start');
  358. const query = { ...tq, school_id };
  359. const pipeline = [{ $match: query }];
  360. const baseCol = { time_start: 1, title: 1 };
  361. // #region 整理课程数据
  362. pipeline.push({
  363. $project: {
  364. ...baseCol,
  365. money: { $toDouble: '$money' },
  366. },
  367. });
  368. baseCol.money = 1;
  369. // #endregion
  370. // #region 正式学员
  371. pipeline.push({ $addFields: { lesson_id: { $toString: '$_id' } } });
  372. baseCol.lesson_id = 1;
  373. pipeline.push({
  374. $lookup: {
  375. from: 'lessonStudent',
  376. localField: 'lesson_id',
  377. foreignField: 'lesson_id',
  378. pipeline: [{ $group: { _id: '$lesson_id', num: { $sum: 1 } } }],
  379. as: 'zStudent',
  380. },
  381. });
  382. pipeline.push({ $set: { zStudent: { $sum: '$zStudent.num' } } });
  383. pipeline.push({ $project: { ...baseCol, zStudent: { $toDouble: '$zStudent' } } });
  384. baseCol.zStudent = 1;
  385. // #endregion
  386. // #region 临时学员
  387. pipeline.push({
  388. $lookup: {
  389. from: 'tempLessonApply',
  390. localField: 'lesson_id',
  391. foreignField: 'lesson_id',
  392. pipeline: [{ $group: { _id: '$lesson_id', num: { $sum: 1 } } }],
  393. as: 'lStudent',
  394. },
  395. });
  396. pipeline.push({ $set: { lStudent: { $sum: '$lStudent.num' } } });
  397. pipeline.push({ $project: { ...baseCol, lStudent: { $toDouble: '$lStudent' } } });
  398. baseCol.lStudent = 1;
  399. pipeline.push({ $set: { total: { $multiply: [ '$money', { $add: [ '$zStudent', '$lStudent' ] }] } } });
  400. // #endregion
  401. const qp = _.cloneDeep(pipeline);
  402. if (parseInt(skip)) qp.push({ $skip: parseInt(skip) });
  403. if (parseInt(limit)) qp.push({ $limit: parseInt(limit) });
  404. const data = await this.lessonModel.aggregate(qp);
  405. const tp = _.cloneDeep(pipeline);
  406. tp.push(this.totalPip());
  407. const tr = await this.lessonModel.aggregate(tp);
  408. const total = this.getTotal(tr);
  409. return { data, total };
  410. }
  411. // 聚合总数管道
  412. totalPip() {
  413. return {
  414. $count: 'total',
  415. };
  416. }
  417. /**
  418. * 取出聚合查询的总数
  419. * @param {Array} data 聚合查询总数的结果($count)
  420. * @param {String} key 总数的字段
  421. * @return {Number} 返回总数
  422. */
  423. getTotal(data, key = 'total') {
  424. return _.get(_.head(data), key, 0);
  425. }
  426. resetQuery(time, key = 'time') {
  427. let query = {};
  428. const { year, month, lastDate } = this.getPartsOfNow();
  429. const timeQuery = (start, end) => ({ $and: [{ [key]: { $gte: start } }, { [key]: { $lte: end } }] });
  430. if (time === 'm') {
  431. const start = `${year}-${month}-01`;
  432. const end = `${year}-${month}-${lastDate}`;
  433. query = { ...query, ...timeQuery(start, end) };
  434. } else if ([ '3m', '6m' ].includes(time)) {
  435. const ms = _.head(time.split('')); // 月份数量 3/6/...
  436. const start = moment().subtract(ms, 'months').format('YYYY-MM-01');
  437. const { year, month, lastDate } = this.getPartsOfNow();
  438. const end = `${year}-${month}-${lastDate}`;
  439. query = { ...query, ...timeQuery(start, end) };
  440. } else if (time === '1y') {
  441. const { year } = this.getPartsOfNow();
  442. const start = `${year}-01-01`;
  443. const end = `${year}-12-31`;
  444. query = { ...query, ...timeQuery(start, end) };
  445. }
  446. return query;
  447. }
  448. // 获取现在时间的各个部分 年月日时分秒 和 当月最后一天是几号
  449. getPartsOfNow(time = new Date()) {
  450. const year = moment(time).year();
  451. let month = moment(time).month() + 1;
  452. if (month < 10) month = `0${month}`;
  453. const date = moment(time).date();
  454. const hour = moment(time).hour();
  455. const minute = moment(time).minute();
  456. const second = moment(time).second();
  457. const lastDate = moment(`${year}-${month}-01`).add(1, 'months').subtract(1, 'days')
  458. .date();
  459. return { year, month, date, hour, minute, second, lastDate };
  460. }
  461. // 获取两个时间点内的每天
  462. getEachDay(start, end) {
  463. const arr = [];
  464. let i = 0;
  465. const addDay = (s, i) => moment(s).add(i, 'days').format('YYYY-MM-DD');
  466. while (!moment(addDay(start, i)).isAfter(end, 'day')) {
  467. arr.push(addDay(start, i));
  468. i++;
  469. }
  470. return arr;
  471. }
  472. // 根据数据获取日期
  473. getDate(time) {
  474. const year = moment(time).year();
  475. let month = moment(time).month() + 1;
  476. if (month < 10) month = `0${month}`;
  477. const date = moment(time).date();
  478. return `${year}-${month}-${date}`;
  479. }
  480. // 获取月份第一天的列表, 往前推 pushNum 个月
  481. getMonthList(pushNum, date) {
  482. if (!_.isNumber(pushNum)) pushNum = parseInt(pushNum);
  483. const arr = [];
  484. const { year, month } = this.getPartsOfNow(date);
  485. const sDate = `${year}-${month}-01`;
  486. for (let i = 0; i < pushNum; i++) {
  487. const { year, month } = this.getPartsOfNow(moment(sDate).subtract(i, 'months'));
  488. arr.push(`${year}-${month}-01`);
  489. }
  490. return arr;
  491. }
  492. }
  493. module.exports = StatisticsService;