120 lines
3.6 KiB
PHP
120 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Models\OrderProfit;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Show;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
use App\Admin\Extensions\Grid\Tools\ProfitBatchSuccess;
|
|
use App\Admin\Actions\Show\ProfitSuccess;
|
|
use App\Enums\PayWay;
|
|
|
|
class OrderProfitController extends AdminController
|
|
{
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
return Grid::make(OrderProfit::with(['order', 'user']), function (Grid $grid) {
|
|
|
|
$grid->disableViewButton(false);
|
|
|
|
$grid->column('order.sn');
|
|
$grid->column('user.phone');
|
|
$grid->column('role_name');
|
|
$grid->column('growth_value');
|
|
$grid->column('ratio')->display(function ($v) {
|
|
return $v . '%';
|
|
});
|
|
$grid->column('money');
|
|
$grid->column('status')->using(OrderProfit::$statusMap)->dot(OrderProfit::$statusColor);
|
|
$grid->column('created_at');
|
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->panel();
|
|
$filter->like('order.sn')->width(3);
|
|
$filter->like('user.phone')->width(3);
|
|
});
|
|
|
|
// $grid->showRowSelector();
|
|
// $grid->batchActions(function (Grid\Tools\BatchActions $batch) {
|
|
// $batch->disableDelete();
|
|
// $batch->add(new ProfitBatchSuccess());
|
|
// });
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, OrderProfit::with(['order', 'user']), function (Show $show) {
|
|
$show->field('id');
|
|
$show->field('order.sn');
|
|
$show->field('user.phone');
|
|
$show->field('role_name');
|
|
$show->field('growth_value');
|
|
$show->field('ratio')->as(function ($v) {
|
|
return $v . '%';
|
|
});
|
|
$show->field('money');
|
|
$show->field('status')->using(OrderProfit::$statusMap)->dot(OrderProfit::$statusColor);
|
|
$show->field('paid_at');
|
|
$show->field('pay_way')->using([
|
|
PayWay::Offline->value => PayWay::Offline->text(),
|
|
PayWay::WxpayTransfer->value => PayWay::WxpayTransfer->text()
|
|
])->label();
|
|
$show->field('pay_no');
|
|
$show->field('remarks');
|
|
$show->field('created_at');
|
|
$show->field('updated_at');
|
|
|
|
$show->panel()->tools(function (Show\Tools $tools) use ($show) {
|
|
$tools->disableEdit();
|
|
$tools->disableDelete();
|
|
});
|
|
|
|
$show->tools(function (Show\Tools $tools) {
|
|
$tools->append(new ProfitSuccess());
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new OrderProfit(), function (Form $form) {
|
|
$form->display('id');
|
|
$form->text('order_id');
|
|
$form->text('from_user_id');
|
|
$form->text('user_id');
|
|
$form->text('role');
|
|
$form->text('role_name');
|
|
$form->text('growth_value');
|
|
$form->text('ratio');
|
|
$form->text('money');
|
|
$form->text('status');
|
|
$show->field('pay_way');
|
|
$show->field('pay_no');
|
|
$show->field('paid_at');
|
|
|
|
$form->display('created_at');
|
|
$form->display('updated_at');
|
|
});
|
|
}
|
|
}
|