|
@@ -12,6 +12,22 @@ class TransactionService extends CrudService {
|
|
|
this.model = this.ctx.model.Transaction;
|
|
|
}
|
|
|
|
|
|
+ async query(query, { skip = 0, limit = 0 } = {}) {
|
|
|
+ query = this.ctx.service.util.util.dealQuery(query);
|
|
|
+ const { user_id, supplier, demander, status, ...info } = query;
|
|
|
+ query.status = status.split(',');
|
|
|
+ let res;
|
|
|
+ if (!user_id) {
|
|
|
+ res = await this.model.find(query).skip(parseInt(skip)).limit(parseInt(limit))
|
|
|
+ .sort({ 'meta.createdAt': -1 });
|
|
|
+ } else {
|
|
|
+ const nquery = { ...info, $or: [{ supplier: user_id }, { demander: user_id }] };
|
|
|
+ res = await this.model.find(nquery).skip(parseInt(skip)).limit(parseInt(limit))
|
|
|
+ .sort({ 'meta.createdAt': -1 });
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 审核交易
|
|
|
* @param {Object} { id } 交易数据的id
|