|
@@ -9,6 +9,7 @@ const assert = require('assert');
|
|
|
class IndexService extends CrudService {
|
|
|
constructor(ctx) {
|
|
|
super(ctx, 'index');
|
|
|
+ this.redis = this.app.redis;
|
|
|
this.patentModel = this.ctx.model.Patent;
|
|
|
this.code = this.ctx.model.Code;
|
|
|
this.productModel = this.ctx.model.Product;
|
|
@@ -17,6 +18,7 @@ class IndexService extends CrudService {
|
|
|
this.personalModel = this.ctx.model.Personal;
|
|
|
this.organizationModel = this.ctx.model.Organization;
|
|
|
this.surveyModel = this.ctx.model.Survey;
|
|
|
+ this.dockUser = this.ctx.model.DockUser;
|
|
|
this.tranModel = this.ctx.model.Transaction;
|
|
|
}
|
|
|
/**
|
|
@@ -153,7 +155,7 @@ class IndexService extends CrudService {
|
|
|
value: surveys,
|
|
|
});
|
|
|
const trans = await this.tranModel.aggregate([
|
|
|
- { $match: { status: { $in: [ '0', '1', '2' ] } } },
|
|
|
+ { $match: { status: { $in: [ '0', '1', '3' ] } } },
|
|
|
{
|
|
|
$group: {
|
|
|
_id: '$status',
|
|
@@ -171,7 +173,7 @@ class IndexService extends CrudService {
|
|
|
});
|
|
|
arr.push({
|
|
|
name: '对接完成',
|
|
|
- value: _.get(trans.find(f => f._id === '2'), 'value', 0),
|
|
|
+ value: _.get(trans.find(f => f._id === '3'), 'value', 0),
|
|
|
});
|
|
|
return arr;
|
|
|
}
|
|
@@ -207,6 +209,46 @@ class IndexService extends CrudService {
|
|
|
{ name: '东北师范大学' },
|
|
|
];
|
|
|
}
|
|
|
+
|
|
|
+ // 展会首页统计
|
|
|
+ async dockIndex({ dock_id }) {
|
|
|
+ // 同时在线人数(伪)
|
|
|
+ const tszx = await this.redis.get('login_number');
|
|
|
+ // 特邀嘉宾
|
|
|
+ const tyjb = await this.personalModel.count({ is_expert: true });
|
|
|
+ // 洽谈合作 达成意向 交易完成
|
|
|
+ const trans = await this.tranModel.aggregate([
|
|
|
+ { $match: { status: { $in: [ '0', '1', '3' ] } } },
|
|
|
+ {
|
|
|
+ $group: {
|
|
|
+ _id: '$status',
|
|
|
+ value: { $sum: 1 },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ]);
|
|
|
+ const qthz = _.get(trans.find(f => f._id === '0'), 'value', 0);
|
|
|
+ const dcyx = _.get(trans.find(f => f._id === '1'), 'value', 0);
|
|
|
+ const jywc = _.get(trans.find(f => f._id === '3'), 'value', 0);
|
|
|
+ // 参展项目
|
|
|
+ const res = await this.dockUser.aggregate()
|
|
|
+ .match({ dock_id: ObjectId(dock_id), 'goodsList.type': '1', 'goodsList.dockStatus': '1' })
|
|
|
+ .unwind('$goodsList')
|
|
|
+ .group({
|
|
|
+ _id: '$dock_id',
|
|
|
+ count: { $sum: 1 },
|
|
|
+ });
|
|
|
+ const czxm = _.get(res[0], 'count');
|
|
|
+ const arr = [
|
|
|
+ { name: '同时在线', num: tszx, unit: '人' },
|
|
|
+ { name: '特邀嘉宾', num: tyjb, unit: '人' },
|
|
|
+ { name: '洽谈合作', num: qthz, unit: '项' },
|
|
|
+ { name: '达成意向', num: dcyx, unit: '项' },
|
|
|
+ { name: '交易完成', num: jywc, unit: '项' },
|
|
|
+ { name: '参展项目', num: czxm, unit: '项' },
|
|
|
+ ];
|
|
|
+ return arr;
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = IndexService;
|