From 359e9eef48a58428e45439c2bbea3d5344e4a30a Mon Sep 17 00:00:00 2001 From: Karlcarlo Date: Wed, 1 Apr 2026 01:26:30 +0800 Subject: [PATCH] =?UTF-8?q?refactor(privacy-phone):=20=E5=B0=86=E9=9A=90?= =?UTF-8?q?=E7=A7=81=E6=89=8B=E6=9C=BA=E9=85=8D=E7=BD=AE=E4=BB=8E=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E8=BF=81=E7=A7=BB=E8=87=B3=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改 PrivacyPhoneServices 从读取数据库配置改为读取 .env 环境变量,提升配置灵活性与安全性。 更新 SQL 迁移文件,移除向系统配置表插入配置的语句,并添加配置方式说明。 --- app/services/other/PrivacyPhoneServices.php | 6 +++--- docs/privacy_phone_update.sql | 10 ++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/app/services/other/PrivacyPhoneServices.php b/app/services/other/PrivacyPhoneServices.php index d72dd5a..579104a 100644 --- a/app/services/other/PrivacyPhoneServices.php +++ b/app/services/other/PrivacyPhoneServices.php @@ -34,7 +34,7 @@ class PrivacyPhoneServices extends BaseServices */ public function getAppKey(): string { - return sys_config('privacy_phone_appkey', ''); + return env('PRIVACY_PHONE.APPKEY', ''); } /** @@ -43,7 +43,7 @@ class PrivacyPhoneServices extends BaseServices */ public function getAppSecret(): string { - return sys_config('privacy_phone_appsecret', ''); + return env('PRIVACY_PHONE.APPSECRET', ''); } /** @@ -52,7 +52,7 @@ class PrivacyPhoneServices extends BaseServices */ public function isEnabled(): bool { - return (bool)sys_config('privacy_phone_status', 0); + return (bool)env('PRIVACY_PHONE.ENABLE', false); } /** diff --git a/docs/privacy_phone_update.sql b/docs/privacy_phone_update.sql index 54a25e0..69f6bd5 100644 --- a/docs/privacy_phone_update.sql +++ b/docs/privacy_phone_update.sql @@ -3,18 +3,12 @@ -- 说明: AX模式下 user_phone 直接存储隐私手机号 -- private_bind_id 存储真实手机号(用于解绑) -- private_phone_status 存储绑定状态 +-- 配置方式: 通过 .env 文件配置 (不再使用数据库配置) --- 1. 订单表添加字段 +-- 订单表添加字段 ALTER TABLE `eb_store_order` ADD COLUMN `private_bind_id` VARCHAR(18) NOT NULL DEFAULT '' COMMENT '隐私绑定真实手机号(用于解绑)' AFTER `user_address`, ADD COLUMN `private_phone_status` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '隐私手机绑定状态:0未绑定,1已绑定' AFTER `private_bind_id`; --- 2. 系统配置表添加隐私手机号配置 -INSERT INTO `eb_system_config` (`id`, `is_store`, `menu_name`, `type`, `input_type`, `config_tab_id`, `parameter`, `upload_type`, `required`, `width`, `high`, `value`, `info`, `desc`, `sort`, `status`) VALUES -(NULL, 0, 'privacy_phone_status', 'radio', 'input', 1, '0=>关闭\n1=>开启', 0, '', 0, 0, '0', '隐私手机号功能', '开启后订单发货使用隐私手机号', 0, 1), -(NULL, 0, 'privacy_phone_appkey', 'text', 'input', 1, '', 0, 'required:true', 100, 0, '', '米糠云AppKey', '米糠云小号平台AppKey', 0, 1), -(NULL, 0, 'privacy_phone_appsecret', 'text', 'input', 1, '', 0, 'required:true', 100, 0, '', '米糠云AppSecret', '米糠云小号平台AppSecret', 0, 1); - -- 查询验证 -- SELECT id, order_id, user_phone, private_bind_id, private_phone_status FROM eb_store_order LIMIT 10; --- SELECT * FROM eb_system_config WHERE menu_name LIKE 'privacy_phone%';