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