first commit
This commit is contained in:
226
app/Admin/Controllers/ConfigController.php
Normal file
226
app/Admin/Controllers/ConfigController.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Config;
|
||||
use App\Models\Order;
|
||||
use Encore\Admin\Facades\Admin;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Form\Tools;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Storage;
|
||||
|
||||
class ConfigController extends Controller
|
||||
{
|
||||
|
||||
public function withdraw(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('提现设置')
|
||||
->body($this->withdrawConfigForm());
|
||||
}
|
||||
|
||||
public function order(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('订单设置')
|
||||
->body($this->orderConfigForm());
|
||||
}
|
||||
|
||||
public function front(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('前台设置')
|
||||
->body($this->frontConfigForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化表单
|
||||
* @Author:<C.Jason>
|
||||
* @Date:2019-05-16T09:42:07+0800
|
||||
* @return [type] [description]
|
||||
*/
|
||||
private function initForm()
|
||||
{
|
||||
$form = new Form(new Config);
|
||||
|
||||
$form->tools(function (Tools $tools) {
|
||||
$tools->disableList();
|
||||
$tools->disableDelete();
|
||||
$tools->disableView();
|
||||
});
|
||||
$form->footer(function ($footer) {
|
||||
$footer->disableReset();
|
||||
$footer->disableViewCheck();
|
||||
$footer->disableEditingCheck();
|
||||
$footer->disableCreatingCheck();
|
||||
});
|
||||
$form->setAction('/admin/configs');
|
||||
$form->setTitle(' ');
|
||||
$form->setWidth(1, 2);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现设置
|
||||
* @Author:<C.Jason>
|
||||
* @Date:2019-05-16T09:41:49+0800
|
||||
* @return [type] [description]
|
||||
*/
|
||||
protected function withdrawConfigForm()
|
||||
{
|
||||
$form = $this->initForm();
|
||||
|
||||
$form->text('widthdraw_min_money', '最小提现金额')->setWidth(2, 2)->prepend('<i class="fa fa-shopping-cart fa-fw"></i>')->append('元')->default(config('widthdraw_min_money', 0));
|
||||
$form->rate('widthdraw_rate', '提现手续费')->setWidth(2, 2)->default(config('widthdraw_rate', 0));
|
||||
$form->switch('open_widthdraw_wechat', '提现至微信余额')->states()->default(config('open_widthdraw_wechat'));
|
||||
$form->switch('open_widthdraw_bank', '提现至银行卡')->states()->default(config('open_widthdraw_bank'));
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单设置
|
||||
* @Author:<C.Jason>
|
||||
* @Date:2019-05-16T09:41:43+0800
|
||||
* @return [type] [description]
|
||||
*/
|
||||
protected function orderConfigForm()
|
||||
{
|
||||
$form = $this->initForm();
|
||||
|
||||
$form->text('open_full_buy', '满多少可以下单')
|
||||
->setWidth(4, 2)
|
||||
->prepend('<i class="fa fa-shopping-cart fa-fw"></i>')
|
||||
->append('元')
|
||||
->default(config('open_full_buy', 0))
|
||||
->help('最小下单金额');
|
||||
|
||||
$form->text('auto_cancel_order', '自动取消未支付订单')
|
||||
->setWidth(4, 2)
|
||||
->prepend('<i class="fa fa-clock-o fa-fw"></i>')
|
||||
->append('分钟')
|
||||
->default(config('auto_cancel_order', 0))
|
||||
->help('系统下单之后自动减库存,防止长期不支付占用库存,只能使用整数');
|
||||
|
||||
$form->text('order_limit_warning', '下单距离提醒')->setWidth(4, 2)->prepend('<i class="fa fa-map-marker fa-fw"></i>')->append('KM')->default(config('order_limit_warning', 0))->help('下单时,超过距离,提醒用户下单距离, 0代表不限制');
|
||||
|
||||
$form->switch('open_balance_pay', '开启余额支付')->states()->default(config('open_balance_pay'));
|
||||
|
||||
$form->text('min_recharge', '最小充值金额')
|
||||
->setWidth(4, 2)
|
||||
->append('元')
|
||||
->default(config('min_recharge', 0));
|
||||
|
||||
$form->switch('open_order_notify', '订单提醒开关')->states()->default(config('open_order_notify'));
|
||||
$form->switch('stock_method', '下单即减库存')->states()->default(config('stock_method'));
|
||||
$form->switch('open_order_message', '开启订单留言')->states()->default(config('open_order_message'));
|
||||
$form->switch('open_comment_audit', '开启评价审核')->states()->default(config('open_comment_audit'));
|
||||
|
||||
$form->table('refund_resason', '退款原因', function ($table) {
|
||||
$table->text('value', '原因');
|
||||
})->value(array_values(json_decode(config('refund_resason'), true) ?: []));
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* 团长设置
|
||||
* @Author:<C.Jason>
|
||||
* @Date:2019-05-16T09:41:34+0800
|
||||
* @return [type] [description]
|
||||
*/
|
||||
protected function headConfigForm()
|
||||
{
|
||||
$form = $this->initForm();
|
||||
|
||||
$form->switch('open_head_apply', '开启前台申请入口')->states()->default(config('open_head_apply'))->help('关闭后,隐藏前台团长申请入口,只能通过业务员扫码申请');
|
||||
$form->rate('default_head_rate', '团长提成比例')->setWidth(6, 2)->default(config('default_head_rate', 10))->help('预计团长可得佣金 = 商品最终的成交价格 * 比例%');
|
||||
$form->text('comunity_limit_mile', '社区距离限制')->setWidth(6, 2)->prepend('<i class="fa fa-map-marker fa-fw"></i>')->append('KM')->default(config('comunity_limit_mile', 0))->help('社区列表限制某个距离内显示, 0代表不限制');
|
||||
$form->switch('open_community_verifiel', '前端添加核销会员')->states()->default(config('open_community_verifiel'));
|
||||
$form->text('communityhead_apply_mobile', '团长申请电话')->setWidth(6, 2)->default(config('communityhead_apply_mobile'));
|
||||
$form->editor('communityhead_apply_page', '团长申请页面内容')->setWidth(6, 2)->default(config('communityhead_apply_page', '团长申请页面内容'));
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片设置
|
||||
* @Author:<C.Jason>
|
||||
* @Date:2019-05-16T09:41:27+0800
|
||||
* @return [type] [description]
|
||||
*/
|
||||
protected function picturesConfigForm()
|
||||
{
|
||||
$form = $this->initForm();
|
||||
|
||||
$form->image('login_form_background', '登录页背景')->value(config('login_form_background'));
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享设置
|
||||
* @Author:<C.Jason>
|
||||
* @Date:2019-05-16T09:41:22+0800
|
||||
* @return [type] [description]
|
||||
*/
|
||||
private function shareConfigForm()
|
||||
{
|
||||
$form = $this->initForm();
|
||||
$form->text('index_share_title', '首页分享标题')->setWidth(6, 2)->default(config('index_share_title'));
|
||||
$form->image('index_share_image', '首页分享图片')->value(config('index_share_image'));
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* 前台设置
|
||||
* @Author:<C.Jason>
|
||||
* @Date:2019-05-16T09:41:17+0800
|
||||
* @return [type] [description]
|
||||
*/
|
||||
private function frontConfigForm()
|
||||
{
|
||||
$form = $this->initForm();
|
||||
$form->switch('open_recruit_supplier', '供应商申请入口')->states()->default(config('open_recruit_supplier'));
|
||||
$form->switch('open_recruit_agent', '代理商申请入口')->states()->default(config('open_recruit_agent'));
|
||||
$form->switch('open_service', '联系客服入口')->states()->default(config('open_service'));
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存配置的方法
|
||||
* @Author:<C.Jason>
|
||||
* @Date:2019-05-16T09:41:05+0800
|
||||
* @param Request $request [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
foreach ($request->except(['_token', '_previous_']) as $key => $value) {
|
||||
if ($value instanceof UploadedFile) {
|
||||
$path = $value->store('system', config('admin.upload.disk'));
|
||||
$value = Storage::disk(config('admin.upload.disk'))->url($path);
|
||||
}
|
||||
if ($key == 'refund_resason' && is_array($value)) {
|
||||
$save = [];
|
||||
foreach ($value as $item) {
|
||||
if ($item['_remove_'] == 0) {
|
||||
$save[]['value'] = $item['value'];
|
||||
}
|
||||
}
|
||||
$value = json_encode($save);
|
||||
}
|
||||
Config::updateOrCreate(
|
||||
['name' => $key],
|
||||
['value' => $value]
|
||||
);
|
||||
}
|
||||
|
||||
admin_toastr('保存成功', 'success');
|
||||
return back();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user