From 731cd17802aa4e4b422088435508ab75be7ae18a Mon Sep 17 00:00:00 2001 From: liufumingren Date: Mon, 21 Sep 2026 17:40:39 +0800 Subject: [PATCH] 1 --- application/index/controller/Index.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index ef23302..0da2b1f 100644 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -546,6 +546,21 @@ class Index extends Frontend $type = $this->request->get('type', 3); // 默认授权所有权限 $view = $this->request->get('view', 'pc'); // 默认PC端 $appid = $this->request->get('appid', ''); // 可选:指定要授权的公众号appid + $storeId = (int)$this->request->get('store_id', 0); // 门店ID,由跳转方通过URL带入 + $userId = (int)$this->request->get('user_id', 0); // 用户ID,由跳转方通过URL带入 + + // 写入授权上下文,供 authNotic 回跳时读取(跨系统共享) + $stateKey = 'auth_state:' . $state; + $stateData = [ + 'store_id' => $storeId, + 'user_id' => $userId, + 'create_time' => time() + ]; + $this->redis->setex($stateKey, 600, json_encode($stateData, JSON_UNESCAPED_UNICODE)); + \think\Log::info('授权页写入 auth_state: ' . $stateKey . ' => ' . json_encode($stateData, JSON_UNESCAPED_UNICODE)); + if (empty($storeId) && empty($userId)) { + \think\Log::error('授权页缺少 store_id/user_id 参数,authNotic 绑定将无法定位门店: state=' . $state); + } // 生成授权链接(把 state 带入回调地址,微信回跳 authNotic 时才能还原上下文) $authUrl = $this->getAuthUrl($type, $view, $state);