toArray(),null,"code"); $provinceCodeArray = array_keys($provinceCode); $city = AreaModel::getByPCodes($provinceCodeArray,true); $city = array_column($city,null,"code"); $items = DictionaryRepository::getInstance()->getAllBusinessCircleList(); $items->each(function ($item)use($city) { $areaText = ''; if (!empty($item['province_text'])) { $areaText = $item['province_text'].'·'; } if (!empty($item['city_text']) && $item['city_text'] != '市辖区') { $areaText .= $item['city_text'].'·'; } if (!empty($item['county_text'])) { $areaText .= $item['county_text']; } $item['name_text'] = $item['name']; if (!empty($areaText)) { $item['name_text'] = $item['name'] . '「'.$areaText.'」'; } return $item; }); foreach ($items->toArray() as $item){ if(isset($city[$item["city"]])){ $city[$item["city"]]["children"][]=$item; } } foreach ($city as $item){ if (isset($provinceCode[$item["pcode"]])){ $provinceCode[$item["pcode"]]["children"][] =$item; } } return $this->json(0,"success",array_values($provinceCode)); } }