chore(addon/aikefu): 获取简单的配置信息,包括:enabled,status
This commit is contained in:
@@ -8,6 +8,9 @@ return [
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
'KefuGetConfig' => [
|
||||
'addon\aikefu\event\KefuGetConfig'
|
||||
],
|
||||
'KefuChat' => [
|
||||
'addon\aikefu\event\KefuChat'
|
||||
],
|
||||
|
||||
53
src/addon/aikefu/event/KefuGetConfig.php
Normal file
53
src/addon/aikefu/event/KefuGetConfig.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace addon\aikefu\event;
|
||||
|
||||
use addon\aikefu\model\Config as KefuConfigModel;
|
||||
|
||||
/**
|
||||
* 获取智能客服配置信息
|
||||
*/
|
||||
class KefuGetConfig
|
||||
{
|
||||
/**
|
||||
* 处理获取配置信息事件
|
||||
* @param array $data 事件数据
|
||||
* @return array
|
||||
*/
|
||||
public function handle($data)
|
||||
{
|
||||
$site_id = $data['site_id'] ?? 0;
|
||||
|
||||
$response_data = [
|
||||
'enabled' => false,
|
||||
'status' => 'disabled'
|
||||
];
|
||||
|
||||
try {
|
||||
// 获取智能客服配置
|
||||
$kefu_config_model = new KefuConfigModel();
|
||||
$config_info = $kefu_config_model->getConfig($site_id);
|
||||
|
||||
$response_data = [
|
||||
'enabled' => false,
|
||||
'status' => 'disabled'
|
||||
];
|
||||
|
||||
// 处理配置信息
|
||||
if (!empty($config_info['data']['value'])) {
|
||||
$config = $config_info['data']['value'];
|
||||
|
||||
// 服务状态
|
||||
$response_data['enabled'] = $config['status'] == 1;
|
||||
$response_data['status'] = $config['status'] == 1 ? 'enabled' : 'disabled';
|
||||
}
|
||||
|
||||
return $response_data;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$response_data['status'] = 'error';
|
||||
$response_data['error'] = $e->getMessage();
|
||||
return $response_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ class Config extends BaseApi
|
||||
$map_config = $config_model->getMapConfig($this->site_id, 'shop')[ 'data' ][ 'value' ];
|
||||
|
||||
// 智能客服配置信息
|
||||
$aikefu_config = event('KefuGetInfo', ['site_id' => $this->site_id]);
|
||||
$aikefu_config = event('KefuGetConfig', ['site_id' => $this->site_id]);
|
||||
|
||||
$website_model = new SiteModel();
|
||||
$site_info = $website_model->getSiteInfo([ [ 'site_id', '=', $this->site_id ] ], 'site_id,site_domain,site_name,logo,seo_title,seo_keywords,seo_description,site_tel,logo_square')[ 'data' ];
|
||||
|
||||
Reference in New Issue
Block a user