From fc4f74704b3d5575e57b5dfe10e9f55ad6ff9339 Mon Sep 17 00:00:00 2001 From: todaywindy Date: Fri, 23 May 2025 18:05:28 +0800 Subject: [PATCH] map --- .../admin/controller/workers/Worker.php | 32 +++- .../admin/view/orders/dispatch/map.html | 158 +++++++++++++----- 2 files changed, 143 insertions(+), 47 deletions(-) diff --git a/application/admin/controller/workers/Worker.php b/application/admin/controller/workers/Worker.php index fdbb5df..7fd53be 100644 --- a/application/admin/controller/workers/Worker.php +++ b/application/admin/controller/workers/Worker.php @@ -272,7 +272,6 @@ class Worker extends Backend public function dispatchList() { - $area_id = request()->get('area_id'); list($where, $sort, $order, $offset, $limit) = $this->buildparams(); @@ -288,7 +287,9 @@ class Worker extends Backend ->where('status', '>=', Order::STATUS_DRAFT); return 'doing_order'; }]) - ->field(['id', 'name', 'tel', 'area_id', 'lng', 'lat']); + ->field( + ['id', 'name', 'tel', 'area_id', 'lng', 'lat'] + ); if ($area_id) { $code = $this->getSelectAreaCode(substr_replace($area_id, '00', -2)); @@ -302,4 +303,31 @@ class Worker extends Backend } + + + public function dispatchMapList() + { + $order_id = request()->get('order_id'); + if ($order_id) { + $order = (new Order())->where('id',$order_id)->select(); + + if (!empty($order)) { + $order = $order[0]; + } + + $worker_info = Db::query("SELECT id,name, tel, distance,star,lng, lat +FROM ( + SELECT id, `name`, tel, lng, lat,star, + ST_Distance_Sphere( + point(lng, lat), + point(?, ?) + ) AS distance + FROM fa_worker +) AS t +WHERE distance < 50000 +ORDER BY distance;",[$order->lng,$order->lat]); + dd($worker_info); + } + } + } diff --git a/application/admin/view/orders/dispatch/map.html b/application/admin/view/orders/dispatch/map.html index f135ea8..3d0fa62 100644 --- a/application/admin/view/orders/dispatch/map.html +++ b/application/admin/view/orders/dispatch/map.html @@ -5,8 +5,9 @@ 地图派单示例 + -
+
+
+ +
+
+ +
+ +
+
+
+ 张三 + +
+
+
+ 电话:138****1234 + 星级: + ★★★★★ + +
+
+ 距离:2.5 公里 + 订单数:3 +
+
+
+
+ + +
+
+
+ 李四 + +
+
+
+ 电话:137****5678 + 星级: + ★★★★☆ + +
+
+ 距离:4.1 公里 + 订单数:1 +
+
+
+
+ +
+