浏览代码

Merge remote-tracking branch 'origin/test' into test

liuzejian 1 年之前
父节点
当前提交
2f94f4686e

+ 12 - 12
modules/Channel/Http/Controllers/WechatOpenPlatformController.php

@@ -127,15 +127,16 @@ class WechatOpenPlatformController extends CatchController
 
         $componentInfo = WechatOpenPlatformService::getComponentInfoByAppid($component_appid);
         $openPlatform = WechatOpenPlatformService::buildApplication($componentInfo);
-        myLog("wx-xiaoxi")->info('-------开始处理---'.get_date());
+
         $server = $openPlatform->server;
         $message = $server->getMessage();
-        myLog("wx-xiaoxi")->info([
-            'authorizer_appid' => $authorizer_appid,
-            'component_appid' => $component_appid,
-            'param' => $request->all(),
-            'msg' => $message,
-        ]);
+        // myLog("wx-xiaoxi")->info('-------开始处理---'.get_date());
+        // myLog("wx-xiaoxi")->info([
+        //     'authorizer_appid' => $authorizer_appid,
+        //     'component_appid' => $component_appid,
+        //     'param' => $request->all(),
+        //     'msg' => $message,
+        // ]);
         $appInfo = WechatOpenPlatformService::getRefreshToken($authorizer_appid,$component_appid);
         $wechatAppId = getProp($appInfo,'id');
 
@@ -143,13 +144,12 @@ class WechatOpenPlatformController extends CatchController
         unset($appInfo);
 
         $app->server->push(function ($message) use($app,$authorizer_appid,$wechatAppId) {
-            myLog("wx-xiaoxi")->info("----文本消息---");
-            myLog("wx-xiaoxi")->info("体消息:");
-            myLog("wx-xiaoxi")->info($message);
+            // myLog("wx-xiaoxi")->info("----文本消息---");
+            // myLog("wx-xiaoxi")->info("体消息:");
+            // myLog("wx-xiaoxi")->info($message);
             return WechatCommonService::handleMessage($app,$wechatAppId ,$authorizer_appid,$message);
         });
-
-        myLog("wx-xiaoxi")->info('-------结束处理---'.get_date());
+        // myLog("wx-xiaoxi")->info('-------结束处理---'.get_date());
         return $app->server->serve()->send();
     }
 }

+ 24 - 1
modules/Channel/Services/WechatOpenPlatform/WechatOpenPlatformService.php

@@ -5,13 +5,16 @@ namespace Modules\Channel\Services\WechatOpenPlatform;
 use EasyWeChat\Factory;
 use EasyWeChat\OpenPlatform\Application;
 use EasyWeChat\OpenPlatform\Message;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Query\Builder;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\DB;
 use Modules\Channel\Models\WechatAuthorizationInfo;
 use Modules\Common\Errors\Errors;
 use Modules\Common\Exceptions\CommonBusinessException;
+use Modules\Common\Services\BaseService;
 
-class WechatOpenPlatformService
+class WechatOpenPlatformService extends BaseService
 {
     public static function getComponentInfoByCompanyUid($companyUid) {
         $componentInfo = DB::table('wechat_open_platform_infos')
@@ -89,4 +92,24 @@ class WechatOpenPlatformService
             'is_enabled'  =>  1,
         ])->first();
     }
+
+    /**
+     *  获取公众号的refreshToken
+     * name:getAppInfoById
+     * @param $id 公众号授权id
+     * @return Model|Builder|object|null
+     */
+    public static function getAppInfoById($id)
+    {
+        $info =   DB::table('wechat_authorization_infos')
+            ->where([
+                'id' =>  $id,
+                'is_enabled'  =>  1,
+            ])->first();
+        if (is_empty($info)){
+            self::throwErrMsg("公众号不存在或已取消授权");
+        }
+        return  $info;
+
+    }
 }

+ 14 - 0
modules/Common/Services/BaseService.php

@@ -49,4 +49,18 @@ class BaseService
             ['value' => 'miniprogram', 'name' => "小程序"],
         ];
     }
+
+    /**
+     * 微信公众号菜菜单系统类型
+     * name: getWechatMenuSystemType
+     * @return \string[][]
+     * date 2023/07/11 11:00
+     */
+    public static  function  getWechatMenuSystemType(): array
+    {
+        return [
+            ['value' => 'android', 'name' => "安卓"],
+            ['value' => 'ios', 'name' => "苹果"],
+        ];
+    }
 }

