|
@@ -131,7 +131,6 @@ class OrderDetailService extends CrudService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
async query(filter, { skip = 0, limit, sort, desc, projection } = {}) {
|
|
|
// 处理排序
|
|
|
if (sort && _.isString(sort)) {
|
|
@@ -230,6 +229,17 @@ class OrderDetailService extends CrudService {
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ async count(filter) {
|
|
|
+ let condition = _.cloneDeep(filter);
|
|
|
+ condition = await this.beforeQuery(condition);
|
|
|
+ condition = this.dealFilter(condition);
|
|
|
+ const pipline = [{ $project: { _id: 1, id: { $toString: '$_id' } } }, { $sort: { 'meta.createdAt': -1 } }];
|
|
|
+ pipline.push({ $match: condition });
|
|
|
+ pipline.push({ $count: 'id' });
|
|
|
+ const rs = await this.model.aggregate(pipline);
|
|
|
+ return _.get(_.head(rs), 'id');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = OrderDetailService;
|