|
|
@@ -545,14 +545,18 @@ class CustomerService extends Service
|
|
|
$model->where('c_third_platform_id', '>',0);
|
|
|
}
|
|
|
}
|
|
|
- if(! empty($data['title_t'])) {
|
|
|
- // 清理用户输入,去除前后空白并替换多个连续空格为单个空格
|
|
|
+ if (!empty($data['title_t'])) {
|
|
|
$cleanTitle = preg_replace('/\s+/', ' ', trim($data['title_t']));
|
|
|
$id = (new RangeService())->crtContactSearch($data);
|
|
|
- // 构建查询时使用 TRIM 和 REPLACE 来清理数据库字段中的空白字符
|
|
|
- $model->whereRaw("TRIM(REPLACE(title, ' ', '')) LIKE ?", ['%' . str_replace(' ', '', $cleanTitle) . '%'])
|
|
|
- ->orWhere('consulting_product', 'LIKE', '%'.$data['title_t'].'%')
|
|
|
- ->orWhereIn('id', $id);
|
|
|
+
|
|
|
+ $model->where(function ($q) use ($cleanTitle, $data, $id) {
|
|
|
+ $q->whereRaw(
|
|
|
+ "REPLACE(title, ' ', '') LIKE ?",
|
|
|
+ ['%' . str_replace(' ', '', $cleanTitle) . '%']
|
|
|
+ )
|
|
|
+ ->orWhere('consulting_product', 'LIKE', '%' . $data['title_t'] . '%')
|
|
|
+ ->orWhereIn('id', $id);
|
|
|
+ });
|
|
|
}
|
|
|
if(! empty($data['id'])) $model->where('id', $data['id']);
|
|
|
if(! empty($data['customer_id'])){
|
|
|
@@ -859,14 +863,6 @@ class CustomerService extends Service
|
|
|
->select($field)
|
|
|
->orderby('id', 'desc');
|
|
|
|
|
|
- if(! empty($data['title_t'])) {
|
|
|
- // 清理用户输入,去除前后空白并替换多个连续空格为单个空格
|
|
|
- $cleanTitle = preg_replace('/\s+/', ' ', trim($data['title_t']));
|
|
|
- // 构建查询时使用 TRIM 和 REPLACE 来清理数据库字段中的空白字符
|
|
|
- $model->whereRaw("TRIM(REPLACE(title, ' ', '')) LIKE ?", ['%' . str_replace(' ', '', $cleanTitle) . '%'])
|
|
|
- ->orWhere('consulting_product', 'LIKE', '%'.$data['title_t'].'%')
|
|
|
- ->orWhere('contact', 'LIKE', '%'.$data['title_t'].'%');
|
|
|
- }
|
|
|
if(! empty($data['customer_id'])){
|
|
|
$customer_id = explode(',',$data['customer_id']);
|
|
|
$model->whereIn('id', $customer_id);
|