新增仓库库存查询功能
在商品列表的库存查询中增加了仓库库存选项。通过请求参数 is_warehouse,可选择是否仅查询仓库中的商品库存。此功能增强了库存管理的灵活性,允许管理员根据需要查看不同类型的库存信息。
This commit is contained in:
parent
6afd0be1c8
commit
054ddaddcc
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user