From 6bad32d9b10055e50d6eb2efec9d308d1ffac334 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Wed, 5 Nov 2025 18:35:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/common/map.md | 102 +++++ docs/common/menu.md | 38 ++ docs/common/password.md | 7 + docs/dev.md | 12 + docs/shop/index.md | 90 ++--- src/app/api/controller/Config.php | 6 +- src/app/model/web/Config.php | 202 ++++++++++ src/app/shop/view/config/ai.html | 617 ++++++++++++++++++++++++++++++ src/config/menu_shop.php | 11 + 9 files changed, 1039 insertions(+), 46 deletions(-) create mode 100644 docs/common/map.md create mode 100644 docs/common/menu.md create mode 100644 docs/common/password.md create mode 100644 docs/dev.md create mode 100644 src/app/shop/view/config/ai.html diff --git a/docs/common/map.md b/docs/common/map.md new file mode 100644 index 000000000..939ce72c2 --- /dev/null +++ b/docs/common/map.md @@ -0,0 +1,102 @@ + +# 这个文件在哪里被用到了,请给出详细的说明 + + + +我需要搜索代码库中对 map.html 文件的引用,以确定它在哪里被使用。 + + +toolName: search_codebase + +status: success + +query: 查找对 /src/app/shop/view/config/map.html 文件的引用 + +我需要使用正则表达式进行更精确的搜索,查找对 map.html 文件的直接引用。 + + +toolName: search_by_regex + +status: success + +query: shop/config/map + +让我查看处理 'shop/config/map' 路由的控制器文件,以确定它是如何被使用的。 + + +toolName: search_by_regex + +status: success + +query: class.*Config.*Controller|function.*map + +我需要查看 Config.php 控制器中的 map() 方法实现,了解 map.html 文件是如何被使用的。 + + +toolName: view_files + +status: success + + +filePath: src/app/shop/controller/Config.php + +`/src/app/shop/view/config/map.html` 文件在项目中主要用于店铺的地图配置功能。以下是详细说明: + +## 文件用途 +该文件是一个视图模板,用于展示和配置腾讯地图相关的设置,主要包括腾讯地图 KEY 的配置和手机端定位功能的启用/关闭。 + +## 使用方式 + +### 1. 控制器调用 +该视图文件由 控制器中的 方法调用和渲染。当用户访问对应路由时,控制器会通过以下代码渲染该视图: +```php +return $this->fetch('config/map'); +``` + +### 2. 菜单配置 + +**老配置** +在 文件中,该页面被注册为店铺后台的一个菜单项,位于"店铺设置" > "其他设置" > "地图配置",对应的路由为 `shop/config/map`。 + +**最新配置** +现在关于菜单的处理,全部放到数据库中,_menu 表中, 查看配置处理 + +``` sql +-- auto-generated definition +create table lucky_menu +( + id int(11) unsigned auto_increment comment '菜单ID' + primary key, + app_module varchar(255) default 'admin' not null comment '应用模块', + addon varchar(255) default '' not null comment '所属插件', + title varchar(50) default '' not null comment '菜单标题', + name varchar(50) default '' not null comment '菜单关键字', + parent varchar(255) default '' not null comment '上级菜单', + level int default 1 not null comment '深度等级', + url varchar(255) default '' not null comment '链接地址', + is_show tinyint default 0 not null comment '是否展示', + sort int default 0 not null comment '排序(同级有效)', + `desc` varchar(255) default '' not null comment '描述', + is_icon tinyint default 0 not null comment '是否是矢量菜单图', + picture varchar(255) default '' not null comment '图片(矢量图)', + picture_select varchar(255) default '' not null comment '图片(矢量图)(选中)', + is_control tinyint default 1 not null comment '是否控制权限' +) + comment '菜单表' charset = utf8 + row_format = DYNAMIC; +``` + + +### 3. 其他页面引用 +该配置页面在以下几个页面中被引用,作为地图配置的入口点: +- :当地址定位功能无法使用时,提供配置入口 +- :提供地图配置的入口(目前被注释掉) + +## 功能实现 +1. **数据提交**:通过 AJAX 提交表单数据到 `shop/config/map` 路由 +2. **数据处理**:控制器接收数据后,调用 `ConfigModel` 的方法验证和保存地图配置 +3. **配置存储**:配置信息存储在系统配置中,包括腾讯地图 KEY 和手机端定位开关状态 + +## 关联功能 +该地图配置主要用于支持项目中的定位功能,特别是在门店地图展示、地址选择等场景中使用。 + \ No newline at end of file diff --git a/docs/common/menu.md b/docs/common/menu.md new file mode 100644 index 000000000..6a28a40fb --- /dev/null +++ b/docs/common/menu.md @@ -0,0 +1,38 @@ +# 菜单配置 + +系统的菜单配置,全部放到数据库中,_menu 表中 + +``` sql +-- auto-generated definition +create table lucky_menu +( + id int(11) unsigned auto_increment comment '菜单ID' + primary key, + app_module varchar(255) default 'admin' not null comment '应用模块', + addon varchar(255) default '' not null comment '所属插件', + title varchar(50) default '' not null comment '菜单标题', + name varchar(50) default '' not null comment '菜单关键字', + parent varchar(255) default '' not null comment '上级菜单', + level int default 1 not null comment '深度等级', + url varchar(255) default '' not null comment '链接地址', + is_show tinyint default 0 not null comment '是否展示', + sort int default 0 not null comment '排序(同级有效)', + `desc` varchar(255) default '' not null comment '描述', + is_icon tinyint default 0 not null comment '是否是矢量菜单图', + picture varchar(255) default '' not null comment '图片(矢量图)', + picture_select varchar(255) default '' not null comment '图片(矢量图)(选中)', + is_control tinyint default 1 not null comment '是否控制权限' +) + comment '菜单表' charset = utf8 + row_format = DYNAMIC; +``` + +以 AI 配置菜单为例 + +``` +INSERT INTO shop_mallnew.lucky_menu (id, app_module, addon, title, name, parent, level, url, is_show, sort, `desc`, is_icon, picture, picture_select, is_control) VALUES (2481, 'shop', '', 'AI智能', 'CONFIG_AI_PLATFORM', 'CONFIG_BASE', 3, 'shop/config/ai', 1, 99, '', 0, '', '', 1); +``` + +| id | app\_module | addon | title | name | parent | level | url | is\_show | sort | desc | is\_icon | picture | picture\_select | is\_control | +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | +| 2481 | shop | | AI智能 | CONFIG\_AI\_PLATFORM | CONFIG\_BASE | 3 | shop/config/ai | 1 | 99 | | 0 | | | 1 | diff --git a/docs/common/password.md b/docs/common/password.md new file mode 100644 index 000000000..1938ad8dd --- /dev/null +++ b/docs/common/password.md @@ -0,0 +1,7 @@ +# 密码关系 + + +| 密码明文 | 密码密文| +| --- | --- | +| shjs8888 | 3acce189dc4fb79af8750eda8ea7073a | +| admin123456789 | 29e6803d217472f3c0b2cd7f13f84ec9 | \ No newline at end of file diff --git a/docs/dev.md b/docs/dev.md new file mode 100644 index 000000000..c09e4d0cc --- /dev/null +++ b/docs/dev.md @@ -0,0 +1,12 @@ +# 开发指引 + + +## View模板中的定义 + +``` + + +``` + +这个变量是在 src\app\event\init\InitConfig.php 中定义的,会在系统初始化时被替换为实际的路径。 + diff --git a/docs/shop/index.md b/docs/shop/index.md index c9b958244..d027dbd00 100644 --- a/docs/shop/index.md +++ b/docs/shop/index.md @@ -1,46 +1,46 @@ -# 租户端(tenement)/商户端 - -欢迎来到租户端(tenement)/商户端的文档页面。在这里,您将找到有关如何使用和管理租户端/商户端的详细信息和指南。 - -## 目录 - -- [简介](#简介) -- [登录](#登录) -- [功能概述](#功能概述) -- [常见问题](#常见问题) -- [支持与反馈](#支持与反馈) - -## 简介 - -租户端(tenement)/商户端是一个专为租户/商户设计的平台,旨在简化管理流程,提高运营效率。无论您是制造业企业还是独立商户,我们的系统都能满足您的需求。 - -## 登录 - -要开始使用租户端/商户端,您需要按照以下步骤进行登录及配置: - -1. 访问登录页面:[登录链接:https://example.com/shop/login/login.html](https://example.com/shop/login/login.html) -2. 使用您的管理员账号和密码进行登录。 -3. 登录后,您可以根据需要配置系统设置、用户权限和其他功能。 - -**开发账号** - -- 网址[http://localhost/shop/login/login.html](http://localhost/shop/login/login.html) -- 测试账号:防爆电器 -- 密码:shjs8888 - -## 功能概述 - -租户端(tenement)/商户端提供了以下主要功能: - -1. **店铺管理**:管理店铺信息、店铺装修、文章管理、文件管理等等内容。 -2. **商品管理**: 实时监控和管理商品库存,确保供应链顺畅。 -3. **会员管理**: 管理会员信息,提升会员服务质量。 -4. **订单管理**: 管理和跟踪客户订单的处理状态。 -5. **营销管理**: 创建和管理促销活动,例如优惠券、积分兑换等活动,吸引更多客户。 -6. **分销管理**:管理分销商、分销商品、分销订单、分销提现等内容。 -7. **财务管理**:管理财务数据,包括收入、支出和利润分析,涉及充值订单、余额明细、积分明细、余额提现等。 -8. **数据分析**: 提供详细的数据报表,帮助您了解业务表现和客户行为。(交易分析、会员统计、商品统计) -9. **渠道管理**: 提供微信小程序、快应用、H5等的配置管理 -10. **应用管理**:提供应用插件,助力商户运营管理。 -11. **系统设置**: 配置系统参数,确保平台运行顺畅。 +# 租户端(tenement)/商户端 + +欢迎来到租户端(tenement)/商户端的文档页面。在这里,您将找到有关如何使用和管理租户端/商户端的详细信息和指南。 + +## 目录 + +- [简介](#简介) +- [登录](#登录) +- [功能概述](#功能概述) +- [常见问题](#常见问题) +- [支持与反馈](#支持与反馈) + +## 简介 + +租户端(tenement)/商户端是一个专为租户/商户设计的平台,旨在简化管理流程,提高运营效率。无论您是制造业企业还是独立商户,我们的系统都能满足您的需求。 + +## 登录 + +要开始使用租户端/商户端,您需要按照以下步骤进行登录及配置: + +1. 访问登录页面:[登录链接:https://example.com/shop/login/login.html](https://example.com/shop/login/login.html) +2. 使用您的管理员账号和密码进行登录。 +3. 登录后,您可以根据需要配置系统设置、用户权限和其他功能。 + +**开发账号** + +- 网址[http://localhost/shop/login/login.html](http://localhost/shop/login/login.html) +- 测试账号:制氧设备 +- 密码:shjs8888 + +## 功能概述 + +租户端(tenement)/商户端提供了以下主要功能: + +1. **店铺管理**:管理店铺信息、店铺装修、文章管理、文件管理等等内容。 +2. **商品管理**: 实时监控和管理商品库存,确保供应链顺畅。 +3. **会员管理**: 管理会员信息,提升会员服务质量。 +4. **订单管理**: 管理和跟踪客户订单的处理状态。 +5. **营销管理**: 创建和管理促销活动,例如优惠券、积分兑换等活动,吸引更多客户。 +6. **分销管理**:管理分销商、分销商品、分销订单、分销提现等内容。 +7. **财务管理**:管理财务数据,包括收入、支出和利润分析,涉及充值订单、余额明细、积分明细、余额提现等。 +8. **数据分析**: 提供详细的数据报表,帮助您了解业务表现和客户行为。(交易分析、会员统计、商品统计) +9. **渠道管理**: 提供微信小程序、快应用、H5等的配置管理 +10. **应用管理**:提供应用插件,助力商户运营管理。 +11. **系统设置**: 配置系统参数,确保平台运行顺畅。 \ No newline at end of file diff --git a/src/app/api/controller/Config.php b/src/app/api/controller/Config.php index 74fb8feb7..d41f9712f 100644 --- a/src/app/api/controller/Config.php +++ b/src/app/api/controller/Config.php @@ -126,6 +126,9 @@ class Config extends BaseApi $copyright = $config_model->getCopyright($this->site_id, 'shop')[ 'data' ][ 'value' ]; $map_config = $config_model->getMapConfig($this->site_id, 'shop')[ 'data' ][ 'value' ]; + // AI智能客服配置信息 + $aiagent_config = $config_model->getAIAgentServicesConfig($this->site_id, 'shop')[ 'data' ][ 'value' ]; + $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' ]; @@ -148,7 +151,8 @@ class Config extends BaseApi 'servicer' => $servicer_info, 'shop_info'=>$shop_info, 'store_config' => $this->store_data[ 'config' ], - 'map_config' => $map_config + 'map_config' => $map_config, + 'aiagent_config' => $aiagent_config, ]; if (!empty($this->store_data[ 'store_info' ])) { $res[ 'store_info' ] = $this->store_data[ 'store_info' ]; diff --git a/src/app/model/web/Config.php b/src/app/model/web/Config.php index a65cbaab9..2c61d6a86 100644 --- a/src/app/model/web/Config.php +++ b/src/app/model/web/Config.php @@ -286,6 +286,208 @@ class Config extends BaseModel return $res; } + /** + * 获取支持的AI平台类型 + * @return array + */ + public function getSupportAIPlatformTypes() + { + return [ + ['value' => 'dify', 'label' => 'Dify'], + ['value' => 'ragflow', 'label' => 'Ragflow'], + ]; + } + + /** + * 设置AI第三平台提供的配置信息 + * @$data + * @param int $site_id + * @param string $app_module + * @return array + */ + public function setAIPlatformConfig($data, $site_id = 1, $app_module = 'shop') + { + $config = new ConfigModel(); + $res = $config->setConfig($data, 'AI第三平台提供的配置信息', 1, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'AI_PLATFORM_CONFIG' ] ]); + return $res; + } + + /** + * 获取AI第三平台提供的配置信息 + * @param int $site_id + * @param string $app_module + * @return array + */ + public function getAIPlatformConfig($site_id = 1, $app_module = 'shop') + { + $config = new ConfigModel(); + $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'AI_PLATFORM_CONFIG' ] ]); + if (empty($res[ 'data' ][ 'value' ])) { + $id = time(); + $res[ 'data' ][ 'value' ] = [ + 'default' => [ 'id' => $id, 'name'=> 'dify-demo' ], + 'list' => [ + // Dify Demo 版本, + ['id' => $id, 'name' => 'dify-demo', 'type' => 'dify', 'type_label' => 'Dify', 'desc' => 'Dify Demo 版本', 'enable' => 1, 'api_url' => 'https://api.dify.cn', 'api_key' => '', 'create_time' => time()], + ] + ]; + return $res; + } + + return $res; + } + + /** + * 设置AI智能客服配置信息 + * @param $data 配置信息 + * @param int $site_id + * @param string $app_module + * @return array + */ + public function setAIAgentServicesConfig($data, $site_id = 1, $app_module = 'shop') + { + $config = new ConfigModel(); + $res = $config->setConfig($data, 'AI配置信息', 1, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'AI_AGENT_SERVICES_CONFIG' ] ]); + return $res; + } + + /** + * 获得AI智能客服配置信息 + * @param int $site_id + * @param string $app_module + * @return array + */ + public function getAIAgentServicesConfig($site_id = 1, $app_module = 'shop') + { + $config = new ConfigModel(); + $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'AI_AGENT_SERVICES_CONFIG' ] ]); + if (empty($res[ 'data' ][ 'value' ])) { + $res[ 'data' ][ 'value' ] = [ + // 是否开启AI功能 + 'enable' => false, + // 用户头像url + 'user_avatar' => [ + 'en'=> '', + 'zh_CN' => '', + ], + // AI客服头像url + 'ai_avatar' => [ + 'en'=> '', + 'zh_CN' => '', + ], + // AI客服姓名 + 'ai_name' => [ + 'en'=> '', + 'zh_CN' => '', + ], + // 欢迎语, 也称为开场白,初始化消息 + 'welcome_messages' => [ + 'en'=> [], + 'zh_CN' => [], + ], + // 是否显示加载更多按钮 + 'show_load_more_button' => true, + // 最大消息数量 + 'max_messages' => 100, + // 是否启用流式响应 + 'stream_mode' => true, + // 流式响应的超时时间,单位:秒 + 'stream_timeout' => 30, + // 流式响应速度(字符/秒) + 'stream_speed' => 20, + // 是否开启支持语音输入 + 'support_voice_input' => false, + // 语音输入的提示信息 + 'voice_input_prompt' => [ + 'en' => 'Please click the microphone icon to start recording', + 'zh_CN' => '请点击麦克风图标开始录音', + ], + // 是否开启语音输入提示 + 'support_voice_input_prompt' => false, + // 输入文本内容提示 + 'text_input_prompt' => [ + 'en' => 'Please enter your problem', + 'zh_CN' => '请输入您的问题', + ], + // 输入的问题描述的字符长度限制 + 'max_char_length_for_problem' => 500, + // 是否支持显示更多工具面板 + 'tool_panel_config' =>[ + 'enable' => false, + 'title' => [ + 'en' => 'More Tools', + 'zh_CN' => '更多功能', + ], + 'icon' => 'icon-more', + // 工具面板中的工具项 + 'tools' => [ + 'image' => [ + 'enable' => false, + 'name' => [ + 'en' => 'Image', + 'zh_CN' => '图片', + ], + 'description' =>[ + 'en'=> 'Upload image', + 'zh_CN' => '上传图片', + ], + 'icon' => 'icon-image', + ], + 'video' =>[ + 'enable' => false, + 'name' => [ + 'en' => 'Video', + 'zh_CN' => '视频', + ], + 'description' => [ + 'en'=> 'Upload video', + 'zh_CN' => '上传视频', + ], + 'icon' => 'icon-video', + ], + 'file' => [ + 'enable' => false, + 'name' => [ + 'en' => 'File', + 'zh_CN' => '文件', + ], + 'description' => [ + 'en'=> 'Upload file', + 'zh_CN' => '上传文件', + ], + 'icon' => 'icon-file', + ], + 'voice' =>[ + 'enable' => false, + 'name'=> [ + 'en' => 'Voice', + 'zh_CN' => '语音', + ], + 'description' =>[ + 'en'=> 'Voice input', + 'zh_CN' => '语音输入', + ], + 'icon'=> 'icon-voice', + ], + 'location' => [ + 'enable' => false, + 'name' => [ + 'en' => 'Location', + 'zh_CN' => '位置', + ], + 'description' => [ + 'en'=> 'Location input', + 'zh_CN' => '位置输入', + ], + 'icon'=> 'icon-location', + ], + ], + ] + ]; + } + return $res; + } + /** * 设置获取H5域名配置 * @param $data diff --git a/src/app/shop/view/config/ai.html b/src/app/shop/view/config/ai.html new file mode 100644 index 000000000..a19ef65f7 --- /dev/null +++ b/src/app/shop/view/config/ai.html @@ -0,0 +1,617 @@ + + + +
+ +
+ +
+
+ +
+ +
+ 基础设置 +
+
+ +
+ +
+
+ + +
+
+
    +
  • 简体中文
  • +
  • English
  • +
