Appearance
系统配置
MineShop 提供完善的系统配置管理,通过值对象封装配置项,支持基础设置、商品、订单、支付、物流、会员等多个维度。
🎯 配置架构
┌─────────────────────────────────────────────────────────────┐
│ DomainMallSettingService │
│ 商城配置聚合服务 │
├─────────────────────────────────────────────────────────────┤
│ BasicSetting │ ProductSetting │ OrderSetting │
│ 基础设置 │ 商品设置 │ 订单设置 │
├─────────────────────────────────────────────────────────────┤
│ PaymentSetting │ ShippingSetting │ MemberSetting │
│ 支付设置 │ 物流设置 │ 会员设置 │
├─────────────────────────────────────────────────────────────┤
│ ContentSetting │ IntegrationSetting │
│ 内容设置 │ 集成设置 │
└─────────────────────────────────────────────────────────────┘✨ 配置分类
1. 基础设置 (BasicSetting)
| 配置项 | 说明 | 默认值 |
|---|---|---|
| name | 商城名称 | MineMall 商城 |
| logo | 商城 Logo | - |
| support_email | 客服邮箱 | support@minemall.local |
| hotline | 客服热线 | 400-888-0000 |
2. 商品设置 (ProductSetting)
| 配置项 | 说明 | 默认值 |
|---|---|---|
| auto_generate_sku | 自动生成 SKU | true |
| max_gallery | 最大图片数 | 9 |
| stock_warning | 库存预警阈值 | 20 |
| allow_preorder | 允许预售 | false |
| content_filter | 内容过滤词 | [] |
3. 订单设置 (OrderSetting)
| 配置项 | 说明 | 默认值 |
|---|---|---|
| auto_close_minutes | 自动关闭时间(分钟) | 30 |
| auto_confirm_days | 自动确认收货(天) | 7 |
| after_sale_days | 售后期限(天) | 15 |
| enable_invoice | 启用发票 | true |
| invoice_provider | 发票服务商 | system |
| customer_service | 客服电话 | 400-888-1000 |
4. 支付设置 (PaymentSetting)
| 配置项 | 说明 | 默认值 |
|---|---|---|
| wechat_enabled | 微信支付开关 | false |
| wechat_config | 微信支付配置 | [] |
| refund_review | 退款需审核 | true |
| settlement_cycle_days | 结算周期(天) | 7 |
| balance_enabled | 余额支付开关 | true |
5. 物流设置 (ShippingSetting)
| 配置项 | 说明 | 默认值 |
|---|---|---|
| default_method | 默认配送方式 | express |
| enable_pickup | 启用自提 | true |
| pickup_address | 自提地址 | - |
| free_shipping_threshold | 包邮门槛 | 0 |
| supported_providers | 支持的快递 | [] |
| remote_area_enabled | 偏远地区加价 | false |
6. 会员设置 (MemberSetting)
| 配置项 | 说明 | 默认值 |
|---|---|---|
| enable_growth | 启用成长值 | true |
| register_points | 注册赠送积分 | 100 |
| sign_in_reward | 签到奖励 | 5 |
| invite_reward | 邀请奖励 | 50 |
| points_expire_months | 积分过期月数 | 24 |
| vip_levels | VIP 等级定义 | [] |
| points_ratio | 积分兑换比例 | 100 |
📦 配置服务
php
// DomainMallSettingService.php
final class DomainMallSettingService extends IService
{
public function basic(): BasicSetting
{
return $this->basic ??= new BasicSetting(
(string) $this->value('mall.basic.name', 'MineMall 商城'),
(string) $this->value('mall.basic.logo', ''),
(string) $this->value('mall.basic.support_email', 'support@minemall.local'),
(string) $this->value('mall.basic.hotline', '400-888-0000'),
);
}
public function product(): ProductSetting
{
return $this->product ??= new ProductSetting(
(bool) $this->value('mall.product.auto_generate_sku', true),
(int) $this->value('mall.product.max_gallery', 9),
(int) $this->value('mall.product.stock_warning', 20),
(bool) $this->value('mall.product.allow_preorder', false),
$this->normalizeLines($this->value('mall.product.content_filter', [])),
);
}
// ... 其他配置方法
}🔧 使用示例
php
// 获取库存预警阈值
$threshold = $this->mallSettingService->product()->stockWarning();
// 获取订单自动关闭时间
$minutes = $this->mallSettingService->order()->autoCloseMinutes();
// 检查微信支付是否启用
if ($this->mallSettingService->payment()->wechatEnabled) {
// 处理微信支付
}💻 API 接口
| 接口 | 方法 | 说明 |
|---|---|---|
/admin/settings | GET | 获取所有配置 |
/admin/settings/{group} | GET | 获取分组配置 |
/admin/settings | PUT | 更新配置 |
⚠️ 注意事项
- 缓存: 配置读取后会缓存,修改后需清除缓存
- 类型安全: 使用值对象确保类型安全
- 默认值: 所有配置都有合理的默认值
- 验证: 配置更新时进行数据验证