135 lines
5.4 KiB
PHP
135 lines
5.4 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Admin\Repositories\DealerDeliveryBill;
|
|
use App\Admin\Repositories\DealerDeliveryProduct;
|
|
use App\Enums\DealerDeliveryBillStatus;
|
|
use App\Enums\PayWay;
|
|
use Dcat\Admin\Admin;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
use Dcat\Admin\Layout\Row;
|
|
use Dcat\Admin\Show;
|
|
use Dcat\Admin\Widgets\Box;
|
|
|
|
class DealerDeliveryBillController extends AdminController
|
|
{
|
|
protected $title = '云仓提货单';
|
|
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
$repository = DealerDeliveryBill::with(['user.userInfo']);
|
|
|
|
return Grid::make($repository, function (Grid $grid) {
|
|
$grid->model()->orderBy('id', 'desc');
|
|
|
|
$grid->column('id')->sortable();
|
|
$grid->column('sn', '提货单号');
|
|
$grid->column('user.phone', '手机号');
|
|
$grid->column('user.userInfo.nickname', '昵称');
|
|
$grid->column('shipping_fee', '运费')->prepend('¥');
|
|
$grid->column('pay_way', '支付方式')->display(function ($v) {
|
|
return $v?->text();
|
|
})->circleDot(PayWay::colors());
|
|
$grid->column('pay_at', '付款时间')->display(function ($v) {
|
|
return $v?->toDateTimeString();
|
|
});
|
|
$grid->column('status', '状态')->display(function ($v) {
|
|
return $v?->text();
|
|
})->circleDot(DealerDeliveryBillStatus::colors());
|
|
$grid->column('created_at', '创建时间')->display(function ($v) {
|
|
return $v?->toDateTimeString();
|
|
});
|
|
|
|
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
|
if (Admin::user()->can('dcat.admin.dealer_orders.show')) {
|
|
$actions->append('<a style="cursor: pointer;" target="_blank" href="'.admin_route('dealer_delivery_bills.show', [$actions->row]).'"><i class="feather icon-eye"></i> 显示 </a>');
|
|
}
|
|
});
|
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->panel();
|
|
$filter->like('sn', '提货单号')->width(4);
|
|
$filter->like('user.phone', '手机号')->width(4);
|
|
$filter->equal('status', '状态')->select(DealerDeliveryBillStatus::texts())->width(4);
|
|
$filter->between('pay_at', '付款时间')->dateTime()->width(4);
|
|
$filter->between('created_at', '创建时间')->dateTime()->width(4);
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return function (Row $row) use ($id) {
|
|
$row->column(5, function ($column) use ($id) {
|
|
$builder = DealerDeliveryBill::with(['user.userInfo']);
|
|
|
|
$column->row(Show::make($id, $builder, function (Show $show) {
|
|
$show->field('sn', '提货单号');
|
|
$show->field('user.phone', '手机号');
|
|
$show->field('user.user_info.nickname', '昵称');
|
|
$show->field('shipping_fee', '运费');
|
|
$show->field('remark', '备注');
|
|
$show->field('status', '状态')->as(function () {
|
|
return $this->status?->text();
|
|
})->circleDot(DealerDeliveryBillStatus::colors());
|
|
$show->field('created_at')->as(function ($v) {
|
|
return $this->created_at->toDateTimeString();
|
|
});
|
|
|
|
$show->divider();
|
|
$show->field('consignee_name', '收货人');
|
|
$show->field('consignee_telephone', '联系方式');
|
|
$show->field('consignee', '收货地址')->as(function () {
|
|
return $this->consignee_zone . ' '. $this->consignee_address;
|
|
});
|
|
|
|
$show->divider();
|
|
$show->field('pay_sn', '支付单号');
|
|
$show->field('pay_way', '支付方式')->as(function () {
|
|
return $this->pay_way?->text();
|
|
})->circleDot(PayWay::colors());
|
|
$show->field('pay_at', '付款时间')->as(function () {
|
|
return $this->pay_at?->toDateTimeString();
|
|
});
|
|
$show->field('out_trade_no', '外部交易号');
|
|
|
|
|
|
$show->panel()
|
|
->tools(function (Show\Tools $tools) use ($show) {
|
|
$tools->disableEdit();
|
|
$tools->disableDelete();
|
|
});
|
|
}));
|
|
});
|
|
$row->column(7, function ($column) use ($id) {
|
|
$repository = DealerDeliveryProduct::with(['product']);
|
|
|
|
$column->row(Box::make('提货单商品', Grid::make($repository, function (Grid $grid) use ($id) {
|
|
$grid->model()->where('delivery_bill_id', $id);
|
|
|
|
$grid->column('product.name', '名称');
|
|
$grid->column('product.cover', '封面')->image(50, 50);
|
|
$grid->column('qty', '数量');
|
|
$grid->disableActions();
|
|
$grid->disablePagination();
|
|
$grid->disableRefreshButton();
|
|
})));
|
|
});
|
|
};
|
|
}
|
|
}
|