Merge pull request 'dev' (#3) from dev into main

Reviewed-on: #3
This commit is contained in:
mkm 2024-06-19 17:41:06 +08:00
commit 5a27841a02
2 changed files with 51 additions and 76 deletions

View File

@ -12,7 +12,7 @@ class ProductController extends BaseApiController{
*/ */
public function lists(){ public function lists(){
return $this->dataLists(new ProductLists(),1); return $this->dataLists(new ProductLists());
} }
/** /**

View File

@ -92,44 +92,23 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface,Li
$this->searchWhere[] = ['store_id', '=', $store_id]; $this->searchWhere[] = ['store_id', '=', $store_id];
} }
$class_all = $this->request->get('class_all'); $class_all = $this->request->get('class_all');
$where=[];
if ($class_all) { if ($class_all) {
//查3级别的 //查3级别的
$arr = Cate::where('pid', $class_all)->column('id'); $arr = Cate::where('pid', $class_all)->column('id');
if ($arr) { if ($arr) {
$arr2 = Cate::where('pid', 'in', $arr)->column('id'); $arr2 = Cate::where('pid', 'in', $arr)->column('id');
$where[]=['cate_id','in',array_merge($arr,$arr2)]; $this->searchWhere[] = ['cate_id', 'in', array_merge($arr, $arr2)];
} }
} }
if(empty($where) && $class_all){
//2或者1
$where[]=['cate_id','=',$class_all];
}
$this->searchWhere[] = ['status', '=', 1]; $this->searchWhere[] = ['status', '=', 1];
$this->searchWhere[] = ['stock', '>', 0]; $this->searchWhere[] = ['stock', '>', 0];
$M_store_id=$this->request->__get('store_id'); $data = StoreBranchProduct::where($this->searchWhere)
if($M_store_id){
$where[]=['store_id','=',$M_store_id];
$data = StoreBranchProduct::where($this->searchWhere)->where($where)
->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id', 'price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch']) ->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id', 'price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch'])
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->with(['className', 'unitName']) ->with(['className', 'unitName'])
->order($this->sortOrder) ->order($this->sortOrder)
->select() ->select()?->toArray();
->toArray();
}else{
$data = StoreBranchProduct::where($this->searchWhere)->where($where)
->field(['id', 'product_id','cate_id','store_name','cost', 'store_id','price', 'bar_code','image','sales','store_info','delete_time','unit','batch'])
->limit($this->limitOffset, $this->limitLength)
->with(['className','unitName'])
->order($this->sortOrder)
->select()
->toArray();
}
// $check = DictType::where('type','activities')->find(); // $check = DictType::where('type','activities')->find();
// foreach ($data as &$value){ // foreach ($data as &$value){
// if(isset($check) && $check['status'] == 1){ // if(isset($check) && $check['status'] == 1){
@ -143,7 +122,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface,Li
// } // }
// } // }
return $data; return $data;
} }
@ -188,13 +166,10 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface,Li
$where[] = ['store_id', '=', $M_store_id]; $where[] = ['store_id', '=', $M_store_id];
$data = StoreBranchProduct::where($this->searchWhere)->where($where) $data = StoreBranchProduct::where($this->searchWhere)->where($where)
->count(); ->count();
} else { } else {
$data = StoreBranchProduct::where($this->searchWhere)->where($where) $data = StoreBranchProduct::where($this->searchWhere)->where($where)
->count(); ->count();
} }
return $data; return $data;
} }
} }