+ 2 - 2
modules/Video/Http/Controllers/EpisodeController.php

@@ -30,11 +30,11 @@ class EpisodeController extends CatchController
             ->where([
                 'video_id' => $request->integer('video_id'),
                 'is_enabled' => 1
-            ])->select('series_name', 'series_sequence', 'video_key', 'duration', 'id', 'video_id');
+            ]);
         if ($isFee == 1){
             $videoSeries->where('series_sequence',"<",$video->charge_sequence);
         }
-        $videoSeries->orderBy('series_sequence', 'asc')
+        $videoSeries =   $videoSeries->select('series_name', 'series_sequence', 'video_key', 'duration', 'id', 'video_id')->orderBy('series_sequence', 'asc')
             ->paginate($request->integer('limit', 15));
         /**
          * 增加微信审核状态

+ 7 - 10
modules/WechatPlatform/Http/Controllers/WechatAuthorizationInfoController.php

@@ -42,6 +42,7 @@ class WechatAuthorizationInfoController extends CatchController
         if($nick_name){
             $where[] = ['wechat_authorization_infos.nick_name','like',"%".$nick_name."%"];
         }
+        $is_export = $request->get('is_export');
 
         $result = $this->wechatAuthorizationInfo->where($where)
         ->join('wechat_open_platform_infos','wechat_open_platform_infos.app_id','=','wechat_authorization_infos.component_appid')
@@ -49,22 +50,18 @@ class WechatAuthorizationInfoController extends CatchController
         ->join('users','users.id','=','wechat_authorization_infos.user_id')
         ->select('wechat_authorization_infos.nick_name','wechat_authorization_infos.authorizer_appid','miniprogram.name as xcx_name',
         'wechat_authorization_infos.authorizer_refresh_token','users.username','wechat_authorization_infos.id'
-        ,'wechat_open_platform_infos.app_id','wechat_open_platform_infos.secret','wechat_open_platform_infos.token','wechat_open_platform_infos.aes_key')
-        ->paginate($page_size);
-
+        ,'wechat_open_platform_infos.app_id','wechat_open_platform_infos.secret','wechat_open_platform_infos.token','wechat_open_platform_infos.aes_key');
+        if($is_export){
+            $result = $result->get();
+        }else{
+            $result = $result->paginate($page_size);
+        }
 
         foreach($result as $item){
             //todo 获取粉丝数
             $item->fans_count = 0;
             $application = WechatOpenPlatformService::buildApplication($item);
             try{
-                /*
-                $officialAccount = $application->getOfficialAccountWithRefreshToken($item->authorizer_appid, $item->authorizer_refresh_token);
-                $api = $officialAccount->getClient();
-                $response = $api->get('/cgi-bin/user/list', []);
-                if($response->isSuccessful()){
-                    $item->fans_count = $response['total'];
-                }*/
                 $officialAccount = $application->officialAccount($item->authorizer_appid,$item->authorizer_refresh_token);
                 $users = $officialAccount->user->list();  // $n
                 $item->fans_count = $users['total'];

+ 66 - 1
modules/WechatPlatform/Http/Controllers/WechatMenuController.php

@@ -11,7 +11,12 @@ namespace Modules\WechatPlatform\Http\Controllers;
 
 use Catch\Base\CatchController;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Modules\Channel\Services\WechatOpenPlatform\WechatOpenPlatformService;
+use Modules\Manage\Enmus\MiniprogramType;
 use Modules\User\Http\Controllers\UserTrait;
+use Modules\WechatPlatform\Http\Requests\WechatMenuRequest;
+use Modules\WechatPlatform\Services\WechatMenuService;
 
 
 class WechatMenuController extends CatchController
@@ -32,7 +37,67 @@ class WechatMenuController extends CatchController
     }
 
 
