From 613251ae1fbb2ff710aaa7247c41cda99394efc5 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 16 Jan 2023 14:35:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=95=86=E5=9F=8E1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community/CommunityRepository.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/app/common/repositories/community/CommunityRepository.php b/app/common/repositories/community/CommunityRepository.php index 8c26db40..07b93b6a 100644 --- a/app/common/repositories/community/CommunityRepository.php +++ b/app/common/repositories/community/CommunityRepository.php @@ -119,7 +119,58 @@ class CommunityRepository extends BaseRepository if ($list) $list = $list->toArray(); return compact('count','list'); } + public function getApiListTwo(array $where, int $page, int $limit, $userInfo) + { + if (!$userInfo){ + $count=0; + $list=[]; + return compact('count','list'); + } + $village_id=Db::name('nk_user')->where('user_id',$userInfo->uid)->value('village_id'); + if (!$village_id){ + $count=0; + $list=[]; + return compact('count','list'); + } + $arr=Db::name('community_address')->where('village_id',$village_id)->page($page, $limit)->select(); + if (count($arr)==0){ + $count=0; + $list=[]; + return compact('count','list'); + } + $arr2=[]; + foreach ($arr as $k=>$v){ + $arr2[]=$v['community_id']; + } + $arrWhere=['id_and_in'=>$arr2]; + $query = $this->dao->getSearch($arrWhere)->order('start DESC,create_time DESC,community_id DESC'); + $query->with([ + 'author' => function($query) use($userInfo){ + $query->field('uid,real_name,status,avatar,nickname,count_start'); + }, + 'is_start' => function($query) use ($userInfo) { + $query->where('left_id',$userInfo->uid ?? null); + }, + 'topic' => function($query) { + $query->where('status', 1)->where('is_del',0); + $query->field('topic_id,topic_name,status,category_id,pic,is_del'); + }, + 'relevance' => [ + 'spu' => function($query) { + $query->field('spu_id,store_name,image,price,product_type,activity_id,product_id'); + } + ], + 'is_fans' => function($query) use($userInfo){ + $query->where('left_id',$userInfo->uid?? 0); + } + ]); + $count = Db::name('community_address')->where('village_id',$village_id)->count(); + $list = $query->setOption('field',[]) + ->field('community_id,title,image,topic_id,count_start,count_reply,start,create_time,uid,status,is_show,content') + ->select()->append(['time']); + return compact('count','list'); + } public function getFirtVideo($where,$page, $userInfo) { $with =[];