refactor(warehouse): 优化仓库产品列表数据处理
- 添加对软删除数据的查询 - 修复价格和总价的空值问题 - 调整字段名称和计算逻辑 - 优化数据展示格式
This commit is contained in:
parent
c2df6b1c7e
commit
7c21a22f28
@ -76,10 +76,12 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
->field(['id', 'oid','admin_id','supplier_id', 'store_id', 'warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price', 'purchase', 'cost', 'total_price', 'manufacture', 'expiration_date', 'status', 'mark', 'create_time','is_pay'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->withTrashed()
|
||||
->select()->each(function ($item) {
|
||||
$item->store_name = '';
|
||||
$item->image = '';
|
||||
$item->price = '';
|
||||
$item->price = $item['price']??0;
|
||||
$item->purchase = $item['purchase']??0;
|
||||
$item->unit_name = '';
|
||||
$item->store_info = '';
|
||||
$item->top_cate_name = '';
|
||||
@ -106,8 +108,12 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
$item->admin_name = '';
|
||||
}
|
||||
if ($item->product_id) {
|
||||
$find = StoreProduct::where('id', $item->product_id)->field('price,image,store_name,unit,store_info,top_cate_id')->withTrashed()->find();
|
||||
$find = StoreProduct::where('id', $item->product_id)->field('price,purchase,image,store_name,unit,store_info,top_cate_id')->withTrashed()->find();
|
||||
if($find){
|
||||
if($item->purchase<=0){
|
||||
$item->purchase = $find->purchase;
|
||||
$item->total_price=bcmul($find->purchase,$item->nums,2);
|
||||
}
|
||||
$item->store_name = $find->store_name . '|' . $item->product_id;
|
||||
$item->image = $find->image;
|
||||
$item->price = $find->price;
|
||||
@ -200,8 +206,9 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
'financial_pm_name' => '出入库',
|
||||
'system_store_name' => '门店',
|
||||
'nums' => '数量',
|
||||
'purchase' => '价格',
|
||||
'total_price' => '总价',
|
||||
'purchase' => '供货价',
|
||||
'price' => '零售价',
|
||||
'total_price' => '供货总价',
|
||||
'create_time' => '操作时间',
|
||||
];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user