浏览代码

菜单更新

zqwang 1 年之前
父节点
当前提交
e7b207fc87
共有 1 个文件被更改,包括 5 次插入8 次删除
  1. 5 8
      modules/WechatPlatform/Services/WechatMenuService.php

+ 5 - 8
modules/WechatPlatform/Services/WechatMenuService.php

@@ -49,7 +49,6 @@ class WechatMenuService extends BaseService
         if (is_empty($info)) {
         if (is_empty($info)) {
             self::throwErrMsg('该菜单不存在或已删除');
             self::throwErrMsg('该菜单不存在或已删除');
         }
         }
-
         WechatMenu::where('id', $id)->update($param);
         WechatMenu::where('id', $id)->update($param);
         $data = [
         $data = [
             'type' => $param['type'],
             'type' => $param['type'],
@@ -57,8 +56,8 @@ class WechatMenuService extends BaseService
             'msg_content' => $param['msg_content']
             'msg_content' => $param['msg_content']
         ];
         ];
         WechatAccountMenuDetail::where('menu_id', $id)->update($data);
         WechatAccountMenuDetail::where('menu_id', $id)->update($data);
-        $appIds = WechatAccountMenuDetail::where(['status' => 1, 'menu_id' => $info->id])->pluck('wechat_authorization_info_id')->toArray();
         // 更新公众号菜单
         // 更新公众号菜单
+        $appIds = WechatAccountMenuDetail::where(['status' => 1, 'menu_id' => $info->id])->pluck('wechat_authorization_info_id')->toArray();
         self::createWechatMenus($appIds,$id);
         self::createWechatMenus($appIds,$id);
         return ['msg' => '操作成功'];
         return ['msg' => '操作成功'];
     }
     }
@@ -89,12 +88,13 @@ class WechatMenuService extends BaseService
                 "client_platform_type" => $val->type == "iso" ? "1" : "2",
                 "client_platform_type" => $val->type == "iso" ? "1" : "2",
             ];
             ];
             $res = $app->menu->create($val->content, $matchRule);
             $res = $app->menu->create($val->content, $matchRule);
-
+            myLog('wx-meun')->info(['res' => $res]);
 
 
             $errcode = getProp($res,'errcode',"");
             $errcode = getProp($res,'errcode',"");
             if (intval($errcode) ==  65303){
             if (intval($errcode) ==  65303){
                 $res = $app->menu->create($val->content);
                 $res = $app->menu->create($val->content);
             }
             }
+            myLog('wx-meun')->info(['res' => $res]);
             $wxMenuId = getProp($res, 'menuid', "");
             $wxMenuId = getProp($res, 'menuid', "");
             $res = $app->menu->create($val->content, $matchRule);
             $res = $app->menu->create($val->content, $matchRule);
             myLog('wx-meun')->info(['res' => $res,'mid' => $wxMenuId]);
             myLog('wx-meun')->info(['res' => $res,'mid' => $wxMenuId]);
@@ -237,12 +237,8 @@ class WechatMenuService extends BaseService
                 }
                 }
             }
             }
             // $allSet = WechatAccountMenuDetail::query()->where('user_id', $info->user_id)->get();
             // $allSet = WechatAccountMenuDetail::query()->where('user_id', $info->user_id)->get();
-
+            $appIds = [];
             foreach ($wechatAccountInfos as $val) {
             foreach ($wechatAccountInfos as $val) {
-                if (!in_array($val->id, $appIds)) {
-                    $createAddIp[] = $val->id;
-                }
-
                 $data['wechat_accounts'][] = [
                 $data['wechat_accounts'][] = [
                     'id' => $val->id,
                     'id' => $val->id,
                     'appid' => $val->authorizer_appid,
                     'appid' => $val->authorizer_appid,
@@ -288,6 +284,7 @@ class WechatMenuService extends BaseService
         } catch (\Exception $exception) {
         } catch (\Exception $exception) {
             self::throwErrMsg('操作失败');
             self::throwErrMsg('操作失败');
         }
         }
+        $createAddIp = WechatAccountMenuDetail::where(['status' => 1, 'menu_id' => $info->id])->pluck('wechat_authorization_info_id')->toArray();
         myLog('wx-meun')->info(['c' => $createAddIp,'del' => $delAppId]);
         myLog('wx-meun')->info(['c' => $createAddIp,'del' => $delAppId]);
         if (!empty($createAddIp)) {
         if (!empty($createAddIp)) {
             self::createWechatMenus($createAddIp,$id);
             self::createWechatMenus($createAddIp,$id);