From 054ddaddcced30cc5b7869954657f48749ff1cf7 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 16 Oct 2024 11:30:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=93=E5=BA=93=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在商品列表的库存查询中增加了仓库库存选项。通过请求参数 is_warehouse,可选择是否仅查询仓库中的商品库存。此功能增强了库存管理的灵活性,允许管理员根据需要查看不同类型的库存信息。 --- app/admin/lists/store_product/StoreProductLists.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index cab0de4df..86fdfbdc9 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -61,11 +61,12 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $this->searchWhere[] = ['cate_id', '=', $class_all]; } } + $is_warehouse=$this->request->get('is_warehouse',0); return StoreProduct::where($this->searchWhere) ->field(['id', 'image', 'store_info', 'store_name', 'top_cate_id', 'two_cate_id', 'swap', 'product_type', 'cate_id', 'batch', 'price', 'vip_price', 'sales', 'stock', 'is_show', 'unit', 'cost', 'rose', 'purchase', 'bar_code', 'manufacturer_information']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select()->each(function ($item) { + ->select()->each(function ($item) use($is_warehouse) { $item['bar_code_two'] = ''; if (in_array($item['unit'], [2, 21])) { $item['bar_code_two'] = $item['bar_code']; @@ -99,10 +100,14 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $item['product_type_name'] = '普通商品'; } $item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name'); - $nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); $stock = StoreBranchProduct::where('store_id', '<>', '4')->where('product_id', $item['id'])->sum('stock'); - $item['stock'] = bcadd($nums, $stock); $item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name'); + if($is_warehouse==1){ + $item['stock'] = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); + }else{ + $nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); + $item['stock'] = bcadd($nums, $stock); + } return $item; })?->toArray(); }