消息模块完善

This commit is contained in:
Dev
2026-10-08 16:28:21 +08:00
parent 379d29a356
commit 107cbbe971
17 changed files with 401 additions and 28 deletions
@@ -112,6 +112,7 @@ class EasyWeChatService
/**
* 发送小程序订阅消息
* 只要走了订阅消息,就同步发送一条站内消息(失败不影响订阅消息主流程)
* @param $user_id
* @param $template_id
* @param array $msgData
@@ -123,6 +124,17 @@ class EasyWeChatService
$response = $this->app->getClient()->postJson('/cgi-bin/message/subscribe/send', $data);
$res = $response->toArray(false);
Log::info('发送订阅消息-res' . json_encode(['data' => $data, 'res' => $res], JSON_UNESCAPED_UNICODE));
//同步写站内消息(extra_json.page 直接复用订阅消息的跳转页面)
try {
MessageService::createBySubscribe($user_id, $template_id, $msgData, $data['page'] ?? '');
} catch (\Exception $e) {
Log::error('订阅消息同步站内消息失败:' . json_encode([
'user_id' => $user_id,
'template_id' => $template_id,
'error' => $e->getMessage(),
], JSON_UNESCAPED_UNICODE));
}
}
/**