|
@@ -380,6 +380,44 @@ class IndexService extends CrudService {
|
|
}
|
|
}
|
|
return { data, total };
|
|
return { data, total };
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ async patentUserIndex({ id }) {
|
|
|
|
+ const disclosure = this.ctx.model.Patent.Disclosure;
|
|
|
|
+ // 预评估:预评估报告的数据数量,申请中:所有的数据
|
|
|
|
+ const condition = [
|
|
|
|
+ { $match: { user_id: ObjectId(id) } },
|
|
|
|
+ {
|
|
|
|
+ $lookup: {
|
|
|
|
+ from: 'disclosure_report',
|
|
|
|
+ localField: '_id',
|
|
|
|
+ foreignField: 'disclosure_id',
|
|
|
|
+ as: 'report',
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ { $group: { _id: '', total: { $sum: 1 } } },
|
|
|
|
+ ];
|
|
|
|
+ const r1 = await disclosure.aggregate(condition);
|
|
|
|
+ const report = _.get(_.head(r1), 'total', 0);
|
|
|
|
+ const havehand = await disclosure.count({ user_id: ObjectId(id) });
|
|
|
|
+ const apply = { report, havehand };
|
|
|
|
+ // 发明,使用新型,其他
|
|
|
|
+ const invent = await disclosure.count({ user_id: ObjectId(id), type: '发明' });
|
|
|
|
+ const practical = await disclosure.count({ user_id: ObjectId(id), type: '使用新型' });
|
|
|
|
+ const other = await disclosure.count({ user_id: ObjectId(id), $and: [{ type: { $ne: '使用新型' } }, { type: { $ne: '发明' } }] });
|
|
|
|
+ const patent = { invent, practical, other };
|
|
|
|
+ // 消息:未读,已读,通知(所有)
|
|
|
|
+ const noticeModel = this.ctx.model.Patent.Notice;
|
|
|
|
+ const unread = await noticeModel.count({ to: ObjectId(id), is_read: false });
|
|
|
|
+ const read = await noticeModel.count({ to: ObjectId(id), is_read: true });
|
|
|
|
+ const notice = await noticeModel.count({ to: ObjectId(id) });
|
|
|
|
+ const message = { unread, read, notice };
|
|
|
|
+ // TODO 交易: 许可, 转移,质押
|
|
|
|
+ const permit = 0;
|
|
|
|
+ const transfer = 0;
|
|
|
|
+ const pledge = 0;
|
|
|
|
+ const deal = { permit, transfer, pledge };
|
|
|
|
+ return { apply, patent, message, deal };
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
module.exports = IndexService;
|
|
module.exports = IndexService;
|