fix: fb_leads 导入时对 full_name 增加 URL 过滤与长度截断
修复询盘自动导入因 full_name 含粘连 URL(如 "Saif Ullahhttps://...") 导致同步到 inquiry_log.contacts(varchar 255) 时超长报错、整批回滚卡死的问题。 - 新增 normalizeFullName():去掉粘连 URL + 截断到 255 - switch 新增 full_name 分支 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -114,6 +114,11 @@ class FbFileImportService
|
|||||||
$item['phone'] = $this->normalizePhone($raw);
|
$item['phone'] = $this->normalizePhone($raw);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// ✅ 姓名:去掉粘连的 URL,并截断到下游 inquiry_log.contacts 列长度(255)
|
||||||
|
case 'full_name':
|
||||||
|
$item['full_name'] = $this->normalizeFullName($raw);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (is_string($raw)) $raw = trim($raw);
|
if (is_string($raw)) $raw = trim($raw);
|
||||||
$item[$field] = $raw;
|
$item[$field] = $raw;
|
||||||
@@ -192,6 +197,27 @@ class FbFileImportService
|
|||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 姓名清洗:
|
||||||
|
* - 去掉粘连的 URL(如 "Saif Ullahhttps://..." → "Saif Ullah")
|
||||||
|
* - 纯链接记录清洗后为空字符串
|
||||||
|
* - 截断到 255(下游 inquiry_log.contacts 列长度,避免同步入库时超长报错)
|
||||||
|
*/
|
||||||
|
protected function normalizeFullName($raw): string
|
||||||
|
{
|
||||||
|
if ($raw === null) return '';
|
||||||
|
|
||||||
|
$s = trim((string)$raw);
|
||||||
|
if ($s === '') return '';
|
||||||
|
|
||||||
|
// 去掉 URL(连同前面可能的空白/不可见字符)
|
||||||
|
$s = preg_replace('#\s*https?://\S+#i', '', $s);
|
||||||
|
$s = trim($s);
|
||||||
|
|
||||||
|
// 截断到下游 contacts 列长度兜底
|
||||||
|
return mb_substr($s, 0, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规范化 is_organic 字段为 0/1
|
* 规范化 is_organic 字段为 0/1
|
||||||
|
|||||||
Reference in New Issue
Block a user