feat: 优化 SystemStoreStorageLists 类中的查询逻辑
This commit is contained in:
parent
c8b5607300
commit
2df0bf5c1f
@ -29,7 +29,7 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['admin_id', 'staff_id', 'status','type'],
|
||||
'=' => ['admin_id', 'staff_id', 'status', 'type'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -45,12 +45,12 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$this->searchWhere[] = ['store_id','=',$this->adminInfo['store_id']];//只显示当前门店的入库记录
|
||||
if($this->request->__get('status')==-1){
|
||||
$this->searchWhere[] = ['status','>=',0];
|
||||
$this->searchWhere[] = ['store_id', '=', $this->adminInfo['store_id']]; //只显示当前门店的入库记录
|
||||
if ($this->request->__get('status') == -1) {
|
||||
$this->searchWhere[] = ['status', '>=', 0];
|
||||
}
|
||||
return SystemStoreStorage::where($this->searchWhere)
|
||||
->field(['id', 'store_id', 'admin_id', 'staff_id', 'product_id', 'nums','mark', 'status'])
|
||||
->field(['id', 'store_id', 'admin_id', 'staff_id', 'product_id', 'nums', 'mark', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['status' => 'aes'])
|
||||
->select()->each(function ($item) {
|
||||
@ -62,9 +62,15 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI
|
||||
} else {
|
||||
$item['staff_name'] = '无';
|
||||
}
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('store_name,image')->find();
|
||||
$item['store_name']=$find['store_name'];
|
||||
$item['image']=$find['image'];
|
||||
$find = StoreProduct::where('id', $item['product_id'])->field('store_name,image')->find();
|
||||
if ($find) {
|
||||
$item['store_name'] = $find['store_name'];
|
||||
$item['image'] = $find['image'];
|
||||
} else {
|
||||
$item['store_name'] = '';
|
||||
$item['image'] = '';
|
||||
}
|
||||
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
@ -81,5 +87,4 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI
|
||||
{
|
||||
return SystemStoreStorage::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user