chore(addon/aikefu): 调整config的配置内容

This commit is contained in:
2025-12-06 13:25:15 +08:00
parent 0ff979917c
commit d8a0dd5d31
2 changed files with 70 additions and 64 deletions

View File

@@ -1,4 +1,9 @@
<?php
/**
* 智能客服配置模型
* 用于存储和管理智能客服的配置信息
* 版本1.0.0
*/
namespace addon\aikefu\model;
@@ -20,15 +25,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;
}