diff --git a/app/api/controller/Index.php b/app/api/controller/Index.php index a7a0d159..05e9234a 100644 --- a/app/api/controller/Index.php +++ b/app/api/controller/Index.php @@ -80,7 +80,20 @@ class Index extends Api $result = RegionLogic::city(); return JsonServer::success('', $result); } - + /** + * @notes 热门城市 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 胥聪 + * @date 2026/04/17 21:05 + */ + public function hotCity() + { + $result = RegionLogic::hotCity(); + return JsonServer::success('', $result); + } /** * @notes 腾讯地图逆地址解析(坐标位置描述) * @return \think\response\Json diff --git a/app/common/logic/RegionLogic.php b/app/common/logic/RegionLogic.php index aa089715..d2348841 100644 --- a/app/common/logic/RegionLogic.php +++ b/app/common/logic/RegionLogic.php @@ -46,7 +46,22 @@ class RegionLogic extends Logic return $lists; } + public static function hotCity() + { + $arr = ["上海市","北京市","广州市","深圳市","杭州市","嘉兴市","泉州市", + "漳州市","西安市","苏州市","哈尔滨市","菏泽市","惠州市","厦门市","济宁市","威海市","福州市"]; + $result = '"' . implode('","', $arr) . '"'; + $lists = DevRegion::where(['level'=>2]) + ->where("name","in",$result) + ->field('id,parent_id,level,name,short,city_code,zip_code,gcj02_lng,gcj02_lat,db09_lng,db09_lat,remark1,remark2') + ->select() + ->toArray(); + $lists = self::groupByInitials($lists); + unset($lists[null]); + + return $lists; + } /** * 二维数组根据首字母分组排序