From 4c23e18b2006cdd7a99a8d5b162344c56ba8df2a Mon Sep 17 00:00:00 2001 From: dengbw Date: Thu, 12 Jan 2023 14:35:56 +0800 Subject: [PATCH] admin_stock_112 --- admin/controllers/items/Stock.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/admin/controllers/items/Stock.php b/admin/controllers/items/Stock.php index 392b448e..d7fa5a32 100644 --- a/admin/controllers/items/Stock.php +++ b/admin/controllers/items/Stock.php @@ -161,8 +161,23 @@ class Stock extends HD_Controller foreach ($res_biz as $v) { $months = []; foreach ($dateMonths as $v2) { - - $data = $v2['firstDay'] . '/' . $v2['lastDay']; + $where2 = $where3 = ['biz_id' => $v['id'], 'log_date>=' => $v2['firstDay'], 'log_date<=' => $v2['lastDay']]; + $res_log = $this->mdStockLog->select_groupby('s_id', $where2, 'id desc', 0, 0, 'brand_id,s_id'); + $data = ''; + if ($res_log) { + $str_ids = implode(',', array_unique(array_column($res_log, 'brand_id'))); + $map_brand = $this->mdAutoBrand->map('id', 'name', ["id in ({$str_ids})" => null]); + $str_ids = implode(',', array_unique(array_column($res_log, 's_id'))); + $map_sery = $this->mdAutoSeries->map('id', 'name', ["id in ({$str_ids})" => null]); + foreach ($res_log as $v3) { + $where3['s_id'] = $v3['s_id']; + $res_log2 = $this->mdStockLog->select_groupby('item_id', $where3, "total desc,id desc", 1, 1 + , "count(id) as total"); + $count = $res_log2 ? $res_log2[0]['total'] : 0; + $title = "{$map_brand[$v3['brand_id']]}-{$map_sery[$v3['s_id']]} {$count}天"; + $data = $data ? $data . ',' . $title : $title; + } + } $months[] = ['name' => $v2['name'], 'data' => $data]; } $biz[] = ['biz_name' => $v['biz_name'], 'months' => $months];