From a3b21b5bca1dc128c0df77d3e72c8772b98eaccd Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 14 Mar 2024 09:49:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BC=BA=E5=A4=B1=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/traits/CategoresDao.php | 15 +++++++++++++++ crmeb/traits/CategoresRepository.php | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/crmeb/traits/CategoresDao.php b/crmeb/traits/CategoresDao.php index 6c157bfb..8a8657fd 100644 --- a/crmeb/traits/CategoresDao.php +++ b/crmeb/traits/CategoresDao.php @@ -86,6 +86,21 @@ 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 359e4aaa..48ea6171 100644 --- a/crmeb/traits/CategoresRepository.php +++ b/crmeb/traits/CategoresRepository.php @@ -78,6 +78,12 @@ trait CategoresRepository } + + public function getApiTwolist($merID,$status = null) + { + return formatCategory($this->dao->getTwoAll($merID,$status)->hidden(['path','level','mer_id','create_time'])->toArray(), $this->dao->getPk()); + } + /** * 根据ID 查询是否存在 * @param int $merId