first commit
This commit is contained in:
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();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user