You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
3.8 KiB
121 lines
3.8 KiB
<?php
|
|
|
|
namespace App\AdminAgent\Controllers;
|
|
|
|
use App\Common\OrderStatus;
|
|
use App\Common\PayType;
|
|
use App\Models\Order;
|
|
use App\Models\Supplier;
|
|
use Dcat\Admin\Admin;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Show;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
|
|
class GroupOrderController extends AdminController
|
|
{
|
|
protected $translation = 'order';
|
|
protected $title = '订单列表';
|
|
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
return Grid::make(new Order(['guide', 'agentCloud:id,agent_id']), function (Grid $grid) {
|
|
$grid->disableDeleteButton();
|
|
$grid->disableBatchDelete();
|
|
$grid->disableCreateButton();
|
|
$grid->disableRowSelector();
|
|
$grid->disableEditButton();
|
|
|
|
$grid->model()->whereHas('agentCloud', function ($query) {
|
|
return $query->where('agent_id', Admin::user()->id);
|
|
});
|
|
|
|
$grid->column('id')->sortable();
|
|
$grid->column('order_no')->limit(10);
|
|
$grid->column('name');
|
|
$grid->column('mobile');
|
|
$grid->column('title');
|
|
$grid->column('picture')->image('', 60, 60);
|
|
$grid->column('agent_cloud_pid', '产品ID');
|
|
$grid->column('agent_cloud_price', '销售价');
|
|
$grid->column('guide.name', '地接名称')->display(fn() => $this->guide->name);
|
|
$grid->column('guide.contact_phone', '地接电话')->display(fn() => $this->guide->contact_phone);
|
|
$grid->column('paid_at');
|
|
$grid->column('paid_money');
|
|
$grid->column('pay_type')->using(PayType::array());
|
|
$grid->column('price');
|
|
$grid->column('status')->using(OrderStatus::array());
|
|
$grid->column('created_at');
|
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->panel();
|
|
|
|
$filter->equal('id')->width(2);
|
|
$filter->equal('mobile')->width(2);
|
|
$filter->equal('order_no')->width(3);
|
|
$filter->equal('status')->select(OrderStatus::array())->width(2);
|
|
|
|
$option = Supplier::query()->pluck('company_name', 'id');
|
|
$filter->equal('product.supplier_id', '供应商')->select($option)->width(3);
|
|
|
|
$filter->between('created_at')->datetime()->width(4);
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, new Order(['guide:id,name']), function (Show $show) {
|
|
$show->disableDeleteButton();
|
|
$show->disableEditButton();
|
|
|
|
$show->field('id');
|
|
$show->field('order_no');
|
|
$show->field('name');
|
|
$show->field('mobile');
|
|
$show->field('title');
|
|
$show->field('picture')->image('', 80, 80);
|
|
$show->field('agent_cloud_pid');
|
|
$show->field('agent_cloud_price');
|
|
$show->field('guide.name', '地接名称')->as(fn() => $this->guide->name);
|
|
$show->field('guide.contact_phone', '地接电话')->as(fn() => $this->guide->contact_phone);
|
|
$show->field('paid_at');
|
|
$show->field('paid_money');
|
|
$show->field('pay_type')->using(PayType::array());
|
|
$show->field('price');
|
|
$show->field('status')->using(OrderStatus::array());
|
|
$show->field('created_at');
|
|
$show->field('updated_at');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new Order(), function (Form $form) {
|
|
$form->disableDeleteButton();
|
|
|
|
$form->display('id');
|
|
})->saving(function (Form $form) {
|
|
return $form->response()->error('操作禁止');
|
|
})->deleting(function (Form $form) {
|
|
return $form->response()->error('操作禁止');
|
|
});
|
|
}
|
|
}
|