From 157ea7f46dabb3efc717402a88f12e77392a5d8d Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Mon, 15 Dec 2025 16:31:06 +0800 Subject: [PATCH] =?UTF-8?q?chore(docker):=20=E4=BF=9D=E5=AD=98=E5=85=B3?= =?UTF-8?q?=E9=94=AE=E4=BF=A1=E6=81=AF=EF=BC=8C=E4=B8=8EDev=E5=88=86?= =?UTF-8?q?=E6=94=AF=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 3 +- src/app/model/web/Config.php | 39 +++++++ src/app/shop/controller/Config.php | 26 +++++ src/app/shop/view/config/wxwork.html | 146 +++++++++++++++++++++++++++ src/index.php | 11 +- src/think | 10 +- 6 files changed, 225 insertions(+), 10 deletions(-) create mode 100644 src/app/shop/view/config/wxwork.html diff --git a/docker-compose.yml b/docker-compose.yml index c66f65151..7eb5cf572 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -140,4 +140,5 @@ volumes: networks: sass-platform-net: name: ${PROJECT_NAME}_${APP_ENV}_net - driver: bridge \ No newline at end of file + driver: bridge + external: true \ No newline at end of file diff --git a/src/app/model/web/Config.php b/src/app/model/web/Config.php index a65cbaab9..bed6c07bc 100644 --- a/src/app/model/web/Config.php +++ b/src/app/model/web/Config.php @@ -847,6 +847,45 @@ class Config extends BaseModel // return $data; // } + /** + * 设置企业微信配置 + * @param $data + * @param int $site_id + * @param string $app_module + * @return array + */ + public function setWxworkConfig($data, $site_id = 1, $app_module = 'shop') + { + $config = new ConfigModel(); + $res = $config->setConfig($data, '企业微信配置', 1, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'WXWORK_CONFIG' ] ]); + return $res; + } + + /** + * 获取企业微信配置 + * @param int $site_id + * @param string $app_module + * @return array + */ + public function getWxworkConfig($site_id = 1, $app_module = 'shop') + { + $config = new ConfigModel(); + $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'WXWORK_CONFIG' ] ]); + if (empty($res[ 'data' ][ 'value' ])) { + $res[ 'data' ][ 'value' ] = [ + 'corp_id' => '', + 'agent_id' => '', + 'contact_id' => '', + 'contact_url' => '', + 'timestamp' => '', + 'nonceStr' => '', + 'signature' => '', + 'enabled' => false + ]; + } + return $res; + } + /** * 设置商品编码设置 * @param $data diff --git a/src/app/shop/controller/Config.php b/src/app/shop/controller/Config.php index a8316c045..da961574f 100644 --- a/src/app/shop/controller/Config.php +++ b/src/app/shop/controller/Config.php @@ -210,6 +210,32 @@ class Config extends BaseShop } + /** + * 企业微信配置 + */ + public function wxwork() + { + $config_model = new ConfigModel(); + if (request()->isJson()) { + $data = [ + 'corp_id' => input('corp_id', ''), + 'agent_id' => input('agent_id', ''), + 'contact_id' => input('contact_id', ''), + 'contact_url' => input('contact_url', ''), + 'timestamp' => input('timestamp', ''), + 'nonceStr' => input('nonceStr', ''), + 'signature' => input('signature', ''), + 'enabled' => input('enabled', 0) + ]; + $this->addLog('修改企业微信配置'); + return $config_model->setWxworkConfig($data, $this->site_id, $this->app_module); + } else { + $config_result = $config_model->getWxworkConfig($this->site_id, $this->app_module); + $this->assign('wxwork_config', $config_result[ 'data' ][ 'value' ]); + return $this->fetch('config/wxwork'); + } + } + /** * 域名跳转配置 */ diff --git a/src/app/shop/view/config/wxwork.html b/src/app/shop/view/config/wxwork.html new file mode 100644 index 000000000..157f19602 --- /dev/null +++ b/src/app/shop/view/config/wxwork.html @@ -0,0 +1,146 @@ + + +
+
+ +
+ +
+
开启后,企业微信相关功能将可用
+
+ +
+ +
+ +
+
+

企业微信的企业ID,可在企业微信管理后台获取

+
+
+ +
+ +
+ +
+
+

企业微信应用的AgentId,创建应用后获取

+
+
+ +
+ +
+ +
+
+

企业微信客服的ID,用于客服功能

+
+
+ +
+ +
+ +
+
+

企业微信活码的链接地址

+
+
+ +
+ +
+ +
+
+

用于验证的时间戳,通常由系统自动生成

+
+
+ +
+ +
+ +
+
+

用于验证的随机字符串

+
+
+ +
+ +
+ +
+
+

用于验证的签名,通常由系统自动生成

+
+
+ +
+ + +
+
+ + \ No newline at end of file diff --git a/src/index.php b/src/index.php index b509ed1a2..aea6158b1 100644 --- a/src/index.php +++ b/src/index.php @@ -68,11 +68,12 @@ if ($appEnv) { if (is_file($envFile)) { $app->env->load($envFile); } -} - -// 3. 为了兼容性,如果存在.env.local也加载(优先级最高) -if (is_file(__DIR__ . '/.env.local')) { - $app->env->load(__DIR__ . '/.env.local'); +} else { + echo "⚠️ 警告:未设置APP_ENV环境变量,默认使用local环境。\n"; + // 3. 为了兼容性,如果存在.env.local也加载(优先级最高) + if (is_file(__DIR__ . '/.env.local')) { + $app->env->load(__DIR__ . '/.env.local'); + } } // 执行HTTP应用并响应 diff --git a/src/think b/src/think index 74fa7b6f8..af41fe22f 100644 --- a/src/think +++ b/src/think @@ -21,12 +21,14 @@ if ($appEnv) { if (is_file($envFile)) { $app->env->load($envFile); } +} else { + echo "⚠️ 警告:未设置APP_ENV环境变量,默认使用local环境。\n"; + // 3. 为了兼容性,如果存在.env.local也加载(优先级最高) + if (is_file(__DIR__ . '/.env.local')) { + $app->env->load(__DIR__ . '/.env.local'); + } } -// 3. 为了兼容性,如果存在.env.local也加载(优先级最高) -if (is_file(__DIR__ . '/.env.local')) { - $app->env->load(__DIR__ . '/.env.local'); -} // 应用初始化 $app->console->run(); \ No newline at end of file