feat(warehouse_order): 优化产品查询和分类名称显示

- 在 WarehouseOrderController 中使用 withTrashed() 方法查询产品,以包含软删除的产品
- 修改 StoreProductLists 中的分类名称显示逻辑,显示完整的分类路径
This commit is contained in:
mkm 2024-11-19 16:36:06 +08:00
parent 0b8e5372c4
commit 8889b01989
2 changed files with 6 additions and 5 deletions

View File

@ -203,7 +203,7 @@ class WarehouseOrderController extends BaseAdminController
$credit_pay = 0;
$cash_pay = 0;
foreach ($data as $key => &$value) {
$find = StoreProduct::where('id', $value->product_id)->find();
$find = StoreProduct::where('id', $value->product_id)->withTrashed()->find();
$value->store_name = $find['store_name'] ?? '';
$value->store_info = $find['store_info'] ?? '';
if (!empty($find['unit'])) {
@ -248,9 +248,9 @@ class WarehouseOrderController extends BaseAdminController
$total_price=0;
foreach ($data as $key => &$value) {
if(in_array($order['store_id'],[17,18])){
$find = StoreBranchProduct::where('product_id', $value->product_id)->where('store_id',$order['store_id'])->find();
$find = StoreBranchProduct::where('product_id', $value->product_id)->where('store_id',$order['store_id'])->withTrashed()->find();
}else{
$find = StoreProduct::where('id', $value->product_id)->find();
$find = StoreProduct::where('id', $value->product_id)->withTrashed()->find();
}
$value->store_name = $find['store_name'] ?? '';
$value->store_info = $find['store_info'] ?? '';
@ -311,7 +311,7 @@ class WarehouseOrderController extends BaseAdminController
$system_store = SystemStore::where('id', $warehouseOrder['store_id'])->value('introduction');
$data = WarehouseProduct::where('oid', $id)->where('financial_pm',0)->field('oid,product_id,nums')->select()
->each(function ($item) use ($system_store,$warehouseOrder) {
$find = StoreProduct::where('id', $item['product_id'])->field('store_name,unit')->find();
$find = StoreProduct::where('id', $item['product_id'])->field('store_name,unit')->withTrashed()->find();
$unit_name = StoreProductUnit::where('id', $find['unit'])->value('name');
$item['system_store'] = $system_store;
$item['subtitle'] = $item['oid'].' '.convertStringToNumber($item['nums']).'/'.$unit_name;

View File

@ -100,7 +100,8 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
}
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
$stock = StoreBranchProduct::where('store_id', '<>', '4')->where('product_id', $item['id'])->sum('stock');
$item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name');
$category = StoreCategory::where('id','in',[$item['top_cate_id'],$item['two_cate_id'],$item['cate_id']])->column('name');
$item['cate_name'] =implode('/', $category);
if($is_warehouse==1){
$item['stock'] = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums');
}else{