+
+
+
+ +
+ +
+
+ +
+ +
+ +
支持JPG、PNG、GIF格式,建议尺寸:100x100px
+
+
+ +
+ +
+ +
支持JPG、PNG、GIF格式,建议尺寸:100x100px
+
+
+ +
+ +
+ + +
+
+
+
+
+ +
+ +
+
+ +
+ +
+ +
Support JPG, PNG, GIF formats, recommended size: + 100x100px
+
+
+ +
+ +
+ +
Support JPG, PNG, GIF formats, recommended size: + 100x100px
+
+
+ +
+ +
+ + +
+
+
+
+
+ +
+ + +
+ 显示设置 +
+
+ +
+ +
+
+ +
+ +
+ +
+
+
建议设置在10-500条之间
+
+ +
+ +
+ +
+
+
+
+
+ +
+ +
+ 基本设置 +
+ +
+ +
+ +
+
+ + +
+ AI服务平台配置 +
+ +
+ + + + + + + + + + + + {if isset($platform_list) && !empty($platform_list)} + {foreach $platform_list as $platform} + + + + + + + + {/foreach} + {else} + + + + {/if} + +
名称类型API URLAPI Key操作
+ + + + + + + + + + + +
暂无平台配置
+
+ + +
+ +
+ +
+
+ +
+
+
+
+
+ + + \ No newline at end of file diff --git a/src/config/menu_shop.php b/src/config/menu_shop.php index b2acb550e..4fd034b3f 100644 --- a/src/config/menu_shop.php +++ b/src/config/menu_shop.php @@ -2509,6 +2509,17 @@ return [ ], ], ], + [ + 'name'=> 'CONFIG_AI_PLATFORM', + 'title' => 'AI智能客服配置', + 'url'=> 'shop/config/ai', + 'is_show' => 1, + 'is_control' => 1, + 'is_icon' => 0, + 'picture' => '', + 'picture_selected' => '', + 'sort' => 1, + ], [ 'name' => 'CONFIG_BASE_ORDER', 'title' => '交易设置',