From 53a4199ba64bfdc8498e003a1c6da116cebfed69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Mon, 1 Feb 2021 13:36:14 +0800 Subject: [PATCH] Update ShopOrderSend.php --- app/data/controller/ShopOrderSend.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/data/controller/ShopOrderSend.php b/app/data/controller/ShopOrderSend.php index 6659f280f..f70a5f83b 100644 --- a/app/data/controller/ShopOrderSend.php +++ b/app/data/controller/ShopOrderSend.php @@ -34,10 +34,12 @@ class ShopOrderSend extends Controller $this->address = sysdata('ordersend'); // 状态数据统计 $this->total = ['t0' => 0, 't1' => 0, 't2' => 0, 'ta' => 0]; - $this->app->db->name($this->table)->fieldRaw('status,count(1) total')->group('status')->select()->map(function ($vo) { + $db = $this->app->db->name('ShopOrder')->whereIn('status', [3, 4, 5]); + $query = $this->app->db->name($this->table)->whereRaw("order_no in {$db->field('order_no')->buildSql()}"); + foreach ($query->fieldRaw('status,count(1) total')->group('status')->cursor() as $vo) { $this->total["t{$vo['status']}"] = $vo['total']; $this->total["ta"] += $vo['total']; - }); + } // 订单列表查询 $query = $this->_query($this->table)->order('id desc'); $query->dateBetween('address_datetime,send_datetime')->equal('status')->like('send_number#truck_number,order_no'); @@ -71,6 +73,9 @@ class ShopOrderSend extends Controller protected function _index_page_filter(array &$data) { OrderService::instance()->buildItemData($data, false); + $orders = array_unique(array_column($data, 'order_no')); + $orderList = $this->app->db->name('ShopOrder')->whereIn('order_no', $orders)->column('*', 'order_no'); + foreach ($data as &$vo) $vo['order'] = $orderList[$vo['order_no']] ?? []; } /**