代码优化
This commit is contained in:
@@ -333,8 +333,9 @@ class WorkbenchGroupPushJob
|
||||
{
|
||||
$sendData = [];
|
||||
|
||||
// 内容处理
|
||||
if (!empty($content['content'])) {
|
||||
// 内容处理(小程序素材 content 为 JSON,不能按文本推送)
|
||||
$contentTypeNum = (int)($content['contentType'] ?? 0);
|
||||
if (!empty($content['content']) && $contentTypeNum !== 5) {
|
||||
// 京东转链
|
||||
if (!empty($config['promotionSiteId'])) {
|
||||
$WorkbenchController = new WorkbenchController();
|
||||
@@ -430,6 +431,49 @@ class WorkbenchGroupPushJob
|
||||
];
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
// 小程序:content 为 JSON,与触客宝快捷语 / 存客宝表单一致(可含 body 内容消息)
|
||||
$mini = json_decode($content['content'] ?? '', true);
|
||||
if (is_array($mini) && ($mini['type'] ?? '') === 'miniprogram') {
|
||||
$body = trim((string)($mini['body'] ?? $mini['contentMessage'] ?? $mini['message'] ?? ''));
|
||||
if ($body !== '') {
|
||||
if ($type == 'group') {
|
||||
$sendData[] = [
|
||||
'content' => $body,
|
||||
'msgType' => 1,
|
||||
'wechatAccountId' => $wechatAccountId,
|
||||
'wechatChatroomId' => $targetId,
|
||||
];
|
||||
} else {
|
||||
$sendData[] = [
|
||||
'content' => $body,
|
||||
'msgType' => 1,
|
||||
];
|
||||
}
|
||||
}
|
||||
$miniPayload = [
|
||||
'type' => 'miniprogram',
|
||||
'title' => $mini['title'] ?? '',
|
||||
'des' => $mini['des'] ?? '',
|
||||
'gh' => $mini['gh'] ?? '',
|
||||
'pagepath' => $mini['pagepath'] ?? '',
|
||||
'previewImage' => $mini['previewImage'] ?? '',
|
||||
];
|
||||
if ($type == 'group') {
|
||||
$sendData[] = [
|
||||
'content' => $miniPayload,
|
||||
'msgType' => 49,
|
||||
'wechatAccountId' => $wechatAccountId,
|
||||
'wechatChatroomId' => $targetId,
|
||||
];
|
||||
} else {
|
||||
$sendData[] = [
|
||||
'content' => $miniPayload,
|
||||
'msgType' => 49,
|
||||
];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $sendData;
|
||||
|
||||
Reference in New Issue
Block a user