【程序目录】用户列表标签搜索优化

This commit is contained in:
吴昊天 2022-08-26 09:56:39 +08:00
parent eebc637bea
commit 9a44d705b1

View File

@ -171,10 +171,15 @@ class UserWechatUserDao extends BaseDao
}
//用户标签
if (isset($where['label_id']) && $where['label_id']) {
$model = $model->where(function ($query) use ($where, $userAlias) {
$labelIds = explode(',', $where['label_id']);
foreach ($labelIds as $item) {
$query->whereFindInSet($userAlias . 'label_ids', $item);
$model = $model->whereIn($userAlias . 'uid', function ($query) use ($where) {
if (is_array($where['label_id'])) {
$query->name('user_label_relation')->whereIn('label_id', $where['label_id'])->field('uid')->select();
} else {
if (strpos($where['label_id'], ',') !== false) {
$query->name('user_label_relation')->whereIn('label_id', explode(',', $where['label_id']))->field('uid')->select();
} else {
$query->name('user_label_relation')->where('label_id', $where['label_id'])->field('uid')->select();
}
}
});
}