feat: 添加商品库存查询功能

This commit is contained in:
mkm 2024-08-07 13:45:14 +08:00
parent dbb933f12f
commit 8ea1011492

View File

@ -10,6 +10,7 @@ use app\common\lists\ListsSearchInterface;
use app\common\model\store_category\StoreCategory;
use app\common\model\store_product_unit\StoreProductUnit;
use app\common\model\system_store\SystemStore;
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
/**
* 商品列表列表
@ -64,6 +65,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
->order(['id' => 'desc'])
->select()->each(function ($item) {
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
$item['stock'] = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums');
$item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name');
return $item;
})?->toArray();