From 0ff979917c362b9c8684ae603bf2f4edde138ee7 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Sat, 6 Dec 2025 12:52:30 +0800 Subject: [PATCH] =?UTF-8?q?chore(addon/aikefu):=20=E8=B0=83=E6=95=B4config?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/addon/aikefu/model/Config.php | 9 +++++++++ src/addon/aikefu/shop/controller/Kefu.php | 10 +++++----- src/addon/aikefu/shop/view/kefu/config.html | 8 ++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/addon/aikefu/model/Config.php b/src/addon/aikefu/model/Config.php index b0de5f4b3..4515fdabe 100644 --- a/src/addon/aikefu/model/Config.php +++ b/src/addon/aikefu/model/Config.php @@ -20,6 +20,15 @@ class Config extends BaseModel public function setConfig($data, $site_id = 0, $app_module = 'shop') { $config = new ConfigModel(); + + // 获取原始配置 + $original_config = $this->getConfig($site_id, $app_module)['data']['value'] ?? []; + + // 如果 API Key 为空或保持不变,则使用原始值 + if (isset($data['api_key']) && empty($data['api_key'])) { + $data['api_key'] = $original_config['api_key'] ?? ''; + } + $res = $config->setConfig($data, '智能客服配置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'AIKEFU_CONFIG']]); return $res; } diff --git a/src/addon/aikefu/shop/controller/Kefu.php b/src/addon/aikefu/shop/controller/Kefu.php index e4abd26c8..43bb14009 100644 --- a/src/addon/aikefu/shop/controller/Kefu.php +++ b/src/addon/aikefu/shop/controller/Kefu.php @@ -33,7 +33,7 @@ class Kefu extends BaseShop return $result; } else { // 获取配置 - $config_info = $kefu_config_model->getConfig($this->site_id); + $config_info = $kefu_config_model->getConfig($this->site_id, $this->app_module)['data']['value'] ?? []; $this->assign('config_info', $config_info); return $this->fetch('kefu/config'); } @@ -143,8 +143,8 @@ class Kefu extends BaseShop $kefu_conversation_model = new KefuConversationModel(); $kefu_message_model = new KefuMessageModel(); - // 开启事务 - $this->model->startTrans(); +// 开启事务 + \think\facade\Db::startTrans(); try { // 删除会话关联的消息 @@ -167,12 +167,12 @@ class Kefu extends BaseShop ]); // 提交事务 - $this->model->commit(); + \think\facade\Db::commit(); return $this->success($result); } catch (\Exception $e) { // 回滚事务 - $this->model->rollback(); + \think\facade\Db::rollback(); return $this->error($e->getMessage()); } } diff --git a/src/addon/aikefu/shop/view/kefu/config.html b/src/addon/aikefu/shop/view/kefu/config.html index 566d6dbfa..b02327aad 100644 --- a/src/addon/aikefu/shop/view/kefu/config.html +++ b/src/addon/aikefu/shop/view/kefu/config.html @@ -14,7 +14,7 @@