179 lines
7.2 KiB
PHP
179 lines
7.2 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Admin\Actions\Show\AfterSaleFinance;
|
|
use App\Admin\Actions\Show\AfterSaleShipping;
|
|
use App\Admin\Actions\Show\AfterSaleVerify;
|
|
use App\Admin\Repositories\AfterSale;
|
|
use App\Models\AfterSale as AfterSaleModel;
|
|
use App\Models\AfterSaleLog;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
use Dcat\Admin\Layout\Row;
|
|
use Dcat\Admin\Show;
|
|
|
|
class AfterSaleController extends AdminController
|
|
{
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
$builder = AfterSale::with(['user', 'order', 'orderProduct']);
|
|
return Grid::make($builder, function (Grid $grid) {
|
|
$grid->column('id')->sortable();
|
|
$grid->column('user.phone');
|
|
$grid->column('order.sn');
|
|
$grid->column('sn');
|
|
$grid->column('orderProduct.name');
|
|
$grid->column('num');
|
|
$grid->column('amount');
|
|
$grid->column('type')->using([
|
|
AfterSaleModel::TYPE_REFUND_AND_RETURN => '退款退货',
|
|
AfterSaleModel::TYPE_REFUND => '退款',
|
|
AfterSaleModel::TYPE_CHANGE => '换货',
|
|
AfterSaleModel::TYPE_FILL => '漏发',
|
|
])->label();
|
|
$grid->column('state')->using([
|
|
AfterSaleModel::STATE_APPLY=>'待补充资料',
|
|
AfterSaleModel::STATE_VERIFY=>'待审核',
|
|
AfterSaleModel::STATE_AGREE=>'待确认',
|
|
AfterSaleModel::STATE_SHIPPING=>'待收货',
|
|
AfterSaleModel::STATE_FINANCE=>'待打款',
|
|
AfterSaleModel::STATE_FINISH=>'已完成',
|
|
AfterSaleModel::STATE_CANCEL=>'已取消',
|
|
])->dot([
|
|
AfterSaleModel::STATE_APPLY=>'warning',
|
|
AfterSaleModel::STATE_VERIFY=>'danger',
|
|
AfterSaleModel::STATE_AGREE=>'warning',
|
|
AfterSaleModel::STATE_SHIPPING=>'primary',
|
|
AfterSaleModel::STATE_FINANCE=>'primary',
|
|
AfterSaleModel::STATE_FINISH=>'success',
|
|
]);
|
|
// $grid->column('remarks');
|
|
// $grid->column('tracking_number');
|
|
$grid->column('created_at');
|
|
$grid->column('updated_at')->sortable();
|
|
$grid->model()->orderBy('created_at', 'desc');
|
|
|
|
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
|
$actions->disableView(false);
|
|
});
|
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->panel();
|
|
$filter->equal('state')->select([
|
|
AfterSaleModel::STATE_APPLY=>'待补充资料',
|
|
AfterSaleModel::STATE_VERIFY=>'待审核',
|
|
AfterSaleModel::STATE_AGREE=>'待确认',
|
|
AfterSaleModel::STATE_SHIPPING=>'待收货',
|
|
AfterSaleModel::STATE_FINANCE=>'待打款',
|
|
AfterSaleModel::STATE_FINISH=>'已完成',
|
|
AfterSaleModel::STATE_CANCEL=>'已取消',
|
|
])->width(3);
|
|
$filter->equal('user.phone')->width(3);
|
|
$filter->equal('order.sn')->width(3);
|
|
$filter->equal('sn')->width(3);
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return function (Row $row) use ($id) {
|
|
$row->column(4, function ($column) use ($id) {
|
|
$builder = AfterSale::with(['user', 'order', 'orderProduct']);
|
|
$column->row(Show::make($id, $builder, function (Show $show) {
|
|
$show->field('id');
|
|
$show->field('sn');
|
|
$show->field('order.sn');
|
|
$show->field('order_product.name');
|
|
$show->field('num');
|
|
$show->field('type')->using([
|
|
AfterSaleModel::TYPE_REFUND_AND_RETURN => '退款退货',
|
|
AfterSaleModel::TYPE_REFUND => '退款',
|
|
AfterSaleModel::TYPE_CHANGE => '换货',
|
|
AfterSaleModel::TYPE_FILL => '漏发',
|
|
])->label();
|
|
$show->field('state')->using([
|
|
AfterSaleModel::STATE_APPLY=>'待补充资料',
|
|
AfterSaleModel::STATE_VERIFY=>'待审核',
|
|
AfterSaleModel::STATE_AGREE=>'待确认',
|
|
AfterSaleModel::STATE_SHIPPING=>'待收货',
|
|
AfterSaleModel::STATE_FINANCE=>'待打款',
|
|
AfterSaleModel::STATE_FINISH=>'已完成',
|
|
AfterSaleModel::STATE_CANCEL=>'已取消',
|
|
])->dot([
|
|
AfterSaleModel::STATE_APPLY=>'warning',
|
|
AfterSaleModel::STATE_VERIFY=>'danger',
|
|
AfterSaleModel::STATE_AGREE=>'warning',
|
|
AfterSaleModel::STATE_SHIPPING=>'primary',
|
|
AfterSaleModel::STATE_FINANCE=>'primary',
|
|
AfterSaleModel::STATE_FINISH=>'success',
|
|
]);
|
|
// $show->field('order_product.cover')->image();
|
|
$show->field('created_at');
|
|
$show->field('updated_at');
|
|
$show->panel()
|
|
->tools(function (Show\Tools $tools) use ($show) {
|
|
$tools->disableEdit();
|
|
$tools->disableDelete();
|
|
if ($show->model()->state == AfterSaleModel::STATE_VERIFY) {
|
|
$tools->append(new AfterSaleVerify());
|
|
}
|
|
if ($show->model()->state == AfterSaleModel::STATE_SHIPPING) {
|
|
$tools->append(new AfterSaleShipping());
|
|
}
|
|
if ($show->model()->state == AfterSaleModel::STATE_FINANCE) {
|
|
$tools->append(new AfterSaleFinance());
|
|
}
|
|
});
|
|
}));
|
|
});
|
|
$row->column(8, function ($column) use ($id) {
|
|
$logs = AfterSaleLog::where('after_sale_id', $id)->latest('id')->get();
|
|
$title = '售后明细';
|
|
$column->row(admin_view('admin.show.timeline', compact('title', 'logs')));
|
|
});
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new AfterSale(), function (Form $form) {
|
|
$form->display('id');
|
|
$form->text('user_id');
|
|
$form->text('order_id');
|
|
$form->text('sn');
|
|
$form->text('order_product_id');
|
|
$form->text('num');
|
|
$form->text('amount');
|
|
$form->text('type');
|
|
$form->text('state');
|
|
$form->text('description');
|
|
$form->text('images');
|
|
$form->text('remarks');
|
|
$form->text('tracking_number');
|
|
|
|
$form->display('created_at');
|
|
$form->display('updated_at');
|
|
});
|
|
}
|
|
}
|