|
@@ -221,10 +221,26 @@ class ProductInventoryService extends Service
|
|
|
if(empty($data['crt_time'][0]) || empty($data['crt_time'][1])) return [false,'时间必须选择'];
|
|
|
$return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
|
|
|
$model->whereBetween('a.crt_time',[$return[0],$return[1]]);
|
|
|
-
|
|
|
- if(! empty($data['product_category_id'])) $model->whereIn("b.product_category_id", $data['product_category_id']);
|
|
|
+ if(! empty($data['product_name'])){
|
|
|
+ $product_name = $data['product_name'];
|
|
|
+ $id = Product::where('del_time',0)
|
|
|
+ ->when(! empty($product_name), function ($query) use ($product_name) {
|
|
|
+ return $query->where('title', 'LIKE', '%'.$product_name.'%');
|
|
|
+ })
|
|
|
+ ->select('id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $model->whereIn('a.product_id',array_unique(array_column($id,'id')));
|
|
|
+ }
|
|
|
+ if(! empty($data['product_category_name'])){
|
|
|
+ $product_category_name = $data['product_category_name'];
|
|
|
+ $c = ProductCategory::where('del_time',0)
|
|
|
+ ->where('title', 'LIKE', '%'.$product_category_name.'%')
|
|
|
+ ->select('id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $model->whereIn('b.product_category_id',array_unique(array_column($c,'id')));
|
|
|
+ }
|
|
|
if(! empty($data['code'])) $model->where('b.code', 'LIKE', '%'.$data['code'].'%');
|
|
|
- if(! empty($data['product_id'])) $model->where('a.product_id', $data['product_id']);
|
|
|
+ if(! empty($data['order_number'])) $model->where('a.order_number', 'LIKE', '%'.$data['order_number'].'%');
|
|
|
|
|
|
$list = $model->get()->toArray();
|
|
|
$list = $this->fillData($list, $return);
|