diff --git a/addons/shopro/controller/Ccblife.php b/addons/shopro/controller/Ccblife.php index f51ce2b..1d78849 100644 --- a/addons/shopro/controller/Ccblife.php +++ b/addons/shopro/controller/Ccblife.php @@ -39,9 +39,20 @@ class Ccblife extends Common $ccbParamSJ = $this->request->param('ccbParamSJ', ''); $otherParams = $this->request->param(); + // 记录接收到的参数(调试用) + Log::info('建行登录接收参数: ' . json_encode([ + 'method' => $this->request->method(), + 'ccbParamSJ_exists' => !empty($ccbParamSJ), + 'ccbParamSJ_length' => strlen($ccbParamSJ), + 'all_params' => array_keys($otherParams), + 'content_type' => $this->request->header('content-type') + ], JSON_UNESCAPED_UNICODE)); + // 验证必要参数 if (empty($ccbParamSJ)) { - $this->error('缺少必要参数'); + $this->error('缺少必要参数 ccbParamSJ', [ + 'received_params' => array_keys($otherParams) + ]); } // 从插件配置文件直接加载(避免config()缓存问题) @@ -110,8 +121,23 @@ class Ccblife extends Common 'redirect_url' => $redirectUrl ]); + } catch (\think\exception\HttpResponseException $e) { + // HttpResponseException 是框架正常的响应机制,直接向上抛出 + throw $e; } catch (\Exception $e) { - $this->error($e->getMessage()); + // 记录详细错误日志 + Log::error('建行生活登录失败: ' . $e->getMessage()); + Log::error('错误文件: ' . $e->getFile()); + Log::error('错误行号: ' . $e->getLine()); + Log::error('错误堆栈: ' . $e->getTraceAsString()); + + // 返回友好的错误信息(如果异常消息为空,给默认提示) + $errorMsg = $e->getMessage() ?: '登录失败,请稍后重试'; + $this->error($errorMsg, [ + 'error_type' => get_class($e), + 'error_file' => basename($e->getFile()), + 'error_line' => $e->getLine() + ]); } } @@ -136,7 +162,7 @@ class Ccblife extends Common } // 处理用户登录/注册 - $userInfo = $this->processUserLogin($ccbUserId, $mobile, '', [ + $userInfo = $this->processUserLogin($ccbUserId, $mobile, [ 'nickname' => $nickname, 'avatar' => $avatar ]); @@ -153,8 +179,12 @@ class Ccblife extends Common 'userInfo' => $userInfo ]); + } catch (\think\exception\HttpResponseException $e) { + // HttpResponseException 是框架正常的响应机制,直接向上抛出 + throw $e; } catch (\Exception $e) { Log::error('建行自动登录失败: ' . $e->getMessage()); + Log::error('错误堆栈: ' . $e->getTraceAsString()); $this->error('登录失败: ' . $e->getMessage()); } } @@ -346,6 +376,9 @@ class Ccblife extends Common // 返回解密后的数据 $this->success('解密成功', $decryptedParams); + } catch (\think\exception\HttpResponseException $e) { + // HttpResponseException 是框架正常的响应机制,直接向上抛出 + throw $e; } catch (\Exception $e) { Log::error('建行参数解密失败: ' . json_encode([ 'error' => $e->getMessage(),