|
@@ -288,17 +288,10 @@ class ProductService extends Service
|
|
|
->select($field)
|
|
|
->orderby('code', 'asc');
|
|
|
|
|
|
-
|
|
|
- if(! empty($data['title'])) {
|
|
|
- // 清理用户输入,去除前后空白并替换多个连续空格为单个空格
|
|
|
- $cleanTitle = preg_replace('/\s+/', ' ', trim($data['title']));
|
|
|
- // 构建查询时使用 TRIM 和 REPLACE 来清理数据库字段中的空白字符
|
|
|
- $model->whereRaw("TRIM(REPLACE(title, ' ', '')) LIKE ?", ['%' . str_replace(' ', '', $cleanTitle) . '%']);
|
|
|
- }
|
|
|
-
|
|
|
- if(! empty($data['product_category_id'])) $model->where('product_category_id', $data['product_category_id']);
|
|
|
+ if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
|
|
|
if(! empty($data['category'])) $model->where('code', 'LIKE', '%'.$data['category'].'%');
|
|
|
if(! empty($data['size'])) $model->where('size', 'LIKE', '%'.$data['size'].'%');
|
|
|
+ if(! empty($data['code'])) $model->where('code', 'LIKE', '%'.$data['code'].'%');
|
|
|
if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
|
|
|
$return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
|
|
|
$model->where('crt_time','>=',$return[0]);
|