From 71dca13119e4a87b92816517875023fe03c21a6c Mon Sep 17 00:00:00 2001 From: mzl Date: Tue, 16 Jun 2026 16:47:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20fb=5Fleads=20=E5=AF=BC=E5=85=A5=E6=97=B6?= =?UTF-8?q?=E5=AF=B9=20full=5Fname=20=E5=A2=9E=E5=8A=A0=20URL=20=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E4=B8=8E=E9=95=BF=E5=BA=A6=E6=88=AA=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复询盘自动导入因 full_name 含粘连 URL(如 "Saif Ullahhttps://...") 导致同步到 inquiry_log.contacts(varchar 255) 时超长报错、整批回滚卡死的问题。 - 新增 normalizeFullName():去掉粘连 URL + 截断到 255 - switch 新增 full_name 分支 Co-Authored-By: Claude --- app/inquiry/service/FbFileImportService.php | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/inquiry/service/FbFileImportService.php b/app/inquiry/service/FbFileImportService.php index 93c3474..9c7e9dd 100644 --- a/app/inquiry/service/FbFileImportService.php +++ b/app/inquiry/service/FbFileImportService.php @@ -114,6 +114,11 @@ class FbFileImportService $item['phone'] = $this->normalizePhone($raw); break; + // ✅ 姓名:去掉粘连的 URL,并截断到下游 inquiry_log.contacts 列长度(255) + case 'full_name': + $item['full_name'] = $this->normalizeFullName($raw); + break; + default: if (is_string($raw)) $raw = trim($raw); $item[$field] = $raw; @@ -192,6 +197,27 @@ class FbFileImportService 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