From 1d37a2c27031c632710d586fbf26ab1c294583a3 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Sat, 26 Aug 2023 17:47:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BF=AE=E5=A4=8D=E4=BA=A4?= =?UTF-8?q?=E6=98=93=E5=A4=A7=E5=8E=85=E4=B8=AD=E7=9A=84=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E5=BA=94=E6=A0=B9=E6=8D=AE=E5=AF=B9=E5=BA=94=E7=9A=84=E5=95=86?= =?UTF-8?q?=E6=88=B7=E7=B1=BB=E5=9E=8B=E5=B1=95=E7=A4=BA=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repositories/community/CommunityRepository.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/common/repositories/community/CommunityRepository.php b/app/common/repositories/community/CommunityRepository.php index 25ef518b..cd9f6467 100644 --- a/app/common/repositories/community/CommunityRepository.php +++ b/app/common/repositories/community/CommunityRepository.php @@ -109,9 +109,17 @@ class CommunityRepository extends BaseRepository $config = systemConfig("community_app_switch"); // if (!isset($where['is_type']) && $config) $where['is_type'] = is_array($config) ? implode(',', $config) : $config; if (empty($where['is_type'])) $where['is_type'] = '1,2'; + $uIdArray = []; + if ($where['is_type'] == 3) { + $categoryId = Db::name('merchant')->where('uid', $userInfo->uid)->where('status', 1)->value('category_id'); + $uIdArray = Db::name('merchant')->where('category_id', $categoryId)->where('status', 1)->where('uid', '>', 0)->column('uid'); + } $where['is_del'] = 0; - $query = $this->dao->search($where)->when(in_array(self::COMMUNITY_TYPE_RESALE, explode(',', $where['is_type'])), function ($query) { - $query->where('is_sale', 0); + $query = $this->dao->search($where)->when(in_array(self::COMMUNITY_TYPE_RESALE, explode(',', $where['is_type'])), function ($query) use ($where, $uIdArray) { + $query->where('Community.is_sale', 0); + if (is_array($uIdArray) && count($uIdArray) > 0) { + $query->whereIn('Community.uid', $uIdArray); + } })->order('start DESC,Community.create_time DESC,community_id DESC'); $query->with([ 'author' => function($query) use($userInfo){ @@ -138,7 +146,6 @@ class CommunityRepository extends BaseRepository $list = $query->page($page, $limit)->setOption('field',[]) ->field('community_id,title,image,resale_type,topic_id,Community.count_start,count_reply,start,Community.create_time,Community.uid,Community.status,is_show,content,video_link,is_type,refusal') ->select()->append(['time']); - if ($list) $list = $list->toArray(); foreach ($list as $k => $item) { if ($item['is_type'] == self::COMMUNITY_TYPE_RESALE) {