From de459e01d2c2e0db57ab0c95497b347630360f19 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 2 Dec 2023 13:53:21 +0800 Subject: [PATCH] =?UTF-8?q?dataview=20=E8=AE=A2=E5=8D=95=E6=8E=92=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/Order.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controller/api/dataview/Order.php b/app/controller/api/dataview/Order.php index 5cd8c5bd..ffb6775f 100644 --- a/app/controller/api/dataview/Order.php +++ b/app/controller/api/dataview/Order.php @@ -126,14 +126,16 @@ class Order extends BaseController $type = $this->request->get('type',2); // 1今日 2总计 $townList = Db::name('geo_street')->field('street_code,street_name')->where('area_code', $this->areaCode)->select()->toArray(); // 镇/街道列表 + $orderCount = 0; foreach ($townList as &$town) { // 查询订单数 $orderCountQuery = Db::name('product_order_log')->where('street_code', $town['street_code'])->where('status', 1); if ($type == 1) { $orderCountQuery->whereDay('create_time', 'today'); } - $orderCount = $orderCountQuery->count(); - $town['order_count'] = $orderCount; + $tempOrderCount = $orderCountQuery->count(); + $town['order_count'] = $tempOrderCount; + $orderCount += $tempOrderCount; } unset($town); // $orderRankingQuery = Db::name('product_order_log')->alias('op') @@ -149,6 +151,6 @@ class Order extends BaseController $orderCountArr = array_column($townList, 'order_count'); array_multisort($orderCountArr, SORT_DESC, $townList); - return app('json')->success($townList); + return app('json')->success(compact('orderCount', 'townList')); } } \ No newline at end of file