-    public function add(){
+    public function add(WechatMenuRequest $request)
+    {
+        $param  = $this->handelParam($request->validated());
+
+    }
+
+    // 处理参数
+    private function handelParam($param)
+    {
+        $info = DB::table('miniprogram')->where('id', $param['miniprogram_id'])->first();
+        if (empty($info)) {
+            WechatMenuService::throwErrMsg("小程序不正确");
+        }
+        if ($info->status != 1) {
+            WechatMenuService::throwErrMsg("此小程序暂不提供使用");
+        }
+        if ($info->type != MiniprogramType::WEIXIN->value()) {
+            WechatMenuService::throwErrMsg("关键词回复设置仅支持微信小程序");
+        }
+        $param['miniprogram_appid'] = $info->appid;
+        $info = DB::table('user_has_miniprograms')->where('uid', $this->getLoginUserId())->where('miniprogram_id', $param['miniprogram_id'])->where('is_enabled', 1)->value('id');
+        if (empty($info)) {
+            WechatMenuService::throwErrMsg("没有此小程序的使用权限");
+        }
+        $errs = "";
+        if (count($param['content']) >3){
+            WechatMenuService::throwErrMsg("底部菜单不能超过3个");
+        }
+        $menus = [];
+        foreach ($param['content'] as  $val){
+            $temp = ['name' => $val['name']];
+            if (getProp($val,'sub_button')){
+                // 有二级菜单
+                if (count($val['sub_button']) > 5){
+                    $errs .= getProp($val,'name')."的二级菜单超过5个";
+                    continue ;
+                }
+                foreach ($val['sub_button'] as   $sub){
+                    $res = $this->checkMenuItem($sub);
+                }
+            }else{
+                // 一级菜单
+                $res = $this->checkMenuItem($sub);
+            }
+        }
+    }
+
+    private function checkMenuItem($sub)
+    {
+        $type = getProp($sub,'type');
+        if (!in_array($type,["click",'miniprogram','scancode_waitmsg'])){
+            return ['status' => 0,'msg' =>  "类型非法"];
+        }
+    }
 
+    public function test(){
+        $info = WechatOpenPlatformService::getAppInfoById(8);
+        $componentInfo = WechatOpenPlatformService::getComponentInfoByAppid($info->component_appid);
+        $openPlatform = WechatOpenPlatformService::buildApplication($componentInfo);
+        $app = $openPlatform->officialAccount($info->authorizer_appid, getProp($info,'authorizer_refresh_token'));
+        unset($appInfo);
+        return $app->menu->list();
     }
 }

+ 61 - 0
modules/WechatPlatform/Http/Requests/WechatMenuRequest.php

@@ -0,0 +1,61 @@
+<?php
+/**
+ *
+ * @file:WechatMenuRequest.php
+ * @Date: 2023/7/11
+ * @Time: 10:49
+ */
+
+
+namespace Modules\WechatPlatform\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+use Modules\WechatPlatform\Services\WechatMenuService;
+
+class WechatMenuRequest extends FormRequest
+{
+    /**
+     * rules
+     *
+     * @return array
+     */
+    public function rules(): array
+    {
+        return [
+            'type' => [
+                "required",
+                function ($attribute, $value, $fail) {
+                    $types = array_column(WechatMenuService::getWechatMenuSystemType(), 'value');
+                    if (!in_array($value, $types)) {
+                        $fail("系统类型不正确!");
+                        exit();
+                    }
+                }
+            ],
+            'miniprogram_id' => [
+                'required',
+                'Integer',
+                "gt:0",
+            ],
+            "content" =>   "required|array",
+        ];
+    }
+
+
+    /**
+     * messages
+     *
+     * @return string[]
+     */
+    public function messages(): array
+    {
+        return [
+            'type.required' => '系统类型必须填写',
+            "miniprogram_id.required" => "小程序必须填写",
+            "content.required" => "菜单必须填写",
+            "content.array" => "菜单格式不正确",
+        ];
+    }
+}
+
+

+ 1 - 1
modules/WechatPlatform/Models/WechatOfficialUserInfo.php

@@ -10,7 +10,7 @@ class WechatOfficialUserInfo extends BaseModel
     protected $table = 'wechat_official_user_info';
 
     protected $fillable = [
-        'id', 'uid', 'gzh_appid', "unsubscribe_at", 'user_id', 'puser_id', 'mp_openid', 'unionid', 'is_subscribe', 'subscribe_time', 'subscribe_time_str', 'active_end', 'updated_at', 'created_at',
+        'id', 'uid', 'gzh_appid', "gzh_id", "active_at", "unsubscribe_at", 'user_id', 'puser_id', 'mp_openid', 'unionid', 'is_subscribe', 'subscribe_time', 'subscribe_time_str', 'active_end', 'updated_at', 'created_at',
     ];
 
 }

+ 53 - 39
modules/WechatPlatform/Services/WechatCommonService.php

