feat: 管理后台客户详情同步显示WhatsApp导入截图
crmAdmin 的 getCustomer() 增加与业务端相同的截图键->签名<img>转换 (列表/详情弹窗 v-html 渲染)。注:Excel 导出走 strip_tags, 截图键文本将不再出现在导出文件中(私有图片本也无法嵌入Excel)。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -463,9 +463,36 @@ class CustomerService
|
|||||||
$customer['enter_user_name'] = empty($customer['enter_user_id']) ? '' : User::where('id',$customer['enter_user_id'])->value('name');
|
$customer['enter_user_name'] = empty($customer['enter_user_id']) ? '' : User::where('id',$customer['enter_user_id'])->value('name');
|
||||||
$customer['user_name'] = empty($customer['user_id']) ? '公海' : User::where('id',$customer['user_id'])->value('name');
|
$customer['user_name'] = empty($customer['user_id']) ? '公海' : User::where('id',$customer['user_id'])->value('name');
|
||||||
|
|
||||||
|
// WhatsApp导入截图:desc_collect 里的 OSS 对象键 -> 带签名 <img>(前端 v-html 渲染)
|
||||||
|
$customer['desc_collect'] = self::signScreenshotImages((string)($customer['desc_collect'] ?? ''));
|
||||||
|
|
||||||
return $customer;
|
return $customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将 desc_collect 中 crm_whatsapp 截图的 OSS 对象键替换为带签名的 <img> 标签。
|
||||||
|
* 键按原文匹配签名(历史记录为双斜杠键,对象即存于该键,不可归一)。
|
||||||
|
*/
|
||||||
|
private static function signScreenshotImages(string $desc): string
|
||||||
|
{
|
||||||
|
if ($desc === '' || strpos($desc, 'crm_whatsapp/') === false) {
|
||||||
|
return $desc;
|
||||||
|
}
|
||||||
|
return preg_replace_callback(
|
||||||
|
'/([A-Za-z0-9_\-]+(?:\/[A-Za-z0-9_\-]+)*\/+crm_whatsapp\/[A-Za-z0-9_\-\.]+\.(?:png|jpe?g|webp))/',
|
||||||
|
function ($m) {
|
||||||
|
try {
|
||||||
|
$url = (new OssService())->generatePrivateUrl($m[1], 7 * 86400);
|
||||||
|
return '<img src="' . htmlspecialchars($url, ENT_QUOTES) . '" '
|
||||||
|
. 'style="max-width:100%;height:auto;display:block;margin:4px 0" />';
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return $m[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
$desc
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function detail($params)
|
public function detail($params)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user