$item) { if ($item[$pidField] == $pid) { unset($items[$ki]); $item['children'] = $this->recursionChildrenList($items, $item[$primaryField], $pidField, $primaryField); $list[] = $item; } } return $list; } /** * 获取所有的商圈数据 */ public function getAllBusinessCircleList(array $fields=[]) { try { return BusinessCircle::field($fields) ->order(['sort'=>'desc', 'id'=>'asc']) ->select(); } catch (\Exception $e) { return new Collection(); } } /** * 获取商圈详情 * * @param int $id * @param array $fields * @param callable|null $call * @return array|\think\Model|null */ public function findBusinessCircleById(int $id, array $fields = [], callable $call = null) { try { return BusinessCircle::findById($id, $fields, $call); } catch (\Exception $e) { return null; } } /** * 获取商家分类数据 */ public function getBusinessTypeList(array $where=[], array $fields = [], callable $call=null, array $order = []) { try { $res = Category::findList($where, $fields, 1, 0, $call, $order); return $res['list']; } catch (\Exception $e) { return new Collection(); } } /** * 获取商家分类详情 * @param int $id * @param array $fields * @param callable|null $call * @return array|\think\Model|null */ public function findBusinessTypeById(int $id, array $fields = [], callable $call = null) { try { return Category::findById($id, $fields, $call); } catch (\Exception $e) { return null; } } }