@@ -43,34 +43,26 @@ class WechatCommonService extends BaseService
     {
         switch ($message['MsgType']) {
             case 'event':
-                return '收到事件消息';
-                break;
+                return self::handleEvent($app, $wechatInfoId, $appid, $message);
             case 'text':
                 // 更新用户活跃时间
-                self::updateUserActivityTime($app, $appid, $message['FromUserName']);
+                self::updateUserActivityTime($app,$appid, $message['FromUserName'],$wechatInfoId );
                 return self::handleTextMessage($wechatInfoId, $message);
-            case 'image':
-                return '收到图片消息';
-                break;
-            case 'voice':
-                return '收到语音消息';
-                break;
-            case 'video':
-                return '收到视频消息';
-                break;
-            case 'location':
-                return '收到坐标消息';
-                break;
-            case 'unsubscribe':
-                self::updateUserInfo($app, $appid, $message['FromUserName'], false);
-                return '取消关注';
-                break;
-            case 'subscribe':
-                self::updateUserInfo($app, $appid, $message['FromUserName'], true);
-                return self::handleSubscribeMessage($wechatInfoId, $message);
+            // case 'image':
+            //     return '收到图片消息';
+            // case 'voice':
+            //     return '收到语音消息';
+            // case 'video':
+            //     return '收到视频消息';
+            // case 'location':
+            //     return '收到坐标消息';
+            // case 'link':
+            //     return '收到链接消息';
+            // case 'file':
+            //     return '收到文件消息';
             default:
+                self::updateUserActivityTime($app, $appid, $message['FromUserName'],$wechatInfoId);
                 return '收到其它消息';
-                break;
         }
         return "";
     }
@@ -100,19 +92,21 @@ class WechatCommonService extends BaseService
      * @param $openId
      * date 2023/07/10 18:30
      */
