yonge 3 weeks ago
parent
commit
30a7ba0d5b

+ 4 - 1
crmeb/app/jobs/MiniProgramKefuReplyJob.php

@@ -55,7 +55,10 @@ class MiniProgramKefuReplyJob extends BaseJobs
             $coze = app()->make(CozeServices::class);
             $reply = $coze->chatText('mini_' . $openid, $content);
             if ($reply !== '') {
-                MiniProgramService::staffTo($openid, $reply);
+                $sendResult = MiniProgramService::staffTo($openid, $reply);
+                if (($sendResult['errcode'] ?? 0) != 0) {
+                    Log::error('小程序客服 Coze 回复发送失败:' . json_encode($sendResult, JSON_UNESCAPED_UNICODE));
+                }
             }
         } catch (\Throwable $e) {
             Log::error('小程序客服 Coze 回复失败:' . $e->getMessage());

+ 1 - 6
crmeb/crmeb/services/app/MiniProgramService.php

@@ -891,7 +891,6 @@ class MiniProgramService
      */
     public static function serve(): Response
     {
-        Log::error('小程序miniServe入口已进入');
         $wechat = self::application(true);
         $server = $wechat->server;
         self::hook($server);
@@ -902,17 +901,13 @@ class MiniProgramService
     private static function hook($server)
     {
         $server->setMessageHandler(function ($message) {
-            Log::error('小程序客服回调原始消息:' . json_encode($message, JSON_UNESCAPED_UNICODE));
-            Log::error('小程序客服回调MsgType:' . json_encode($message->MsgType ?? null, JSON_UNESCAPED_UNICODE));
             switch ($message->MsgType) {
                 case 'text':
                     $content = trim((string)($message->Content ?? ''));
                     $openid = (string)($message->FromUserName ?? '');
-                    Log::error('小程序客服回调进入text分支:' . json_encode($message, JSON_UNESCAPED_UNICODE));
                     if ($content !== '' && $openid !== '') {
                         $messageId = (string)($message->MsgId ?? md5($openid . $content . ($message->CreateTime ?? time())));
-                        $dispatchRes = MiniProgramKefuReplyJob::dispatchAsync($openid, $content, $messageId);
-                        Log::error('小程序客服Coze已入队:openid=' . $openid . ' content=' . $content . ' messageId=' . $messageId . ' result=' . json_encode($dispatchRes, JSON_UNESCAPED_UNICODE));
+                        MiniProgramKefuReplyJob::dispatchAsync($openid, $content, $messageId);
                     }
                     return 'success';
                 case 'event':