提交代码
This commit is contained in:
226
app/Admin/Controllers/CashOutController.php
Normal file
226
app/Admin/Controllers/CashOutController.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\Cashout\Audit;
|
||||
use App\Admin\Exporters\CashOutExport;
|
||||
use App\Models\Cashout;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Grid\Displayers\Modal;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Illuminate\Http\Request;
|
||||
use Storage;
|
||||
|
||||
class CashOutController extends AdminController
|
||||
{
|
||||
protected $title = '用户提现管理';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Cashout);
|
||||
$grid->disableCreateButton();
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableEdit();
|
||||
$actions->disableView();
|
||||
if ($actions->row->state == "INIT") {
|
||||
$actions->add(new Audit);
|
||||
}
|
||||
});
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user', function ($query) {
|
||||
$query->where('id', $this->input);
|
||||
});
|
||||
}, '用户序号');
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user.identity', function ($query) {
|
||||
$query->where('identity_id', $this->input);
|
||||
});
|
||||
}, '级别')->select([
|
||||
' ' => '全部',
|
||||
'5' => '一级',
|
||||
'4' => '二级',
|
||||
'3' => '三级',
|
||||
'1' => '员工',
|
||||
'2' => '商户',
|
||||
]);
|
||||
});
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user', function ($query) {
|
||||
$query->where('username', $this->input);
|
||||
});
|
||||
}, '手机号');
|
||||
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user.info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
}, '用户名称');
|
||||
});
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('state', '状态')->select([
|
||||
' ' => '全部',
|
||||
'INIT' => '审核中',
|
||||
'PASS' => '通过',
|
||||
'REJECT' => '驳回',
|
||||
]);
|
||||
$filter->equal('created_at', '提交时间')->date();
|
||||
});
|
||||
});
|
||||
|
||||
$grid->model()->orderBy('id', 'desc');
|
||||
|
||||
$grid->column('id', '排序')->sortable();
|
||||
$grid->column('用户序号')->display(function () {
|
||||
return $this->user->id;
|
||||
});
|
||||
$grid->column('手机号')->display(function () {
|
||||
return $this->user->username;
|
||||
});
|
||||
|
||||
$grid->column('用户名称')->display(function () {
|
||||
return $this->user->info->nickname;
|
||||
});
|
||||
$grid->column('级别')->display(function () {
|
||||
return $this->user->identity_text;
|
||||
});
|
||||
$grid->column('支付宝账户')->display(function () {
|
||||
if ($this->cash_account_no) {
|
||||
return $this->cash_account_no;
|
||||
} else {
|
||||
return $this->user->cashAccount->alipay_account;
|
||||
}
|
||||
});
|
||||
$grid->column('支付宝商户二维码')->display(function ($title, $column) use ($grid) {
|
||||
if ($this->user->cashAccount->alipay_account_code) {
|
||||
$modal = new Modal('点击查看', $grid, $column, $this);
|
||||
$str = $modal->display('支付宝商户二维码', function ($modal) {
|
||||
return '<div style="width:100%;text-align:center;"><img style="max-height:50vh;margin:auto;" src="' . Storage::disk('admin')->url($modal->user->cashAccount->alipay_account_code) . '"></div>';
|
||||
});
|
||||
return $str;
|
||||
} else {
|
||||
return '无';
|
||||
}
|
||||
});
|
||||
|
||||
$grid->column('variable', '提现金额');
|
||||
$grid->column('审核状态')->display(function ($state) {
|
||||
switch ($this->state) {
|
||||
case 'INIT':
|
||||
return "<span style='color:red'>审核中</span>";
|
||||
break;
|
||||
case 'PASS':
|
||||
return "<span style='color:blue'>通过</span>";
|
||||
break;
|
||||
case 'REJECT':
|
||||
return "<span style='color:grey'>驳回</span>";
|
||||
break;
|
||||
}
|
||||
});
|
||||
$grid->column('created_at', '创建时间');
|
||||
$grid->column('updated_at', '修改时间');
|
||||
|
||||
$grid->footer(function ($query) {
|
||||
$all = number_format(Cashout::sum('variable'), 2) ?? 0;
|
||||
$init = number_format(Cashout::where('state', 'INIT')->sum('variable'), 2) ?? 0;
|
||||
$pass = number_format(Cashout::where('state', 'PASS')->sum('variable'), 2) ?? 0;
|
||||
$reject = number_format(Cashout::where('state', 'REJECT')->sum('variable'), 2) ?? 0;
|
||||
return '<label class="label label-success">总提现额:' . $all . '</label> <label class="label label-success">审核中:' . $init . '</label> <label class="label label-success">通过:' . $pass . '</label> <label class="label label-success">驳回:' . $reject . '</label>';
|
||||
});
|
||||
|
||||
$grid->exporter(new CashOutExport());
|
||||
return $grid;
|
||||
}
|
||||
|
||||
//某人收益详情
|
||||
public function logs(Content $content, Request $request)
|
||||
{
|
||||
$grid = new Grid(new Cashout);
|
||||
$user = User::find($request->user_id);
|
||||
|
||||
$grid->disableCreateButton();
|
||||
|
||||
$grid->disableActions();
|
||||
$grid->filter(function ($filter) {
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('state', '状态')->select([
|
||||
' ' => '全部',
|
||||
'INIT' => '审核中',
|
||||
'PASS' => '通过',
|
||||
'REJECT' => '驳回',
|
||||
]);
|
||||
$filter->equal('created_at', '提交时间')->date();
|
||||
});
|
||||
});
|
||||
|
||||
$grid->model()->where('user_id', $user->id)->orderBy('id', 'desc');
|
||||
|
||||
$grid->column('id', '排序')->sortable();
|
||||
$grid->column('用户序号')->display(function () {
|
||||
return $this->user->id;
|
||||
});
|
||||
$grid->column('用户账号')->display(function () {
|
||||
return $this->user->username;
|
||||
});
|
||||
|
||||
$grid->column('用户名称')->display(function () {
|
||||
return $this->user->info->nickname;
|
||||
});
|
||||
$grid->column('级别')->display(function () {
|
||||
return $this->user->identity_text;
|
||||
});
|
||||
$grid->column('支付宝账户')->display(function () {
|
||||
if ($this->cash_account_no) {
|
||||
return $this->cash_account_no;
|
||||
} else {
|
||||
return $this->user->cashAccount->alipay_account;
|
||||
}
|
||||
});
|
||||
$grid->column('支付宝商户二维码')->display(function ($title, $column) use ($grid) {
|
||||
if ($this->user->cashAccount->alipay_account_code) {
|
||||
$modal = new Modal('点击查看', $grid, $column, $this);
|
||||
$str = $modal->display('支付宝商户二维码', function ($modal) {
|
||||
return '<div style="width:100%;text-align:center;"><img style="max-height:50vh;margin:auto;" src="' . Storage::disk('admin')->url($modal->user->cashAccount->alipay_account_code) . '"></div>';
|
||||
});
|
||||
return $str;
|
||||
} else {
|
||||
return '无';
|
||||
}
|
||||
});
|
||||
|
||||
$grid->column('variable', '提现金额');
|
||||
$grid->column('审核状态')->display(function ($state) {
|
||||
switch ($this->state) {
|
||||
case 'INIT':
|
||||
return "<span style='color:red'>审核中</span>";
|
||||
break;
|
||||
case 'PASS':
|
||||
return "<span style='color:blue'>通过</span>";
|
||||
break;
|
||||
case 'REJECT':
|
||||
return "<span style='color:grey'>驳回</span>";
|
||||
break;
|
||||
}
|
||||
});
|
||||
$grid->column('created_at', '创建时间');
|
||||
$grid->column('updated_at', '修改时间');
|
||||
$grid->exporter(new CashOutExport());
|
||||
|
||||
return $content
|
||||
->header($user->info->nickname . '的提现详情')
|
||||
->description('列表')
|
||||
->body($grid);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user