Browse Source

系统设置修改

develop
李可松 4 years ago
parent
commit
99780a2294
  1. 10
      app/AdminAgent/Forms/Setting.php
  2. 2
      app/Http/Controllers/Api/TestController.php
  3. 5
      app/Models/AgentSetting.php
  4. 4
      resources/lang/zh_CN/setting.php

10
app/AdminAgent/Forms/Setting.php

@ -21,7 +21,7 @@ class Setting extends Form
AgentSetting::updateOrCreate( AgentSetting::updateOrCreate(
['agent_id' => Admin::user()->id], ['agent_id' => Admin::user()->id],
['setting' => json_encode($input), 'agent_id' => Admin::user()->id],
['setting' => $input, 'agent_id' => Admin::user()->id],
); );
return $this->response()->success('保存成功')->refresh(); return $this->response()->success('保存成功')->refresh();
@ -32,8 +32,10 @@ class Setting extends Form
*/ */
public function form() public function form()
{ {
$this->text('earnest')->required()->help('用户支付订金、定金、首付款的金额');
$this->text('earnest_timeout')->required()->help('单位:分钟。当通过订金、定金、首付款支付时,用户超过该时间未支付将关闭订单,且定金不退');
$this->text('order_timeout')->required()->default(1440)
->help('订单超时时间,单位:分钟。(订金、定金支付的超时时间将根据产品设定的超时时间)');
$this->radio('auto_shelves')->options(['否', '是'])->required()->default(1)
->help('是否自动上架合作供应商的产品,如果选是,当合作供应商发布新产品之后,将自动上架供应商的产品');
} }
/** /**
@ -44,6 +46,6 @@ class Setting extends Form
public function default() public function default()
{ {
$setting = AgentSetting::where('agent_id', Admin::user()->id)->value('setting'); $setting = AgentSetting::where('agent_id', Admin::user()->id)->value('setting');
return is_string($setting) ? json_decode($setting, true) : [];
return $setting ?? [];
} }
} }

2
app/Http/Controllers/Api/TestController.php

@ -16,6 +16,6 @@ class TestController
public function index() public function index()
{ {
//test //test
return AgentSetting::val(1, 'earnest') ?? 198.88;
return AgentSetting::val(11, 'order_timeout') ?? 188;
} }
} }

5
app/Models/AgentSetting.php

@ -9,6 +9,7 @@ class AgentSetting extends BaseModel
use HasFactory; use HasFactory;
protected $fillable = ['agent_id', 'setting']; protected $fillable = ['agent_id', 'setting'];
protected $casts = ['setting' => 'json'];
public function __construct(array $attributes = []) public function __construct(array $attributes = [])
{ {
@ -16,9 +17,9 @@ class AgentSetting extends BaseModel
$this->timestamps = false; $this->timestamps = false;
} }
public function scopeVal($query, $agent_id, $key)
public static function val($agent_id, $key)
{ {
$setting = json_decode($query->where('agent_id', $agent_id)->value('setting'), true);
$setting = static::query()->where('agent_id', $agent_id)->value('setting');
return $setting[$key] ?? null; return $setting[$key] ?? null;
} }
} }

4
resources/lang/zh_CN/setting.php

@ -5,8 +5,8 @@ return [
'setting' => '系统设置', 'setting' => '系统设置',
], ],
'fields' => [ 'fields' => [
'earnest' => '定金金额',
'earnest_timeout' => '定金支付超时时间',
'order_timeout' => '订单超时时间',
'auto_shelves' => '自动上架',
], ],
'options' => [ 'options' => [
], ],

Loading…
Cancel
Save