Browse Source

代理商设置修改

develop
李可松 4 years ago
parent
commit
a04654afda
  1. 25
      MySQL_change.sql
  2. 18
      app/AdminAgent/Controllers/SettingController.php
  3. 49
      app/AdminAgent/Forms/Setting.php
  4. 18
      app/Models/AgentSetting.php
  5. 13
      resources/lang/zh_CN/setting.php

25
MySQL_change.sql

@ -177,3 +177,28 @@ ALTER TABLE `agent_products`
# 11:07 2021/8/26 # 11:07 2021/8/26
DROP TABLE `waterfall_ads`; DROP TABLE `waterfall_ads`;
# 19:25 2021/8/26
CREATE TABLE `pay_debugs` (
`id` INT(10) NOT NULL AUTO_INCREMENT,
`agent_id` INT(10) NOT NULL DEFAULT '0' COMMENT '代理商ID',
`type` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '1:支付;2:退款;',
`content` TEXT NULL DEFAULT NULL COMMENT '回调内容' COLLATE 'utf8_general_ci',
`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`) USING BTREE,
INDEX `agent_id` (`agent_id`) USING BTREE
)
COMMENT='微信支付回调记录'
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
CREATE TABLE `agent_settings` (
`id` INT(10) NOT NULL AUTO_INCREMENT,
`agent_id` INT(10) NOT NULL COMMENT '代理商ID',
`setting` JSON NOT NULL COMMENT '设置值,JSON格式',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `agent_id` (`agent_id`) USING BTREE
)
COMMENT='代理商设置配置'
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

18
app/AdminAgent/Controllers/SettingController.php

@ -0,0 +1,18 @@
<?php
namespace App\AdminAgent\Controllers;
use App\AdminAgent\Forms\Setting;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Widgets\Card;
class SettingController extends AdminController
{
public function index(Content $content)
{
return $content
->title('系统设置')
->body(new Card('&nbsp;', new Setting()));
}
}

49
app/AdminAgent/Forms/Setting.php

@ -0,0 +1,49 @@
<?php
namespace App\AdminAgent\Forms;
use App\Models\AgentSetting;
use Dcat\Admin\Admin;
use Dcat\Admin\Widgets\Form;
class Setting extends Form
{
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
// dump($input);
AgentSetting::updateOrCreate(
['agent_id' => Admin::user()->id],
['setting' => json_encode($input), 'agent_id' => Admin::user()->id],
);
return $this->response()->success('保存成功')->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->text('earnest')->required()->help('用户支付订金、定金、首付款的金额');
$this->text('earnest_timeout')->required()->help('单位:分钟。当通过订金、定金、首付款支付时,用户超过该时间未支付将关闭订单,且定金不退');
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
$setting = AgentSetting::where('agent_id', Admin::user()->id)->value('setting');
return is_string($setting) ? json_decode($setting, true) : [];
}
}

18
app/Models/AgentSetting.php

@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class AgentSetting extends BaseModel
{
use HasFactory;
protected $fillable = ['agent_id', 'setting'];
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->timestamps = false;
}
}

13
resources/lang/zh_CN/setting.php

@ -0,0 +1,13 @@
<?php
return [
'labels' => [
'Setting' => '系统设置',
'setting' => '系统设置',
],
'fields' => [
'earnest' => '定金金额',
'earnest_timeout' => '定金支付超时时间',
],
'options' => [
],
];
Loading…
Cancel
Save