From 039d696b9b9fed9822151f3ba301ccfeb631d511 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 11 Nov 2023 18:09:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/server/StoreCategory.php | 15 +++++++++++++-- crmeb/traits/CategoresDao.php | 12 ++++++++++++ crmeb/traits/CategoresRepository.php | 5 ++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/app/controller/api/server/StoreCategory.php b/app/controller/api/server/StoreCategory.php index 4d7208be..a2a7ad5c 100644 --- a/app/controller/api/server/StoreCategory.php +++ b/app/controller/api/server/StoreCategory.php @@ -172,8 +172,19 @@ class StoreCategory extends BaseController /** * 分类 */ - public function list_level($pid=0,$level=0){ - $select= Db::name('store_category')->where('pid',$pid)->where('level',$level)->where('is_show',1)->where('mer_id',0)->select(); + public function list_level($pid=0,$level=0,$type=0){ + $where['pid']=$pid; + $where['level']=$level; + $where['is_show']=1; + $where['mer_id']=0; + if($type==0){ + $select= Db::name('store_category')->where($where)->field('store_category_id,pid,cate_name,sort,pic,is_show,is_hot')->select(); + }else{ + unset($where['pid']); + $arr=$this->repository->getApiTwolist(0,1); + + $select=formatCategory($arr,'store_category_id'); + } return app('json')->success($select); } diff --git a/crmeb/traits/CategoresDao.php b/crmeb/traits/CategoresDao.php index b456c8dd..b50beaef 100644 --- a/crmeb/traits/CategoresDao.php +++ b/crmeb/traits/CategoresDao.php @@ -86,6 +86,18 @@ trait CategoresDao })->order('sort DESC,'.$this->getPk().' DESC')->select(); } + /** + * 获取二级分类 + * @param int $mer_id + * @return mixed + * @author Qinii + */ + public function getTwoAll($mer_id = 0,$status = null) + { + return $this->getModel()::getDB()->whereIn('level',[0,1])->where('mer_id', $mer_id)->when(($status !== null),function($query)use($status){ + $query->where($this->getStatus(),$status); + })->order('sort DESC,'.$this->getPk().' DESC')->select(); + } /** * 通过id 获取path * @param int $id 需要检测的数据 diff --git a/crmeb/traits/CategoresRepository.php b/crmeb/traits/CategoresRepository.php index 9bcb3ec4..caa4effe 100644 --- a/crmeb/traits/CategoresRepository.php +++ b/crmeb/traits/CategoresRepository.php @@ -37,7 +37,10 @@ trait CategoresRepository { return formatCategory($this->dao->getAll($merID,$status)->hidden(['path','level','mer_id','create_time'])->toArray(), $this->dao->getPk()); } - + public function getApiTwolist($merID,$status = null) + { + return formatCategory($this->dao->getTwoAll($merID,$status)->hidden(['path','level','mer_id','create_time'])->toArray(), $this->dao->getPk()); + } /** * 筛选用 * @Author:Qinii