admin_stock_112

This commit is contained in:
dengbw
2023-01-12 14:35:56 +08:00
parent 36f42a33e8
commit 4c23e18b20
+17 -2
View File
@@ -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];