let q_filter = await db.collection('queen-group').aggregate().match({
_id: queen_id
}).project({
_id: true,
openid: true
})
.lookup({
from: 'queen-group-admin',
let: {
queen_id: '$_id'
},
pipeline: $.pipeline()
.match(
dbCmd.expr($.and([$.eq(['$queen_id', '$$queen_id']), $.eq(['$admin_is_delete',
false
]), $.eq(['$admin_status', true])]))
).project({
admin_openid: 1,
admin_name: 1
}).lookup({
from: 'queen-user',
let: {
admin_openid: '$admin_openid'
},
pipeline: $.pipeline()
.match(
dbCmd.expr($.eq(['$openid', '$$admin_openid']))
).project({
nickName: 1,
p_openid: 1,
subscribe: 1
}).done(),
as: 'user_info',
}).done(),
as: 'q_admin'
})
.lookup({
from: 'queen-group-business',
let: {
queen_id: '$_id'
},
pipeline: $.pipeline()
.match(
dbCmd.expr($.and([$.eq(['$queen_id', '$$queen_id']), $.eq(['$b_is_delete',
false
]), $.eq(['$b_status', true])]))
)
.sort({
sort: -1
})
.project({
b_name: 1,
})
.done(),
as: 'q_business',
})
.lookup({
from: 'queen-group-window',
let: {
queen_id: '$_id'
},
pipeline: $.pipeline()
.match(
dbCmd.expr($.and([$.eq(['$$queen_id', '$queen_id']), $.eq(['$w_is_delete',
false
])]))
)
.sort({
sort: -1
})
.project({
w_name: 1,
w_include: 1
})
.done(),
as: 'q_window',
})
.lookup({
from: 'queen-user',
let: {
openid: '$openid'
},
pipeline: $.pipeline()
.match(
dbCmd.expr(($.eq(['$openid', '$$openid'])))
)
.project({
nickName: 1,
avatarUrl: 1,
openid: 1
})
.done(),
as: 'q_create_user',
})
.end()
let q_order = await db.collection('queen-call-order').aggregate()
.match(dbCmd.and(match_list, dbCmd.or([{
order_pre_num: search ? new RegExp(search, 'gi') : search
}, {
'user_info.value': search ? new RegExp(search, 'gi') : search
}])))
.sort({
order_time: _sort
})
.skip(pagination.current * pagination.pageSize)
.limit(pagination.pageSize)
.lookup({
from: 'queen-group-business',
let: {
work_id: '$work_id'
},
pipeline: $.pipeline()
.match(
dbCmd.expr($.eq(['$_id', '$$work_id']))
)
.sort({
sort: -1
})
.project({
b_name: 1,
})
.done(),
as: 'business_info',
})
.lookup({
from: 'queen-call-order-log',
let: {
log_id: '$_id'
},
pipeline: $.pipeline()
.match(
dbCmd.expr(($.eq(['$order_id', '$$log_id'])))
)
.project({
create_time: 1,
current_state: 1
})
.done(),
as: 'q_order_log',
})
.lookup({
from: 'queen-user',
let: {
openid: '$openid'
},
pipeline: $.pipeline()
.match(
dbCmd.expr(($.eq(['$openid', '$$openid'])))
)
.project({
nickName: 1,
avatarUrl: 1,
cid: 1,
p_openid: 1,
subscribe: 1
})
.done(),
as: 'order_user',
})
.lookup({
from: 'queen-group-admin',
let: {
complete_openid: '$complete_openid',
queen_id: '$queen_id'
},
pipeline: $.pipeline()
.match(
dbCmd.expr(($.and([$.eq(['$admin_openid', '$$complete_openid']), $.eq(['$queen_id',
'$$queen_id'
]), $.eq(['$admin_is_delete', false])])))
)
.lookup({
from: 'queen-user',
let: {
admin_openid: '$admin_openid'
},
pipeline: $.pipeline()
.match(
dbCmd.expr(($.eq(['$openid', '$$admin_openid'])))
)
.project({
nickName: 1,
avatarUrl: 1,
cid: 1,
p_openid: 1,
0 个评论
要回复文章请先登录或注册