-    private static function updateUserActivityTime($app, $appid, $openId)
+    private static function updateUserActivityTime($app, $appid, $openId, $wechatInfoId)
     {
 
         $info = WechatOfficialUserInfo::query()->where('mp_openid', $openId)->where('gzh_appid', $appid)->first();
         $data = [
             'mp_openid' => $openId,
             'gzh_appid' => $appid,
+            'gzh_id' =>  $wechatInfoId,
             'active_at' => time(),
         ];
         if (is_empty($info)) {
-            $data = self::getUserInfo($app,$appid,$openId);
+            $data = self::getUserInfo($app,$appid,$openId,$wechatInfoId);
+            $data['active_at'] = time();
         }else{
-            if ($info->uid == 0){
+            if ($info->uid == 0 && !empty($info->unionid)){
                 $data['uid'] = intval(DB::table('wechat_miniprogram_users')->where('unionid', $info->unionid)->value('id'));
             }
         }
@@ -121,7 +115,7 @@ class WechatCommonService extends BaseService
     }
 
     /**
-     *  更新用户时间
+     *  关注取消关注更新用户信息
      * name: updateUserInfo
      * @param $app
      * @param $appid
@@ -129,13 +123,14 @@ class WechatCommonService extends BaseService
      * @param $is_gz
      * date 2023/07/10 18:31
      */
-    private static function updateUserInfo($app, $appid, $openId, $is_gz)
+    private static function updateUserInfo($app, $appid, $openId, $wechatInfoId, $is_gz)
     {
 
         if (!$is_gz) {
             $data = [
                 'mp_openid' => $openId,
                 'gzh_appid' => $appid,
+                'gzh_id' => $wechatInfoId,
                 'active_at' => time(),
                 'is_subscribe' => 0,
                 'unsubscribe_at' => get_date(),
@@ -144,6 +139,7 @@ class WechatCommonService extends BaseService
             $data = [
                 'mp_openid' => $openId,
                 'gzh_appid' => $appid,
+                'gzh_id' => $wechatInfoId,
                 'is_subscribe' => 1,
                 'subscribe_time' => time(),
                 'subscribe_time_str' => get_date(),
@@ -151,12 +147,11 @@ class WechatCommonService extends BaseService
         }
         $info = WechatOfficialUserInfo::query()->where('mp_openid', $openId)->where('gzh_appid', $appid)->first();
         if ($is_gz == true && is_empty($info)) {
-            $data = self::getUserInfo($app,$appid,$openId);
+            $data = self::getUserInfo($app,$appid,$openId,$wechatInfoId);
             WechatOfficialUserInfo::updateOrCreate(['mp_openid' => $data['mp_openid'], 'gzh_appid' => $data['gzh_appid']], $data);
         }else{
-
             if (!is_empty($info)){
-                if ($info->uid == 0){
+                if ($info->uid == 0 && !empty($info->unionid)){
                     $data['uid'] = intval(DB::table('wechat_miniprogram_users')->where('unionid', $info->unionid)->value('id'));
                 }
                 WechatOfficialUserInfo::updateOrCreate(['mp_openid' => $data['mp_openid'], 'gzh_appid' => $data['gzh_appid']], $data);
@@ -164,7 +159,7 @@ class WechatCommonService extends BaseService
         }
     }
 
-    /**
+    /**3
      *  构建用户数据
      * name: getUserInfo
      * @param $app
@@ -172,24 +167,43 @@ class WechatCommonService extends BaseService
      * @param $openId
      * date 2023/07/10 18:31
      */
-    protected  static  function getUserInfo($app,$appid,$openId){
+    protected  static  function getUserInfo($app,$appid,$openId, $wechatInfoId){
         $user = $app->user->get($openId);
-        $data = [
+        return [
             'mp_openid' => $openId,
             'gzh_appid' => $appid,
+            'gzh_id' => $wechatInfoId,
             'unionid' => $user['unionid'],
             'is_subscribe' => $user['subscribe'],
             'subscribe_time' => $user['subscribe_time'],
             'subscribe_time_str' => get_date($user['subscribe_time']),
-            'active_at' => time(),
-            'uid' => intval(DB::table('wechat_miniprogram_users')->where('unionid', $user['unionid'])->value('id')),
+            'uid' => !is_empty($user['unionid']) ? intval(DB::table('wechat_miniprogram_users')->where('unionid', $user['unionid'])->value('id')) : 0,
         ];
     }
 
-    private static function handleSubscribeMessage($wechatAppId)
+    /**
+     *  处理事件消息
+     * name: handleEvent
+     * @param $app
+     * @param $wechatInfoId
+     * @param $appid
+     * @param $message
+     * @return mixed|string
+     * date 2023/07/11 09:15
+     */
+    private static function handleEvent($app,  $wechatInfoId, $appid, $message)
     {
-        $back = WechatSubscribeService::getContent($wechatAppId);
-        return $back ?: "";
+        switch ($message['Event']) {
+            case 'unsubscribe':
+                self::updateUserInfo($app, $appid, $message['FromUserName'], $wechatInfoId,false);
+                return '取消关注';
+            case 'subscribe':
+                self::updateUserInfo($app, $appid, $message['FromUserName'],$wechatInfoId, true);
+                return WechatSubscribeService::getContent($wechatInfoId);
+            default:
+                return '收到其它消息';
+        }
+        return  '';
     }
 
 

+ 7 - 3
modules/WechatPlatform/Services/WechatKeywordsService.php

@@ -163,7 +163,7 @@ class WechatKeywordsService extends BaseService
             DB::rollBack();
             self::throwErrMsg('删除失败');
         }
-        return "操作成功";
+        return ['msg' => "操作成功"];
     }
 
     public static function allocation($id, $wxAuthIds)
@@ -249,7 +249,7 @@ class WechatKeywordsService extends BaseService
     {
         $set = MiniprogramWechatGlobalConfig::where(['user_id' => $userId, 'puser_id' => $puserId, 'miniprogram_id' => $miniprogramId])
             ->where('type', self::KEYWORD_SET_KEY)->value('value');
-        return $set == 1 ? 1 : 0;
+        return ['data' => $set == 1 ? 1 : 0];
     }
 
     public static function setConfig($param)
@@ -260,7 +260,7 @@ class WechatKeywordsService extends BaseService
             $param
         );
         if ($res) {
-            return "操作成功";
+            return ['msg' => "操作成功"];
         }
         return "操作失败";
     }
@@ -284,6 +284,10 @@ class WechatKeywordsService extends BaseService
         if (is_empty($info)) {
             return "";
         }
+        $set = self::getConfig($info->user_id,$info->puser_id,$info->miniprogram_id);
+        if (getProp($set['data'] == 0)){
+            return  '';
+        }
         WechatAccountKeywordLog::where('id', $info->id)->increment('send_total', 1);
         WechatKeywords::where('id', $info->weacht_keyworld_id)->increment('send_total', 1);
         return $info->content;

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

@@ -0,0 +1,28 @@
+<?php
+/**
+ * 公众号菜单
+ * @file:WechatMenuService.php
+ * @Date: 2023/7/11
+ * @Time: 10:53
+ */
+
+
+namespace Modules\WechatPlatform\Services;
+
+use Modules\Common\Services\BaseService;
+
+class WechatMenuService extends BaseService
+{
+    /**
+     *  添加菜单
+     * name: addMenu
+     * @param $param
+     * date 2023/07/11 11:38
+     */
+    public static function addMenu($param)
+    {
+
+    }
+
+
+}

+ 7 - 3
modules/WechatPlatform/Services/WechatSubscribeService.php

@@ -35,7 +35,7 @@ class WechatSubscribeService extends BaseService
     {
         $set = MiniprogramWechatGlobalConfig::where(['user_id' =>  $userId,'puser_id' =>  $puserId,'miniprogram_id' =>  $miniprogramId])
             ->where('type',self::KEYWORD_SET_KEY)->value('value');
-        return $set == 1 ? 1 :0;
+        return ['data' => $set == 1 ? 1 : 0];
     }
 
     /**
@@ -53,7 +53,7 @@ class WechatSubscribeService extends BaseService
             $param
         );
         if($res){
-            return "操作成功";
+            return ['msg' => "操作成功"];
         }
         self::throwErrMsg("操作失败");
     }
@@ -62,7 +62,7 @@ class WechatSubscribeService extends BaseService
     {
         $res = WechatSubscribeMsg::create($param);
         if ($res) {
-            return "操作成功";
+            return ['msg' => "操作成功"];
         }
         self::throwErrMsg("操作失败");
     }
@@ -281,6 +281,10 @@ class WechatSubscribeService extends BaseService
         if (is_empty($info)) {
             return "";
         }
+        $set = self::getConfig($info->user_id,$info->puser_id,$info->miniprogram_id);
+        if (getProp($set['data'] == 0)){
+            return  '';
+        }
         WechatAccountSubscribeDetail::where('id', $info->id)->increment('send_total', 1);
         WechatSubscribeMsg::where('id', $info->weacht_keyworld_id)->increment('send_total', 1);
 

+ 22 - 2
modules/WechatPlatform/routes/route.php

@@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Route;
 use Modules\WechatPlatform\Http\Controllers\KFMessageController;
 use Modules\WechatPlatform\Http\Controllers\WechatAuthorizationInfoController;
 use Modules\WechatPlatform\Http\Controllers\CommonController;
+use Modules\WechatPlatform\Http\Controllers\WechatMenuController;
 use Modules\WechatPlatform\Http\Controllers\WechatSubscribeController;
 use Modules\WechatPlatform\Http\Controllers\WechatKeywordsController;
 
@@ -20,7 +21,7 @@ Route::prefix('wechatPlatform')->group(function(){
     });
 
     // 关键字列表
-    Route::prefix('keyword')->group(function () {
+    Route::prefix('keyword')->middleware('roleCheck:optimizer')->group(function () {
         // 获取关键词设置
         Route::any('getConfig/{miniprogramId}',[WechatKeywordsController::class,'getConfig'])->withoutMiddleware(config('catch.route.middlewares'));
         // 关键词全局设置
@@ -54,7 +55,7 @@ Route::prefix('wechatPlatform')->group(function(){
     });
 
     // 被关注回复
-    Route::prefix('subscribe')->group(function (){
+    Route::prefix('subscribe')->middleware('roleCheck:optimizer')->group(function (){
         // 获取全局设置
         Route::any('getConfig/{miniprogramId}',[WechatSubscribeController::class,'getConfig'])->withoutMiddleware(config('catch.route.middlewares'));
         // 保存全局设置
@@ -75,4 +76,23 @@ Route::prefix('wechatPlatform')->group(function(){
         Route::any("auth_list/{id}",[WechatSubscribeController::class,'authList']);
     });
 
+    // 公众号菜单
+    Route::prefix('menu')->middleware('roleCheck:optimizer')->group(function (){
+      // 列表
+        Route::any("list",[WechatMenuController::class,'list']);
+        // 添加
+        Route::post('add',[WechatMenuController::class,'add']);
+        // 编辑
+        Route::post('edit/{id}',[WechatMenuController::class,'edit']);
+        // 详情
+        Route::any('detail/{id}',[WechatMenuController::class,'detail']);
+        // 删除
+        Route::any('del',[WechatMenuController::class,'del']);
+        // 配置公众号
+        Route::post('allocation/{id}',[WechatMenuController::class,'allocation']);
+        // 公众号配置选择项
+        Route::any("auth_list/{id}",[WechatMenuController::class,'authList']);
+        Route::any("test",[WechatMenuController::class,'test']);
+    });
+
 });