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