Quellcode durchsuchen

点击关键词回复

zqwang vor 1 Jahr
Ursprung
Commit
3ecadd05c1

+ 2 - 0
modules/WechatPlatform/Services/WechatCommonService.php

@@ -200,6 +200,8 @@ class WechatCommonService extends BaseService
             case 'subscribe':
                 self::updateUserInfo($app, $appid, $message['FromUserName'],$wechatInfoId, true);
                 return WechatSubscribeService::getContent($wechatInfoId);
+            case 'CLICK':
+                return  WechatMenuService::getClickInfoContent($wechatInfoId,$message['EventKey']);
             default:
                 return '收到其它消息';
         }

+ 23 - 0
modules/WechatPlatform/Services/WechatMenuService.php

@@ -351,4 +351,27 @@ class WechatMenuService extends BaseService
         return "操作成功";
     }
 
+    /**
+     *  点击事件回复
+     * name: getClickInfoContent
+     * @param $wechatInfoId
+     * date 2023/07/12 16:37
+     */
+    public static function getClickInfoContent($wechatAppId,$key)
+    {
+        $info = WechatAccountMenuDetail::query()::where([
+            'status' => 1,
+            'wechat_authorization_info_id' => $wechatAppId,
+        ])->first();
+        if (is_empty($info)){
+            return "";
+        }
+        $content  = $info->msg_content;
+        if (empty($content)){
+            return  "";
+        }
+        $content = getProp($content,$key);
+        return  $content ?: "";
+    }
+
 }