feat: 业务端客户详情显示WhatsApp导入截图
getCustomer()(/crm/customer/list 列表与详情弹窗共用)把 desc_collect 中 crm_whatsapp 截图的 OSS 对象键替换为带签名 <img>(7天有效期,每次请求重签)。 键按原文签名(历史双斜杠键的对象即存于该键);前端 v-html 渲染,零改动。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ use app\common\model\Corp;
|
|||||||
use app\common\model\CustomerAudit;
|
use app\common\model\CustomerAudit;
|
||||||
use app\common\model\InquiryLog;
|
use app\common\model\InquiryLog;
|
||||||
use app\common\model\User;
|
use app\common\model\User;
|
||||||
|
use app\common\service\OssService;
|
||||||
use app\common\traits\crud\CrudServiceTrait;
|
use app\common\traits\crud\CrudServiceTrait;
|
||||||
use app\crm\logic\CustomerLogic;
|
use app\crm\logic\CustomerLogic;
|
||||||
use app\crm\model\Channel;
|
use app\crm\model\Channel;
|
||||||
@@ -377,9 +378,36 @@ class CustomerService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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