first commit
This commit is contained in:
293
app/Admin/Controllers/AccountController.php
Normal file
293
app/Admin/Controllers/AccountController.php
Normal file
@@ -0,0 +1,293 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Account;
|
||||
use App\Models\Head;
|
||||
use App\Models\HeadAccount;
|
||||
use App\Models\HeadProfit;
|
||||
use App\Models\User;
|
||||
use AsLong\UserAccount\Models\UserAccount;
|
||||
use AsLong\UserAccount\Models\UserAccountLog;
|
||||
use AsLong\UserAccount\Models\UserAccountRule;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Form\Tools;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Widgets\Table;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AccountController extends Controller
|
||||
{
|
||||
use HasResourceActions;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function users(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('会员账户')
|
||||
->body($this->userGrid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
* @return Grid
|
||||
*/
|
||||
protected function userGrid()
|
||||
{
|
||||
$grid = new Grid(new UserAccount);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableRowSelector();
|
||||
$grid->paginate(10);
|
||||
|
||||
$grid->model()->with('user.info');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user', function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
});
|
||||
}, '用户昵称');
|
||||
});
|
||||
|
||||
$grid->column('用户昵称')->display(function () {
|
||||
$avatar = '<img src="' . $this->user->info->avatar . '" alt="" style="width:40px;height:40px;border-radius:50%" />';
|
||||
return $avatar . ' ' . $this->user->info->nickname;
|
||||
});
|
||||
|
||||
$grid->cash('现金账户')->modal('近期账变(20条)', function ($model) {
|
||||
$comments = $model->logs()->where('type', 'cash')->take(20)->orderBy('created_at', 'desc')->get()->map(function ($log) {
|
||||
return [$log->id, $log->rule->title, $log->variable, $log->frozen_text, $log->created_at, $log->source_formart];
|
||||
});
|
||||
return new Table(['ID', '触发事件', '变更数额', '已结算', '变更时间', '描述'], $comments->toArray());
|
||||
});
|
||||
|
||||
$grid->score('积分账户')->modal('近期账变(20条)', function ($model) {
|
||||
$comments = $model->logs()->where('type', 'score')->take(20)->orderBy('created_at', 'desc')->get()->map(function ($log) {
|
||||
return [$log->id, $log->rule->title, $log->variable, $log->frozen_text, $log->created_at, $log->source_formart];
|
||||
});
|
||||
return new Table(['ID', '触发事件', '变更数额', '已结算', '变更时间', '描述'], $comments->toArray());
|
||||
});
|
||||
$grid->updated_at('最后变更时间');
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableEdit();
|
||||
$actions->disableView();
|
||||
$actions->append('<a href="/admin/accounts/users/' . $actions->getKey() . '">账户日志</a> ');
|
||||
$actions->append('<a href="/admin/accounts/users/' . $actions->getKey() . '/recharge">充值余额</a>');
|
||||
});
|
||||
return $grid;
|
||||
}
|
||||
|
||||
public function recharge(Request $request, Content $content, User $user)
|
||||
{
|
||||
if ($request->isMethod('POST')) {
|
||||
try {
|
||||
$res = Account::executeRule($user, 'recharge', $request->amount, false, ['type' => 'recharge', 'admin' => 1]);
|
||||
admin_toastr('充值成功');
|
||||
return redirect()->action('\App\Admin\Controllers\AccountController@users');
|
||||
} catch (\Exception $e) {
|
||||
admin_toastr($e->getMessage(), 'error');
|
||||
}
|
||||
} else {
|
||||
return $content
|
||||
->header('账户充值')
|
||||
->description($user->info->nickname)
|
||||
->body($this->rechargeForm($user));
|
||||
}
|
||||
}
|
||||
|
||||
protected function rechargeForm($user)
|
||||
{
|
||||
$form = new Form(new User);
|
||||
$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(route('accounts.recharge', ['user' => $user]));
|
||||
$form->setTitle(' ');
|
||||
$form->setWidth(1, 2);
|
||||
|
||||
$form->currency('amount', '充值金额')->symbol('¥');
|
||||
|
||||
return $form->render();
|
||||
}
|
||||
|
||||
public function user_logs(Content $content, User $user)
|
||||
{
|
||||
return $content
|
||||
->header('账户日志')
|
||||
->description($user->info->nickname)
|
||||
->body($this->userLogsGrid($user->id));
|
||||
}
|
||||
|
||||
protected function userLogsGrid($user_id)
|
||||
{
|
||||
$grid = new Grid(new UserAccountLog);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableRowSelector();
|
||||
$grid->disableActions();
|
||||
|
||||
$grid->model()->where('user_id', $user_id)->orderBy('id', 'desc')->with(['rule']);
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('type', '账户类型')->select(config('user_account.account_type'));
|
||||
$filter->equal('rule.id', '触发规则')->select(
|
||||
UserAccountRule::pluck('title', 'id')
|
||||
);
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('variable', '账户变动');
|
||||
$filter->equal('balance', '当期余额');
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->between('created_at', '入账时间')->datetime();
|
||||
$filter->equal('frozen', '已结算')->select([
|
||||
0 => '是',
|
||||
1 => '否',
|
||||
]);
|
||||
});
|
||||
// $filter->expand();
|
||||
});
|
||||
|
||||
$grid->column('账户类型')->display(function () {
|
||||
return $this->type_text;
|
||||
});
|
||||
$grid->column('rule.title', '触发规则');
|
||||
$grid->variable('账户变动');
|
||||
$grid->balance('当期余额');
|
||||
$grid->column('已结算')->display(function () {
|
||||
return $this->frozen_text;
|
||||
});
|
||||
$grid->created_at('入账时间');
|
||||
return $grid;
|
||||
}
|
||||
|
||||
public function heads(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('团长账户')
|
||||
->body($this->headGrid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
* @return Grid
|
||||
*/
|
||||
protected function headGrid()
|
||||
{
|
||||
$grid = new Grid(new HeadAccount);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableRowSelector();
|
||||
$grid->disableFilter();
|
||||
|
||||
$grid->model()->with(['head.user.info']);
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('head_id', '团长编号');
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('head.community_name', '社区名称');
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('head.head_name', '团长姓名');
|
||||
});
|
||||
// $filter->expand();
|
||||
});
|
||||
|
||||
$grid->head_id('团长编号')->sortable();
|
||||
$grid->column('用户')->display(function () {
|
||||
$avatar = '<img src="' . $this->head->user->info->avatar . '" alt="" style="width:40px;height:40px;border-radius:50%" />';
|
||||
return $avatar . ' ' . $this->head->user->info->nickname;
|
||||
});
|
||||
|
||||
$grid->column('社区/团长')->display(function () {
|
||||
return $this->head->community_name . '<br/>' . $this->head->head_name;
|
||||
});
|
||||
$grid->balance('账户余额');
|
||||
$grid->updated_at('最后变更时间');
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableEdit();
|
||||
$actions->disableView();
|
||||
$actions->append('<a href="/admin/accounts/heads/' . $actions->getKey() . '">账户日志</a>');
|
||||
});
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 团长账户日志
|
||||
* @Author:<C.Jason>
|
||||
* @Date:2019-04-17T11:32:12+0800
|
||||
* @param Content $content [description]
|
||||
* @param Head $head [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function head_logs(Content $content, Head $head)
|
||||
{
|
||||
return $content
|
||||
->header('账户日志')
|
||||
->description($head->head_name)
|
||||
->body($this->headLogsGrid($head->id));
|
||||
}
|
||||
|
||||
protected function headLogsGrid($head_id)
|
||||
{
|
||||
$grid = new Grid(new HeadProfit);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableRowSelector();
|
||||
$grid->disableActions();
|
||||
$grid->disableFilter();
|
||||
|
||||
$grid->model()->where('head_id', $head_id)->orderBy('id', 'desc')->with(['order', 'detail.item']);
|
||||
|
||||
$grid->column('order.orderid', '订单编号');
|
||||
$grid->column('order.amount', '订单总额');
|
||||
$grid->column('商品名称')->display(function () {
|
||||
return $this->detail->item->name;
|
||||
});
|
||||
$grid->column('detail.price', '商品价格');
|
||||
$grid->column('detail.number', '购买数量');
|
||||
$grid->column('商品小计')->display(function () {
|
||||
return $this->detail->total;
|
||||
});
|
||||
$grid->amount('结算金额');
|
||||
$grid->column('结算比例')->display(function () {
|
||||
return number_format($this->amount / $this->detail->total * 100, 2) . '%';
|
||||
});
|
||||
$grid->column('结算状态')->display(function () {
|
||||
if ($this->status == 1) {
|
||||
return '<span class="label label-success">已结算</span>';
|
||||
} else {
|
||||
return '<span class="label label-default">待结算</span>';
|
||||
}
|
||||
});
|
||||
$grid->created_at('创建时间');
|
||||
$grid->settled_at('结算时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
143
app/Admin/Controllers/ArticleController.php
Normal file
143
app/Admin/Controllers/ArticleController.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Article;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Show;
|
||||
|
||||
class ArticleController extends Controller
|
||||
{
|
||||
use HasResourceActions;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('资讯管理')
|
||||
->description('列表')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Show interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function show($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('资讯管理')
|
||||
->description('详情')
|
||||
->body($this->detail($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('资讯管理')
|
||||
->description('编辑')
|
||||
->body($this->form()->edit($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function create(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('资讯管理')
|
||||
->description('创建')
|
||||
->body($this->form());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Article);
|
||||
|
||||
$grid->id('ID');
|
||||
$grid->title('标题');
|
||||
$grid->description('简介')->display(function ($text) {
|
||||
return str_limit($text, 100, '...');
|
||||
});
|
||||
$grid->cover('标题图')->image('', 60, 60);
|
||||
$grid->status('状态')->switch();
|
||||
$grid->order('排序');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
// 去掉默认的id过滤器
|
||||
$filter->disableIdFilter();
|
||||
// 在这里添加字段过滤器
|
||||
$filter->like('title', '标题');
|
||||
});
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
$show = new Show(Article::findOrFail($id));
|
||||
|
||||
$show->id('ID');
|
||||
$show->title('标题');
|
||||
$show->description('简介');
|
||||
$show->cover('标题图')->image('', 60, 60);
|
||||
$show->content('详情');
|
||||
$show->status('状态')->using(['1' => '正常', '0' => '关闭']);
|
||||
$show->order('排序');
|
||||
$show->clicks('浏览量');
|
||||
|
||||
return $show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Article);
|
||||
|
||||
$form->text('title', '标题')->rules('required');
|
||||
$form->textarea('description', '简介')->rules('max:255', ['max' => '简介最多255字']);
|
||||
$form->image('cover', '标题图');
|
||||
$form->editor('content', '详情')->rules('required', ['required' => '详情不能为空']);
|
||||
$form->switch('status', '状态')->default(1);
|
||||
$form->number('order', '排序')->default(0);
|
||||
$form->number('clicks', '浏览量')->default(0);
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
10
app/Admin/Controllers/AuthController.php
Normal file
10
app/Admin/Controllers/AuthController.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Encore\Admin\Controllers\AuthController as BaseAuthController;
|
||||
|
||||
class AuthController extends BaseAuthController
|
||||
{
|
||||
|
||||
}
|
||||
70
app/Admin/Controllers/BankController.php
Normal file
70
app/Admin/Controllers/BankController.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Bank;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Show;
|
||||
|
||||
class BankController extends AdminController
|
||||
{
|
||||
/**
|
||||
* Title for current resource.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $title = '提现银行';
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Bank);
|
||||
|
||||
$grid->column('id', __('Id'));
|
||||
$grid->column('title', __('银行名称'));
|
||||
$grid->status('状态')->switch();
|
||||
$grid->column('created_at', __('添加时间'));
|
||||
$grid->column('updated_at', __('更新时间'));
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
$show = new Show(Bank::findOrFail($id));
|
||||
|
||||
$show->field('id', __('Id'));
|
||||
$show->field('title', __('Title'));
|
||||
$show->field('status', __('Status'));
|
||||
$show->field('created_at', __('Created at'));
|
||||
$show->field('updated_at', __('Updated at'));
|
||||
|
||||
return $show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Bank);
|
||||
|
||||
$form->text('title', __('银行名称'));
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
174
app/Admin/Controllers/CategoryController.php
Normal file
174
app/Admin/Controllers/CategoryController.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Category;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Column;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Layout\Row;
|
||||
use Encore\Admin\Show;
|
||||
use Encore\Admin\Tree;
|
||||
use Encore\Admin\Widgets\Box;
|
||||
use Encore\Admin\Widgets\Form as WidgetsForm;
|
||||
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
use HasResourceActions;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('部门')
|
||||
->row(function (Row $row) {
|
||||
$row->column(6, $this->treeView());
|
||||
|
||||
$row->column(6, function (Column $column) {
|
||||
$form = new WidgetsForm();
|
||||
|
||||
$form->select('parent_id', '上级部门')->options(Category::selectOptions(function ($model) {
|
||||
return $model->where('status', 1);
|
||||
}, '一级部门'));
|
||||
$form->text('title', '部门名称')->rules('required');
|
||||
$form->textarea('description', '部门简介')->rows(4)->rules('nullable');
|
||||
$form->number('order', '排序')->default(0);
|
||||
$form->switch('status', '显示')->states()->default(1);
|
||||
|
||||
$form->action('/admin/categories');
|
||||
|
||||
$column->append((new Box('新增部门', $form))->style('success'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Encore\Admin\Tree
|
||||
*/
|
||||
protected function treeView()
|
||||
{
|
||||
return Category::tree(function (Tree $tree) {
|
||||
$tree->disableCreate();
|
||||
$tree->branch(function ($branch) {
|
||||
if ($branch['status'] == 1) {
|
||||
$payload = "<i class='fa fa-eye text-primary'></i> ";
|
||||
} else {
|
||||
$payload = "<i class='fa fa-eye text-gray'></i> ";
|
||||
}
|
||||
$payload .= " [ID:{$branch['id']}] - ";
|
||||
$payload .= " <strong>{$branch['title']}</strong> ";
|
||||
$payload .= " <small style='color:#999'>{$branch['description']}</small>";
|
||||
|
||||
return $payload;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function show($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('Detail')
|
||||
->description('description')
|
||||
->body($this->detail($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('Edit')
|
||||
->description('description')
|
||||
->body($this->form()->edit($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function create(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('Create')
|
||||
->description('description')
|
||||
->body($this->form());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Category);
|
||||
|
||||
$grid->id('Id');
|
||||
$grid->title('部门名称');
|
||||
$grid->description('部门简介');
|
||||
$grid->order('排序');
|
||||
$grid->status('显示')->switch();
|
||||
$grid->created_at('创建时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
$show = new Show(Category::findOrFail($id));
|
||||
|
||||
$show->id('Id');
|
||||
$show->created_at('Created at');
|
||||
$show->updated_at('Updated at');
|
||||
|
||||
return $show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Category);
|
||||
|
||||
$form->select('parent_id', '上级部门')->options(Category::selectOptions(function ($model) {
|
||||
return $model->where('status', 1);
|
||||
}, '一级部门'));
|
||||
$form->text('title', '部门名称')->rules('required');
|
||||
$form->textarea('description', '部门简介')->rows(4)->rules('nullable');
|
||||
$form->number('order', '排序')->default(0);
|
||||
$form->switch('status', '显示')->states()->default(1);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
14
app/Admin/Controllers/Controller.php
Normal file
14
app/Admin/Controllers/Controller.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use HasResourceActions, AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
138
app/Admin/Controllers/ExplainController.php
Normal file
138
app/Admin/Controllers/ExplainController.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Explain;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Show;
|
||||
|
||||
class ExplainController extends Controller
|
||||
{
|
||||
use HasResourceActions;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('解读管理')
|
||||
->description('列表')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Show interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function show($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('解读管理')
|
||||
->description('详情')
|
||||
->body($this->detail($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('解读管理')
|
||||
->description('编辑')
|
||||
->body($this->form()->edit($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function create(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('解读管理')
|
||||
->description('创建')
|
||||
->body($this->form());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Explain);
|
||||
|
||||
$grid->id('ID');
|
||||
$grid->title('标题');
|
||||
$grid->description('简介');
|
||||
$grid->status('状态')->switch();
|
||||
$grid->order('排序');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
// 去掉默认的id过滤器
|
||||
$filter->disableIdFilter();
|
||||
// 在这里添加字段过滤器
|
||||
$filter->like('title', '标题');
|
||||
});
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
$show = new Show(Explain::findOrFail($id));
|
||||
|
||||
$show->id('ID');
|
||||
$show->title('标题');
|
||||
$show->description('简介');
|
||||
$show->content('详情');
|
||||
$show->status('状态')->using(['1' => '正常', '0' => '关闭']);
|
||||
$show->order('排序');
|
||||
$show->clicks('浏览量');
|
||||
|
||||
return $show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Explain);
|
||||
|
||||
$form->text('title', '标题')->rules('required');
|
||||
$form->textarea('description', '简介');
|
||||
$form->editor('content', '详情')->rules('required', ['required' => '详情不能为空']);
|
||||
$form->switch('status', '状态')->default(1);
|
||||
$form->number('order', '排序')->default(0);
|
||||
$form->number('clicks', '浏览量')->default(0);
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
247
app/Admin/Controllers/FinanceController.php
Normal file
247
app/Admin/Controllers/FinanceController.php
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\Finance;
|
||||
use App\Models\OrderPayment;
|
||||
use Artisan;
|
||||
use Carbon\Carbon;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
|
||||
class FinanceController extends Controller
|
||||
{
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('财务概览')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Finance);
|
||||
$grid->disableRowSelector();
|
||||
$grid->disableActions();
|
||||
|
||||
$grid->model()->latest()->with(['company']);
|
||||
// $grid->paginate(Company::count());
|
||||
|
||||
$grid->tools(function ($tools) {
|
||||
$tools->batch(function ($batch) {
|
||||
$batch->disableDelete();
|
||||
});
|
||||
});
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('company.name', '公司名称');
|
||||
$filter->like('sn', '#SN#');
|
||||
$filter->equal('status', '结算状态')->select([
|
||||
0 => '初始化',
|
||||
1 => '结算中',
|
||||
2 => '结算失败',
|
||||
9 => '结算完成',
|
||||
]);
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->date('date', '结算日期');
|
||||
$filter->equal('type', '账单类型')->select([
|
||||
'day' => '日账单',
|
||||
'week' => '周账单',
|
||||
'month' => '月账单',
|
||||
'quarter' => '季账单',
|
||||
'year' => '年账单',
|
||||
'custom' => '自定义',
|
||||
]);
|
||||
$filter->group('orders', '订单总数', function ($group) {
|
||||
$group->gt('大于');
|
||||
$group->lt('小于');
|
||||
$group->nlt('不小于');
|
||||
$group->ngt('不大于');
|
||||
$group->equal('等于');
|
||||
});
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->between('start_time', '结算期始')->datetime();
|
||||
$filter->between('end_time', '结算期止')->datetime();
|
||||
});
|
||||
// $filter->expand();
|
||||
});
|
||||
|
||||
$grid->id('Id')->sortable();
|
||||
$grid->column('公司名称/#SN#')->display(function () {
|
||||
return $this->company->name . '<br>' . $this->sn;
|
||||
});
|
||||
$grid->column('日期/类型')->display(function () {
|
||||
$ret = $this->date . '<br>';
|
||||
$ret .= $this->type_text;
|
||||
return $ret;
|
||||
});
|
||||
$grid->column('结算周期')->display(function () {
|
||||
return $this->start_time . '<br>' . $this->end_time;
|
||||
});
|
||||
|
||||
$grid->column('销售/退款金额')->display(function () {
|
||||
return $this->total_sales . '<br>' . $this->total_refunds;
|
||||
});
|
||||
|
||||
$grid->total_cost('成本金额');
|
||||
$grid->column('订单总数/支付')->display(function () {
|
||||
return $this->orders . ' / ' . $this->orders_paid;
|
||||
});
|
||||
$grid->refunds('退款数量');
|
||||
$grid->heads('参与团长');
|
||||
$grid->users('参与用户');
|
||||
$grid->goods('销售商品');
|
||||
$grid->column('状态')->display(function () {
|
||||
switch ($this->status) {
|
||||
case 0:
|
||||
return '<span class="label label-default">初始化</span>';
|
||||
break;
|
||||
case 1:
|
||||
return '<span class="label label-warning">结算中</span>';
|
||||
break;
|
||||
case 2:
|
||||
return '<span class="label label-danger">结算失败</span>';
|
||||
break;
|
||||
case 9:
|
||||
return '<span class="label label-success">结算完成</span>';
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$grid->column('创建/更新时间')->display(function () {
|
||||
return $this->created_at . '<br>' . $this->updated_at;
|
||||
});
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
public function create(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('手动生成账单')
|
||||
->body($this->form());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Finance);
|
||||
$form->setWidth(3, 2);
|
||||
$form->footer(function ($footer) {
|
||||
$footer->disableViewCheck();
|
||||
$footer->disableCreatingCheck();
|
||||
$footer->disableEditingCheck();
|
||||
});
|
||||
|
||||
$form->datetimeRange('start_at', 'end_at', '日期范围')->help('选择日期范围的情况下,下面的属性会失效');
|
||||
|
||||
$form->date('date', '账单日期')->default(Carbon::now()->toDateString());
|
||||
$form->select('type', '账单类型')->options([
|
||||
'day' => '日账单',
|
||||
'week' => '周账单',
|
||||
'month' => '月账单',
|
||||
'quarter' => '季账单',
|
||||
'year' => '年账单',
|
||||
'custom' => '自定义',
|
||||
])->default('day')->setWidth(2, 2);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
$date = request('date');
|
||||
$type = request('type');
|
||||
|
||||
$start_at = request('start_at');
|
||||
$end_at = request('end_at');
|
||||
|
||||
try {
|
||||
|
||||
if ($start_at && $end_at) {
|
||||
Artisan::call('bill:create', [
|
||||
'--day' => $date,
|
||||
'--type' => [$start_at, $end_at],
|
||||
]);
|
||||
} else {
|
||||
Artisan::call('bill:create', [
|
||||
'--day' => $date,
|
||||
'--type' => $type,
|
||||
]);
|
||||
}
|
||||
admin_toastr('账单生成成功', 'success');
|
||||
return redirect('/admin/finances');
|
||||
} catch (\Exception $e) {
|
||||
admin_toastr($e->getMessage(), 'error');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
public function orders(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('订单支付记录')
|
||||
->description('所有订单的支付记录,包含未支付的信息')
|
||||
->body($this->ordersGrid());
|
||||
}
|
||||
|
||||
public function ordersGrid()
|
||||
{
|
||||
$grid = new Grid(new OrderPayment);
|
||||
$grid->disableRowSelector();
|
||||
$grid->disableActions();
|
||||
$grid->disableCreateButton();
|
||||
|
||||
$grid->model()->latest()->with(['order']);
|
||||
|
||||
$grid->tools(function ($tools) {
|
||||
$tools->batch(function ($batch) {
|
||||
$batch->disableDelete();
|
||||
});
|
||||
});
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('order.orderid', '订单编号');
|
||||
$filter->like('out_trade_no', '支付单号');
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('transaction_id', '交易单号');
|
||||
$filter->equal('type', '支付方式')->select([
|
||||
'wxpay' => '微信支付',
|
||||
'balance' => '余额支付',
|
||||
]);
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->between('end_at', '支付时间')->datetime();
|
||||
$filter->between('created_at', '创建时间')->datetime();
|
||||
});
|
||||
// $filter->expand();
|
||||
});
|
||||
|
||||
$grid->id('#Id#')->sortable();
|
||||
$grid->column('order.orderid', '订单编号');
|
||||
$grid->out_trade_no('支付单号');
|
||||
$grid->transaction_id('交易单号');
|
||||
$grid->end_at('支付时间');
|
||||
|
||||
$grid->column('支付方式')->display(function () {
|
||||
return $this->type_text;
|
||||
});
|
||||
|
||||
$grid->created_at('创建时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
}
|
||||
151
app/Admin/Controllers/GoodsController.php
Normal file
151
app/Admin/Controllers/GoodsController.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Goods;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Show;
|
||||
|
||||
class GoodsController extends Controller
|
||||
{
|
||||
use HasResourceActions;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
|
||||
return $content
|
||||
->header('产品包管理')
|
||||
->description('description')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Show interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function show($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('Detail')
|
||||
->description('description')
|
||||
->body($this->detail($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('编辑产品包')
|
||||
->body($this->form()->edit($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function create(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('新增产品包')
|
||||
->body($this->form());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Goods);
|
||||
$grid->model()->orderBy('id', 'desc');
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
});
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
$filter->like('name', '产品包名称');
|
||||
$filter->equal('status', '产品包状态')->select([
|
||||
1 => '正常',
|
||||
0 => '禁用',
|
||||
]);
|
||||
});
|
||||
|
||||
$grid->id('ID');
|
||||
$grid->cover('封面')->image('', 60, 60);
|
||||
$grid->name('产品包名称');
|
||||
$grid->description('试读');
|
||||
$grid->price('价格');
|
||||
$grid->column('类型')->display(function () {
|
||||
return $this->type_text;
|
||||
});
|
||||
$grid->status('状态')->switch();
|
||||
$grid->created_at('创建时间');
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
$show = new Show(Goods::findOrFail($id));
|
||||
|
||||
$show->id('编号');
|
||||
$show->name('产品包名称');
|
||||
$show->price('价格');
|
||||
$show->created_at('创建时间');
|
||||
|
||||
return $show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Goods);
|
||||
|
||||
$form->text('name', '产品包名称')->rules('required');
|
||||
$form->textarea('description', '试读')->rules('required|max:255', [
|
||||
'required' => '试读不能为空',
|
||||
'max' => '试读不能超过255字',
|
||||
]);
|
||||
$form->text('price', '价格')->rules('required');
|
||||
$form->image('cover', '封面');
|
||||
$form->select('type', '类型')->options([
|
||||
'1' => '普通产品',
|
||||
'2' => '升级产品',
|
||||
])->rules('required');
|
||||
$form->editor('content', '详情')->rules('required', ['required' => '详情不能为空']);
|
||||
$form->switch('status', '状态')->default(1);
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
82
app/Admin/Controllers/HomeController.php
Normal file
82
app/Admin/Controllers/HomeController.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Encore\Admin\Layout\Column;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Layout\Row;
|
||||
use Encore\Admin\Widgets\InfoBox;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function index(Content $content)
|
||||
{
|
||||
// return $content
|
||||
// ->header('项目看板')
|
||||
// ->description('Description...');
|
||||
return $content
|
||||
->header('看板')
|
||||
->description()
|
||||
->row(function (Row $row) {
|
||||
$row->column(3, function (Column $column) {
|
||||
$column->append(new InfoBox('用户总数', 'users', 'aqua', '/admin/user', User::count()));
|
||||
});
|
||||
$row->column(3, function (Column $column) {
|
||||
$column->append(new InfoBox('今日新增', 'users', 'yellow', '/admin/user', User::whereDate('created_at', Carbon::today())->count()));
|
||||
});
|
||||
|
||||
})
|
||||
->row(function (Row $row) {
|
||||
$row->column(3, function (Column $column) {
|
||||
$orders = Order::whereDate('paid_at', Carbon::today())->count();
|
||||
$column->append(new InfoBox('今日订单', 'print', 'green', '/admin/orders', $orders));
|
||||
});
|
||||
$row->column(3, function (Column $column) {
|
||||
$totals = Order::whereDate('paid_at', Carbon::today())->sum('amount');
|
||||
$column->append(new InfoBox('今日收款', 'dollar', 'orange', '/admin/orders', number_format($totals, 2)));
|
||||
});
|
||||
})
|
||||
->row(function (Row $row) {
|
||||
// $row->column(3, function (Column $column) {
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'red', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'yellow', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'aqua', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'blue', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'light-blue', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'green', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'navy', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'teal', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'olive', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'lime', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'orange', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'fuchsia', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'purple', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'maroon', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'black', '/admin/users', 'Null'));
|
||||
|
||||
// });
|
||||
|
||||
// $row->column(3, function (Column $column) {
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'red-active', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'yellow-active', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'aqua-active', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'blue-active', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'light-blue-active', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'green-active', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'navy-active', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'teal-active', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'olive-active', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'lime-active', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'orange-active', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'fuchsia-active', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'purple-active', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'maroon-active', '/admin/users', 'Null'));
|
||||
// $column->append(new InfoBox('今日新增', 'users', 'black-active', '/admin/users', 'Null'));
|
||||
|
||||
// });
|
||||
});
|
||||
}
|
||||
}
|
||||
119
app/Admin/Controllers/IdentityController.php
Normal file
119
app/Admin/Controllers/IdentityController.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Widgets\Table;
|
||||
use RuLong\Identity\Models\Identity;
|
||||
|
||||
class IdentityController extends Controller
|
||||
{
|
||||
use HasResourceActions;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('用户身份管理')
|
||||
->description('仅供超级管理员管理')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('编辑身份')
|
||||
->body($this->form()->edit($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$identity_model = new Identity();
|
||||
$grid = new Grid(new Identity);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableFilter();
|
||||
$grid->disableExport();
|
||||
$grid->disableRowSelector();
|
||||
$grid->tools(function ($tools) {
|
||||
$tools->batch(function ($batch) {
|
||||
$batch->disableDelete();
|
||||
});
|
||||
});
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableView();
|
||||
});
|
||||
$grid->column('id', '身份编号');
|
||||
$grid->column('title', '身份名称');
|
||||
|
||||
$grid->useridentitys('人数')->count()->modal('详细信息', function ($model) {
|
||||
$users = $model->useridentitys->map(function ($useridentity) {
|
||||
return [$useridentity->user_id, $useridentity->user->info->nickname, $useridentity->user->info->mobile, $useridentity->user->created_at];
|
||||
});
|
||||
return new Table(['ID', '昵称', '手机号', '注册时间'], $users->toArray());
|
||||
});
|
||||
|
||||
$grid->column('配置项')->display(function () {
|
||||
return $this->config_text;
|
||||
});
|
||||
|
||||
$grid->created_at('创建时间');
|
||||
$grid->updated_at('更新时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Identity);
|
||||
$form->display('id', 'ID');
|
||||
$form->text('title', '身份名称')->rules('required');
|
||||
|
||||
$form->embeds('configs', '配置项', function ($form) {
|
||||
$configArray = config('rulong_identity.configs');
|
||||
foreach ($configArray as $key => $config) {
|
||||
$name = $config['name'];
|
||||
$rule = $config['rule'];
|
||||
$form->rate($key, $name)->rules($rule['rules'], $rule['prompt'])->setWidth(1);
|
||||
}
|
||||
});
|
||||
|
||||
$form->tools(function (Form\Tools $tools) {
|
||||
$tools->disableDelete();
|
||||
$tools->disableView();
|
||||
});
|
||||
|
||||
$form->footer(function ($footer) {
|
||||
$footer->disableReset();
|
||||
$footer->disableViewCheck();
|
||||
$footer->disableCreatingCheck();
|
||||
});
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
143
app/Admin/Controllers/OrderController.php
Normal file
143
app/Admin/Controllers/OrderController.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Exporters\OrderExporter;
|
||||
use App\Admin\Extensions\Actions\OrderDeliver;
|
||||
use App\Models\Order;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Facades\Admin;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Show;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
use HasResourceActions;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('订单列表')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Show interface.
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function show(Order $order, Content $content)
|
||||
{
|
||||
return Admin::content(function (Content $content) use ($order) {
|
||||
$content->header('订单详情');
|
||||
|
||||
$content->body(view("admin.order.detail", compact('order')));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Order);
|
||||
$grid->disableCreateButton();
|
||||
|
||||
$grid->model()->orderBy('id', 'desc')->with(['details.item', 'user.info', 'payment']);
|
||||
|
||||
$grid->paginate(10);
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableEdit();
|
||||
$actions->disableView();
|
||||
$actions->append('<p><a href="' . $this->getResource() . '/' . $this->getRouteKey() . '" class="btn btn-xs btn-default">订单详情</a></p>');
|
||||
if ($actions->row->canDeliver() && $actions->row->state == Order::ORDER_DELIVER) {
|
||||
$actions->append(new OrderDeliver($actions->row));
|
||||
}
|
||||
});
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('orderid', '订单编号');
|
||||
$filter->equal('state', '订单状态')->select([
|
||||
Order::ORDER_UNPAY => '待支付',
|
||||
Order::ORDER_PAID => '已支付',
|
||||
Order::ORDER_CANCEL => '已取消',
|
||||
]);
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user', function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
});
|
||||
}, '下单用户');
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->between('created_at', '下单时间')->datetime();
|
||||
$filter->between('paid_at', '付款时间')->datetime();
|
||||
});
|
||||
// $filter->expand();
|
||||
});
|
||||
|
||||
$grid->orderid('订单编号')->display(function ($model) {
|
||||
$ret = "<a href='orders/{$this->orderid}' style='font-size:18px'>{$this->orderid}</a>";
|
||||
$ret .= '<br/><span style="color:#999">商品数量:' . $this->details()->sum('number') . '</span>';
|
||||
return $ret;
|
||||
});
|
||||
$grid->column('商品信息')->display(function () {
|
||||
$ret = '';
|
||||
foreach ($this->details as $detail) {
|
||||
$ret .= '<p style="font-size: 12px;line-height: 18px;margin: 0px;padding: 0px">' . $detail['item']['name'] . ' <span style="color:red">' . number_format($detail['price'], 2) . '</span> * ' . $detail['number'] . '</p>';
|
||||
}
|
||||
return $ret;
|
||||
});
|
||||
$grid->column('下单用户')->display(function () {
|
||||
$ret = '<img src="' . $this->user->info->avatar . '" alt="" class="img img-thumbnail" style="max-width:40px;max-height:40px;vertical-align:top">';
|
||||
$ret .= '<div style="display:inline-block;margin-left:5px">' . $this->user->info->nickname;
|
||||
$ret .= '<br/>' . $this->user->info->mobile . '</div>';
|
||||
return $ret;
|
||||
});
|
||||
|
||||
$grid->column('价格')->display(function () {
|
||||
$ret = '商品小计:' . number_format($this->amount, 2);
|
||||
$ret .= '<br/>应收总额:' . number_format($this->total, 2);
|
||||
return $ret;
|
||||
});
|
||||
|
||||
$grid->column('状态')->display(function () {
|
||||
$ret = $this->state_text . '<br>';
|
||||
// $ret .= $this->status . '<br>';
|
||||
if ($this->payment) {
|
||||
$ret .= $this->payment->type_text . '<br>';
|
||||
$ret .= $this->payment->out_trade_no . '<br>';
|
||||
$ret .= $this->payment->transaction_id;
|
||||
}
|
||||
return $ret;
|
||||
});
|
||||
|
||||
$grid->column('下单时间/付款时间')->display(function ($gd) {
|
||||
$ret = $this->created_at . '<br/>';
|
||||
$ret .= $this->paid_at;
|
||||
return $ret;
|
||||
});
|
||||
|
||||
$grid->disableExport(false);
|
||||
$grid->exporter(new OrderExporter());
|
||||
|
||||
return $grid->render();
|
||||
}
|
||||
|
||||
}
|
||||
187
app/Admin/Controllers/PolicyController.php
Normal file
187
app/Admin/Controllers/PolicyController.php
Normal file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Category;
|
||||
use App\Models\ChinaArea;
|
||||
use App\Models\Policy;
|
||||
use App\Models\Trade;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Show;
|
||||
|
||||
class PolicyController extends Controller
|
||||
{
|
||||
use HasResourceActions;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('资讯管理')
|
||||
->description('列表')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Show interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function show($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('资讯管理')
|
||||
->description('详情')
|
||||
->body($this->detail($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('资讯管理')
|
||||
->description('编辑')
|
||||
->body($this->form()->edit($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function create(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('资讯管理')
|
||||
->description('创建')
|
||||
->body($this->form());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Policy);
|
||||
|
||||
$grid->id('ID');
|
||||
// $grid->column('类型')->display(function () {
|
||||
// return $this->type == 'policy' ? '政策' : '解读';
|
||||
// });
|
||||
$grid->title('标题');
|
||||
$grid->no('文件号');
|
||||
$grid->category()->title('所属部门');
|
||||
// $grid->trade()->title('所属行业');
|
||||
|
||||
$grid->trades('所属行业')->display(function ($trades) {
|
||||
|
||||
$trades = array_map(function ($trade) {
|
||||
return "<span class='label label-success'>{$trade['title']}</span>";
|
||||
}, $trades);
|
||||
|
||||
return join(' ', $trades);
|
||||
});
|
||||
|
||||
$grid->areas('实行地区')->display(function ($areas) {
|
||||
|
||||
$areas = array_map(function ($area) {
|
||||
return "<span class='label label-success'>{$area['name']}</span>";
|
||||
}, $areas);
|
||||
|
||||
return join(' ', $areas);
|
||||
});
|
||||
|
||||
$grid->cover('标题图')->image('', 60, 60);
|
||||
$grid->status('状态')->switch();
|
||||
$grid->order('排序');
|
||||
$grid->begined_at('发布时间');
|
||||
// $grid->ended_at('结束时间');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
|
||||
// 去掉默认的id过滤器
|
||||
$filter->disableIdFilter();
|
||||
// 在这里添加字段过滤器
|
||||
$filter->like('title', '标题');
|
||||
});
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
$show = new Show(Policy::findOrFail($id));
|
||||
|
||||
$show->id('ID');
|
||||
$show->title('标题');
|
||||
$show->description('简介');
|
||||
$show->cover('标题图')->image('', 60, 60);
|
||||
$show->content('详情');
|
||||
$show->status('状态')->using(['1' => '正常', '0' => '关闭']);
|
||||
$show->order('排序');
|
||||
$show->clicks('浏览量');
|
||||
$show->begined_at('发布时间');
|
||||
// $show->ended_at('结束时间');
|
||||
|
||||
return $show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Policy);
|
||||
|
||||
$form->text('title', '标题')->rules('required');
|
||||
$form->text('no', '文件号')->rules('required');
|
||||
|
||||
$form->select('category_id', '所属部门')->options(Category::selectOptions(function ($model) {
|
||||
return $model->where('status', 1);
|
||||
}, ''))->rules('required');
|
||||
|
||||
// $form->multipleSelect('trade_id', '所属行业')->options(Trade::selectOptions(function ($model) {
|
||||
// return $model->where('status', 1);
|
||||
// }, ''))->rules('required');
|
||||
|
||||
$form->multipleSelect('trades', '所属行业')->options(Trade::where('status', 1)->pluck('title', 'id'), null)->rules('required');
|
||||
$form->multipleSelect('areas', '区域')->options(ChinaArea::where('parent_id', 9)->Orwhere('id', 9)->pluck('name', 'id'), null)->rules('required');
|
||||
// $form->datetimeRange('begined_at', 'ended_at', '生效时间')->rules('required');
|
||||
$form->datetime('begined_at', '发布时间')->rules('required');
|
||||
// $form->textarea('description', '简介');
|
||||
$form->image('cover', '标题图');
|
||||
$form->editor('content', '详情')->rules('required', ['required' => '详情不能为空']);
|
||||
$form->switch('status', '状态')->default(1);
|
||||
$form->number('order', '排序')->default(0);
|
||||
$form->number('clicks', '浏览量')->default(0);
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
178
app/Admin/Controllers/TradeController.php
Normal file
178
app/Admin/Controllers/TradeController.php
Normal file
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Trade;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Column;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Layout\Row;
|
||||
use Encore\Admin\Show;
|
||||
use Encore\Admin\Tree;
|
||||
use Encore\Admin\Widgets\Box;
|
||||
use Encore\Admin\Widgets\Form as WidgetsForm;
|
||||
|
||||
class TradeController extends Controller
|
||||
{
|
||||
use HasResourceActions;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('行业')
|
||||
->row(function (Row $row) {
|
||||
$row->column(6, $this->treeView());
|
||||
|
||||
$row->column(6, function (Column $column) {
|
||||
$form = new WidgetsForm();
|
||||
|
||||
$form->select('parent_id', '上级行业')->options(Trade::selectOptions(function ($model) {
|
||||
return $model->where('status', 1);
|
||||
}, '一级行业'));
|
||||
$form->text('title', '行业名称')->rules('required');
|
||||
$form->textarea('description', '行业简介')->rows(4)->rules('nullable');
|
||||
$form->number('order', '排序')->default(0);
|
||||
$form->switch('status', '显示')->states()->default(1);
|
||||
|
||||
$form->action('/admin/trades');
|
||||
|
||||
$column->append((new Box('新增行业', $form))->style('success'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Encore\Admin\Tree
|
||||
*/
|
||||
protected function treeView()
|
||||
{
|
||||
return Trade::tree(function (Tree $tree) {
|
||||
$tree->disableCreate();
|
||||
$tree->branch(function ($branch) {
|
||||
if ($branch['status'] == 1) {
|
||||
$payload = "<i class='fa fa-eye text-primary'></i> ";
|
||||
} else {
|
||||
$payload = "<i class='fa fa-eye text-gray'></i> ";
|
||||
}
|
||||
$payload .= " [ID:{$branch['id']}] - ";
|
||||
$payload .= " <strong>{$branch['title']}</strong> ";
|
||||
$payload .= " <small style='color:#999'>{$branch['description']}</small>";
|
||||
|
||||
return $payload;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function show($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('Detail')
|
||||
->description('description')
|
||||
->body($this->detail($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('编辑')
|
||||
->description('行业')
|
||||
->body($this->form()->edit($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function create(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('Create')
|
||||
->description('description')
|
||||
->body($this->form());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Trade);
|
||||
|
||||
$grid->id('Id');
|
||||
$grid->title('行业名称');
|
||||
$grid->description('行业简介');
|
||||
$grid->order('排序');
|
||||
$grid->status('显示')->switch();
|
||||
$grid->created_at('创建时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
$show = new Show(Trade::findOrFail($id));
|
||||
|
||||
$show->id('Id');
|
||||
$show->parent_id('Parent id');
|
||||
$show->title('Title');
|
||||
$show->description('简介');
|
||||
$show->order('Order');
|
||||
$show->status('Status');
|
||||
$show->created_at('Created at');
|
||||
$show->updated_at('Updated at');
|
||||
|
||||
return $show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Trade);
|
||||
|
||||
$form->select('parent_id', '上级行业')->options(Trade::selectOptions(function ($model) {
|
||||
return $model->where('status', 1);
|
||||
}, '一级行业'));
|
||||
$form->text('title', '行业名称')->rules('required');
|
||||
$form->textarea('description', '行业简介')->rows(4)->rules('nullable');
|
||||
$form->number('order', '排序')->default(0);
|
||||
$form->switch('status', '显示')->states()->default(1);
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
30
app/Admin/Controllers/UploadController.php
Normal file
30
app/Admin/Controllers/UploadController.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class UploadController extends Controller
|
||||
{
|
||||
|
||||
public function editor(Request $request)
|
||||
{
|
||||
$files = $request->file("image");
|
||||
|
||||
if (empty($files)) {
|
||||
return response()->json(['errno' => 5, 'msg' => '请选择文件']);
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
$path = $file->store(
|
||||
'editor/' . date('Y/m/d'),
|
||||
config('admin.upload.disk')
|
||||
);
|
||||
|
||||
$data[] = Storage::disk(config('admin.upload.disk'))->url($path);
|
||||
}
|
||||
|
||||
return ['errno' => 0, 'data' => $data];
|
||||
}
|
||||
}
|
||||
294
app/Admin/Controllers/UserController.php
Normal file
294
app/Admin/Controllers/UserController.php
Normal file
@@ -0,0 +1,294 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Config;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Facades\Admin;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Form\Tools;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Illuminate\Http\Request;
|
||||
use RuLong\Identity\Models\Identity;
|
||||
use RuLong\Identity\Models\IdentityLog;
|
||||
use RuLong\Identity\Models\UserIdentity;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
use HasResourceActions;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('会员管理')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Show interface.
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function show(User $user, Content $content)
|
||||
{
|
||||
}
|
||||
|
||||
//空升
|
||||
public function emptys(User $user, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('空升')
|
||||
->body($this->UserEmptyForm($user));
|
||||
}
|
||||
|
||||
//执行空升
|
||||
public function DoEmpty(User $user, Request $request)
|
||||
{
|
||||
$identity_id = $request->identity_id;
|
||||
if ($identity_id == 6) {
|
||||
$identity = UserIdentity::where('identity_id', 6)->first();
|
||||
if ($identity) {
|
||||
$identity->user->identityUpdate(1, 'EmptyUp');
|
||||
}
|
||||
}
|
||||
|
||||
$user->identityUpdate($identity_id, 'EmptyUp');
|
||||
|
||||
if ($identity_id == 1) {
|
||||
$year = Config::where('name', 'upgrade_time')->value('value') ?? 1;
|
||||
$user->vipd_at = Carbon::now();
|
||||
$user->vip_end_at = Carbon::now()->addYear($year);
|
||||
$user->save();
|
||||
}
|
||||
admin_toastr('升级成功');
|
||||
return redirect()->intended('/admin/user');
|
||||
}
|
||||
|
||||
//空升记录
|
||||
public function logs(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('空升记录')
|
||||
->body($this->emptyGrid());
|
||||
}
|
||||
|
||||
public function emptyGrid()
|
||||
{
|
||||
$grid = new Grid(new IdentityLog);
|
||||
$grid->disableRowSelector();
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user.info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
}, '空升用户');
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->between('created_at', '空升时间')->datetime();
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('channel', '升级途径')->select([
|
||||
'EmptyUp' => '后台升级',
|
||||
'AutoUp' => '自动升级',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
$grid->disableCreateButton();
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableEdit();
|
||||
$actions->disableView();
|
||||
});
|
||||
|
||||
$grid->paginate(10);
|
||||
|
||||
$grid->model()->where('other', 'like', "%EmptyUp%")->orderBy('created_at', 'desc')->with(['user']);
|
||||
|
||||
$grid->id('Id')->sortable();
|
||||
|
||||
$grid->column('用户')->display(function () {
|
||||
return $this->user->info->nickname;
|
||||
});
|
||||
|
||||
$grid->column('空升前')->display(function () {
|
||||
return $this->before_identity_title;
|
||||
});
|
||||
|
||||
$grid->column('空升后')->display(function () {
|
||||
return $this->identity_title;
|
||||
});
|
||||
|
||||
$grid->column('类型')->display(function () {
|
||||
return $this->channel_text;
|
||||
});
|
||||
|
||||
$grid->created_at('升级时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new User);
|
||||
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableRowSelector();
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableEdit();
|
||||
$actions->disableView();
|
||||
$actions->append('<p><a href="' . route('user.empty', $this->getRouteKey()) . '" class="btn btn-xs btn-default">空升</a></p>');
|
||||
$actions->append('<p><a href="' . route('user.remark', $actions->getKey()) . '" class="btn btn-xs btn-default">备注</a></p>');
|
||||
// $actions->append('<a href="/admin/users/remark' . $this->getRouteKey() . '/recharge">备注</a>');
|
||||
});
|
||||
|
||||
$grid->paginate(10);
|
||||
|
||||
$grid->model()->orderBy('id', 'desc')->with(['info', 'account', 'orders']);
|
||||
|
||||
$grid->id('Id')->sortable();
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('info.nickname', '会员昵称');
|
||||
});
|
||||
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
$query->where('mobile', $this->input);
|
||||
});
|
||||
}, '会员手机号');
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('头像 昵称')->display(function () {
|
||||
$avatar = '<img src="' . $this->info->avatar . '" alt="" style="width:40px;height:40px;border-radius:50%" />';
|
||||
return $avatar . ' ' . $this->info->nickname;
|
||||
});
|
||||
|
||||
$grid->column('手机号')->display(function () {
|
||||
return $this->info->mobile;
|
||||
});
|
||||
|
||||
$grid->column('备注')->display(function () {
|
||||
return $this->info->remark;
|
||||
});
|
||||
|
||||
$grid->column('企业名')->display(function () {
|
||||
return $this->info->company;
|
||||
});
|
||||
|
||||
$grid->column('企业注册地')->display(function () {
|
||||
return $this->info->area;
|
||||
});
|
||||
|
||||
$grid->column('推荐人')->display(function () {
|
||||
return $this->parent ? $this->parent->info->nickname . '(' . $this->parent->id . ')' : '';
|
||||
});
|
||||
|
||||
$grid->column('账户')->display(function () {
|
||||
$ret = '余额:' . $this->account->cash;
|
||||
return $ret;
|
||||
});
|
||||
|
||||
$grid->column('等级')->display(function () {
|
||||
return $this->identity_text;
|
||||
});
|
||||
|
||||
$grid->vip_end_at('会员到期时间');
|
||||
$grid->created_at('注册时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function UserEmptyForm($user)
|
||||
{
|
||||
$identitys = Identity::where('id', '!=', $user->identity->identity_id)->orderBy('id', 'asc')->pluck('title', 'id')->toArray();
|
||||
$identitys[0] = '普通用户';
|
||||
ksort($identitys);
|
||||
$form = new Form(new User);
|
||||
$form->text('title', '当前等级')->value($user->identity_text)->readonly();
|
||||
$form->select('identity_id', '目标等级')->options($identitys)->required();
|
||||
$form->disableReset();
|
||||
$form->setAction('/admin/user/' . $user->id . '/empty');
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加备注
|
||||
* @param Content $content [description]
|
||||
* @param User $user [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function remark(Request $request, Content $content, User $user)
|
||||
{
|
||||
if ($request->isMethod('POST')) {
|
||||
try {
|
||||
$user->info->remark = $request->remark;
|
||||
$user->info->save();
|
||||
admin_toastr('设置成功');
|
||||
return redirect()->action('\App\Admin\Controllers\UserController@index');
|
||||
} catch (\Exception $e) {
|
||||
admin_toastr($e->getMessage(), 'error');
|
||||
}
|
||||
} else {
|
||||
return $content
|
||||
->header('设置备注')
|
||||
->description($user->info->nickname)
|
||||
->body($this->UserInfoForm($user));
|
||||
}
|
||||
}
|
||||
|
||||
protected function UserInfoForm($user)
|
||||
{
|
||||
$form = new Form(new User);
|
||||
$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(route('user.remark', ['user' => $user]));
|
||||
$form->setTitle(' ');
|
||||
$form->setWidth(1, 2);
|
||||
|
||||
$form->text('remark', '备注')->value($user->info->remark);
|
||||
|
||||
return $form->render();
|
||||
}
|
||||
}
|
||||
169
app/Admin/Controllers/WithdrawController.php
Normal file
169
app/Admin/Controllers/WithdrawController.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Withdraw;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Form\Tools;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WithdrawController extends Controller
|
||||
{
|
||||
use HasResourceActions;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('提现列表')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
public function show(Withdraw $withdraw, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('提现详情');
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Withdraw);
|
||||
$grid->disableRowSelector();
|
||||
$grid->disableCreateButton();
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableEdit();
|
||||
$actions->disableView();
|
||||
if (in_array($actions->row->status, [0, 1, 3])) {
|
||||
$actions->append('<a href="/admin/withdraws/status/' . $actions->getKey() . '">审核</a> ');
|
||||
}
|
||||
});
|
||||
|
||||
$grid->model()->orderBy('id', 'desc')->with(['user']);
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('type', '提现方式')->select(['wxpay' => '微信支付', 'bank' => '银行卡']);
|
||||
$filter->equal('status', '提现状态')->select([0 => '申请中', 1 => '处理中', 2 => '被驳回', 3 => '审核通过', 9 => '已转账']);
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->between('created_at', '申请时间')->datetime();
|
||||
$filter->between('updated_at', '更新时间')->datetime();
|
||||
});
|
||||
// $filter->expand();
|
||||
});
|
||||
|
||||
$grid->id('Id')->sortable();
|
||||
$grid->column('bank_user', '提现人');
|
||||
$grid->money('提现金额');
|
||||
$grid->service('手续费');
|
||||
|
||||
$grid->column('提现方式')->display(function () {
|
||||
if ($this->type == 'wxpay') {
|
||||
return '<span class="label label-success">' . $this->type_text . '</span>';
|
||||
} else {
|
||||
return '<span class="label label-warning">' . $this->type_text . '</span>';
|
||||
}
|
||||
})->modal('银行卡信息', function ($model) {
|
||||
$ret = '<p>' . $model->bank_name . '</p>';
|
||||
$ret .= '<p>' . $model->bank_card . '</p>';
|
||||
$ret .= '<p>' . $model->bank_user . '</p>';
|
||||
return $ret;
|
||||
});
|
||||
|
||||
$grid->column('提现状态')->display(function () {
|
||||
return $this->status_text;
|
||||
})->label();
|
||||
|
||||
$grid->created_at('申请时间');
|
||||
$grid->paid_at('支付时间');
|
||||
$grid->updated_at('更新时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
public function status(Request $request, Content $content, Withdraw $withdraw)
|
||||
{
|
||||
if ($request->isMethod('POST')) {
|
||||
if (in_array($request->status, [2])) {
|
||||
admin_toastr('当前状态不可操作');
|
||||
return redirect()->intended('/admin/withdraws');
|
||||
}
|
||||
|
||||
try {
|
||||
if ($withdraw->update(['status' => $request->status])) {
|
||||
admin_toastr('审核通过');
|
||||
return redirect()->intended('/admin/withdraws');
|
||||
} else {
|
||||
admin_toastr('审核失败');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
admin_toastr($e->getMessage(), 'error');
|
||||
}
|
||||
} else {
|
||||
return $content
|
||||
->header('充值审核')
|
||||
->body($this->statusFrom($withdraw));
|
||||
}
|
||||
}
|
||||
|
||||
public function statusFrom($withdraw)
|
||||
{
|
||||
$allStatus = [
|
||||
'0' => '申请中',
|
||||
'1' => '处理中',
|
||||
'2' => '拒绝',
|
||||
'3' => '通过',
|
||||
'9' => '已转账',
|
||||
];
|
||||
|
||||
$status = [];
|
||||
if ($withdraw->status == 3) {
|
||||
$status = ['9' => '已转账'];
|
||||
} else {
|
||||
foreach ($allStatus as $key => $value) {
|
||||
if ($key > $withdraw->status) {
|
||||
$status[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ksort($status);
|
||||
$form = new Form(new Withdraw);
|
||||
$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(route('withdraws.status', ['withdraw' => $withdraw]));
|
||||
$form->setTitle('审核提现');
|
||||
$form->setWidth(1, 2);
|
||||
//0申请中1处理中2拒绝3通过9已转账
|
||||
$form->select('status', '状态')->options($status)->required();
|
||||
|
||||
return $form->render();
|
||||
}
|
||||
|
||||
}
|
||||
66
app/Admin/Exporters/GoodsExporter.php
Normal file
66
app/Admin/Exporters/GoodsExporter.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: 朝霞
|
||||
* Date: 2019/5/14
|
||||
* Time: 1:51 PM
|
||||
*/
|
||||
|
||||
namespace App\Admin\Exporters;
|
||||
|
||||
use Encore\Admin\Grid\Exporters\AbstractExporter;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class GoodsExporter extends AbstractExporter
|
||||
{
|
||||
/**
|
||||
* @Notes 商品导出
|
||||
* @Author 朝霞
|
||||
* @DateTime 2019/5/14 2:09 PM
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
Excel::create('商品导出', function ($excel) {
|
||||
$excel->sheet('Sheetname', function ($sheet) {
|
||||
$head = ['商品ID','商品名称','成本价','销售价','市场价','销量','库存','销售分公司','状态','开团时间','截团时间','创建时间', '最后更新时间'];
|
||||
$body = ['id','name','cost_price','price','original_price','sales','stock','companies','status','activity_begined_at','activity_ended_at','created_at', 'updated_at'];
|
||||
$bodyRows = collect($this->getData())->map(function ($item)use($body) {
|
||||
foreach ($body as $keyName){
|
||||
switch ($keyName) {
|
||||
case 'status' :
|
||||
switch (array_get($item, $keyName)) {
|
||||
case 0:
|
||||
$arr[] = '审核中';
|
||||
break;
|
||||
case 1:
|
||||
$arr[] = '上架';
|
||||
break;
|
||||
case -1:
|
||||
$arr[] = '下架';
|
||||
break;
|
||||
default:
|
||||
$arr[] = '未知状态';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'companies' :
|
||||
$companies = array_get($item, 'companies');
|
||||
$arr[] = count($companies) > 0 ? implode('/', array_column($companies,'name')) : '';
|
||||
break;
|
||||
default:
|
||||
$arr[] = array_get($item, $keyName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $arr;
|
||||
});
|
||||
|
||||
$rows = collect([$head])->merge($bodyRows);
|
||||
$sheet->rows($rows);
|
||||
|
||||
});
|
||||
})->export('xlsx');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
165
app/Admin/Exporters/OrderExporter.php
Normal file
165
app/Admin/Exporters/OrderExporter.php
Normal file
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Exporters;
|
||||
|
||||
use App\Models\Order;
|
||||
use Encore\Admin\Grid\Exporters\AbstractExporter;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class OrderExporter extends AbstractExporter
|
||||
{
|
||||
|
||||
/**
|
||||
* @Notes 订单导出
|
||||
* @Author 朝霞
|
||||
* @DateTime 2019/5/14 9:39 AM
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
Excel::create('订单明细', function ($excel) {
|
||||
$excel->sheet('Sheetname', function ($sheet) {
|
||||
$head = ['订单编号', '商品总数', '商品名称', '商品数量', '商品单价', '商品小计', '商品总额', '营收总额', '下单用户', '订单状态', '支付方式', '商户订单号', '微信支付单号', '创建时间', '付款时间', '最后更新时间'];
|
||||
$body = ['orderid', 'goods_count', 'goods_name', 'goods_number', 'goods_price', 'goods_amount', 'amount', 'total', 'user.info.nickname', 'state', 'payment.type', 'payment.out_trade_no', 'payment.transaction_id', 'created_at', 'paid_at', 'updated_at'];
|
||||
|
||||
$bodyRows_array = collect($this->getData())->map(function ($item) use ($body) {
|
||||
$i = 0;
|
||||
$details = array_get($item, 'details');
|
||||
foreach ($details as $key => $value) {
|
||||
foreach ($body as $keyName) {
|
||||
if ($i > 0) {
|
||||
switch ($keyName) {
|
||||
case 'goods_name':
|
||||
$arr[$key][] = $value['item']['name'];
|
||||
break;
|
||||
case 'goods_number':
|
||||
$arr[$key][] = $value['number'];
|
||||
break;
|
||||
case 'goods_price':
|
||||
$arr[$key][] = $value['price'];
|
||||
break;
|
||||
case 'goods_amount':
|
||||
$arr[$key][] = number_format($value['price'] * $value['number'], 2);
|
||||
break;
|
||||
default:
|
||||
$arr[$key][] = ' ';
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch ($keyName) {
|
||||
case 'goods_count':
|
||||
$arr[$key][] = array_sum(array_map(function ($val) {return $val['number'];}, $details));
|
||||
break;
|
||||
case 'goods_name':
|
||||
$arr[$key][] = $value['item']['name'];
|
||||
break;
|
||||
case 'goods_number':
|
||||
$arr[$key][] = $value['number'];
|
||||
break;
|
||||
case 'goods_price':
|
||||
$arr[$key][] = $value['price'];
|
||||
break;
|
||||
case 'goods_amount':
|
||||
$arr[$key][] = number_format($value['price'] * $value['number'], 2);
|
||||
break;
|
||||
case 'freight':
|
||||
$arr[$key][] = empty(array_get($item, $keyName)) ? 0 : array_get($item, $keyName);
|
||||
break;
|
||||
case 'total':
|
||||
$freight = empty(array_get($item, 'freight')) ? 0 : array_get($item, 'freight');
|
||||
$arr[$key][] = number_format(bcadd(array_get($item, 'amount'), $freight, 3), 2);
|
||||
break;
|
||||
case 'state':
|
||||
$state = self::state_text(array_get($item, $keyName));
|
||||
$arr[$key][] = $state;
|
||||
break;
|
||||
case 'payment.type':
|
||||
switch (array_get($item, $keyName)) {
|
||||
case 'wxpay':
|
||||
$arr[$key][] = '微信支付';
|
||||
break;
|
||||
case 'balance':
|
||||
$arr[$key][] = '余额支付';
|
||||
break;
|
||||
default:
|
||||
$arr[$key][] = '';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$arr[$key][] = array_get($item, $keyName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $arr;
|
||||
});
|
||||
|
||||
$bodyRows = [];
|
||||
foreach ($bodyRows_array as $key => $Rows) {
|
||||
foreach ($Rows as $row) {
|
||||
array_push($bodyRows, $row);
|
||||
}
|
||||
}
|
||||
$rows = collect([$head])->merge($bodyRows);
|
||||
$sheet->rows($rows);
|
||||
});
|
||||
})->export('xlsx');
|
||||
|
||||
}
|
||||
|
||||
protected function state_text($orderState): string
|
||||
{
|
||||
switch ($orderState) {
|
||||
case Order::ORDER_INIT:
|
||||
$state = '订单初始化';
|
||||
break;
|
||||
case Order::ORDER_UNPAY:
|
||||
$state = '待支付';
|
||||
break;
|
||||
case Order::ORDER_PAID:
|
||||
$state = '已支付';
|
||||
break;
|
||||
case Order::ORDER_DELIVER:
|
||||
$state = '发货处理中';
|
||||
break;
|
||||
case Order::ORDER_DELIVERED:
|
||||
$state = '已发货';
|
||||
break;
|
||||
case Order::ORDER_SIGNED:
|
||||
$state = '已签收';
|
||||
break;
|
||||
case Order::ORDER_COMPLETED:
|
||||
$state = '已完成';
|
||||
break;
|
||||
case Order::ORDER_CLOSED:
|
||||
$state = '已关闭';
|
||||
break;
|
||||
case Order::ORDER_CANCEL:
|
||||
$state = '已取消';
|
||||
break;
|
||||
case Order::REFUND_APPLY:
|
||||
$state = '申请退款';
|
||||
break;
|
||||
case Order::REFUND_AGREE:
|
||||
$state = '同意退款';
|
||||
break;
|
||||
case Order::REFUND_PROCESS:
|
||||
$state = '退款中';
|
||||
break;
|
||||
case Order::REFUND_COMPLETED:
|
||||
$state = '退款完毕';
|
||||
break;
|
||||
case Order::REFUND_REFUSE:
|
||||
$state = '拒绝退款';
|
||||
break;
|
||||
default:
|
||||
$state = '未知状态';
|
||||
break;
|
||||
}
|
||||
|
||||
return $state;
|
||||
}
|
||||
|
||||
}
|
||||
22
app/Admin/Extensions/CKEditor1.php
Normal file
22
app/Admin/Extensions/CKEditor1.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Extensions;
|
||||
|
||||
use Encore\Admin\Form\Field;
|
||||
|
||||
class CKEditor extends Field
|
||||
{
|
||||
public static $js = [
|
||||
'/vendor/ckeditor/ckeditor.js',
|
||||
'/vendor/ckeditor/adapters/jquery.js',
|
||||
];
|
||||
|
||||
protected $view = 'admin.ckeditor';
|
||||
|
||||
public function render()
|
||||
{
|
||||
$this->script = "$('textarea.{$this->getElementClassString()}').ckeditor();";
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
40
app/Admin/Extensions/Tools/BatchSend.php
Normal file
40
app/Admin/Extensions/Tools/BatchSend.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Extensions\Tools;
|
||||
|
||||
use Encore\Admin\Grid\Tools\BatchAction;
|
||||
|
||||
class BatchSend extends BatchAction
|
||||
{
|
||||
protected $action;
|
||||
|
||||
public function __construct($action = 1)
|
||||
{
|
||||
$this->action = $action;
|
||||
}
|
||||
|
||||
public function script()
|
||||
{
|
||||
return <<<EOT
|
||||
|
||||
$('{$this->getElementClass()}').on('click', function() {
|
||||
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '{$this->resource}/release',
|
||||
data: {
|
||||
_token:LA.token,
|
||||
ids: selectedRows(),
|
||||
action: {$this->action}
|
||||
},
|
||||
success: function () {
|
||||
$.pjax.reload('#pjax-container');
|
||||
toastr.success('操作成功');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
EOT;
|
||||
|
||||
}
|
||||
}
|
||||
40
app/Admin/Extensions/Tools/BatchShelves.php
Normal file
40
app/Admin/Extensions/Tools/BatchShelves.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Extensions\Tools;
|
||||
|
||||
use Encore\Admin\Grid\Tools\BatchAction;
|
||||
|
||||
class BatchShelves extends BatchAction
|
||||
{
|
||||
protected $status;
|
||||
|
||||
public function __construct($status = 1)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function script()
|
||||
{
|
||||
return <<<EOT
|
||||
|
||||
$('{$this->getElementClass()}').on('click', function() {
|
||||
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '{$this->resource}/release',
|
||||
data: {
|
||||
_token:LA.token,
|
||||
ids: selectedRows(),
|
||||
status: {$this->status}
|
||||
},
|
||||
success: function () {
|
||||
$.pjax.reload('#pjax-container');
|
||||
toastr.success('操作成功');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
EOT;
|
||||
|
||||
}
|
||||
}
|
||||
36
app/Admin/Extensions/Tools/CommentAudit.php
Normal file
36
app/Admin/Extensions/Tools/CommentAudit.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Extensions\Tools;
|
||||
|
||||
use Encore\Admin\Grid\Tools\BatchAction;
|
||||
|
||||
class CommentAudit extends BatchAction
|
||||
{
|
||||
protected $status;
|
||||
|
||||
public function __construct($status = 1)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function script()
|
||||
{
|
||||
return <<<EOT
|
||||
$('{$this->getElementClass()}').on('click', function() {
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '{$this->resource}/release',
|
||||
data: {
|
||||
_token:LA.token,
|
||||
ids: selectedRows(),
|
||||
status: {$this->status}
|
||||
},
|
||||
success: function () {
|
||||
$.pjax.reload('#pjax-container');
|
||||
}
|
||||
});
|
||||
});
|
||||
EOT;
|
||||
|
||||
}
|
||||
}
|
||||
40
app/Admin/Extensions/Tools/ReleasePost.php
Normal file
40
app/Admin/Extensions/Tools/ReleasePost.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Extensions\Tools;
|
||||
|
||||
use Encore\Admin\Grid\Tools\BatchAction;
|
||||
|
||||
class ReleasePost extends BatchAction
|
||||
{
|
||||
protected $action;
|
||||
|
||||
public function __construct($action = 1)
|
||||
{
|
||||
$this->action = $action;
|
||||
}
|
||||
|
||||
public function script()
|
||||
{
|
||||
return <<<EOT
|
||||
|
||||
$('{$this->getElementClass()}').on('click', function() {
|
||||
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '{$this->resource}/release',
|
||||
data: {
|
||||
_token:LA.token,
|
||||
ids: selectedRows(),
|
||||
action: {$this->action}
|
||||
},
|
||||
success: function () {
|
||||
$.pjax.reload('#pjax-container');
|
||||
toastr.success('操作成功');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
EOT;
|
||||
|
||||
}
|
||||
}
|
||||
43
app/Admin/Extensions/WangEditor.php
Normal file
43
app/Admin/Extensions/WangEditor.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Extensions;
|
||||
|
||||
use Encore\Admin\Form\Field;
|
||||
|
||||
class WangEditor extends Field
|
||||
{
|
||||
protected $view = 'admin.wang-editor';
|
||||
|
||||
protected static $css = [
|
||||
'/vendor/wangEditor-3.1.1/release/wangEditor.min.css',
|
||||
];
|
||||
|
||||
protected static $js = [
|
||||
'/vendor/wangEditor-3.1.1/release/wangEditor.min.js',
|
||||
];
|
||||
|
||||
public function render()
|
||||
{
|
||||
$_token = csrf_token();
|
||||
$name = $this->formatName($this->column);
|
||||
|
||||
$this->script = <<<EOT
|
||||
|
||||
var E = window.wangEditor
|
||||
var editor = new E('#{$this->id}');
|
||||
editor.customConfig.zIndex = 0
|
||||
editor.customConfig.uploadImgServer = '/admin/uploads/editor'
|
||||
editor.customConfig.uploadImgMaxSize = 2 * 1024 * 1024
|
||||
editor.customConfig.uploadFileName = 'image[]'
|
||||
editor.customConfig.uploadImgParams = {
|
||||
_token: '{$_token}'
|
||||
}
|
||||
editor.customConfig.onchange = function (html) {
|
||||
$('input[name=\'$name\']').val(html);
|
||||
}
|
||||
editor.create()
|
||||
|
||||
EOT;
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
28
app/Admin/bootstrap.php
Normal file
28
app/Admin/bootstrap.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use App\Admin\Extensions\WangEditor;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
Form::forget(['map']);
|
||||
Form::extend('editor', WangEditor::class);
|
||||
|
||||
Form::init(function (Form $form) {
|
||||
$form->disableEditingCheck();
|
||||
$form->disableCreatingCheck();
|
||||
$form->disableViewCheck();
|
||||
|
||||
$form->tools(function (Form\Tools $tools) {
|
||||
$tools->disableDelete();
|
||||
$tools->disableView();
|
||||
$tools->disableList();
|
||||
});
|
||||
});
|
||||
|
||||
Grid::init(function (Grid $grid) {
|
||||
$grid->disableExport();
|
||||
$grid->disableRowSelector();
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
$actions->disableView();
|
||||
});
|
||||
});
|
||||
54
app/Admin/routes.php
Normal file
54
app/Admin/routes.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
Admin::registerAuthRoutes();
|
||||
|
||||
Route::group([
|
||||
'prefix' => config('admin.route.prefix'),
|
||||
'namespace' => config('admin.route.namespace'),
|
||||
'middleware' => config('admin.route.middleware'),
|
||||
], function (Router $router) {
|
||||
$router->post('uploads/editor', 'UploadController@editor')->name('uploads.editor');
|
||||
$router->get('/', 'HomeController@index')->name('admin.home');
|
||||
// 部门
|
||||
$router->resource('categories', 'CategoryController');
|
||||
// 行业
|
||||
$router->resource('trades', 'TradeController');
|
||||
//政策和解读
|
||||
$router->resource('policys', 'PolicyController');
|
||||
//文章
|
||||
$router->resource('articles', 'ArticleController');
|
||||
//文章
|
||||
$router->resource('explains', 'ExplainController');
|
||||
//产品包
|
||||
$router->resource('goods', 'GoodsController');
|
||||
|
||||
// 订单管理
|
||||
$router->resource('orders', 'OrderController');
|
||||
//用户管理
|
||||
$router->resource('user', 'UserController');
|
||||
$router->get('user/{user}/empty', 'UserController@emptys')->name('user.empty');
|
||||
$router->post('user/{user}/empty', 'UserController@DoEmpty');
|
||||
$router->any('user/{user}/remark', 'UserController@remark')->name('user.remark');
|
||||
$router->get('userlogs', 'UserController@logs')->name('user.logs');
|
||||
|
||||
$router->resource('identity', 'IdentityController');
|
||||
// 账户
|
||||
$router->get('accounts/users', 'AccountController@users');
|
||||
$router->get('accounts/users/{user}', 'AccountController@user_logs');
|
||||
$router->any('accounts/users/{user}/recharge', 'AccountController@recharge')->name('accounts.recharge');
|
||||
|
||||
// 财务概览
|
||||
$router->get('finances', 'FinanceController@index');
|
||||
$router->get('finances/orders', 'FinanceController@orders');
|
||||
$router->post('finances', 'FinanceController@store');
|
||||
|
||||
//提现
|
||||
$router->get('withdraws', 'WithdrawController@index');
|
||||
$router->get('withdraws/{withdraw}', 'WithdrawController@show');
|
||||
$router->any('withdraws/status/{withdraw}', 'WithdrawController@status')->name('withdraws.status');
|
||||
|
||||
$router->resource('banks', BankController::class);
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user